Skip to content

Instantly share code, notes, and snippets.

@sharkdp
Last active January 2, 2016 19:49
Show Gist options
  • Save sharkdp/8353019 to your computer and use it in GitHub Desktop.
Save sharkdp/8353019 to your computer and use it in GitHub Desktop.
import Data.List
newline [a] = []
newline (a:b:xs) = abs (a-b) : (newline (b:xs))
check prev [] = True
check prev line = all (`notElem` prev) line && nub line == line && check (line ++ prev) (newline line)
main = print $ filter (check []) $ concatMap permutations $ filter ((==5) . length) $ subsequences [1..15]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment