Skip to content

Commit 92abe83

Browse files
committed
some style improvements
1 parent 150bd29 commit 92abe83

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

clojure/day03.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
(defn gear-ratios [gear-values]
1313
(keep
14-
#(when (= (count %) 2)
14+
#(when (= 2 (count %))
1515
(reduce * %))
1616
gear-values))
1717

clojure/day04.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
(fn [amounts line]
2424
(let [copies (amounts line)]
2525
(reduce (fn [amounts delta]
26-
(update amounts (+ line delta 1) + copies))
26+
(update amounts (+ line delta) + copies))
2727
amounts
28-
(range (winners line)))))
28+
(range 1 (inc (winners line))))))
2929
(vec (repeat size 1))
3030
(range size))))
3131

clojure/day05.clj

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44

55
(defn parse-line [line]
6-
(let [[dest src rng] (aoc/integers line)]
6+
(let [[dest src len] (aoc/integers line)]
77
{:lo src
8-
:hi (+ src (dec rng))
8+
:hi (+ src (dec len))
99
:diff (- dest src)}))
1010

1111
(defn parse-maps [maps]
@@ -14,10 +14,11 @@
1414
(sort-by :lo)))
1515

1616
(defn seed-ranges [seeds]
17-
(->> (for [[st rng] (partition 2 seeds)]
18-
{:start st
19-
:stop (+ st (dec rng))})
20-
(sort-by :start)))
17+
(sort-by
18+
:start
19+
(for [[start len] (partition 2 seeds)]
20+
{:start start
21+
:stop (+ start (dec len))})))
2122

2223

2324
(defn convert-number [rules src]

clojure/day06.clj

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919

2020

2121
(defn solve [input]
22-
(let [[times distances] (aoc/parse-input input :ints)
23-
time-2 (fix-keming times)
24-
distance-2 (fix-keming distances)]
25-
[(transduce (map find-winners) * (zipmap times distances))
26-
(find-winners [time-2 distance-2])]))
22+
(let [document (aoc/parse-input input :ints)]
23+
[(transduce (map find-winners) * (aoc/transpose document))
24+
(find-winners (mapv fix-keming document))]))
2725

2826

2927
(solve (aoc/read-file 6))

clojure/day11.clj

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242

4343

4444
(defn solve [input]
45-
(let [lines (aoc/parse-input input)
46-
galaxies (find-galaxies lines)
45+
(let [lines (aoc/parse-input input)
46+
galaxies (find-galaxies lines)
4747
galaxies-x (sort (map first galaxies))
4848
galaxies-y (sort (map second galaxies))
4949
empty-rows (empty-lines lines)
5050
empty-cols (empty-lines (aoc/transpose lines))
51-
distances (+ (calc-dist galaxies-x)
52-
(calc-dist galaxies-y))
51+
distances (+ (calc-dist galaxies-x)
52+
(calc-dist galaxies-y))
5353
expansions (+ (expansion galaxies-x empty-cols)
5454
(expansion galaxies-y empty-rows))]
5555
[(+ distances expansions)

clojure/day13.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(aoc/count-if false? (map = a b)))
77

88

9-
(defn is-mirror? [part pattern nrettap line]
9+
(defn mirror? [part pattern nrettap line]
1010
(let [before (take-last line nrettap)
1111
after (drop line pattern)
1212
diffs (map differences before after)]
@@ -17,7 +17,7 @@
1717

1818
(defn mirror-line [part pattern]
1919
(aoc/find-first
20-
(partial is-mirror? part pattern (rseq pattern))
20+
(partial mirror? part pattern (rseq pattern))
2121
(range 1 (count pattern))))
2222

2323

deps.edn

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
org.clojure/data.int-map {:mvn/version "1.2.1"}
55
org.clojure/core.async {:mvn/version "1.6.681"}
66
org.flatland/ordered {:mvn/version "1.15.11"}
7-
org.clojure/data.priority-map {:mvn/version "1.1.0"}}
7+
org.clojure/data.priority-map {:mvn/version "1.1.0"}
8+
io.github.engelberg/better-cond {:git/tag "v2.1.5" :git/sha "156bc5f"}}
89
:aliases
910
{:profile {:jvm-opts ["-Djdk.attach.allowAttachSelf"]
1011
:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
1112
com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.1.0"}
1213
com.taoensso/tufte {:mvn/version "2.6.3"}}}
13-
:viz {:extra-deps {quil/quil {:mvn/version "4.3.1323"}}}}}
14+
:viz {:extra-deps {quil/quil {:mvn/version "4.3.1323"}}}
15+
:splint {:extra-deps {io.github.noahtheduke/splint {:mvn/version "1.15.0"}}
16+
:main-opts ["-m" "noahtheduke.splint"]}}}

0 commit comments

Comments
 (0)