From 404e640cfb19c64f9dfee0aa73eb9a37fbf9f4a8 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Fri, 25 Feb 2022 16:49:45 -0600 Subject: [PATCH] Further improve Middle Character and Twitter Upon further inspection, Richard and I realized that we didn't need to have `parsed-outputs` at all in problems that just return a string (take the top value from the `:string` stack). So we removed all that from the Middle Character and Twitter problems, and removed the unnecessary calls to `str` in the `levenshtein-distance` calls. Co-authored-by: RichardLussier --- src/propeller/problems/PSB2/middle_character.cljc | 11 +++-------- src/propeller/problems/PSB2/twitter.cljc | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/propeller/problems/PSB2/middle_character.cljc b/src/propeller/problems/PSB2/middle_character.cljc index ee2378b..a665d9b 100644 --- a/src/propeller/problems/PSB2/middle_character.cljc +++ b/src/propeller/problems/PSB2/middle_character.cljc @@ -47,19 +47,14 @@ (:step-limit argmap)) :string)) inputs) - parsed-outputs (map (fn [output] - (if (= output :no-stack-item) - 1000.0 - output)) - 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/twitter.cljc b/src/propeller/problems/PSB2/twitter.cljc index 3d70851..95273e2 100644 --- a/src/propeller/problems/PSB2/twitter.cljc +++ b/src/propeller/problems/PSB2/twitter.cljc @@ -50,19 +50,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)))))