solves 107 in C; broken Haskell solution