-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.clj
33 lines (26 loc) · 878 Bytes
/
3.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(:require 'leiningen.exec)
(require '[clojure.string :as str])
(require '[clojure.java.io :as io])
(defn deliver-present [direction]
(condp = direction
\v [0 -1]
\^ [0 1]
\< [-1 0]
\> [1 0]))
(def input (slurp "3.txt"))
;; part 1 ;; reductions a new learning
(println (count (set
(reductions
#(map + %1 %2)
(list 0 0)
(map deliver-present input)))))
;;part 2
(println (count (set (concat
(reductions
#(map + %1 %2)
(list 0 0)
(map deliver-present (map first (partition 2 input))))
(reductions
#(map + %1 %2)
(list 0 0)
(map deliver-present (map second (partition 2 input))))))))