The_Ghost's solution from SO
Straightforward and not very clever solution for #29
Brute forced #30
Much easier that way