Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Project Euler...
Index -> Contests
Goto page Previous  1, 2, 3 ... 10, 11, 12
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Shah-Cuber




PostPosted: Mon Jul 06, 2009 6:00 pm   Post subject: Re: Project Euler...

5 days of struggling with #246 ... I hate geometry problems >_>
Just calculate a given point from the center of the ellipse ... 'nough said ... Used Wolfram Alpha for most of the calculations =P
Sponsor
Sponsor
Sponsor
sponsor
bbi5291




PostPosted: Tue Jul 07, 2009 5:30 pm   Post subject: Re: Project Euler...

Instead of using Wolfram Alpha, why not download the engine it uses for its calculations - Wolfram Mathematica? http://***********
lol, the domain is censored, but the link still works
Dan




PostPosted: Tue Jul 07, 2009 6:22 pm   Post subject: Re: Project Euler...

bbi5291 @ 7th July 2009, 5:30 pm wrote:

lol, the domain is censored, but the link still works


Theres a reason for that, no links to warez.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Shah-Cuber




PostPosted: Tue Jul 14, 2009 6:53 pm   Post subject: Re: Project Euler...

Finally level 6 Cool ... Embarassed
I have a headache right now, but it took me a week to solve #248, which is numbers for which Euler's totient function equals 13!, a lot of little details to deal with primes, ahhg! ... it was hardcoded ...
Well, at least I can rest now ...
They changed the problem a while back from 100,000 to 150,000 for the number to find.
... great ... i still have to finish Coresilience and Ambiguous Numbers, this is torture. I'll sleep now ...
A.J




PostPosted: Tue Jul 14, 2009 10:52 pm   Post subject: RE:Project Euler...

I am kind of bored now that there aren't any more PE questions to do....it has been about 2 weeks w/out PE..

so I am suggesting new questions to them

and I got addicted to SC....
(I am in a MathCamp at washington....it is soooooooo fun!)
matt271




PostPosted: Thu Jul 16, 2009 12:20 am   Post subject: Re: Project Euler...

to anybody who cares... i think i have the best solution to Problem 40

Quote:
An irrational decimal fraction is created by concatenating the positive integers:

0.123456789101112131415161718192021...

It can be seen that the 12^(th) digit of the fractional part is 1.

If d_(n) represents the n^(th) digit of the fractional part, find the value of the following expression.

d_(1) ? d_(10) ? d_(100) ? d_(1000) ? d_(10000) ? d_(100000) ? d_(1000000)


my solution in c99 is: (i hope this hides for non-spoilers)

c:
#include <stdio.h>
#include <stdlib.h>

int a[] = {1, 10, 190, 2890, 38890, 488890, 5888890};
int b[] = {1, 10, 100, 1000, 10000, 100000, 1000000};

int getindex(int, int*);
int matt(int);
inline int digit(int, int);

int main(int argc, char** argv) {

    int i, p = 1;
    for (i = 1; i < 1000001; i *= 10)
        p *= matt(i);

    printf("%i\n", p);

    return (EXIT_SUCCESS);
}

int getindex(int x, int a[]) {
    int i;
    for (i = 0; i < 7; ++i)
        if (a[i] > x)
            break;

    return --i;
}

int matt(int x) {
    int i = getindex(x, a);

    x -= a[i];

    int q = x / (i + 1);
    int r = x % (i + 1);

    q += b[i];

    return digit(q, r);
}

inline int digit(int q, int r) {
    return q / b[getindex(q, b) - r] % 10;
}


the c code itself is not that impressive, but the math i used i think is. i have (what i like to think is) a brilliant method to derive the numbers u see in array a[] Very Happy

does anybody care? anybodys thoughts? i wanted to post this on the thing for it, but its locked for archive.
Cyril




PostPosted: Thu Jul 16, 2009 2:00 am   Post subject: RE:Project Euler...

Haha, I suppose naming a function after yourself is the best alternative to becoming famous enough as to have others do it for you. Anyways, nice, clean, morally justified solution- out of laziness, I just used an ostringstream and bashed it.
A.J




PostPosted: Wed Jul 22, 2009 11:52 am   Post subject: RE:Project Euler...

Very nice solution Matt.

I like the clean code (you don't see that very often nowadays). However, I do not believe that you have the best solution.

Your method is certainly a good method, but I think there's a better one. However, I might be mistaken.

Once again, I like the cleanliness in the code.
Sponsor
Sponsor
Sponsor
sponsor
Cyril




PostPosted: Thu Jul 23, 2009 11:09 am   Post subject: RE:Project Euler...

http://www.research.att.com/~njas/sequences/A033307

Oh wow, there's a closed-form formula. But this is impractical, as there would be precision errors with computing the Lambert W-function. Interesting though.
Shah-Cuber




PostPosted: Mon Apr 26, 2010 2:24 am   Post subject: Re: Project Euler...

Weeeeee - It's 3 am
Renewing post after 9 months ...
Coming back for new problems & more headaches Confused
Enjoy!
A.J




PostPosted: Mon Apr 26, 2010 7:04 am   Post subject: RE:Project Euler...

Well, the latest problem, p289, is giving me quite some trouble. However the latest few, < 289, were pretty easy. Maybe Project Euler wants < 50 people to have solved all the problems Laughing
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 12 of 12  [ 176 Posts ]
Goto page Previous  1, 2, 3 ... 10, 11, 12
Jump to:   


Style:  
Search: