solves problem 24, but using too much ruby magic
solves problem 21