Solution to problem 9
Solution to problem 9 reworked to use linked list