From fa4b58b6ce7e011ee2b88e86648678c6bcd06e66 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Tue, 7 Dec 2021 18:32:49 +0100 Subject: day06 --- day06 | 1 + day06.bqn | 5 +++++ day06.clj | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 day06 create mode 100644 day06.bqn create mode 100644 day06.clj diff --git a/day06 b/day06 new file mode 100644 index 0000000..445de95 --- /dev/null +++ b/day06 @@ -0,0 +1 @@ +1,1,3,1,3,2,1,3,1,1,3,1,1,2,1,3,1,1,3,5,1,1,1,3,1,2,1,1,1,1,4,4,1,2,1,2,1,1,1,5,3,2,1,5,2,5,3,3,2,2,5,4,1,1,4,4,1,1,1,1,1,1,5,1,2,4,3,2,2,2,2,1,4,1,1,5,1,3,4,4,1,1,3,3,5,5,3,1,3,3,3,1,4,2,2,1,3,4,1,4,3,3,2,3,1,1,1,5,3,1,4,2,2,3,1,3,1,2,3,3,1,4,2,2,4,1,3,1,1,1,1,1,2,1,3,3,1,2,1,1,3,4,1,1,1,1,5,1,1,5,1,1,1,4,1,5,3,1,1,3,2,1,1,3,1,1,1,5,4,3,3,5,1,3,4,3,3,1,4,4,1,2,1,1,2,1,1,1,2,1,1,1,1,1,5,1,1,2,1,5,2,1,1,2,3,2,3,1,3,1,1,1,5,1,1,2,1,1,1,1,3,4,5,3,1,4,1,1,4,1,4,1,1,1,4,5,1,1,1,4,1,3,2,2,1,1,2,3,1,4,3,5,1,5,1,1,4,5,5,1,1,3,3,1,1,1,1,5,5,3,3,2,4,1,1,1,1,1,5,1,1,2,5,5,4,2,4,4,1,1,3,3,1,5,1,1,1,1,1,1 diff --git a/day06.bqn b/day06.bqn new file mode 100644 index 0000000..3e1ebe1 --- /dev/null +++ b/day06.bqn @@ -0,0 +1,5 @@ +d←+˝(↕9)=⌜˜ •BQN '⟨'⊸∾ ∾⟜'⟩' •FChars"day06" +Step ← 1⊸⌽ + (6=↕9)×⊑ + +•Out +´ Step⍟80 d +•Out +´ Step⍟256 d diff --git a/day06.clj b/day06.clj new file mode 100644 index 0000000..e674209 --- /dev/null +++ b/day06.clj @@ -0,0 +1,22 @@ +(ns org.vuxu.aoc2021.day06 + (:require [clojure.string :as str])) + +(def data + (let [values (->> (str/split (str/trim-newline (slurp "day06")) #",") + (mapv parse-long))] + (mapv #(count (filter #{%} values)) (range 0 9)))) + +(defn stepv [fishes] + (mapv (fn [i] + (cond (= i 8) (fishes 0) + (= i 6) (+ (fishes 0) (fishes (inc i))) + :else (fishes (inc i)))) + (range 0 9))) + +(def part1 + (apply + (nth (iterate stepv data) 80))) +;; => 373378 + +(def part2 + (apply + (nth (iterate stepv data) 256))) +;; => 1682576647495 -- cgit 1.4.1