fork download
  1. (defn count-same [acc [x & rest]] (if (= x (first rest)) (recur (inc acc) rest) acc))
  2. (defn count-out-consecutive [matrix coords direction]
  3. (->> coords
  4. (iterate #(mapv + % direction))
  5. (map #(get-in matrix % ::not-found))
  6. (count-same 1)))
  7.  
  8. (println (count-out-consecutive (vec (repeat 3 (vec (repeat 3 0)))) [0 0] [1 1]))
Success #stdin #stdout 1.11s 75560KB
stdin
Standard input is empty
stdout
3