aboutsummaryrefslogtreecommitdiff
path: root/challenge-083/jeongoon
diff options
context:
space:
mode:
authorMyoungjin JEON <jeongoon@gmail.com>2020-10-23 21:30:15 +1100
committerMyoungjin JEON <jeongoon@gmail.com>2020-10-23 21:30:15 +1100
commitbabae0cdb58bb348155a2e546a7bbef088dfafad (patch)
tree1cc663073d287eff48922444b054b9214334ca16 /challenge-083/jeongoon
parent540705ac37db7a8b921be1d6f1afbee6a1cfaafe (diff)
downloadperlweeklychallenge-club-babae0cdb58bb348155a2e546a7bbef088dfafad.tar.gz
perlweeklychallenge-club-babae0cdb58bb348155a2e546a7bbef088dfafad.tar.bz2
perlweeklychallenge-club-babae0cdb58bb348155a2e546a7bbef088dfafad.zip
[ch-083/jeongoon] Haskell simpler better combinations
Diffstat (limited to 'challenge-083/jeongoon')
-rw-r--r--challenge-083/jeongoon/haskell/Combinations.hs25
1 files changed, 0 insertions, 25 deletions
diff --git a/challenge-083/jeongoon/haskell/Combinations.hs b/challenge-083/jeongoon/haskell/Combinations.hs
deleted file mode 100644
index f8c5324f43..0000000000
--- a/challenge-083/jeongoon/haskell/Combinations.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{- Copyright (c) 2020 JEON Myoungjin <jeongoon@g... > -}
-
-module Combinations
- ( combinations
- ) where
-
-combinations :: [a] -> Int -> [[a]]
-combinations [] _ = []
-combinations (m:ms) 1 = [m] : (combinations ms 1)
-combinations [_] 2 = []
-combinations [e,f] 2 = sequence [ [e],[f] ]
-combinations (m:ms) 2 = sequence [ [m], ms ] ++ (combinations ms 2)
-combinations mls n =
- case totalLen `compare` n of
- LT -> []
- EQ -> [mls]
- _ -> [ let leaders = map (mls!!) ids
- in leaders ++ followers |
- ids <- combinations [ 0 .. room ] n',
- let skipCount = (last ids) + 1,
- followers <- (combinations (drop skipCount mls) 2) ]
- where
- totalLen = length mls
- room = totalLen - 2
- n' = n - 2