p052.py: solution to p052