aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-080/tyler-wardhaugh/clojure/src/tw/weekly/c80/t2.clj6
-rw-r--r--challenge-080/tyler-wardhaugh/clojure/test/tw/weekly/c80_test.clj5
2 files changed, 5 insertions, 6 deletions
diff --git a/challenge-080/tyler-wardhaugh/clojure/src/tw/weekly/c80/t2.clj b/challenge-080/tyler-wardhaugh/clojure/src/tw/weekly/c80/t2.clj
index 8d12ce4e14..55586b34a8 100644
--- a/challenge-080/tyler-wardhaugh/clojure/src/tw/weekly/c80/t2.clj
+++ b/challenge-080/tyler-wardhaugh/clojure/src/tw/weekly/c80/t2.clj
@@ -14,10 +14,8 @@
(defn count-candies
"Determine the number of candies needed according to the rules in the task description."
[coll]
- (let [xf (comp (map (juxt (fn [[a b _]] (if (> b a) 1 0))
- (fn [[_ b c]] (if (> b c) 1 0))))
- (map (partial apply + 1)))
- source (partition 3 1 (repeat ##Inf) (concat [##Inf] coll))]
+ (let [xf (map #(inc (if (apply not= %) 1 0)))
+ source (partition 2 1 (list (last coll)) coll)]
(transduce xf + source)))
(defn -main
diff --git a/challenge-080/tyler-wardhaugh/clojure/test/tw/weekly/c80_test.clj b/challenge-080/tyler-wardhaugh/clojure/test/tw/weekly/c80_test.clj
index 7c88e71f6b..32251e39f5 100644
--- a/challenge-080/tyler-wardhaugh/clojure/test/tw/weekly/c80_test.clj
+++ b/challenge-080/tyler-wardhaugh/clojure/test/tw/weekly/c80_test.clj
@@ -14,5 +14,6 @@
(deftest task-2
(testing "Task 2, Count Candies"
- (is (= (count-candies [1, 2, 2]) 4))
- (is (= (count-candies [1, 4, 3, 2]) 7))))
+ (is (= (count-candies [1 2 2]) 4))
+ (is (= (count-candies [1 4 3 2]) 7))
+ (is (= (count-candies [2 1 4 3 1 2]) 11))))