8000 Solve 03 2022 · motform/advent-of-clojure@c983418 · GitHub
[go: up one dir, main page]

Skip to content

Commit c983418

Browse files
committed
Solve 03 2022
1 parent ac41b21 commit c983418

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/advent_of_clojure/2017/03.clj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22

33
(def input 361527)
44

5-
(defn manhattan-distance [pos]
6-
())

src/advent_of_clojure/2022/04.clj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+

0 commit comments

Comments
 (0)
0