POV-Ray : Newsgroups : povray.off-topic : Project Euler Server Time
11 Oct 2024 13:16:57 EDT (-0400)
  Project Euler (Message 31 to 40 of 51)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Mueen Nawaz
Subject: Re: Project Euler metadiscussion
Date: 28 Nov 2007 23:06:10
Message: <474e3ab2$1@news.povray.org>
Invisible wrote:
> Currently for each problem, you either get the answer right or you get
> it wrong. I think it would be nice if you could check intermediate parts
> of the calculation. (E.g., is 103 a prime number? Is 187 an abundant
> number? etc.)

	Well, for all but one of the problems I've worked on, the definitions
in the problem statements are fairly unambiguous.

	Besides, for things like those, you can use Google to get a list of
primes, abundant numbers, etc. But be "careful", sometimes a good Google
search will get you the very answer to the question being asked.

> On the other hand, I suppose they don't want to give too much data away,
> otherwise you could just "solve" the problem by asking the Project Euler
> website a sufficient number of questions. ;-)

	True - almost. If you submit too many answers in a short period of
time, the Web site blocks you for a while.

> I'd kinda like to make my own website like Project Euler. However, I had
> a look, and to get hosting that gives you server-side scripting and a
> database is 5x the price of what I'm currently paying. :-S I can't
> really afford that kind of money...

	The weakened Dollar may help you there.<G>

	What price are you talking about. You definitely can get it for under
$10/mo, and if your needs aren't too stringent, probably $5/mo is not
hard to find.

	The tricky part is making the problems interesting enough for people to
come. A number of problems on the Project Euler site *may* lead you into
some interesting number theory topics...

-- 
I considered atheism but there weren't enough holidays.


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


Post a reply to this message

From: Invisible
Subject: Re: Project Euler metadiscussion
Date: 29 Nov 2007 05:02:28
Message: <474e8e34$1@news.povray.org>
Mueen Nawaz wrote:
> Invisible wrote:
>> Currently for each problem, you either get the answer right or you get
>> it wrong. I think it would be nice if you could check intermediate parts
>> of the calculation. (E.g., is 103 a prime number? Is 187 an abundant
>> number? etc.)
> 
> 	Well, for all but one of the problems I've worked on, the definitions
> in the problem statements are fairly unambiguous.

Well, for "find the millionth prime number" or something, there's not 
much to check. But when the problem is "sum all the primes below 1 
million", it might be nice to know, for example, how many primes there 
are. (Or rather, be able to ask "are there 722 primes?" and get a yes/no 
answer.)

[BTW, I'm damn-well *sure* there used to be a site that tells you 
whether a number is prime, and what the Nth prime number is, and how 
many primes there are below N. Google can no longer find it though...]

>> On the other hand, I suppose they don't want to give too much data away,
>> otherwise you could just "solve" the problem by asking the Project Euler
>> website a sufficient number of questions. ;-)
> 
> 	True - almost. If you submit too many answers in a short period of
> time, the Web site blocks you for a while.

I know what *would* be nice - if the site would keep a list of the 
answers you've already tried which turned out to be wrong! (So many 
off-by-one bugs...)

>> I'd kinda like to make my own website like Project Euler. However, I had
>> a look, and to get hosting that gives you server-side scripting and a
>> database is 5x the price of what I'm currently paying. :-S I can't
>> really afford that kind of money...
> 
> 	The weakened Dollar may help you there.<G>
> 
> 	What price are you talking about. You definitely can get it for under
> $10/mo, and if your needs aren't too stringent, probably $5/mo is not
> hard to find.




> 	The tricky part is making the problems interesting enough for people to
> come. A number of problems on the Project Euler site *may* lead you into
> some interesting number theory topics...

I don't know - almost all of the problems seem to be a case of "write 
this brute-force search algorithm so it doesn't take all day". Very few 
problems appear to possess an elegant mathematical solution. For example:

- Find the 10,001st prime number. Well, sure, there's only one possible 
way to do that. You can't know whether a given prime is the 10,001st or 
not without finding all 10,000 primes below it! Brute-force search, 
plain and simple.

- Take this file full of data, generate some numbers from it, find the 
highest one. Well, again, no mathematics involved. It's a trivial search 
problems. Just gotta write a program fast enough.

- Find a number having some highly obscure property. Well you can 
probably use elegant mathematics to elimatine a few classes of 
possibilities, but it still comes down to a simple search in the end.

A few of the problems admit an elegant mathematical solution. The thing 
with Pythagorean triples, or finding the sum of numbers or the number of 
combinations or something. Slightly more involve some actual maths 
somewhere. But most seem to just involve blindly searching as fast as 
possible. It's not very interesting, but I like seeing my score 
increase. :^)


Post a reply to this message

From: scott
Subject: Re: Project Euler metadiscussion
Date: 29 Nov 2007 07:14:26
Message: <474ead22$1@news.povray.org>
> A few of the problems admit an elegant mathematical solution. The thing 
> with Pythagorean triples, or finding the sum of numbers or the number of 
> combinations or something. Slightly more involve some actual maths 
> somewhere. But most seem to just involve blindly searching as fast as 
> possible. It's not very interesting, but I like seeing my score increase. 
> :^)

Oh I think it is pretty interesting.  In real life you often need to get 
results as quickly as possible.  Part of the skill is being able to decide 
quickly whether it's better to spend 1 minute coding and waiting 10 minutes, 
or spending 10 minutes doing some math and then only having to wait 1 second 
for the answer.

And then another skill is being able to decide *what* to use to get the 
answer (C++, Excel, Haskell, calculator, pencil etc).

There should be a timer that starts the moment you open the problem for the 
first time, and that is stopped when you submit the correct answer.  Not 
sure how you would stop people cheating though.


Post a reply to this message

From: Invisible
Subject: Re: Project Euler metadiscussion
Date: 29 Nov 2007 07:50:11
Message: <474eb583$1@news.povray.org>
scott wrote:

> There should be a timer that starts the moment you open the problem for 
> the first time, and that is stopped when you submit the correct answer.  
> Not sure how you would stop people cheating though.

Or a counter for the number of incorrect results you submitted. ;-)


Post a reply to this message

From: Tim Attwood
Subject: Re: Project Euler metadiscussion
Date: 29 Nov 2007 18:49:32
Message: <474f500c@news.povray.org>
> [BTW, I'm damn-well *sure* there used to be a site that tells you whether 
> a number is prime, and what the Nth prime number is, and how many primes 
> there are below N. Google can no longer find it though...]

The Prime Pages probably has something like that.
http://primes.utm.edu/index.html
You can get the first 15 million primes in files.

There's also an open challenge from the EFF to
calculate a billion digit prime number, with a prize
of $250,000.
http://w2.eff.org/awards/coop.php


Post a reply to this message

From: Mueen Nawaz
Subject: Re: Project Euler metadiscussion
Date: 30 Nov 2007 02:26:40
Message: <474fbb30$1@news.povray.org>
Invisible wrote:
>>     Well, for all but one of the problems I've worked on, the definitions
>> in the problem statements are fairly unambiguous.
> 
> Well, for "find the millionth prime number" or something, there's not
> much to check. But when the problem is "sum all the primes below 1
> million", it might be nice to know, for example, how many primes there
> are. (Or rather, be able to ask "are there 722 primes?" and get a yes/no
> answer.)

	That'd make it easier to solve, though.



	That's an interesting currency conversion you have there...

	Unless you have a good reason to stick with them, simply dump them and
ask around for recommendations of cheaper and better hosts. I'm
currently paying a bit less than you are (albeit that's because I paid
in advance), and I get probably much more than what you want.

(I use Dreamhost - often maligned, but more than satisfies my needs and
wants and I can't find similarly priced alternatives that do).

> I don't know - almost all of the problems seem to be a case of "write
> this brute-force search algorithm so it doesn't take all day". Very few
> problems appear to possess an elegant mathematical solution. For example:
> 
> - Find the 10,001st prime number. Well, sure, there's only one possible
> way to do that. You can't know whether a given prime is the 10,001st or
> not without finding all 10,000 primes below it! Brute-force search,
> plain and simple.
> 
> - Take this file full of data, generate some numbers from it, find the
> highest one. Well, again, no mathematics involved. It's a trivial search
> problems. Just gotta write a program fast enough.

	I'm assuming that these two are just prepping you up for more difficult
(but related) problems later on. Certainly if someone has trouble
generating 10001 primes, he won't get too far.

> - Find a number having some highly obscure property. Well you can
> probably use elegant mathematics to elimatine a few classes of
> possibilities, but it still comes down to a simple search in the end.

	That's sort of the point. Take Problem 43:

"The number, 1406357289, is a 0 to 9 pandigital number because it is
made up of each of the digits 0 to 9 in some order, but it also has a
rather interesting sub-string divisibility property.

Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we
note the following:

    * d2d3d4=406 is divisible by 2
    * d3d4d5=063 is divisible by 3
    * d4d5d6=635 is divisible by 5
    * d5d6d7=357 is divisible by 7
    * d6d7d8=572 is divisible by 11
    * d7d8d9=728 is divisible by 13
    * d8d9d10=289 is divisible by 17

Find the sum of all 0 to 9 pandigital numbers with this property."

	A REAL brute force solution is simple to write, but do you really want
to check over a billion numbers? (I'm guessing anyone who got this far
would not even realize the search space is that big - they'll
automatically optimize).

	Now with some thought you can bring that number down to something very
manageable. You could then code it and be happy, or think more and try
to reduce the search space even more. The more you do this, the more
"painful" it is to code. So then you take on the challenge of writing
the code in a "nicer" way so that it doesn't look like an ugly hack.

	I just went halfway and coded it. I felt bad about that after looking
at the solutions. There were some really simple ways to reduce the
search space _much_ further - on the other hand I did a simplification
few thought of - but the ones I missed negated the need for mine.

	Now some people simply solved this on paper (some of those did use a
calculator to help, though). 	

	The point of the problems is not to solve it _entirely_ mathematically
(although if you can, that's wonderful). It's to use math to make the
problem more tractable (even if it _can_ be done under a minute via
brute force). And for me, it's also a challenge to write the code
somewhat nicely.

	The last problem I worked on (in the 40's) was somewhat brute force and
took over 40 minutes. Haven't had time to think about it much since
then, but I look forward to bringing that down. I have a few ideas on
making the algorithm faster which may suffice, but before I had obtained
the solution, I noticed some mathematical properties which I suspected
held true in general (but couldn't prove it). After computing the
solution, I find the answer does satisfy my hypothesis, and now I don't
want to simply speed up the algorithm, but rather explore my hypothesis
and "speed" it up that way.

	Which is why I enjoy a number of the problems...

> A few of the problems admit an elegant mathematical solution. The thing
> with Pythagorean triples, or finding the sum of numbers or the number of
> combinations or something. Slightly more involve some actual maths
> somewhere. But most seem to just involve blindly searching as fast as
> possible. It's not very interesting, but I like seeing my score
> increase. :^)

	I assume that it'll demand more math thought as you get higher. Many
(most?) have not impressed me as much in that regard thus far. But heck,
it was fun anyway!

-- 
As a child my family's menu consisted of two choices: "Take it, or leave
it."


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


Post a reply to this message

From: Invisible
Subject: Re: Project Euler metadiscussion
Date: 30 Nov 2007 04:25:48
Message: <474fd71c$1@news.povray.org>
Mueen Nawaz wrote:
> Invisible wrote:
>> Well, for "find the millionth prime number" or something, there's not
>> much to check. But when the problem is "sum all the primes below 1
>> million", it might be nice to know, for example, how many primes there
>> are. (Or rather, be able to ask "are there 722 primes?" and get a yes/no
>> answer.)
> 
> 	That'd make it easier to solve, though.

Well yes - but do you have any idea how frustrating it is to spend hours 
trying to make your program work when you don't even know what part is 
broken? Knowing which part is broken doesn't tell you how to fix it, it 
just tells you which part needs fixing...

(Also, a number of questions give insufficient detail to figure out what 
the correct answer is.)


> 
> 	That's an interesting currency conversion you have there...


other...

> 	Unless you have a good reason to stick with them, simply dump them and
> ask around for recommendations of cheaper and better hosts.

I've asked many times. Nobody ever recommends anything.

My current host (1&1) charges quite a low price for serving just static 
HTML, which is mainly what I want. However, if you decide you want CGI, 
they suddenly want to charge a lot more.

(I hate Perl, and PHP would probably be the same. I'd probably want to 
do my CGI scripting in Haskell - and by the looks of it, the only way to 
do *that* is to go for a virtual server package rather than a simple web 
hosting package. That's A LOT of extra complexity, and it's expensive.)

[BTW, I find it interesting that all hosting packages offer MySQL or SQL 
Server, but none offer PostgreSQL...]

> I'm
> currently paying a bit less than you are (albeit that's because I paid
> in advance), and I get probably much more than what you want.
> 
> (I use Dreamhost - often maligned, but more than satisfies my needs and
> wants and I can't find similarly priced alternatives that do).

Well, I'll have a look...

>> I don't know - almost all of the problems seem to be a case of "write
>> this brute-force search algorithm so it doesn't take all day". Very few
>> problems appear to possess an elegant mathematical solution.
> 
> 	I'm assuming that these two are just prepping you up for more difficult
> (but related) problems later on. Certainly if someone has trouble
> generating 10001 primes, he won't get too far.

True, I guess.

>> - Find a number having some highly obscure property. Well you can
>> probably use elegant mathematics to elimatine a few classes of
>> possibilities, but it still comes down to a simple search in the end.
> 
> 	That's sort of the point. Take Problem 43:

Actually I didn't - mainly because I don't know what "pandigital" means.

> 	A REAL brute force solution is simple to write, but do you really want
> to check over a billion numbers? (I'm guessing anyone who got this far
> would not even realize the search space is that big - they'll
> automatically optimize).
> 
> 	Now with some thought you can bring that number down to something very
> manageable. You could then code it and be happy, or think more and try
> to reduce the search space even more. The more you do this, the more
> "painful" it is to code. So then you take on the challenge of writing
> the code in a "nicer" way so that it doesn't look like an ugly hack.

I did see one problem that was solved by a human with pen and paper in 
under 30 seconds. Just move some algebra around and it tells you the 
answer. But most seem to require a machine.

(Many involve prime numbers - and as we all know, it is impossible to 
know anything about prime numbers. You just gotta compute them all the 
long way...)

> 	The point of the problems is not to solve it _entirely_ mathematically
> (although if you can, that's wonderful). It's to use math to make the
> problem more tractable (even if it _can_ be done under a minute via
> brute force). And for me, it's also a challenge to write the code
> somewhat nicely.

Personally, I find that as you come up with better algorithms it gets 
*easier* to code, not harder. ;-) Maybe that's just because I use 
Haskell... The Mathematica solutions are similarly easy.

>> A few of the problems admit an elegant mathematical solution. The thing
>> with Pythagorean triples, or finding the sum of numbers or the number of
>> combinations or something. Slightly more involve some actual maths
>> somewhere. But most seem to just involve blindly searching as fast as
>> possible. It's not very interesting, but I like seeing my score
>> increase. :^)
> 
> 	I assume that it'll demand more math thought as you get higher. Many
> (most?) have not impressed me as much in that regard thus far. But heck,
> it was fun anyway!

Well, it's a challenge I guess. I doubt I'll ever reach 100% though...


Post a reply to this message

From: scott
Subject: Re: Project Euler metadiscussion
Date: 30 Nov 2007 05:59:19
Message: <474fed07@news.povray.org>
> Well yes - but do you have any idea how frustrating it is to spend hours 
> trying to make your program work when you don't even know what part is 
> broken? Knowing which part is broken doesn't tell you how to fix it, it 
> just tells you which part needs fixing...

> I've asked many times. Nobody ever recommends anything.

A friend of mine uses http://www.ipowerweb.com/ and recommended me to use if 
I ever needed a website.  A quick look shows that they offer 300 GB with 
Perl/MySQL/PHP/CGI-BIN/etc for $4.95 / month if you get the 12 month 
package.


Post a reply to this message

From: Invisible
Subject: Re: Project Euler metadiscussion
Date: 30 Nov 2007 06:28:44
Message: <474ff3ec@news.povray.org>
scott wrote:

>> I've asked many times. Nobody ever recommends anything.
> 
> A friend of mine uses http://www.ipowerweb.com/ and recommended me to 
> use if I ever needed a website.  A quick look shows that they offer 300 
> GB with Perl/MySQL/PHP/CGI-BIN/etc for $4.95 / month if you get the 12 
> month package.

TY. I'll check it out later...


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Project Euler metadiscussion
Date: 30 Nov 2007 14:12:07
Message: <47506087@news.povray.org>

> (I hate Perl, and PHP would probably be the same. I'd probably want to 
> do my CGI scripting in Haskell - and by the looks of it, the only way to 
> do *that* is to go for a virtual server package rather than a simple web 
> hosting package. That's A LOT of extra complexity, and it's expensive.)

Find a Haskell interpreter written in PHP or Perl.


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.