Adding rough solution to problem 19 (needs cleanup)