advent-23-clojure/main.clj

28 lines
617 B
Clojure

(ns main
"Advent Of Code 2023 solved in Clojure"
(:require
[day01]
[day02])
(:import
[java.time Instant Duration]))
(defn benchmark
[f day part]
(let [then (Instant/now)
result (f)
now (Instant/now)
time (.toMillis (Duration/between then now))]
(println (str "Day " day " part " part ": " result " (" time " ms)"))))
(defn aoc-23 []
(printf "Advent of Code 2023, solved in Clojure.\n\n")
(benchmark day01/part1 "01" "1")
(benchmark day01/part2 "01" "2")
(benchmark day02/part1 "02" "1")
(benchmark day02/part2 "02" "2")
(println "\nthe end."))
(aoc-23)