Last active
January 2, 2016 19:49
-
-
Save sharkdp/8353019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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