Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: The hardest...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 18 of 23 Topic 4031 of 4325
Post > Topic >>

Re: The hardest Euler problem

by anton@[EMAIL PROTECTED] (Anton Ertl) May 5, 2008 at 05:49 PM

William James <w_a_x_man@[EMAIL PROTECTED]
> writes:
>On May 4, 2:13 am, m...@[EMAIL PROTECTED]
 (Marcel Hendrix) wrote:
>> cac <c...@[EMAIL PROTECTED]
> writes Re: The hardest Euler problem
>> [..]
>>
>> >> Someone posted this PARI/GP solution to problem 12:
>> >> n=0; until(numdiv(n*(n+1)/2) > 500, n++); n*(n+1)/2
>> >> He said it took about 50ms on his Intel 2.52GHz.
>>
>> What else to expect with a built-in number-of-divisors function?
>
>What else?  We expect the Forth version to live up to
>Jeff Fox's boast that rewriting a program in Forth
>makes it 100 times smaller and 1000 times faster.

For all the Project Euler problems, that's pretty easy if you follow
Chuck Moore's principles and Jeff Fox's way of evaluating size and
speed.  I don't know them by heart, so I apologize if I get it wrong,
but one of them is that you shouldn't do at run-time what you can do
at compile-time, and you shouldn't do at compile-time what you can do
at edit time.  So, following these principles, one would work out the
solution with pencil&paper, and then write it down as a Forth program.
I.e., a single, not overly long number.

Pu****ng that on the stack and even printing it to screen certainly
does not take as long as 50ms on this kind of machine, 50us should not
be too hard to achieve, so there's your factor 1000.

Concerning size, if you count that like Jeff Fox, you have to also
include the size of the PARI/GP system, and the libraries and the OS
that it runs on in your total size, and compare that to the size of
the ColorForth program plus ColorForth running on the bare metal;
getting a factor 100 there should not be hard.  Actually ColorForth is
overkill for just printing a single number, so I guess Chuck Moore
could have a simple system for doing just that ready in a few
minuates, and it would be even smaller.

But then he might consider making a program out of the solution to be
useless overhead, and optimize that away, too; that would give us 0
size and 0 run-time, and Jeff Fox would work long hours in writing
down the 0s for the size reduction and speedup factors.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2008:
http://www.complang.tuwien.ac.at/anton/euroforth/ef08.html
 




 23 Posts in Topic:
The hardest Euler problem
Albert van der Horst <  2008-05-02 11:05:34 
Re: The hardest Euler problem
mhx@[EMAIL PROTECTED] (M  2008-05-02 14:18:00 
Re: The hardest Euler problem
Albert van der Horst <  2008-05-02 16:09:01 
Re: The hardest Euler problem
cac <cac@[EMAIL PROTEC  2008-05-02 07:40:21 
Re: The hardest Euler problem
William James <w_a_x_m  2008-05-03 17:06:22 
Re: The hardest Euler problem
cac <cac@[EMAIL PROTEC  2008-05-03 21:36:56 
Re: The hardest Euler problem
cac <cac@[EMAIL PROTEC  2008-05-03 22:27:03 
Re: The hardest Euler problem
mhx@[EMAIL PROTECTED] (M  2008-05-04 09:13:22 
Re: The hardest Euler problem
cac <cac@[EMAIL PROTEC  2008-05-04 01:31:32 
Re: The hardest Euler problem
mhx@[EMAIL PROTECTED] (M  2008-05-04 13:08:37 
Re: The hardest Euler problem
cac <cac@[EMAIL PROTEC  2008-05-04 19:00:19 
Re: The hardest Euler problem
mhx@[EMAIL PROTECTED] (M  2008-05-04 15:41:04 
Re: The hardest Euler problem
anton@[EMAIL PROTECTED]   2008-05-04 13:47:12 
Re: The hardest Euler problem
William James <w_a_x_m  2008-05-05 08:08:17 
Re: The hardest Euler problem
Jonah Thomas <jethomas  2008-05-04 22:51:46 
Re: The hardest Euler problem
cac <cac@[EMAIL PROTEC  2008-05-04 20:44:33 
Re: The hardest Euler problem
William James <w_a_x_m  2008-05-05 10:22:58 
Re: The hardest Euler problem
anton@[EMAIL PROTECTED]   2008-05-05 17:49:46 
Re: The hardest Euler problem
Alex McDonald <blog@[E  2008-05-15 05:20:01 
Re: The hardest Euler problem
Alex McDonald <blog@[E  2008-05-15 06:47:58 
Re: The hardest Euler problem
foxchip <fox@[EMAIL PR  2008-05-23 17:08:24 
Re: The hardest Euler problem
GiulioDeVecchi@[EMAIL PRO  2008-05-15 00:56:07 
Re: The hardest Euler problem
Albert van der Horst <  2008-05-05 00:01:12 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 22:12:33 CST 2008.