~cpp module JollyJumpers where import List jollyJumpers numbers = if (jollySub ((head numbers)-1) (tail numbers) []) == (List.sortBy (flip compare) [1..((head numbers)-1)]) then "Jolly" else "Not Jolly" jollySub 0 numbers result = result jollySub num numbers result = jollySub (num-1) (tail numbers) (result ++ [(abs ((head numbers)-(head (tail numbers))) )])
~cpp JollyJumpers> jollyJumpers [4,1,4,2,3] "Jolly" JollyJumpers> jollyJumpers [5,1,4,2,-1,6] "Not Jolly" JollyJumpers>