aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2022-12-05 17:49:29 +0800
committerkaiwu <kaiwu2004@gmail.com>2022-12-05 17:49:29 +0800
commitb369fbbe155a79fba2437f822f9507c53a8c35e4 (patch)
treefaa11536bb12949d1fa07be96f9e69904fb29044 /src
parent1a311c7983f71668b6f892018328f1669f3574fd (diff)
downloadadvent-of-code-b369fbbe155a79fba2437f822f9507c53a8c35e4.tar.gz
advent-of-code-b369fbbe155a79fba2437f822f9507c53a8c35e4.zip
2019 day10 setup
Diffstat (limited to 'src')
-rw-r--r--src/2019/day10/README.md96
-rw-r--r--src/2019/day10/aoc.cpp10
-rw-r--r--src/2019/day10/aoc.h7
-rw-r--r--src/2019/day10/input34
-rw-r--r--src/CMakeLists.txt1
5 files changed, 148 insertions, 0 deletions
diff --git a/src/2019/day10/README.md b/src/2019/day10/README.md
new file mode 100644
index 0000000..0af8fbd
--- /dev/null
+++ b/src/2019/day10/README.md
@@ -0,0 +1,96 @@
+--- Day 10: Monitoring Station ---
+You fly into the asteroid belt and reach the Ceres monitoring station. The Elves here have an emergency: they're having trouble tracking all of the asteroids and can't be sure they're safe.
+
+The Elves would like to build a new monitoring station in a nearby area of space; they hand you a map of all of the asteroids in that region (your puzzle input).
+
+The map indicates whether each position is empty (.) or contains an asteroid (#). The asteroids are much smaller than they appear on the map, and every asteroid is exactly in the center of its marked position. The asteroids can be described with X,Y coordinates where X is the distance from the left edge and Y is the distance from the top edge (so the top-left corner is 0,0 and the position immediately to its right is 1,0).
+
+Your job is to figure out which asteroid would be the best place to build a new monitoring station. A monitoring station can detect any asteroid to which it has direct line of sight - that is, there cannot be another asteroid exactly between them. This line of sight can be at any angle, not just lines aligned to the grid or diagonally. The best location is the asteroid that can detect the largest number of other asteroids.
+
+For example, consider the following map:
+
+.#..#
+.....
+#####
+....#
+...##
+The best location for a new monitoring station on this map is the highlighted asteroid at 3,4 because it can detect 8 asteroids, more than any other location. (The only asteroid it cannot detect is the one at 1,0; its view of this asteroid is blocked by the asteroid at 2,2.) All other asteroids are worse locations; they can detect 7 or fewer other asteroids. Here is the number of other asteroids a monitoring station on each asteroid could detect:
+
+.7..7
+.....
+67775
+....7
+...87
+Here is an asteroid (#) and some examples of the ways its line of sight might be blocked. If there were another asteroid at the location of a capital letter, the locations marked with the corresponding lowercase letter would be blocked and could not be detected:
+
+#.........
+...A......
+...B..a...
+.EDCG....a
+..F.c.b...
+.....c....
+..efd.c.gb
+.......c..
+....f...c.
+...e..d..c
+Here are some larger examples:
+
+Best is 5,8 with 33 other asteroids detected:
+
+......#.#.
+#..#.#....
+..#######.
+.#.#.###..
+.#..#.....
+..#....#.#
+#..#....#.
+.##.#..###
+##...#..#.
+.#....####
+Best is 1,2 with 35 other asteroids detected:
+
+#.#...#.#.
+.###....#.
+.#....#...
+##.#.#.#.#
+....#.#.#.
+.##..###.#
+..#...##..
+..##....##
+......#...
+.####.###.
+Best is 6,3 with 41 other asteroids detected:
+
+.#..#..###
+####.###.#
+....###.#.
+..###.##.#
+##.##.#.#.
+....###..#
+..#.#..#.#
+#..#.#.###
+.##...##.#
+.....#.#..
+Best is 11,13 with 210 other asteroids detected:
+
+.#..##.###...#######
+##.############..##.
+.#.######.########.#
+.###.#######.####.#.
+#####.##.#.##.###.##
+..#####..#.#########
+####################
+#.####....###.#.#.##
+##.#################
+#####.##.###..####..
+..######..##.#######
+####.##.####...##..#
+.#####..#.######.###
+##...#.##########...
+#.##########.#######
+.####.#.###.###.#.##
+....##.##.###..#####
+.#.#.###########.###
+#.#.#.#####.####.###
+###.##.####.##.#..##
+Find the best location for a new monitoring station. How many other asteroids can be detected from that location?
diff --git a/src/2019/day10/aoc.cpp b/src/2019/day10/aoc.cpp
new file mode 100644
index 0000000..4d200f4
--- /dev/null
+++ b/src/2019/day10/aoc.cpp
@@ -0,0 +1,10 @@
+#include "aoc.h"
+#include <algorithm>
+
+namespace aoc2019 {
+
+std::pair<int, int> day10(line_view file) {
+ return {0, 0};
+}
+
+} // namespace aoc2019
diff --git a/src/2019/day10/aoc.h b/src/2019/day10/aoc.h
new file mode 100644
index 0000000..9951322
--- /dev/null
+++ b/src/2019/day10/aoc.h
@@ -0,0 +1,7 @@
+#pragma once
+#include "common.h"
+
+namespace aoc2019 {
+
+std::pair<int, int> day10(line_view);
+}
diff --git a/src/2019/day10/input b/src/2019/day10/input
new file mode 100644
index 0000000..ef12976
--- /dev/null
+++ b/src/2019/day10/input
@@ -0,0 +1,34 @@
+#..#....#...#.#..#.......##.#.####
+#......#..#.#..####.....#..#...##.
+.##.......#..#.#....#.#..#.#....#.
+###..#.....###.#....##.....#...#..
+...#.##..#.###.......#....#....###
+.####...##...........##..#..#.##..
+..#...#.#.#.###....#.#...##.....#.
+......#.....#..#...##.#..##.#..###
+...###.#....#..##.#.#.#....#...###
+..#.###.####..###.#.##..#.##.###..
+...##...#.#..##.#............##.##
+....#.##.##.##..#......##.........
+.#..#.#..#.##......##...#.#.#...##
+.##.....#.#.##...#.#.#...#..###...
+#.#.#..##......#...#...#.......#..
+#.......#..#####.###.#..#..#.#.#..
+.#......##......##...#..#..#..###.
+#.#...#..#....##.#....#.##.#....#.
+....#..#....##..#...##..#..#.#.##.
+#.#.#.#.##.#.#..###.......#....###
+...#.#..##....###.####.#..#.#..#..
+#....##..#...##.#.#.........##.#..
+.#....#.#...#.#.........#..#......
+...#..###...#...#.#.#...#.#..##.##
+.####.##.#..#.#.#.#...#.##......#.
+.##....##..#.#.#.......#.....####.
+#.##.##....#...#..#.#..###..#.###.
+...###.#..#.....#.#.#.#....#....#.
+......#...#.........##....#....##.
+.....#.....#..#.##.#.###.#..##....
+.#.....#.#.....#####.....##..#....
+.####.##...#.......####..#....##..
+.#.#.......#......#.##..##.#.#..##
+......##.....##...##.##...##......
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 72030bf..8466047 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -61,6 +61,7 @@ set(SOLUTION_FILES
"2019/day7/aoc.cpp"
"2019/day8/aoc.cpp"
"2019/day9/aoc.cpp"
+ "2019/day10/aoc.cpp"
"2020/day1/aoc.cpp"
"2020/day2/aoc.cpp"