Solved problem 24 using Guava's Collections2.orderedPermutations