Solution to P248a in Python
First two problems of CF 252 in Java