Day 10 solution
This one was an absolute beating for me. I am so bad at these sorts of problems. Ultimately I settled on a probably-not-ideal solution that crawls the graph with offsets of each variant of (+/-x,+/-y), marking nodes visited as we come across them so that we end up with a list of asteroids that we can see. Given that this is day 10, and knowing how bad I am at math, I'm assuming this is very far from the intended solution, but it works reasonably quickly and I managed to come up with it myself, so I'm not going to stress too much about it. For asteroid destruction, the best method I could come up with for finding the correct order was to implement an entire Vector class and sort by angle, which worked, but again, I can't decide if it was the intended solution or not. I should start reusing past years' codebases so I don't have to keep building a utility library from scratch.
This commit is contained in:
33
inputs/10p.txt
Normal file
33
inputs/10p.txt
Normal file
@ -0,0 +1,33 @@
|
||||
.#......##.#..#.......#####...#..
|
||||
...#.....##......###....#.##.....
|
||||
..#...#....#....#............###.
|
||||
.....#......#.##......#.#..###.#.
|
||||
#.#..........##.#.#...#.##.#.#.#.
|
||||
..#.##.#...#.......#..##.......##
|
||||
..#....#.....#..##.#..####.#.....
|
||||
#.............#..#.........#.#...
|
||||
........#.##..#..#..#.#.....#.#..
|
||||
.........#...#..##......###.....#
|
||||
##.#.###..#..#.#.....#.........#.
|
||||
.#.###.##..##......#####..#..##..
|
||||
.........#.......#.#......#......
|
||||
..#...#...#...#.#....###.#.......
|
||||
#..#.#....#...#.......#..#.#.##..
|
||||
#.....##...#.###..#..#......#..##
|
||||
...........#...#......#..#....#..
|
||||
#.#.#......#....#..#.....##....##
|
||||
..###...#.#.##..#...#.....#...#.#
|
||||
.......#..##.#..#.............##.
|
||||
..###........##.#................
|
||||
###.#..#...#......###.#........#.
|
||||
.......#....#.#.#..#..#....#..#..
|
||||
.#...#..#...#......#....#.#..#...
|
||||
#.#.........#.....#....#.#.#.....
|
||||
.#....#......##.##....#........#.
|
||||
....#..#..#...#..##.#.#......#.#.
|
||||
..###.##.#.....#....#.#......#...
|
||||
#.##...#............#..#.....#..#
|
||||
.#....##....##...#......#........
|
||||
...#...##...#.......#....##.#....
|
||||
.#....#.#...#.#...##....#..##.#.#
|
||||
.#.#....##.......#.....##.##.#.##
|
5
inputs/10s1.txt
Normal file
5
inputs/10s1.txt
Normal file
@ -0,0 +1,5 @@
|
||||
.#..#
|
||||
.....
|
||||
#####
|
||||
....#
|
||||
...##
|
10
inputs/10s2.txt
Normal file
10
inputs/10s2.txt
Normal file
@ -0,0 +1,10 @@
|
||||
......#.#.
|
||||
#..#.#....
|
||||
..#######.
|
||||
.#.#.###..
|
||||
.#..#.....
|
||||
..#....#.#
|
||||
#..#....#.
|
||||
.##.#..###
|
||||
##...#..#.
|
||||
.#....####
|
10
inputs/10s3.txt
Normal file
10
inputs/10s3.txt
Normal file
@ -0,0 +1,10 @@
|
||||
#.#...#.#.
|
||||
.###....#.
|
||||
.#....#...
|
||||
##.#.#.#.#
|
||||
....#.#.#.
|
||||
.##..###.#
|
||||
..#...##..
|
||||
..##....##
|
||||
......#...
|
||||
.####.###.
|
10
inputs/10s4.txt
Normal file
10
inputs/10s4.txt
Normal file
@ -0,0 +1,10 @@
|
||||
.#..#..###
|
||||
####.###.#
|
||||
....###.#.
|
||||
..###.##.#
|
||||
##.##.#.#.
|
||||
....###..#
|
||||
..#.#..#.#
|
||||
#..#.#.###
|
||||
.##...##.#
|
||||
.....#.#..
|
20
inputs/10s5.txt
Normal file
20
inputs/10s5.txt
Normal file
@ -0,0 +1,20 @@
|
||||
.#..##.###...#######
|
||||
##.############..##.
|
||||
.#.######.########.#
|
||||
.###.#######.####.#.
|
||||
#####.##.#.##.###.##
|
||||
..#####..#.#########
|
||||
####################
|
||||
#.####....###.#.#.##
|
||||
##.#################
|
||||
#####.##.###..####..
|
||||
..######..##.#######
|
||||
####.##.####...##..#
|
||||
.#####..#.######.###
|
||||
##...#.##########...
|
||||
#.##########.#######
|
||||
.####.#.###.###.#.##
|
||||
....##.##.###..#####
|
||||
.#.#.###########.###
|
||||
#.#.#.#####.####.###
|
||||
###.##.####.##.#..##
|
5
inputs/10s6.txt
Normal file
5
inputs/10s6.txt
Normal file
@ -0,0 +1,5 @@
|
||||
.#....#####...#..
|
||||
##...##.#####..##
|
||||
##...#...#.#####.
|
||||
..#.....#...###..
|
||||
..#.#.....#....##
|
Reference in New Issue
Block a user