Solved #6 in ruby.
Alternate solution to #5 in haskell.