Implemented a rather naive solution to Problem 1