solve Problem 59 without using a dictionary file