# Thoughts on Project Euler in Python

I find it very helpful to have the following tools ready to go before doing any Project Euler problems: a list of primes up to 10**9 or so, a list of primitive Pythagorean triplets up to 10**6, and the latest version of a big integer library. Much of Project Euler is based on prime numbers, so I used primegen to create a text file with lots of primes in it. Reimplementing the Sieve of Eratosthenes gets really boring after a while, and the Sieve of Atkin is much better anyway.

Pythagorean triplets show up occasionally, so I have a static text file with primitive triplets up to 10**6. I used an existing pythagorean triplets generator, but the matrix formula isn't too terrible to implement.

Python 3 has much improved support arbitrary length integers over Python 2. The int datatype is gone, replaced by long, then unified back to int again. The only real problem is remembering the change in the integer division operator, but I've used "from future import __division__" practically everywhere.

Generators and comprehensions have big improvements in Python 3+. I really like them for using a functional programming style, and they can improve program speed and reduce memory usage a bit.

Finally, regardless of language, I always try to review some common strategies from dynamic programming and graph search algorithms. It's surprising how often these ideas are part of the best solutions to Project Euler problems.