Solution to problem 20, needs documenting