File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
(def input 361527 )
4
4
5
- (defn manhattan-distance [pos]
6
- ())
Original file line number Diff line number Diff line change
1
+ (ns advent-of-clojure.2022.04
2
+ (:require [clojure.set :as set]
3
+ [clojure.string :as str]))
4
+
5
+ (def parse-digits
6
+ (comp (partial mapv parse-long)
7
+ (partial re-seq #"\d +" )))
8
+
9
+ (def input (->> " resources/2022/04.dat" slurp str/split-lines (mapv parse-digits)))
10
+
11
+ (defn in-bounds? [[x1 y1 x2 y2]]
12
+ (or (and (<= x2 x1) (>= y2 y1))
13
+ (and (<= x1 x2) (>= y1 y2))))
14
+
15
+ (def part-one (->> input (filter in-bounds?) count))
16
+
17
+ (defn overlaps? [[x1 y1 x2 y2]]
18
+ (seq (set/intersection
19
+ (set (range x1 (inc y1)))
20
+ (set (range x2 (inc y2))))))
21
+
22
+ (def part-two (->> input (filter overlaps?) count))
23
+
You can’t perform that action at this time.
0 commit comments