Change 99problems/problem 49 to use pattern matching