Add Python Problem 51

It could use some additional optimization, but it works in under a
minute as is.