euler119.py refactored