init 2017

This commit is contained in:
Adam Jeniski
2026-04-23 15:36:25 -04:00
parent 7057247936
commit 484e507af1
6 changed files with 101 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
(ns day01
(:require input-manager))
(defn to-digit [c] (Character/digit c 10))
(def input (mapv to-digit (input-manager/get-input-raw 2017 01)))
(defn solve [offset]
(let [lookup (fn [idx]
(input (mod idx (count input))))]
(->> input
(map-indexed vector)
(filter (fn [[idx el]]
(= el (lookup (+ offset idx)))))
(map second)
(apply +))))
;; part 1
(solve 1)
;; part 2
(solve (/ (count input) 2))
+25
View File
@@ -0,0 +1,25 @@
(ns day02
(:require input-manager
core))
(def input (mapv (comp #(mapv parse-long %)
core/split-whitespace)
(input-manager/get-input 2017 02)))
;; part 1
(->> input
(map (comp #(apply - %)
(juxt #(apply max %)
#(apply min %))))
(apply +))
(defn find-divisible [l]
(or (first
(for [a (range (count l))
b (range (count l))
:when (and (not= a b)
(= (mod (l a) (l b)) 0))]
(/ (l a) (l b))))
0))
(apply + (map find-divisible input))
+20
View File
@@ -0,0 +1,20 @@
(ns day04
(:require input-manager
core))
(def input (map core/split-whitespace (input-manager/get-input 2017 04)))
;; part 1
(->> input
(filter #(= (count %)
(count (into #{} %))))
count)
;; part 2
(->> input
(filter (fn [l]
(= (count (into #{} (map frequencies l)))
(count l))))
count)
+11
View File
@@ -0,0 +1,11 @@
(ns user
(:require
[clojure.pprint :as pprint]))
(defonce printer (bound-fn* pprint/pprint))
(add-tap printer)
(comment
;; tap debugging
(remove-tap printer))