Problem 066 a partial solution in Java