Commit 044af24 1 parent 7258ba2 commit 044af24 Copy full SHA for 044af24
File tree 1 file changed +9
-14
lines changed
1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change 3
3
[clojure.string :as str]))
4
4
5
5
6
- (defn rotate [platform]
7
- (->> platform
8
- aoc/transpose
9
- (map str/join)))
10
-
6
+ (defn transpose [platform]
7
+ (apply map str platform))
11
8
12
9
(defn move-line [dir line]
13
10
(->> (str/split line #"#" -1 )
20
17
21
18
22
19
(defn move-east [platform]
23
- (pmap #(move-line :right %) platform))
20
+ (vec ( pmap #(move-line :right %) platform) ))
24
21
25
22
(defn move-west [platform]
26
- (pmap #(move-line :left %) platform))
23
+ (vec ( pmap #(move-line :left %) platform) ))
27
24
28
25
(defn move-north [platform]
29
- (-> platform rotate move-west rotate ))
26
+ (-> platform transpose move-west transpose ))
30
27
31
28
(defn move-south [platform]
32
- (-> platform rotate move-east rotate ))
29
+ (-> platform transpose move-east transpose ))
33
30
34
31
(defn spin-cycle [platform]
35
32
(-> platform move-north move-west move-south move-east))
38
35
(defn calc-score [platform]
39
36
(let [platform (vec platform)
40
37
size (count platform)]
41
- (reduce
42
- (fn [acc n]
43
- (+ acc (* (- size n)
44
- (aoc/count-if #{\O} (platform n)))))
45
- 0
38
+ (aoc/sum-map
39
+ (fn [n] (* (- size n)
40
+ (aoc/count-if #{\O} (platform n))))
46
41
(range size))))
47
42
48
43
You can’t perform that action at this time.
0 commit comments