Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #10644
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Euler problem 303 |
| Date | 2012-03-30 15:02 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2012Mar30.170245@mips.complang.tuwien.ac.at> (permalink) |
Project Euler has lifted the thread length limit, so I did another
problem:
<http://projecteuler.net/problem=303>
If you want to participate, you have to work out the solution
yourself, otherwise you find my solution at
http://theforth.net/projects/euler303
The interesting thing here is that for the given problem size and
using the approach I have taken, I needed double-cell numbers and
mixed division on a 64-bit system: a 20-digit number (>64 bits) is
divided by a 4-digit number, with a 16-digit quotient (=< 64 bits).
In the Project Euler Forum lots of solutions were posted that were
similar to mine, but used a hand-derived special case to avoid
exceeding 64-bit numbers; the special case also avoids most of the
run-time.
One other interesting thing is that it generates (decimal) numbers
containing only 0, 1, 2 by converting numbers into strings using base
3, then converting the strings to numbers using base 10. That makes
for a small program, but is slow, and I guess that most of the time is
spent in the conversion to the string. I believe that it is possible
to generate these numbers significantly faster, but that would take
more code.
- 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 2011: http://www.euroforth.org/ef11/
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar
Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-30 15:02 +0000
Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-03-30 22:30 -0700
Re: Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-31 13:08 +0000
Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 00:51 -0700
Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 01:46 -0700
Re: Euler problem 303 mhx@iae.nl (Marcel Hendrix) - 2012-04-01 12:00 +0200
Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 12:57 -0700
Re: Euler problem 303 Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-04-01 23:34 +0000
Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 17:19 -0700
Re: Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-04-02 10:53 +0000
Re: Euler problem 303 Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-31 11:41 +0000
Re: Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-31 13:30 +0000
Re: Euler problem 303 Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-31 18:27 +0000
csiph-web