|
@@ -0,0 +1,357 @@
|
|
|
+const input = `....#...##......##..#..#.#...#.
|
|
|
+..######...#......#....#..#.##.
|
|
|
+..#.#...##......#.#..#..#....#.
|
|
|
+..#.....#..#.#........#.#..#..#
|
|
|
+#......##..###...#.#..#.....#..
|
|
|
+#.......##...###...#....#......
|
|
|
+.....##...#......##.#.#..#.##..
|
|
|
+.........#......#.....#......#.
|
|
|
+..#.#..#....#....#......##.#.##
|
|
|
+.#...#..#.............#.#..#.#.
|
|
|
+....#..#.#.##.#....#..#..#....#
|
|
|
+...#..#.....#.......#...#..#..#
|
|
|
+.....#.....#.......#..#...#....
|
|
|
+.##.......#...#..#........#...#
|
|
|
+...#.......#.#.#...#.#.#......#
|
|
|
+#....#..#.....#......##....#..#
|
|
|
+###.#......#.#.#.#..#....#....#
|
|
|
+......##......#.#...#...#..#...
|
|
|
+.....#......#.#.#......#.#.....
|
|
|
+...##...#..#........#..#.##....
|
|
|
+..##.#.#..#...###..........#.#.
|
|
|
+.#..#..#.....#.........#.###.#.
|
|
|
+....##.....#...#...##..#.##...#
|
|
|
+....#.##....#.....##......#....
|
|
|
+........#.#.........#.#.......#
|
|
|
+#....##.#....#..#...#..........
|
|
|
+#..###......#....##..........##
|
|
|
+....##.#.....#..#.##......#....
|
|
|
+#..#......#......#.............
|
|
|
+...##.....##.......#.......#...
|
|
|
+#...#.#.....#..........#...###.
|
|
|
+#.....#..#.#.###...#......###..
|
|
|
+...##.#......#........#..#.....
|
|
|
+......#.....###.#...##........#
|
|
|
+.#......##......##....#....#...
|
|
|
+..#.#..#.....##....#....#..#...
|
|
|
+..#.#.....#.##.#.....#.....#...
|
|
|
+....#.......#...#.........##...
|
|
|
+.#....#..#.......##.......#....
|
|
|
+..#..##.....#...##.##.#.#......
|
|
|
+.##.#....#............#.......#
|
|
|
+.......#...#..#.#.##.....##..##
|
|
|
+..###....#..#.##........##.#...
|
|
|
+....#.#..#.....#..#.#.....#....
|
|
|
+..#..#.#..............#..#.....
|
|
|
+.......#.#.#.........#......#..
|
|
|
+...##..#.#...#......##.#.......
|
|
|
+#....#.#.........#...#....#..##
|
|
|
+.#..#.#...#.......#.#.#....#.##
|
|
|
+.#..###.#..#.#.....#..#........
|
|
|
+#.#..##.###.....##.........#..#
|
|
|
+#...##...#..##..#..#..........#
|
|
|
+.#...#..#......................
|
|
|
+...##..###...........#.#...##..
|
|
|
+..........#.#....#.#...........
|
|
|
+..#....#....#..#....#.#.#......
|
|
|
+.#..#.....###......#...#...#...
|
|
|
+#.##..#..#.........#..#....#...
|
|
|
+........#......#...#.........#.
|
|
|
+..#.....#.#..##...#.#.#...##...
|
|
|
+..#...........#.##..#.#..#.##..
|
|
|
+..............##...#.#......#..
|
|
|
+#.#..#....#...##.###........#..
|
|
|
+.#...#..#........#........##..#
|
|
|
+.....##..#...#.....#.#.........
|
|
|
+.#...#...#....###...#.#.#..##..
|
|
|
+....#.........#....###..##....#
|
|
|
+.#....#...####...##....####.#..
|
|
|
+..#..#.......#..#......#.#.#...
|
|
|
+....#....#.......##..#.#.......
|
|
|
+..#....#...........##.#.##.....
|
|
|
+#..#..#...##.##....#.#.#.###.##
|
|
|
+...#...#....#.#...##...#....###
|
|
|
+......##........#.........#.#..
|
|
|
+....#####..#..##.......#.#....#
|
|
|
+....##..#...###....#..#.....#..
|
|
|
+..#........#..#.#.....#....#...
|
|
|
+..#....#......#..#...#......#..
|
|
|
+...#.....##...#.#..##.....#..#.
|
|
|
+...#..#.......####.##...#......
|
|
|
+.....#..#..#.##..##....#..#.#..
|
|
|
+..#..#..##.#.#.##..#..#...#....
|
|
|
+...#..........#.........#....##
|
|
|
+.##.....###...............#.##.
|
|
|
+...##...........#.#.#......#..#
|
|
|
+.#...#.#.##....#....#..#.......
|
|
|
+.#...###.#....#..#..#..#......#
|
|
|
+#..#........###...........#..#.
|
|
|
+..#...#......#.#.#......####.#.
|
|
|
+...#.#....##.#.....#.....##....
|
|
|
+...###..#.#.#...#.....#.###..#.
|
|
|
+.#.#..#...##......#..........#.
|
|
|
+##.....#.......#.#..###...#.#..
|
|
|
+##.###....#.....#.....###.#....
|
|
|
+#...#..##....#.#...#...#......#
|
|
|
+.....##.#........#.###.........
|
|
|
+.#..#..#.#......##.#...#.#.....
|
|
|
+#..#.#........##...........##.#
|
|
|
+#...###..#..####..#.#..........
|
|
|
+..#...#....#...##.#....#....##.
|
|
|
+......#.#........#.....#..#....
|
|
|
+#.........#...#.....#...#..##..
|
|
|
+#....#.........#...#.##..###.#.
|
|
|
+#...###...#.##.#.#.............
|
|
|
+#.#....#....#......#....#.#...#
|
|
|
+##...#.##......#..#.#....#.....
|
|
|
+....#...#.##....#..............
|
|
|
+.........##..........#..##..#..
|
|
|
+......##....#.#......#.........
|
|
|
+..#.#..............#......#..##
|
|
|
+...........##.......#.#.#......
|
|
|
+##...#........##.......#.#.....
|
|
|
+....#...#...#....#.#......##...
|
|
|
+...#..#.#.#.........#..#.#....#
|
|
|
+.##.#...#.#.........#.....##.#.
|
|
|
+#.#.....#.#.....#..............
|
|
|
+..#.#..#....#..........#..##...
|
|
|
+...#..#....................#..#
|
|
|
+...........#...........#...#..#
|
|
|
+............#...#............##
|
|
|
+..#....##......##...........#..
|
|
|
+..#..#..#....#....##......##.##
|
|
|
+##..........#..##.##.#...#.....
|
|
|
+............#..#........###.#..
|
|
|
+###...##.#.#....#....#.#....#..
|
|
|
+...#......##...#.......####....
|
|
|
+.......#..#..#.#.....#.........
|
|
|
+........##.......##.....#......
|
|
|
+#.#...#.###....#..#...##.......
|
|
|
+...#.#....#..#####.#..##.#.....
|
|
|
+..#.#..##.......###...#.....#..
|
|
|
+..#.......#..#...#...#..#.##...
|
|
|
+......#..#.......#.....#....#..
|
|
|
+.......#........#.#.......##..#
|
|
|
+.#.#.....#.......#.......##..#.
|
|
|
+..#.#....#.#.#####.....#...#...
|
|
|
+#..#............###.......#..#.
|
|
|
+........##.........#..#...###..
|
|
|
+.#............##...#.....#.....
|
|
|
+.#..##..#....#....#.......#....
|
|
|
+....##..........##.............
|
|
|
+.##..........#..#..#....#...#..
|
|
|
+...#..#..#............####.....
|
|
|
+.............#..#.##..#.#.##...
|
|
|
+.....#........#....#.#.......#.
|
|
|
+###.#..#.#...#....##...........
|
|
|
+....#......#...#....##.......#.
|
|
|
+.......#.#...#.#...#........##.
|
|
|
+..........#........#..#.##.....
|
|
|
+##..#.#.....##.#...............
|
|
|
+.....#....#................#...
|
|
|
+...##....#........##.#....#....
|
|
|
+.....##...###....#.#..#.......#
|
|
|
+.....#.#.........##....###.....
|
|
|
+.#.....##......#..##..##...##.#
|
|
|
+.#..............#.....#.#......
|
|
|
+.##......#..#..#......##.......
|
|
|
+.......#..................#....
|
|
|
+...#.#...##......####.........#
|
|
|
+#....#####.#.#..#..#..#...#...#
|
|
|
+##.#...#.......#....#...#...###
|
|
|
+...#........#.....#...#.##.....
|
|
|
+..##....#.......#....#.......##
|
|
|
+#......#..##...#..##.#.....#.#.
|
|
|
+..###........#.#..#........#.#.
|
|
|
+...#.###..........#.....#.#.#..
|
|
|
+#.###.....#...#...#..##..###...
|
|
|
+#....#.#.....#.#........#......
|
|
|
+........#.......##.......#.....
|
|
|
+...........#...#......##.......
|
|
|
+............#...#....#..#.....#
|
|
|
+#.#.#.#....#.....#.#..........#
|
|
|
+#.##...#...#..#....##.#.......#
|
|
|
+...#..#......#..#...##..##..#..
|
|
|
+#....#......#.#.....##.#..#....
|
|
|
+#....#..##.#......#.#.....#..##
|
|
|
+.#..##....##....#.#...#...#....
|
|
|
+#.#.###....#.#............#...#
|
|
|
+.#.#....#..#..........#....#.#.
|
|
|
+......#..#.#...............##..
|
|
|
+..#......###.#..........#.###..
|
|
|
+....#.##.#..#...##..#.#...#....
|
|
|
+..............#...##.......#.##
|
|
|
+.#...........#....#....#.##....
|
|
|
+#..#....#.....#...#.....##...#.
|
|
|
+.........#...#.##.......#...#.#
|
|
|
+.....#......#.........#.#..#...
|
|
|
+##..........#.#..##...#.#.#....
|
|
|
+##..##.#..#..#.....#.##....#...
|
|
|
+........##....#.#.#....#......#
|
|
|
+.#.##...#.###....#.........#..#
|
|
|
+..........#....###..#.........#
|
|
|
+#.#..#.#...#.......#..##.......
|
|
|
+..#....#...###..............##.
|
|
|
+#..###.....####...#..#..#...#..
|
|
|
+......#..#...###........###....
|
|
|
+..#.....#...#.......#....###..#
|
|
|
+.#.........#.#.#....#.#.......#
|
|
|
+#.#.###.#.#...........#........
|
|
|
+......#..#.........#........#..
|
|
|
+...........##.#........#.#...#.
|
|
|
+.....#.#......##.......#.....##
|
|
|
+...##...#............#..#.....#
|
|
|
+.....#..##....##...##.#..#.#...
|
|
|
+...#...#........#.#......##....
|
|
|
+........#..##..#..#......##.#..
|
|
|
+.#.#.....#.....#...........#.##
|
|
|
+.#...#.#............#......#...
|
|
|
+.....#...#........#....#..#.#..
|
|
|
+...##....#..#...#..............
|
|
|
+#....##.#.#............#.......
|
|
|
+#..#..#.....##..#........##.#.#
|
|
|
+##..#.#....#....##.......###..#
|
|
|
+.#.#.#.....###.....#.#......###
|
|
|
+.....#..#...###...#....#.#...#.
|
|
|
+.##.....................##....#
|
|
|
+.#.....#.........#....#.....##.
|
|
|
+#...#....#.#...###.......#.#..#
|
|
|
+...#.................#.#....#.#
|
|
|
+.##...#.#......................
|
|
|
+.##.#........#...##............
|
|
|
+.#....#.....#.........#.##..##.
|
|
|
+#......#...##..#.........##.##.
|
|
|
+......#......#...####..#.##....
|
|
|
+.###....#..##......#.##......#.
|
|
|
+..#...#....#..#.......#.#......
|
|
|
+#....#...#.................#.#.
|
|
|
+....#.#.#..#...#..#.......#.#.#
|
|
|
+#.#...##.......#.....##.#......
|
|
|
+#.........#.....##..##..#......
|
|
|
+....#..##..#.....#..#..#.#..#..
|
|
|
+......#.#..#.#.#....#.#.......#
|
|
|
+.##......#..#....##...##..#....
|
|
|
+..#..#......#...##..#.##.....#.
|
|
|
+..#..#.......#.#....#.....#...#
|
|
|
+....#.#.....###...#.......#.#..
|
|
|
+..#....##.....##.#........##...
|
|
|
+#...............##....#.....##.
|
|
|
+.#.........#....#...##.###.##.#
|
|
|
+.#.##..#.............#.#.#..#..
|
|
|
+.#.....#.................##....
|
|
|
+..####.........#.#......#.#..#.
|
|
|
+#.......#..........#.#........#
|
|
|
+.#.#...##.....#.#.......#....#.
|
|
|
+..#.##.#.......###....#....#...
|
|
|
+.#....##.............##.#.#.#..
|
|
|
+#.#.....#.#.#.#..#......##..#..
|
|
|
+.............#..........#.#.#..
|
|
|
+...#.#.............#.#...##....
|
|
|
+.......#..#.#.......#..#.#....#
|
|
|
+.............#.........###..#..
|
|
|
+.#.#..#....#.....#..#.....#...#
|
|
|
+#.....#....##..##.#..#........#
|
|
|
+..##..###.....##....#.#..#.....
|
|
|
+..#...##....#...#.#..........#.
|
|
|
+...##..##.#.....#....#.........
|
|
|
+..#...#........##.#..#........#
|
|
|
+#.............#.###......#.##..
|
|
|
+.#...#........#...........#...#
|
|
|
+..##.......#.#..##.##......#...
|
|
|
+...#.#...##....##..#...........
|
|
|
+.#......##........#....##....#.
|
|
|
+.........#..#....#...#..##.##..
|
|
|
+....#..#.#...#.......#.#.##....
|
|
|
+...#.#......#.#..#..#.#....#..#
|
|
|
+.......#........#.........###..
|
|
|
+#.#..#.#.........##............
|
|
|
+##..##..#.##..###...#.#...#....
|
|
|
+.#....#.#..#...#....#.##.....#.
|
|
|
+.#.#.#.#........##...#..#.#.##.
|
|
|
+.#..#.#..#...........#..#......
|
|
|
+..#.##.#...#....#.........#...#
|
|
|
+.....##...#.#...#...#....#.....
|
|
|
+..#..........#.#.#.......##.#..
|
|
|
+#.#............#..#.....#..#...
|
|
|
+..#...........##.#.##.#....#..#
|
|
|
+#..####.....#............#.....
|
|
|
+.##......#####.#..#.....#....#.
|
|
|
+...##..#.#......#.#..#..#...##.
|
|
|
+#....................#.##...#.#
|
|
|
+...#............#.............#
|
|
|
+....#.##..........#.....#......
|
|
|
+....##..##....#.#..............
|
|
|
+...........#....##.#.....#.....
|
|
|
+....#.....#....#....#......#...
|
|
|
+#...##........#...#........#.#.
|
|
|
+........#.....##..#.##.#..#.#.#
|
|
|
+....##......##....#.....##....#
|
|
|
+...#.#........##.......#...##..
|
|
|
+#......##..#.#.#....##......#..
|
|
|
+..#.......#.......##..#.##.....
|
|
|
+.#...#...#.#.............##....
|
|
|
+......#.#.#.........##...#..#.#
|
|
|
+.....#..####....#.##..........#
|
|
|
+...#...#.#....#.....#..#.....##
|
|
|
+.........#.......#......###....
|
|
|
+........##..##..#.#.#...###...#
|
|
|
+.#..##.#....#...##.....#.#.#...
|
|
|
+........##...#...##..#.........
|
|
|
+.........#.......#.##..#...####
|
|
|
+#......#.....#..............#.#
|
|
|
+##..##.#.##.....##...........#.
|
|
|
+#.............#.........#......
|
|
|
+...####.#.##..#.#.#.##.#......#
|
|
|
+..#.....##....#...#............
|
|
|
+#..............#......#...###..
|
|
|
+..#..#.#...#.##.........##.....
|
|
|
+..#...##..#........#..#.##..##.
|
|
|
+......###...#..#....#..#.###...
|
|
|
+...##.##.###.....##.#.......#..
|
|
|
+#....#..###..#.......#.#.#..#..
|
|
|
+..##.............##..##...###.#
|
|
|
+.#.#..#.........#..........#...
|
|
|
+.........#.#.....##...#..#...##
|
|
|
+....#..#....#####..#...#..#....
|
|
|
+...#.....#.....#...#.#..#.#....
|
|
|
+.#..#.............#.......##.#.
|
|
|
+...##.......#.#.....##......#..
|
|
|
+...........##..#.##..###...#.#.
|
|
|
+...........#...........#...#..#
|
|
|
+..#....#.##.#..#..#...........#
|
|
|
+..#.....##...#......#...#......
|
|
|
+...###.###.....##..........#..#`
|
|
|
+
|
|
|
+const dataLines = input.split("\n");
|
|
|
+
|
|
|
+function formatDataLine(dataLine) {
|
|
|
+ return dataLine.split("");
|
|
|
+};
|
|
|
+
|
|
|
+const map = dataLines.map(formatDataLine);
|
|
|
+
|
|
|
+const mapHeight = map.length;
|
|
|
+const mapWidth = map[0].length;
|
|
|
+const pointer = [0,0];
|
|
|
+
|
|
|
+function step(pointer, map, goRight, goDown) {
|
|
|
+ const x = pointer[0];
|
|
|
+ const y = pointer[1];
|
|
|
+ let newX = x + goRight;
|
|
|
+ let newY = y + goDown;
|
|
|
+ if (newX > (mapWidth - 1)) {
|
|
|
+ newX = newX - mapWidth;
|
|
|
+ }
|
|
|
+ pointer[0] = newX;
|
|
|
+ pointer[1] = newY;
|
|
|
+ // has to do y then x. [ row[col, col], ... ]
|
|
|
+ return map[pointer[1]][pointer[0]];
|
|
|
+}
|
|
|
+
|
|
|
+let treeCount = 0;
|
|
|
+while(pointer[1] < (mapHeight - 1)) {
|
|
|
+ const land = step(pointer, map, 3, 1);
|
|
|
+ if (land === "#") treeCount++;
|
|
|
+}
|
|
|
+
|
|
|
+console.log(treeCount);
|