From c6f08d4ca30154cd8166aaa37810cf7257657d16 Mon Sep 17 00:00:00 2001 From: RichardLussier Date: Thu, 3 Mar 2022 14:44:09 -0600 Subject: [PATCH] Fix other read-string uses in PSB2 problems Since removing 'read-string' and 'str' from middle-character and twitter seemed to help diversify the outputs, we chose to replace all other occurrences of this pattern from the other PSB2 problems. Additionally, this conversion with 'read-string' and 'str' was completely unnecessary since the program was already taking from the top of the string stack. --- src/propeller/problems/PSB2/camel_case.cljc | 9 ++------- src/propeller/problems/PSB2/fizz_buzz.cljc | 11 +++-------- src/propeller/problems/PSB2/spin_words.cljc | 9 ++------- src/propeller/problems/PSB2/square_digits.cljc | 11 +++-------- src/propeller/problems/PSB2/substitution_cipher.cljc | 11 +++-------- 5 files changed, 13 insertions(+), 38 deletions(-) diff --git a/src/propeller/problems/PSB2/camel_case.cljc b/src/propeller/problems/PSB2/camel_case.cljc index 99b20be..ba80c6b 100644 --- a/src/propeller/problems/PSB2/camel_case.cljc +++ b/src/propeller/problems/PSB2/camel_case.cljc @@ -78,19 +78,14 @@ (:step-limit argmap)) :string)) inputs) - parsed-outputs (map (fn [output] - (try (read-string output) - #?(:clj (catch Exception e 1000.0) - :cljs (catch js/Error. e 1000.0)))) - outputs) errors (map (fn [correct-output output] (if (= output :no-stack-item) 10000 (metrics/levenshtein-distance correct-output output))) correct-outputs - parsed-outputs)] + outputs)] (assoc individual - :behaviors parsed-outputs + :behaviors outputs :errors errors :total-error #?(:clj (apply +' errors) :cljs (apply + errors))))) diff --git a/src/propeller/problems/PSB2/fizz_buzz.cljc b/src/propeller/problems/PSB2/fizz_buzz.cljc index 4b892e7..ee1f536 100644 --- a/src/propeller/problems/PSB2/fizz_buzz.cljc +++ b/src/propeller/problems/PSB2/fizz_buzz.cljc @@ -46,19 +46,14 @@ (:step-limit argmap)) :string)) inputs) - parsed-outputs (map (fn [output] - (try (read-string output) - #?(:clj (catch Exception e 1000.0) - :cljs (catch js/Error. e 1000.0)))) - outputs) errors (map (fn [correct-output output] (if (= output :no-stack-item) 10000 - (metrics/levenshtein-distance (str correct-output) (str output)))) + (metrics/levenshtein-distance correct-output output))) correct-outputs - parsed-outputs)] + outputs)] (assoc individual - :behaviors parsed-outputs + :behaviors outputs :errors errors :total-error #?(:clj (apply +' errors) :cljs (apply + errors))))) diff --git a/src/propeller/problems/PSB2/spin_words.cljc b/src/propeller/problems/PSB2/spin_words.cljc index 5698f7a..b25386a 100644 --- a/src/propeller/problems/PSB2/spin_words.cljc +++ b/src/propeller/problems/PSB2/spin_words.cljc @@ -74,19 +74,14 @@ (:step-limit argmap)) :string)) inputs) - parsed-outputs (map (fn [output] - (try (read-string output) - #?(:clj (catch Exception e 1000.0) - :cljs (catch js/Error. e 1000.0)))) - outputs) errors (map (fn [correct-output output] (if (= output :no-stack-item) 10000 (metrics/levenshtein-distance correct-output output))) correct-outputs - parsed-outputs)] + outputs)] (assoc individual - :behaviors parsed-outputs + :behaviors outputs :errors errors :total-error #?(:clj (apply +' errors) :cljs (apply + errors))))) diff --git a/src/propeller/problems/PSB2/square_digits.cljc b/src/propeller/problems/PSB2/square_digits.cljc index bc3bc61..76b1a24 100644 --- a/src/propeller/problems/PSB2/square_digits.cljc +++ b/src/propeller/problems/PSB2/square_digits.cljc @@ -46,19 +46,14 @@ (:step-limit argmap)) :string)) inputs) - parsed-outputs (map (fn [output] - (try (read-string output) - #?(:clj (catch Exception e 1000.0) - :cljs (catch js/Error. e 1000.0)))) - outputs) errors (map (fn [correct-output output] (if (= output :no-stack-item) 10000 - (metrics/levenshtein-distance (str correct-output) (str output)))) + (metrics/levenshtein-distance correct-output output))) correct-outputs - parsed-outputs)] + outputs)] (assoc individual - :behaviors parsed-outputs + :behaviors outputs :errors errors :total-error #?(:clj (apply +' errors) :cljs (apply + errors))))) diff --git a/src/propeller/problems/PSB2/substitution_cipher.cljc b/src/propeller/problems/PSB2/substitution_cipher.cljc index 3f83e64..f6b5d49 100644 --- a/src/propeller/problems/PSB2/substitution_cipher.cljc +++ b/src/propeller/problems/PSB2/substitution_cipher.cljc @@ -59,19 +59,14 @@ (:step-limit argmap)) :string)) inputs) - parsed-outputs (map (fn [output] - (try (read-string output) - #?(:clj (catch Exception e 1000.0) - :cljs (catch js/Error. e 1000.0)))) - outputs) errors (map (fn [correct-output output] (if (= output :no-stack-item) 10000 - (metrics/levenshtein-distance (str correct-output) (str output)))) + (metrics/levenshtein-distance correct-output output))) correct-outputs - parsed-outputs)] + outputs)] (assoc individual - :behaviors parsed-outputs + :behaviors outputs :errors errors :total-error #?(:clj (apply +' errors) :cljs (apply + errors)))))