p054.py: bugfix and polish. Now returns correct answer