Rename the function from get-possible-keys to get-all-combinations-for-blocks.
This commit is contained in:
@@ -30,8 +30,8 @@
|
|||||||
(map cs/join)
|
(map cs/join)
|
||||||
(into [])))
|
(into [])))
|
||||||
|
|
||||||
(defn get-possible-keys
|
(defn get-all-combinations-for-blocks
|
||||||
"Return possible keys for a possible key vector. For example, if you have a map: {\\a [\\a \\b \\c] \\b [\\b \\c] \\c [\\a \\c]}, then the vector is [[\\a \\b \\c] [\\b \\c] [\\a \\c]] and keys (\"aba\" \"abc\" ...)."
|
"Return the all combination of blocks in a possible key vector. For example, if you have a map: {\\a [\\a \"bf\" \\c] \\b [\"bf\" \\c] \\c [\\a \\c]}, then the vector is [[\\a \"bf\" \\c] [\"bf\" \\c] [\\a \\c]] and keys (\"abfa\" \"abfc\" ...)."
|
||||||
[possible-key-vector]
|
[possible-key-vector]
|
||||||
(->> (apply comb/cartesian-product possible-key-vector)
|
(->> (apply comb/cartesian-product possible-key-vector)
|
||||||
(map cs/join)))
|
(map cs/join)))
|
||||||
|
|||||||
@@ -27,10 +27,10 @@
|
|||||||
[\a \b] ["ab" "ba"]
|
[\a \b] ["ab" "ba"]
|
||||||
[\a \b \c] ["abc" "acb" "bac" "bca" "cab" "cba"])))
|
[\a \b \c] ["abc" "acb" "bac" "bca" "cab" "cba"])))
|
||||||
|
|
||||||
(deftest get-possible-keys-test
|
(deftest get-all-combinations-for-blocks-test
|
||||||
(testing "The keys must be the all combinations"
|
(testing "The keys must be the all combinations of blocks"
|
||||||
(are [possible-keys-vector expected-keys]
|
(are [possible-keys-vector expected-keys]
|
||||||
(= expected-keys (get-possible-keys possible-keys-vector))
|
(= expected-keys (get-all-combinations-for-blocks possible-keys-vector))
|
||||||
[[\a \b] [\f] [\a \c] [\g]] '("afag" "afcg" "bfag" "bfcg")
|
[[\a \b] [\f] [\a \c] [\g]] '("afag" "afcg" "bfag" "bfcg")
|
||||||
[[\a \b] [\a \c]] '("aa" "ac" "ba" "bc")
|
[[\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"))))
|
[[\a \b \c] [\a \c] [\b \c]] '("aab" "aac" "acb" "acc" "bab" "bac" "bcb" "bcc" "cab" "cac" "ccb" "ccc"))))
|
||||||
|
|||||||
Reference in New Issue
Block a user