about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2020-12-04 12:38:16 +0100
committerLeah Neukirchen <leah@vuxu.org>2020-12-04 12:38:16 +0100
commitd20125b66e35d3380e4e39c4a75fbb6604b6cc00 (patch)
treea47dbfe6cf429db38b30f9a11a6b610058ceaa77
parenta804cd7bdf6cf1557cca4656eeca678925059358 (diff)
downloadadventofcode2020-d20125b66e35d3380e4e39c4a75fbb6604b6cc00.tar.gz
adventofcode2020-d20125b66e35d3380e4e39c4a75fbb6604b6cc00.tar.xz
adventofcode2020-d20125b66e35d3380e4e39c4a75fbb6604b6cc00.zip
day03
-rw-r--r--day03323
-rw-r--r--day03.clj15
-rw-r--r--day03.ijs5
3 files changed, 343 insertions, 0 deletions
diff --git a/day03 b/day03
new file mode 100644
index 0000000..9256a36
--- /dev/null
+++ b/day03
@@ -0,0 +1,323 @@
+...............#.#.............
+##..#....................#...##
+......#..#.#.....#..#.#.##.....
+.........#...#..............#.#
+............#.......##.........
+...#.....#.....#...#.....#..#..
+..............#..##.#..#......#
+.##.....#.....#......##.#......
+.#..........###....#...##....#.
+.....#....#.#.......#......##..
+.#....#......#.......#........#
+..#.#.......#..##.....##.......
+...#.#....#.......#.......#...#
+##.##...##..#......#.#.....#..#
+.#.#.......#..#.#......#...#.#.
+#.......##.......#...#.........
+.....#......#.#.#.....#....##..
+.#.#........#....#..#..#.......
+...#....#..###.........#.....#.
+........#........#........#....
+..##..............#.....#.#..#.
+.#...##.............#.#........
+....#..#...........#.......#...
+..#....#.....................#.
+#.#..................##......##
+.#.##....#......#........#.....
+.........##.....#....#...##..#.
+#..........#..#.#.............#
+.........#...#.#.#.#..##..##...
+#...#.....#..#..#....#...#.....
+..##.....#..................#..
+#..###.....#....#.......#..#...
+...##.##..#............#......#
+........###.........###......#.
+#..##....#.........#.........#.
+....#.....................#....
+#..#..##..#..####.##..#.....##.
+..#...#.#....#....##.....#.....
+...#.#.........#.....#.#.......
+....#................#..#...##.
+....#..#..........#...#.#.##...
+........#..##............#....#
+...#......##..........#.##...#.
+.......##......................
+.......##..........#....#.#...#
+......###.##..##..#....#...#..#
+#.#...........##.....#........#
+..#...........#..###....#.#.#..
+........#...........#......##..
+.........#...##.###...###..#...
+.....#.....#..##.........##....
+...##..............#.....#...##
+.##....#.......###.....#.......
+.#...........##.............##.
+......#..#..##.##......#......#
+........###........#......#.#..
+#.#....#.....#........#......#.
+.##..#.........##...##....#....
+.....#.........#...##.....#....
+.............#........###....#.
+......#.......#.#........#.#...
+..#....#.#...#....#...#.#...##.
+#...#......##..##......#.##.###
+...##.#....#...#....#.........#
+...#..####.....##.#..#.#...##..
+##.#..#....##......#......##...
+###.........#.#..#.#.....#.....
+...#........#..##...#.#.#..#.#.
+...###..#.###.#...#............
+....................###........
+...........#...........#.......
+#..............#.#.........###.
+....................##.....#..#
+#.#.....#.......#...#..........
+.#...#......#....##...#...#....
+.....#.##..................###.
+.........#.#..#.#......#.......
+.......#.....##..#.##.#........
+..#..........#.###.....#....#..
+......#.............#.#........
+........##....#........#.......
+...#.............#....#.#......
+#........#..####.....#.....#.#.
+.##......##...#........#..#.#..
+....##....#...#...#..##...#.#..
+#.##...###..#....##.#..........
+....#.#...#.#...#..##.###...#..
+#.....##..#..#....#.#.....##...
+.#..#..........##.#.....##.....
+.#..#........#.#.#.#...........
+.#..#.....#...........#...#....
+...#......##..........##..#....
+...#..#....#.##...#..#.....###.
+#.#....#.....##................
+#..#......#.#.#.......#........
+......#....#.#....#..##....#..#
+.#.....#.#....###.##.........#.
+.###..#.....#........#.#.......
+.#...#......#..#.#......#.....#
+#...............####...#.....#.
+.......#..........##.#........#
+#........##....##.....###..##..
+#..#.....#..##.....#....#..#...
+#.....#.......##......#.#.....#
+#.##..#......##..#.............
+##...#.....#........##.........
+....#..##....#...#.......#.#...
+....#...#...##..#....#..#...#..
+..............#.#...#....###...
+...#....#..##...##..#....##....
+#.##.#..#..#......#.#.#.#...#..
+.......#..#..##........#......#
+##.#....#....##.#......##.#....
+.#...#..............#........#.
+.#.#....#.........#............
+.#..#..###.............#....#..
+#......#...#.#..##..#...#....#.
+.......................#...#.#.
+.............#..#...##.........
+..#.#..#....#....#........#....
+#......#.##..#...#.#...........
+.....#....#...........##.#..#..
+..#.#.....#..............#.#...
+#.......#.....#................
+#..............#...#....#...#..
+...#...##..#..#............#...
+......###.....................#
+.........#.......##..#....#....
+........#...#.##..#.##......#..
+....###..#.#...#...#..#.#...###
+##...#...##.#...#.#...#.#....#.
+.........#...#.....###.........
+...#........##..#.......##.....
+.#.......##.........#.....##..#
+.#..................#...#......
+.##..#..#.#.....#.###..........
+...#.....##..#.........#...#...
+.#......#.#.......#.#..........
+.........#.#...#..........#.#..
+#..........#.##..#.##....#.....
+.#.#....#.....#..##.....#...#..
+..#........##...##..#..#....#..
+#...........##....#..###....#..
+...........##.........####...#.
+..#........###...#.#.........#.
+.#...............#.##.#.#...#..
+.#.##..#.....#.#.....##..#.....
+...#...#..#.##.##...#.......##.
+..#...#...#......##.##.##...#..
+##....#...#...#...............#
+...##...........#......#..#.#..
+#.........#......#.#.##.....#..
+........#..#.........##........
+..#.#....###.....##..#...#.....
+.........#...#.......#.....##..
+##.....................#...##..
+.#.#..#......#.................
+.....###..#......#..###..#.....
+...#.....##.........#......#..#
+......##.....#...#........#.#..
+..#.#...#......#...#.##.##.....
+...#..........#...#.......#..##
+.###........#........##........
+..#.#.#..........#.#...##......
+.........#........#......###..#
+....##..#.........#...........#
+..####..#............##.......#
+.....##.#..##.........#...#.#..
+...#.........#.....#.....#.....
+.......#...#..#...##.........#.
+...#...#..#...#....#..#........
+#............##.##...#.........
+.#.#.....#.......####.....#....
+..............#......#.#.......
+..............#...........#...#
+#...#........###....#.#....#.#.
+##.#..#..#......#......#.#.#...
+.#..#.....#..#.#..#.#.......##.
+......##.#...#...#......#...#..
+#...........##....#.#..........
+....#.......###.#...#..........
+.......................#.....#.
+........#...#..#...#.#.#.#.#...
+.#.#...........#......##...#...
+.........................#.....
+.................#.##.#...##...
+...#...##.....#.....##....#.#..
+...#...#...................#...
+...#..#..#...#...#....#........
+#....#...#.....#...............
+.......#...........#...#.......
+....#....#.....##.......#......
+.......#..........##...........
+.#.#........#..##....#......#..
+.....#.......#.#.........#...#.
+.#..####.#.#...............#..#
+.....###..#..#..........#.#..##
+..#.......#...#.....##..#..#.#.
+#....#......#..................
+........#.##.#....#...........#
+....#.#....##..#.#.....##......
+...#..#.......#....#.....#.#.#.
+#...#......#.....#.#..........#
+....#....#...............#.....
+..###......................###.
+.##....#..#.......###.....#..#.
+..###............#........#.##.
+.#........#......#.....#..#....
+....#..##...#...#.###.......#.#
+.......#.##...........#.#..#...
+.....#...##....................
+....#....#...##......#.........
+..#............##....###.#...#.
+.#........#...............#....
+#..#.#.##.........#..##....##..
+#.#....#..#.##....##...#.#.....
+.....#.....##....#.#........#..
+#..#...#...#....#....#.........
+...#........#..#.#.....##......
+..#...#...#................##..
+#........#.#.##.......#.#...#..
+#......#..####.##.....#.#..#.#.
+............#..#.#....#......##
+..#.....##....#...#.#..........
+...#...#.........#...#.#.......
+.###..#.......##.##.....#.#.#..
+...#....#...............##.#...
+....##..#..#..#.#......##.....#
+#.#..............##...##...####
+.....#.##...#.#...............#
+.##.....#.........#.......#.#.#
+#.#..#.....#.......#.......#..#
+...#.#.....#.....#......#......
+.......#....#..#.#..........#..
+......#......#.##...#..........
+.....#.......###...#...#.#.....
+#..#.#.........#.....#.##....#.
+..#.#.........#..#..#..#.....#.
+.#..##..#..#....#......#.##..#.
+...##......###.....#.##.##.....
+.#.....#...#..#...#............
+##..##..#.##....#..#...........
+...#..##..#..#.............#.##
+...............##............#.
+..#.....##........##.#...#....#
+.#.#...#.#.#..#.#.....#....#...
+.#....#...............#..#.....
+....#.##..#....#......#...###..
+#................###...#.#.....
+...#...#......##..#.#....#.....
+.#....#....#.#...##............
+....#...##..#..#........#.##...
+..##.....#..#..##..............
+..#..##..#.#..##....#....#....#
+...##.............#............
+#....#....#.#........#.....##.#
+.....#..#.#.....####...###.....
+................#......#.......
+.....#.#.#.#.#....#..#........#
+.##.#...#.#.......##....#....#.
+.....#........#................
+..#.....#..#...#..#...........#
+.#.....#...##.....##..#.#....##
+......#.......#..#......##.#...
+#.#..........#.##.#........#...
+...#..#.............#..........
+#..#..#..........#..##.#.......
+.#..#...............####..#....
+.......#.....#......#.....#.#..
+.#...............#...#.........
+.#..#..........#..#.#..##..#..#
+......##..#.....#..#......###..
+..........#...#..#.......#.....
+.#.#.#..#.....#.##.#...#..#....
+........#.......#.....#.#......
+......#.....##.....#....##.#...
+...............#......#.......#
+..#.#...#.....#.#...##......#..
+#.#.........#.#...#........####
+#..........##..#..#........##..
+.............#..#.......##.#..#
+..#........#.#....#........#.#.
+.#......####..#..#.............
+............###.......#.#..#...
+#.##......##...#...#.........#.
+....##.#.#.#......#....#..#...#
+.#..#.#....#...#.........#.....
+#...#.....##............#...#..
+#.#...#..#.................#...
+............#.#..#.....#.#.#..#
+...................#....#.##...
+.....#...#.#....#....#.#......#
+.......##.#.#......##..........
+.#..#...##.#...#..#......#.....
+......#.#..#..###..##..##......
+.#.#.#.#.....#...###.....#..#..
+.#....#.....#.......#.......#..
+..........##.........####......
+.#.#.............#..#.#...#....
+........#........##...#.#....#.
+........#......................
+..#.#....#...............#...##
+.......#.#...#..#.....##......#
+.#...#....#..........##........
+.#.........#.#............##...
+.....#......##...#.......#..#..
+#.#..#.............#...#...#...
+......#.......#............#...
+...........##....#......##.....
+.#.#..#.....................#..
+##..##.....###..##.#...........
+...##......##....#...##.....#..
+#...#.##.............#.........
+......#..#.........###.#......#
+#.#.....#.....................#
+....#####.....##........#.#..#.
+...........##..##.###..........
+..........##.....#........#...#
+.......#..#......#.....##..##.#
+.....##.#........#.........#...
+......##......................#
+.#.......#.#.#............#..#.
+.....##.#.......#.#........#...
diff --git a/day03.clj b/day03.clj
new file mode 100644
index 0000000..16981d1
--- /dev/null
+++ b/day03.clj
@@ -0,0 +1,15 @@
+(def data
+  (->> (slurp "day03")
+       (clojure.string/split-lines))
+
+(defn slop [step]
+  (->> (range)
+       (map #(mapv (partial * %) step))
+       (take-while #(< (first %) (count data)))
+       (map (fn [[x y]]
+              (nth (cycle (nth data x)) y)))
+       (filter #{\#})
+       (count)))
+
+(slop [1 3]) ; => 270
+(apply * (map slop [[1 1] [1 3] [1 5] [1 7] [2 1]])) ; => 2122848000
diff --git a/day03.ijs b/day03.ijs
new file mode 100644
index 0000000..b1c51f4
--- /dev/null
+++ b/day03.ijs
@@ -0,0 +1,5 @@
+d =: (3000&$;._2) 1!:1 < 'day03'
+slop =: 3 : '+/''#''= d{~ y <@:*"_ 0 i.>.(#d)%{.y'
+
+slop 1 3   NB. 270
+*/ slop&> (1 1; 1 3; 1 5; 1 7; 2 1)  NB. 2122848000