On Jun 21, 9:09 pm, Paul Rubin <no.em...@nospam.invalid> wrote: > John Salerno <johnj...@gmail.com> writes: > > It's frustrating because I have the Python right, but I'm getting > > stuck on the math.... > > "What is the smallest positive number that is evenly divisible by all > > of the numbers from 1 to 20?" > > The answer is lcm [1,2,3, ... 20]. You can figure out how to implement > lcm. > > The Euler problems are not really programming exercises. They are > exercises in math and algorithms. Quite a lot of them involve thinking > clever and fast ways to do stuff that would be trivial (but too slow) by > brute force. In general, once you figure out the right algorithm, > writing the code is easy. But you have to be fairly mathematically > attuned, to have any chance of spotting the algorithm. > > If you want programming exercises that are less mathematical, there are > some nice ones at rubyquiz.com. They are intended for Ruby but of > course you can solve them in Python.
Thanks. So far they are helping me with Python too, but definitely not as much as more general exercises would, I'm sure. The part about writing the code is fun, but once that's done, I seem to end up stuck with an inefficient implementation because I don't know the math tricks behind the problem. I'll check out rubyquiz.com. I've been searching for some Python exercises to do but haven't found too many sites with them, at least not in such a nice and organized way as Project Euler. -- http://mail.python.org/mailman/listinfo/python-list