POV-Ray : Newsgroups : povray.off-topic : Project Euler Server Time
11 Oct 2024 09:18:06 EDT (-0400)
  Project Euler (Message 11 to 20 of 51)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Nicolas Alvarez
Subject: Re: Project Euler
Date: 25 Nov 2007 21:01:52
Message: <474a2910$1@news.povray.org>
Tim Attwood escribió:
>> (1/sqrt(5) * ( (phi^(n+3)-1)/(phi-1) - ((1-phi)^(n+3)-1)/(1-phi-1) )
> P(n,k) = P(n-1,k-1)+P(n-k,k)
> P(n) ~ (1/(4*n*(sqrt 3))) * (e^(pi*(sqrt (2*n/3))))


O_o

Maybe I should stay away from the complex problems then.


Post a reply to this message

From: Mueen Nawaz
Subject: Re: Project Euler
Date: 25 Nov 2007 21:35:16
Message: <474a30e4$1@news.povray.org>
nemesis wrote:
> John VanSickle <evi### [at] hotmailcom> wrote:
>> For instance, the second problem looks iterative, but there is a direct
>> formula for any member of the Fibonacci series
>> (1/sqrt(5) * ( (phi^(n+3)-1)/(phi-1) - ((1-phi)^(n+3)-1)/(1-phi-1) )
> 
> hmm, did you find out the formula for yourself or looked it up somewhere?  Most
> of the fun in solving these puzzles is coming up with solutions by yourself...

	Not too hard if you've studied difference equations (they also go by
another name - forgot what it was).

	The Fibonacci sequence is a simple difference equation: Linear,
homogeneous and constant coefficients. If this sounds like what you may
have learned in differential equations, it's because they can be solved
in almost the same way. Basically, assume a solution of the form a^n,
plug it into the Fibonacci equation and calculate the possible values of
a. You'll get two, and any linear combination of those two will satisfy
the equation. Plug in the initial conditions, and you've solved it.

	To get the partial sum of a Fibonacci sequence, note that it is just
the difference of two geometric sums. A little alteration in indices
gives you the sum of just the even terms.

	Having said all this, I just wrote a program to calculate it. One of
the people on the forums had a neat solution: For large n, the ratio of
two successive Fibonacci numbers is phi, the Golden Ratio. So his code
just started with 2, multiplied by phi^3 (as we only want the even
numbers), and rounded to the nearest integer after each iteration.

-- 
Best file compressor around: DEL *.* (100% compression)


                    /\  /\               /\  /
                   /  \/  \ u e e n     /  \/  a w a z
                       >>>>>>mue### [at] nawazorg<<<<<<
                                   anl


Post a reply to this message

From: Mueen Nawaz
Subject: Re: Project Euler
Date: 25 Nov 2007 21:37:16
Message: <474a315c$1@news.povray.org>
Orchid XP v7 wrote:
> I've heard the name meantioned many times. (It comes up *a lot* on the
> various Haskell mailing lists, Haskell IRC channel, Haskell wiki, etc.)
> I have no idea what it actually is though. (Apparently some kind of set
> of maths-related challenges.) This is the first time I've seen an actual
> URL...

	Well, now you know!

	A lot of people solve them using Haskell, obviously. You should try the
problems. They'll tickle both your Haskell and your mathematical side.

-- 
Best file compressor around: DEL *.* (100% compression)


                    /\  /\               /\  /
                   /  \/  \ u e e n     /  \/  a w a z
                       >>>>>>mue### [at] nawazorg<<<<<<
                                   anl


Post a reply to this message

From: Tim Attwood
Subject: Re: Project Euler
Date: 25 Nov 2007 22:24:30
Message: <474a3c6e$1@news.povray.org>
> A lot of people solve them using Haskell, obviously. You should try the
> problems. They'll tickle both your Haskell and your mathematical side.

According to the statistics page on Project Euler there's about
three times as many people using C/C++ as Haskell, and about
twice as many using Python as Haskell.

The average user rating for Haskell users is a bit higher than
for Python and C users though =)

And you have to like how it has x% genius at the top of the
page, it's almost as good as when Bookworm squeals
"fantastic"


Post a reply to this message

From: Invisible
Subject: Re: Project Euler
Date: 26 Nov 2007 04:12:03
Message: <474a8de3$1@news.povray.org>
Tim Attwood wrote:

> According to the statistics page on Project Euler there's about
> three times as many people using C/C++ as Haskell, and about
> twice as many using Python as Haskell.

In other words, C++ is many times more popular than Haskell. This is not 
news. ;-)

> The average user rating for Haskell users is a bit higher than
> for Python and C users though =)

In other words, most of the people rating them are other Haskell users. :-D


Post a reply to this message

From: John VanSickle
Subject: Re: Project Euler
Date: 26 Nov 2007 16:27:21
Message: <474b3a39@news.povray.org>
nemesis wrote:
> John VanSickle <evi### [at] hotmailcom> wrote:
>> For instance, the second problem looks iterative, but there is a direct
>> formula for any member of the Fibonacci series
>> (1/sqrt(5) * ( (phi^(n+3)-1)/(phi-1) - ((1-phi)^(n+3)-1)/(1-phi-1) )
> 
> hmm, did you find out the formula for yourself or looked it up somewhere?  Most
> of the fun in solving these puzzles is coming up with solutions by yourself...

I looked up the formula for a member of the Fibonacci series (I keep 
forgetting the 1/sqrt(5) constant), but once I had that I figured out 
the rest on my own.

Regards,
John


Post a reply to this message

From: Mueen Nawaz
Subject: Re: Project Euler
Date: 26 Nov 2007 22:54:58
Message: <474b9512$1@news.povray.org>
Invisible wrote:
>> The average user rating for Haskell users is a bit higher than
>> for Python and C users though =)
> 
> In other words, most of the people rating them are other Haskell users. :-D

	No - you misunderstood. A person's user rating is related to how many
problems he/she has solved. So the average Haskell user has solved more
than the average C user, and roughly about the same as the average
Python user...

-- 
Isn't it counterproductive to have incandescent bulbs in a fridge?


                    /\  /\               /\  /
                   /  \/  \ u e e n     /  \/  a w a z
                       >>>>>>mue### [at] nawazorg<<<<<<
                                   anl


Post a reply to this message

From: Invisible
Subject: Re: Project Euler
Date: 27 Nov 2007 04:26:23
Message: <474be2bf$1@news.povray.org>
Mueen Nawaz wrote:
> Invisible wrote:
>>> The average user rating for Haskell users is a bit higher than
>>> for Python and C users though =)
>> In other words, most of the people rating them are other Haskell users. :-D
> 
> 	No - you misunderstood. A person's user rating is related to how many
> problems he/she has solved. So the average Haskell user has solved more
> than the average C user, and roughly about the same as the average
> Python user...

Aaahhhh... So Haskell programmers are either bigger nerds or have more 
free time than C programmers? ;-)


Post a reply to this message

From: scott
Subject: Re: Project Euler
Date: 27 Nov 2007 05:10:15
Message: <474bed07$1@news.povray.org>
> Aaahhhh... So Haskell programmers are either bigger nerds or have more 
> free time than C programmers? ;-)

C(++) programmers probably have real software to write ;-)


Post a reply to this message

From: nemesis
Subject: Re: Project Euler
Date: 27 Nov 2007 06:55:00
Message: <web.474c0496caa71fbc99be1d360@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:
> According to the statistics page on Project Euler there's about
> three times as many people using C/C++ as Haskell, and about
> twice as many using Python as Haskell.

OTOH, most C++ solutions I've seen in the forum are the trivial, straightforward
loopy and slow performant solutions, using pretty much the same obvious
algorithm.  Many Haskell solutions came up with amazingly concise and creative
algorithms.

but I was really impressed with the assembly and math solutions...


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.