Add the function that return all key combinations for a possible key vector.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -36,3 +36,9 @@
|
||||
(->> (apply comb/cartesian-product possible-key-vector)
|
||||
(map cs/join)))
|
||||
|
||||
(defn get-possible-key-combinations
|
||||
"Return possible keys for a possible key vector. For example, if you have a map: {\\a [\\a \\b \\c] \\e [\\f \\g] \\c [\\a \\c]}, then the keys are (\"abcefg\" \"abcegf\" ...)."
|
||||
[possible-key-vector]
|
||||
(->> (map get-all-permutation-for-block possible-key-vector)
|
||||
(get-all-combinations-for-blocks)))
|
||||
|
||||
|
||||
@@ -35,3 +35,16 @@
|
||||
[[\a \b] [\a \c]] '("aa" "ac" "ba" "bc")
|
||||
[[\a \b \c] [\a \c] [\b \c]] '("aab" "aac" "acb" "acc" "bab" "bac" "bcb" "bcc" "cab" "cac" "ccb" "ccc"))))
|
||||
|
||||
(deftest get-possible-key-combinations-test
|
||||
(testing "The keys must be the all combinations, but the blocks must create a permutations which will be joined as a combination"
|
||||
(are [possible-keys-vector expected-keys]
|
||||
(= expected-keys (get-possible-key-combinations possible-keys-vector))
|
||||
[[\a \b] [\f] [\e \c] [\g]] '("abfecg" "abfceg" "bafecg" "bafceg")
|
||||
[[\a \b] [\a \c]] '("abac" "abca" "baac" "baca")
|
||||
[[\a \b \c] [\a \c] [\b \c]] '("abcacbc" "abcaccb" "abccabc" "abccacb"
|
||||
"acbacbc" "acbaccb" "acbcabc" "acbcacb"
|
||||
"bacacbc" "bacaccb" "baccabc" "baccacb"
|
||||
"bcaacbc" "bcaaccb" "bcacabc" "bcacacb"
|
||||
"cabacbc" "cabaccb" "cabcabc" "cabcacb"
|
||||
"cbaacbc" "cbaaccb" "cbacabc" "cbacacb"))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user