From d6ba958b5b10763561048d3f7cfc505bd215bc60 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 14 Nov 2023 21:49:34 +0200 Subject: [PATCH] Rename the function from get-possible-keys to get-all-combinations-for-blocks. --- .../analyzers/simple_substitution.clj | 4 ++-- .../analyzers/simple_substitution_test.clj | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cipher_analytical_machine/analyzers/simple_substitution.clj b/src/cipher_analytical_machine/analyzers/simple_substitution.clj index 3742489..59ad06b 100644 --- a/src/cipher_analytical_machine/analyzers/simple_substitution.clj +++ b/src/cipher_analytical_machine/analyzers/simple_substitution.clj @@ -30,8 +30,8 @@ (map cs/join) (into []))) -(defn get-possible-keys - "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\" ...)." +(defn get-all-combinations-for-blocks + "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] (->> (apply comb/cartesian-product possible-key-vector) (map cs/join))) diff --git a/test/cipher_analytical_machine/analyzers/simple_substitution_test.clj b/test/cipher_analytical_machine/analyzers/simple_substitution_test.clj index 9ae5566..fc80894 100644 --- a/test/cipher_analytical_machine/analyzers/simple_substitution_test.clj +++ b/test/cipher_analytical_machine/analyzers/simple_substitution_test.clj @@ -27,10 +27,10 @@ [\a \b] ["ab" "ba"] [\a \b \c] ["abc" "acb" "bac" "bca" "cab" "cba"]))) -(deftest get-possible-keys-test - (testing "The keys must be the all combinations" +(deftest get-all-combinations-for-blocks-test + (testing "The keys must be the all combinations of blocks" (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] [\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"))))