Skip to content

Instantly share code, notes, and snippets.

@jhickner
Created February 18, 2013 10:11
Show Gist options
  • Select an option

  • Save jhickner/4976384 to your computer and use it in GitHub Desktop.

Select an option

Save jhickner/4976384 to your computer and use it in GitHub Desktop.
import Data.List
check = filter (and . sequence conditions)
where
conditions = map divsBy $ reverse [2..9]
divsBy x = (== 0) . (`rem` x) . fromDigits . take x
fromDigits = foldl' ((+) . (10 *)) 0
solutions = check $ permutations [1..9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment