working solution to 106, not fast enough
106 ok, still needs golfing
golfed problem 106