aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Brattlof <hello@bryanbrattlof.com>2020-12-11 18:22:15 -0500
committerBryan Brattlof <hello@bryanbrattlof.com>2020-12-11 18:22:15 -0500
commit8382d94ed2ee504879b2e63e77cfe1caa4d90fb9 (patch)
tree61be4e3b08f781aa2774d7efb3372e1faaddd4d6
parent85351d531caa4eff23436bf252511af800eb8045 (diff)
downloadadvent-of-code-8382d94ed2ee504879b2e63e77cfe1caa4d90fb9.tar.gz
advent-of-code-8382d94ed2ee504879b2e63e77cfe1caa4d90fb9.tar.bz2
day 3.1 of Advent of Code 2020
-rw-r--r--2020/day03/data/slope.txt323
-rw-r--r--2020/day03/toboggan-trajectory.py35
2 files changed, 358 insertions, 0 deletions
diff --git a/2020/day03/data/slope.txt b/2020/day03/data/slope.txt
new file mode 100644
index 0000000..6d1c464
--- /dev/null
+++ b/2020/day03/data/slope.txt
@@ -0,0 +1,323 @@
+.......#................#......
+...#.#.....#.##.....#..#.......
+..#..#.#......#.#.#............
+....#...#...##.....#..#.....#..
+....#.......#.##......#...#..#.
+...............#.#.#.....#..#..
+...##...#...#..##.###...##.....
+##..#.#...##.....#.#..........#
+.#....#..#..#......#....#....#.
+...........................#...
+..........#.......#..#.....#.#.
+..#.......###..#.#.......#.#...
+....#..#....#....#..........#..
+..##..#.......#.#...#..........
+.....#.......#.....#....#......
+..........##..#................
+....##.#..###...#..##.....#.#..
+..#..#.#.#...#......#...#.....#
+....#.#....#...####.##.........
+..#.........##...##.#..#..#....
+.#......#...#..#..##.#.........
+.#....#.......#..##..##..#.#.#.
+...........#....#......#.......
+..#....#....#...............#..
+..#.....#....###.##.....#.#..#.
+#..........#.#......#.#....#...
+....###...#.#.....#....#.####.#
+........#......#...#...#..##..#
+...##..............##.#.......#
+#..........#...........#.#....#
+#...#....#..####..#............
+###....#........#..............
+...#.##....................#.##
+...#..#.....#.....##...#....#..
+.......###.#...#.........#.....
+.#..#.....#.#..#.....#.........
+#................#.............
+...#......#.#.....##.#.#....#..
+...#..#.#..#.....#...#....#....
+.......#......#........#.....#.
+.#.##..##.....#.#......#.#.#...
+#...............#.....#....#...
+.....#...........#..##.........
+.....#..#........##..#..#.....#
+..###.#.#.......#.#...........#
+##....##....#.#....##...#.##.##
+..................##.#.#.....#.
+.#...........###...#...........
+.#.#....#......#....###.#......
+.......#.##...#...#..#.#.......
+..#.....#.#....#..#............
+.....#..#..#....#..#.........#.
+..##.#......#.....#...#.#..#.#.
+.........#......#....##.......#
+#........#..#.#......#...#.#..#
+...#....#.#..#....##.......###.
+..#...#......#.##..........#...
+........#..#..#...#.......#....
+.##.#..#...#..#........#.#.####
+#..#..#..........#....##...#...
+....#...#........##........#...
+.#......#.......#..#..#........
+#...#.#......#....#............
+#........#..##.#...##..........
+...#..##.....#......##.#..#.#..
+.#.#.....#.....#.####.#..##....
+..........###....#.##...#......
+.......#.......#..#.#.#.##.#..#
+..#.#....#......#.#...#.......#
+.#...#....#......#...#.........
+.#....#..#....#.##.#....#..##..
+...#..#.#..................#...
+.##..#.............##.........#
+...#.#.#................#.....#
+...###..###..................#.
+........##.##..#.#...#.....#...
+.##...##...#...#....#...#......
+#..#....#..#..#.#....#..####...
+.#...............##....##.#....
+#..#................#...#..#...
+.#....#.....#..#.#........#....
+...............##.#..##..##....
+.#......#........#....#.#...#.#
+.#.....#...##.#........#.##.#.#
+..###............#..#.#....#...
+..#.....#.........#....#..#.#..
+.##.....#.#..........#.#....##.
+...#...#....#..#......#.#.#..#.
+#.....#...#....##...#.......##.
+.......#.#.........##..........
+............##.#.##...#.......#
+.....#........##...#........#..
+.#........#.#.#.#....#.........
+#....#..#....#.#..#...#.#......
+....##...........#...#...##.#.#
+......#...##.###.....#.........
+............#..##....##......#.
+......##....#...#.#....#......#
+#..#..#..#.#.#.........#...##.#
+...#.........#...#.........##.#
+#.#.....#.......#.##..#..#.....
+##................#......#....#
+....#..#.......#....##.....#...
+.....#..#...#...#......#.#....#
+..#....#.....#.........#.....#.
+..#..#..........#.....#........
+.......#..##.#......#.#........
+.............##.....#....#.....
+...#....#..#.#.#...............
+........#....##..#...#........#
+..##...............#.....#....#
+........##.#.##.#......#..#....
+..#.##.......#..........##..#..
+.#..............#.#.##.........
+.#.......#....#....#.#.#.......
+.#.##.......#....#......###.#..
+.......#...#............##.....
+........#.#..........##..#.....
+...###..#......#.....##..#..#..
+...........##......#....#......
+..............#....#..#..#.#..#
+....#...#......#.##...#........
+.#.............#..#......###.#.
+#...#..#.#..............##..#.#
+....................#.........#
+..##..#......#.###.....#...#.#.
+.#....#.#........#...#........#
+..#....#.....#..............#..
+##..........#..#..#...#........
+...........#..##...#.......#...
+........##.............#.......
+#....#........#..#.#.###..#....
+...........##..........##......
+#......#.....##.#.##......##...
+..#......#.........#.......#..#
+......#.#....##..##.#...#.#...#
+......#..................##....
+...#....#.#...#.#.......##.....
+#.#...##...##........#...##....
+..#.......#.#.#...#............
+.......#......#..#...#.........
+#...#..#...........##..........
+......#....#.........#.#....#..
+#......#........#...#..##....#.
+.....#.......##..#.#......#..#.
+...........#......#...#......#.
+#.#.##.....#....#.....##......#
+.....##..#.#.#.###........#.#..
+...#...#.#......#......#.......
+......###....#..##...#.#.##....
+#.....#.....#..................
+...#...#......#...............#
+..#............##..#.....#.....
+.#....#...#...#...#...#..#.....
+.##......#.........#.###.#.....
+#.#.##.......##...#........##.#
+.##.#.#......#.....#...#.....#.
+....####.##.......#..##..##.#..
+#.#.......#..##....###..#...#..
+..#..#....#...#.#.#.#...#......
+##.........#.##................
+........#.....................#
+..#...........#..#..##.#..#.#..
+#...#...................#.###..
+##..#............#.........#..#
+...............##...#...##....#
+#.#.....#..#.......#......#....
+.#...#......#............#.....
+#.......#...#..#....#.......#..
+...#....#.##.#....#....#.#.....
+...#..#..............#..#.#..#.
+.........#.....#.#...#..#....#.
+..#..#..#...##.....##.#.....#..
+.#.#..........#........#.......
+...............#........#.#.#..
+.#......#.....#..............#.
+........#.#..............#.#...
+.......#.#....#..#.#.#..#.#.##.
+...##..#...#.#..#...........#..
+#...###.#.....#..#........#....
+.#...##...##...##.#.....###....
+.........#......#.#..##.#.#....
+#....#.#..#...#.#.#....#..#..#.
+.#.#...#......###.....#........
+#.....#.#.......#..#.#...#.....
+.................#.#....#..##..
+#...........#....###..#......#.
+##.#..#....#.#.#.#.............
+#.....#..#...#........#........
+..#..#......#..#.##.#..........
+...#....#..#..........#.#.##.##
+#........#...#.......#..##.#...
+.#.#..#....#.#....#......#.....
+##.......##.#........#...#..##.
+##.##.....#.......#####.#....#.
+..#..###.#.#..#....###..#.##..#
+#.........#.............#.#...#
+..#...##.#..................#..
+.....#.#....#.#..#.#........#.#
+......#.......#.#..##.#.#..#...
+..#......#.#..##......#..#....#
+..##..#..#.##.#..#....#...##...
+###....#...##....##.........#..
+#........##.........#......#..#
+...#.........#......#.##.......
+.....#.#.#....#......#.........
+..#...........#....#......#.#..
+##........#...##.....######....
+....#..#..##.......#..#..#.....
+..#....#..##....#......##....#.
+...##....#........##......#....
+.#.#...###...#......#..........
+#....#..#.##.........#...#.....
+......#..#.........#.##.....#..
+...#............##....#......#.
+...#.....##.....#........#.#..#
+......#.#..#......#.....#..##..
+#.#.........##..........#......
+..###.....#..#....##..........#
+.............##..#....#..##....
+....#.#....##..#......#...#....
+....###.....#..#.......#.......
+............#..#...............
+......#........#..#......#.....
+.#........#.......#.##.......#.
+..#.........#..#.#.....##....#.
+...#.......#.......#.......##.#
+#......##.#.....#......##.#..#.
+#..........#.................#.
+....#..##...........#.....#.#..
+#.###...#............#.#....#.#
+....#......#.#..###....##..#...
+....#...#..........##..........
+..#.#............#...#...###...
+......#...#......#..#.#........
+.#.......#..#...........##...#.
+##...#...##....##.#..#..#.#....
+.......#........#............##
+.#......#...#.#................
+#.#........#.#....#..#.##......
+.......#.#...#....##.......##..
+........#.#.#.........##..##...
+..##...............#.#.###.#...
+......#.#....#..#......##.....#
+###.........#.....#.#.....##...
+.#.#....#.....#.#.##..#.......#
+..#..#.#......#...##..##.#..#..
+...#........#..#....#..........
+#...#.#...#..##....##..........
+.........#........#.##....#..#.
+..#...#.#.......##..........##.
+###...........##.#......#.#..#.
+...#....#...#..#..#......#.....
+.....##.......###.#....###..##.
+...#...#..........#.#......#...
+....#.....##...##..#.#........#
+.....#...#..#.....##...##....#.
+................##.#.##....##.#
+.#..#..#....#.....#....#..#...#
+.....###.....#.................
+#...#..##..#.........#.........
+.....#..#................#.....
+.#..#...#......#..#............
+...#...#.#....#....##...#...##.
+..........#....#.#..#.#.....#..
+....#...###.##...#..#..#......#
+#...#.......#..........#..#....
+.#............#..##.......#...#
+....#..#...#............#..#.#.
+.#....#.......#..#.#......#....
+...#...#............#...#.....#
+....#.#.#..##.#.....#...#.#....
+......#.#.#......#..#...#.....#
+......##.....#.............#...
+..#...#..#.#....#..............
+.#.#..#....#.#..##....###.##...
+..#...........#....#.###.#....#
+.....#.........#.#.............
+...#.#.....#......###......##..
+...#...#.....#.................
+...#..#...##.....##.........#..
+..#...#..#..##..#...#........#.
+##..#.#.##.#....#...........#..
+.......#....##....#...##..#..#.
+#.......##.#...##...##..#.....#
+....#.#...............#......#.
+....#.#...#.....#....#......#..
+.#.........#.#....###........#.
+.#.#.....#.....#.#.#....#.#....
+............#...........#.#..##
+#...#......#..#......#.#.......
+...#.#.#.....#..#...#..##......
+...#.#..#...#....#.........#.#.
+........#..#......##.....#...#.
+...#..#..............#..#......
+.........#.......#...#......#..
+.#......#.....#.....#......#...
+......#.......#....#...#.#.....
+.#.....#.##..#........#...#....
+#.....##..##....#.#.......#..#.
+.#..#...#..#.......#...........
+..#..#...#.....##....#.....#...
+#.#..............#....#..#.....
+.........##...#......#.##...##.
+.###...#.#...#.....#.........#.
+.....#..........##...#..#....##
+.#..#......#....##.#...#.......
+.............###.#.#..#.#.#...#
+.......#...##..#..#.....###....
+##.......#...........#....#.#..
+##......#...#.#................
+.#.####..##.#...............#..
+..#...#.#.#..#...#........#...#
+.##..##.##.....#.......#..#.#..
+...................#......#.#..
+#.##..#..........#.............
+##..#......#....#.#............
+.#........#.....##...#.........
+.##....#..#..##..........#...#.
+#..........##........#..#..#.#.
+####.###.#.....#....#..#.#....#
+..#...#...#.#.......#....#...#.
+......##.###..##.#.###......#.#
diff --git a/2020/day03/toboggan-trajectory.py b/2020/day03/toboggan-trajectory.py
new file mode 100644
index 0000000..41bf35b
--- /dev/null
+++ b/2020/day03/toboggan-trajectory.py
@@ -0,0 +1,35 @@
+from typing import List
+
+EXAMPLE = [
+ '..##.......',
+ '#...#...#..',
+ '.#....#..#.',
+ '..#.#...#.#',
+ '.#...##..#.',
+ '..#.##.....',
+ '.#.#.#....#',
+ '.#........#',
+ '#.##...#...',
+ '#...##....#',
+ '.#..#...#.#',
+]
+
+def encounters(inputs: List[str]) -> int:
+ """return number of tree encounters"""
+ trees, row, col = 0, 0, 0
+ repeats = len(inputs[0])
+ while row < len(inputs):
+ if inputs[row][col % repeats] == '#':
+ trees += 1
+ row += 1
+ col += 3
+ return trees
+
+trees = encounters(EXAMPLE)
+print(f'encounters: {trees}')
+
+with open('data/slope.txt') as f:
+ slope = [l.strip() for l in f]
+
+trees = encounters(slope)
+print(f'encounters: {trees}')