-- Sebastian Fischer @sebfisch -- https://twitter.com/sebfisch/status/752783154411429888 -- permission given https://twitter.com/sebfisch/status/754104295956615174 -- Fails on 41 example -- No division by zero problems import Data.List ( permutations ) solution = head [ (a,x,(b,y,(c,z,d))) | [a,b,c,d] <- permutations [2,5,6,6], ops <- permutations [((+),'+'),((-),'-'),((*),'*'),((/),'/')], let [u,v,w] = map fst $ take 3 ops, let [x,y,z] = map snd $ take 3 ops, (a `u` (b `v` (c `w` d))) == 17 ]