Last active
January 1, 2016 09:19
-
-
Save hokamoto/8124108 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
-- http://d.hatena.ne.jp/guccyon/20090510/p1 | |
combn [] n=[] | |
combn lst 1=map (\x -> [x]) lst | |
combn (x:xs) n=[x:y| y <- combn xs (n-1)] ++ combn xs n | |
ss = combn [1..10] 4 | |
ans = [s | sp <- ss, s <- (permutations sp), let x1 = abs(s !! 0 - s !! 1); x2 = abs(s !! 1 - s !! 2); x3 = abs(s !! 2 - s !! 3); x4 = abs(x1 - x2); x5 = abs(x2 - x3); x6 = abs(x4 - x5) in length (nub (x1:x2:x3:x4:x5:x6:s)) == 10] | |
main = print ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment