Compare commits

..
2 Commits
Author SHA1 Message Date
Maya Herrscher 5c59e7b253 Day 13 2023-12-13 22:24:05 +01:00
Maya Herrscher 1240614f8a Day 12 Part 1 and no working stuff for 2 2023-12-13 22:23:51 +01:00
8 changed files with 2769 additions and 0 deletions

No files matched your search

+109
View File
@@ -0,0 +1,109 @@
--- Day 12: Hot Springs ---
You finally reach the hot springs! You can see steam rising from secluded areas attached to the primary, ornate building.
As you turn to enter, the researcher stops you. "Wait - I thought you were looking for the hot springs, weren't you?" You indicate that this definitely looks like hot springs to you.
"Oh, sorry, common mistake! This is actually the onsen! The hot springs are next door."
You look in the direction the researcher is pointing and suddenly notice the massive metal helixes towering overhead. "This way!"
It only takes you a few more steps to reach the main gate of the massive fenced-off area containing the springs. You go through the gate and into a small administrative building.
"Hello! What brings you to the hot springs today? Sorry they're not very hot right now; we're having a lava shortage at the moment." You ask about the missing machine parts for Desert Island.
"Oh, all of Gear Island is currently offline! Nothing is being manufactured at the moment, not until we get more lava to heat our forges. And our springs. The springs aren't very springy unless they're hot!"
"Say, could you go up and see why the lava stopped flowing? The springs are too cold for normal operation, but we should be able to find one springy enough to launch you up there!"
There's just one problem - many of the springs have fallen into disrepair, so they're not actually sure which springs would even be safe to use! Worse yet, their condition records of which springs are damaged (your puzzle input) are also damaged! You'll need to help them repair the damaged records.
In the giant field just outside, the springs are arranged into rows. For each row, the condition records show every spring and whether it is operational (.) or damaged (#). This is the part of the condition records that is itself damaged; for some springs, it is simply unknown (?) whether the spring is operational or damaged.
However, the engineer that produced the condition records also duplicated some of this information in a different format! After the list of springs for a given row, the size of each contiguous group of damaged springs is listed in the order those groups appear in the row. This list always accounts for every damaged spring, and each number is the entire size of its contiguous group (that is, groups are always separated by at least one operational spring: #### would always be 4, never 2,2).
So, condition records with no unknown spring conditions might look like this:
#.#.### 1,1,3
.#...#....###. 1,1,3
.#.###.#.###### 1,3,1,6
####.#...#... 4,1,1
#....######..#####. 1,6,5
.###.##....# 3,2,1
However, the condition records are partially damaged; some of the springs' conditions are actually unknown (?). For example:
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
Equipped with this information, it is your job to figure out how many different arrangements of operational and broken springs fit the given criteria in each row.
In the first line (???.### 1,1,3), there is exactly one way separate groups of one, one, and three broken springs (in that order) can appear in that row: the first three unknown springs must be broken, then operational, then broken (#.#), making the whole row #.#.###.
The second line is more interesting: .??..??...?##. 1,1,3 could be a total of four different arrangements. The last ? must always be broken (to satisfy the final contiguous group of three broken springs), and each ?? must hide exactly one of the two broken springs. (Neither ?? could be both broken springs or they would form a single contiguous group of two; if that were true, the numbers afterward would have been 2,3 instead.) Since each ?? can either be #. or .#, there are four possible arrangements of springs.
The last line is actually consistent with ten different arrangements! Because the first number is 3, the first and second ? must both be . (if either were #, the first number would have to be 4 or higher). However, the remaining run of unknown spring conditions have many different ways they could hold groups of two and one broken springs:
?###???????? 3,2,1
.###.##.#...
.###.##..#..
.###.##...#.
.###.##....#
.###..##.#..
.###..##..#.
.###..##...#
.###...##.#.
.###...##..#
.###....##.#
In this example, the number of possible arrangements for each row is:
???.### 1,1,3 - 1 arrangement
.??..??...?##. 1,1,3 - 4 arrangements
?#?#?#?#?#?#?#? 1,3,1,6 - 1 arrangement
????.#...#... 4,1,1 - 1 arrangement
????.######..#####. 1,6,5 - 4 arrangements
?###???????? 3,2,1 - 10 arrangements
Adding all of the possible arrangement counts together produces a total of 21 arrangements.
For each row, count all of the different arrangements of operational and broken springs that meet the given criteria. What is the sum of those counts?
Your puzzle answer was 7191.
The first half of this puzzle is complete! It provides one gold star: *
--- Part Two ---
As you look out at the field of springs, you feel like there are way more springs than the condition records list. When you examine the records, you discover that they were actually folded up this whole time!
To unfold the records, on each row, replace the list of spring conditions with five copies of itself (separated by ?) and replace the list of contiguous groups of damaged springs with five copies of itself (separated by ,).
So, this row:
.# 1
Would become:
.#?.#?.#?.#?.# 1,1,1,1,1
The first line of the above example would become:
???.###????.###????.###????.###????.### 1,1,3,1,1,3,1,1,3,1,1,3,1,1,3
In the above example, after unfolding, the number of possible arrangements for some rows is now much larger:
???.### 1,1,3 - 1 arrangement
.??..??...?##. 1,1,3 - 16384 arrangements
?#?#?#?#?#?#?#? 1,3,1,6 - 1 arrangement
????.#...#... 4,1,1 - 16 arrangements
????.######..#####. 1,6,5 - 2500 arrangements
?###???????? 3,2,1 - 506250 arrangements
After unfolding, adding all of the possible arrangement counts together produces 525152.
Unfold your condition records; what is the new sum of possible arrangement counts?
+81
View File
@@ -0,0 +1,81 @@
#!/usr/bin/env python3
import sys, re
from itertools import combinations
from more_itertools import locate
def memo(f):
memo = {}
def f2(x,y):
if (x,y) not in memo: memo[(x,y)] = f(x,y)
return memo[(x,y)]
return f2
def fulfills(spring, cond):
return [len(b) for b in spring.split('.') if len(b) > 0] == cond
def solve_row1(spring, cond):
if fulfills(spring, cond): return 1
sols = 0
not_dam = spring.count('?') + spring.count('#') - sum(cond)
if not_dam < 1: return 0
inds = list(locate(spring, lambda x: x == '?'))
for c in combinations(inds, not_dam):
rs = list(spring)
for i in c:
rs[i] = '.'
if fulfills(''.join(rs),cond): sols += 1
return sols
@memo
def solve_r(spring, cond):
if cond == '': return 1
cond = [int(c) for c in cond.split(',')]
spring = spring.strip('.')
inds = list(locate(spring.strip('.'), lambda x: x == '.'))
if inds == []: return solve_row1(spring, cond)
i = inds[0]
sols = 0
for j in range(0, len(cond)):
if sum(cond[:j]) <= len(list(locate(spring[:i], lambda x: x != '.'))) and sum(cond[j:]) <= len(list(locate(spring[i:], lambda x: x != '.'))):
cond1, cond2 = ','.join([str(c) for c in cond[:j]]), ','.join([str(c) for c in cond[j:]])
sols += solve_r(spring[:i], cond1) * solve_r(spring[i+1:], cond2)
return sols
def solve_reg(spring, cond):
reg = r'^(\.|\?)*'
cond = [int(c) for c in cond.split(',')]
for i, z in enumerate(cond):
reg += '(\?|\#){' + f'{z}' + '}'
if i < (len(cond)-1): reg += '(\.|\?)+'
reg += '(\.|\?)*$'
print(reg, [i for i in re.findall(reg, spring, overlapped = True)])
return sum([1 for i in re.finditer(reg, spring)])
if __name__ == '__main__':
springs = [line.strip('\n').split(' ') for line in open(sys.argv[1])]
res1 = 0
res2 = 0
for s in springs[0:2]:
# res1 += solve_row1(*s)
res1 += solve_reg(*s)
# print(solve_row1(*s))
# solve_reg('?'.join([s[0]] * 5), ','.join([s[1]] * 5))
print(res1, s)
# challenge 1
res1 = str(res1)
print(f"challenge 1:\n{res1}\n")
# challenge 2
res2 = str(res2)
print(f"challenge 2:\n{res2}\n")
+6
View File
@@ -0,0 +1,6 @@
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
+1000
View File
@@ -0,0 +1,1000 @@
?????#?#?.?#?#. 7,3
#??#?#.?.?????? 6,1,5
??#??????#???.? 4,3
?.?..?..????? 1,4
????????.?##???????? 3,1,1,4,1,1
?#??###?#????#?. 6,2,3
???..????# 1,3,1
?#??????#??. 4,2
??.?????#??#? 2,1,5
.?#?.###??. 1,5
?.???#?##?? 1,7
?#???..?.#? 2,2,1
????##???#?.??. 5,2,1
???.???#???? 1,1,3,1
.##?#????.?? 8,1
????.?.?#?? 2,3
.??#??###??#?? 3,4,3
??#???????. 3,1,1
??#????.??##?? 2,2,3,1
??##???.??#???#??? 3,7
.??#.?????..????#?. 1,1,5
.???????.??#?? 7,3
.?#??????.?#???..?? 8,4,2
.?##?.##??? 3,2
???#?##??????.???.?? 1,8,1,1
?#?#?#?.??? 3,1,2
..??#???.?###????.?. 1,4
?#?????.??#??##????? 3,1,5,1
?????##.????????#? 7,6,2
???#??.?.?##.#???##? 2,3,3,7
.??#???#.?????????? 3,1,1,1,1,2
??.?#??#?..?#??? 6,3
??..????#.# 1,2,1
???.#?##??? 1,7
?#??..??????.#? 3,4,2
??.#??????? 2,5,1
?.#??#?????.# 1,1,4,1
?##?#?#???#? 7,1
???#.??.?.?# 3,1,1
.??.????.??#??.#?# 1,3,3,1,1
???#?##??.?.??#?? 8,1,4
?#...?#??.??? 1,4,1
?????#.????#??. 1,1,6
#?????????? 1,4,2
???.?#??#?.? 2,1,1,1
?#?#???##? 4,3
??#???#?#?##???????? 3,12
.#??#??.?????? 5,2
?#?#???#?????. 9,1
#??#?#??##????##?.## 1,14,2
?#????.????????##. 2,2,10
.?##.??.?? 3,1,1
?.??..??#???.?? 1,1,2,1
??????.?.#.????? 5,1,1,1,2
?.?#?????? 1,2
??#####??.#?? 8,1
?#?#???.#?? 2,1,3
.??????.#? 2,1,1
?..???????#????. 4,1,1
??#?.####?.? 2,5,1
???#??.?.????.? 4,1,1,1
.?.??.???#?.?#???.. 1,4,5
??#?..?#??? 1,2
.#?????#??#? 2,4
.?##?.???????? 3,3
??.#???????#??.? 1,5,5,1
.?#..???.? 2,1
??.##???????#.# 1,6,2,1
??????#?????#??.??? 1,1,3,3,1,1
?#?????????#??????# 5,4,4
???#??#??????#???.? 4,8
?#??????????#?#?#?.? 5,9
?.?#?#?.??. 4,2
#.??????.#.?###???. 1,1,3,1,3,1
???..#??.# 3,2,1
??#???#????.????? 11,1,1
?????.#???? 4,1,3
#.#?.?##??#???? 1,1,3,1,1
???#????????????# 8,1,2,1
??????.?????? 1,3
???.???..???#???? 3,3,3,2
????#..??#?.?? 1,1,3,1
??#??.?#?????? 3,6
??.???#???? 2,7
#.?#???#.??#.? 1,3,1,1
?.?????#?#?#..?# 1,8,1,1
????###??? 1,6
???.?????.??? 1,2,1,2
.#.?.???.???.?#???? 1,1,1,1,1,4
?????#???##?.? 5,3
.??.???????? 1,1,2,1
?#?.???#.#??.?? 2,1,2,1,1
.?#.#?..?? 1,2
?????.#?##.?.?##. 2,4,3
.?#?.??????.# 3,2,1,1
##.?????????. 2,3
#???????????#? 3,2,2,3
??????##?##?????? 1,5,3,1
??????##??#???? 3,6
..#??????.?#. 6,1
.?#.##?#.??#?? 2,2,1,4
???#???.#.?. 5,1
..????#???#??.#. 10,1
??#????..?# 5,1
???????##??? 2,3
?#?#?????? 3,1
????#????#?#? 1,2,2,2
..?.??#???.??. 1,1,2,2
??#???#??#.??. 4,4
??##???.#?.?.##? 6,2,1,3
.??.?#??#???# 1,5,2
????.?##???? 1,1,2,1
?#????????????#? 2,6,5
?#??????.???? 7,1
#??#??#..?#??? 5,1,1,1
#?#.#?#????#??? 3,8
#?#???#.???.?? 3,1,1,1
???#??#?#?###.??? 12,1
?.????#???????? 8,1
?.?#?.???..#????? 3,1,6
#??????.?????????? 2,1,1,6,1
????#???.?.??#?## 1,4,1,1,4
????.???#??#.?????# 4,4,1,2,1
????.????? 1,1,2
.?##????#.??.. 7,1
.?..??#.?? 1,1,2
??#?#??????#???.#.# 5,2,2,1,1,1
??????????##??# 1,2,2,5
??..?????.? 3,1
???????.#??????? 1,4,5,1
?#?.?.#?.??? 1,1,1
??.?.#???#?#?###?# 1,1,1,1,9
?.?#.???????#.? 1,1,2,1,1
???#?.?#??.???. 1,2,1,1,3
.#??..##???.?.?#?. 1,1,3,1,1,2
?.#?##.???? 4,1
????#?#???#?#?.#?## 1,11,4
?.#???#?##?#?#??#? 1,1,8,1,2
??????#?###??# 3,6,1
??????.??#??.?#?.?#? 1,1,5,3,3
...?#?.??..?#??? 2,2,3,1
?.?#???##??###?##?. 1,16
..#?#???#???.?##?? 1,3,2,1,3
??.???????????? 6,2
?.????.??#??#?##???? 1,9
#?.#???#????#???#?#? 1,1,1,5,1,1
#??#?.??.?#..?#?? 1,2,2,4
?##??#?##??.??.????? 9,3
??????.??# 1,1,1
?#???#??.??.?#?? 6,1,1,1
?#??#??##???.?#. 9,2
..?????.??. 1,2,1
??..??#???. 1,5
.??#?..?????.? 3,1
?#?????????#?.??.# 1,1,5,1,1
.??????.##?.?..?#?? 5,2,2
.???##.#??#???#?? 1,2,2,3,2
?????.?.?# 5,1
??????#?????#???#??# 6,6,5
?#?#.???#????# 4,3,2,1
??.?.?#????. 1,3
?..?#??#??.?.????## 1,6,1,1,2
?#????#????#.? 7,3
#?.????#?? 1,1,4
.?.???.??? 1,1,1
#?#?###?????.? 11,1
.?????.??#????## 1,9
.???#?????.#??.?? 7,1,1
??.????#.?#?.?????? 2,3,2,1,2
?#?##???#???#???#. 4,7,1
???????????????# 1,3,1,5,1
.????#.?###?#??? 4,4,1,1
#????.??.???#.?? 4,2,1,1,1
?????#???#?? 4,1
??????????????#. 8,2
?????#?????#? 1,8
#???.?.#??##?.???? 1,1,1,6,1,1
?#???.?.?? 1,1,1
??.?#??????#????? 2,3,3,2
??.?????#??#. 1,2,2,1
?..?#??????#??.???# 1,11,1,1
??#????##??###?.??? 1,3,9,2
????????.???..? 2,2,1,3
?#.??#???.??#??# 1,5,2,1
.#.???????#???????. 1,8,4
?#???###?..??.?.??? 7,1,1
?.#??.??#?##.??? 1,1,6,2
...##?#???????????. 2,10,1
??##.?.???##?.??.. 4,1,1,3,2
#.??#???.?#????#? 1,1,2,1,6
??#?#??###?????.???? 14,1
???????.??.?????? 4,1,1,1,2
?##???.????.#??#?? 6,1,1,1,1
??###?.?..?.#?#???? 6,1,1,1,1,1
#???.##.?? 2,2,2
.?.#?.#..??#?#???.?. 1,1,1,8,1
.#?.#???.???#?#? 1,3,5
#???????????###??? 8,8
?????#?##?#? 2,6
###?#?.??? 6,1
.?#??.????. 3,3
#???????.?#.??.# 2,5,1,1
?.#?#???##???.???.?. 1,3,7,1,1
.?##????#.?#???#? 7,5
????#.???#?#.#. 3,1,2,3,1
?.?????#??#.? 4,4
.??..??#?? 1,4
#?#?#??.???????#?? 7,1,1,1,1,1
??#??????????? 4,3
?#???#???.??..#.???? 2,4,1,1,1,1
??.#??.???##?.?? 2,1,5,1
?#??##?.?????..#?? 1,4,1,1,1,1
?.#??..#..?? 3,1,2
?????.##???? 4,6
????..?#???.??### 1,1,3,5
???????.?????????#?? 1,3,10
?#.???????????#??.# 2,1,2,1,5,1
#?#??#???#?.????#?# 3,5,7
??????##?????????.? 4,3,5,1,1
?#??.?????.#????#? 1,1,5,2,1,2
????.??#?????????. 2,4,3,2
??#.????##?. 2,1,4
#.???.?????.??? 1,1,3,1,1
???#.#####?#??##??#? 1,1,14
??????????.?. 1,4
.????????.?.???. 3,1
?#??????..? 3,2,1
#?#.??..???. 1,1,1,2
?#??#..????????? 5,5
.?#?#????##?????.?.. 2,7,1,1
???????####.????### 7,6
?..??#????#?#??#?#?. 10,5
.????#???#??.?#??? 10,2
?.?#?#?##?.?..??. 8,2
?.???..?####??#??.?# 1,2,10,1
.?????#?#??#? 2,5,1
?.??????.?#??????. 4,6
?????????.#???????.? 1,1,1,1,1,5
.????#???.##?#?#??.? 2,7
?.????##?? 1,5
?????.?#??? 3,1,2
.???##.?#.???????.#? 5,1,1,1,2,2
#????#?.???#? 3,1,4
.????.??##? 2,1,3
????.???.?..#?????#. 4,2,5,1
??..??#?#?#.? 2,5,1,1
??#?#?..??.??. 6,2,1
???.????#?#???? 1,1,6
.????.???.? 1,2,1
.#.?????.??..#. 1,4,1,1
?#????#???.?????..?. 2,4,4
?.??##??#????.??? 1,9,1,1
??.?.??#???#.#..?? 1,1,5,1,1
#??#?#??..??.?????. 7,1,3
#??#?#.##.??#?##?? 1,4,2,3,3
????#.#???? 1,2,1
??????????#?##??? 6,7
?..#?#??#????? 1,1,1,6
?.???###???#??##.? 1,4,6,1
????#??.??? 1,3,2
??###??????? 5,3
??????..??????.. 2,2,3
??#??#???? 2,1,1
?#????#????.? 4,5
????????????#?? 4,1,2,1,1
???#.#.??????#?#?#?? 1,1,1,13
?????????.???#??#? 8,4,2
?.?.??#????#??. 1,8
?#?##???#??. 5,2
.?#??##.??? 5,2
#???????.????#???#? 2,1,3,6,2
??#??#?#?????.?? 8,1,2
#.????#?.???????#? 1,6,4,1,1
?#.##?###? 1,7
????????#?????#??? 5,4,2
#????#..??. 2,1,1
?????#?#??. 1,5
??????#??#? 3,3,2
#??##?#???..???? 1,2,4,2
?#.?#.?##??? 1,1,5
.??.?#???#?...? 1,6
???#???#???#.??##??? 1,3,1,1,3,1
???.#?#???#?????? 1,7,3
??.???????#??#?# 1,1,3,1,1
?#.?###??#.?#??? 2,4,1,1,1
##????#.??.??.#?.?? 5,1,1,1,1,1
????#?##??..### 8,3
.??#?.#????..????# 4,1,1,3,1
???##?????##???? 5,1,3,1
??#?#???#???.?.?#.? 11,1
??.????#.?.#??# 1,1,3,1,4
?#?.?##???????# 2,5,5
?#.##??##?..???? 1,7,2
??#??.?##??.???.?# 3,5,3,2
??#?????##?#. 4,5
.????.??.?.#??? 2,2,1,1,1
??#??.???? 1,3,1
?????????????#. 5,1,1,1
???#.???.? 1,1,2
#???????.????? 8,4
..?#?.?#.? 1,1,1
????...????#??# 1,1,1,3,1
??#??#????#? 5,3
?.??.???##? 1,1,3
?????????????. 5,3
?.##???????.##??? 6,1,2,1
?#?????.##?.?#?#?? 2,1,2,4
????.?#?##???.?? 1,1,5,1,1
?#?????#.?.? 3,3,1
???#??#.?#???#?? 1,5,1,1,1
?#??#??.???# 1,3,1,1
??????##??#??????? 1,6,2,5
?#?#????#??.?????? 11,1
.?#??..?#? 2,1
.?????#?.??## 1,3,4
???#???#.?#.# 4,1,1,1
??#?.?????? 3,2,2
?????.#?#? 2,1,2
.???#?.????#???.?. 4,8
???###???#..?#??. 1,6,1,2,1
????..??#???????? 2,5,2
???.?????#?#?#?.? 2,1,5
.????##.?.????.??? 2,2
??.?#.#??..?#?#?. 1,1,2,5
?...?#?###?..?##???. 5,5
?????.#?#? 1,3
??##???.?????... 5,4
???##????. 4,1
.????..??#.? 4,2
.??#?.?.?##?##???#?# 2,12
.????#??????..#.???# 11,1,2
??????.#?# 3,3
.#?????.??? 1,4,1
??????#????????????? 10,6
???#??##???#?? 6,1
??#???...#.???? 4,1,1
?????#??..?????#?? 5,3
?##??##?##?. 3,7
.??.??.???.?.?.? 2,1
??.?#????..???#???? 1,4,7
.????#??????##?#?# 1,1,1,7,1
???????.?????#????# 6,8,1
?####????.?? 9,1
??????????##??#.???# 2,10,1,1,1
??????....#?.???? 3,2
...???.????.???##.. 2,3,3
.???#??#?..??????# 6,3,3
#.?????##????#? 1,1,4,4
?..?#?##??#?#??.?# 1,12,2
?.?#?????..????????. 7,6
??????#?#????#??#.?? 1,13
??#????.?? 2,1,1
??????????#??#?##.? 3,8
##??????#?.? 6,2,1
#.????###????????##? 1,1,13
??#???#?????. 1,8,1
#.#?????#???##????.# 1,3,9,1,1
?????#?#??#?????# 1,1,12
??###??????#?? 5,1
?????##??.#?.# 1,6,1,1
?###???#??##?.? 5,6
?.?????#?#.???????.. 1,2,2,1,4,1
?#.??#??????.#? 2,4,1,1,1
.???##?#?????? 6,3
??????????? 6,1,1
?.?????##?#???#???.? 1,1,1,2,8,1
????#.?#.?#???.?? 3,1,1,4,1
#..##?.???#?#??. 1,2,1,4
#???#??.#??????.?? 2,2,3,1,2
?????##??? 4,1
?.?.???#?. 1,1,1
??????????.????????? 1,6,1,3,2
.??????##?????#?# 2,4,5
.#????#???#?##..? 3,2,5
??????##?. 3,2
?.??.????#?#?#?.??? 1,1,4,1,1,1
#????.??##???????## 1,1,1,6,1,3
???#????.???#.?.??? 6,1,1,1,1,1
??.?.#.?.?#? 1,1,1,1
?????#..????#?#?#?? 2,1,7,1
???????#... 2,1,1
?????????????# 1,4,2
#???#????? 2,5
.???#???.?##??#?#.? 3,3,3
.?#????.?.###?. 5,4
.?#.??##?????.??#? 2,4,3,4
?????.#?##?????#??? 2,2,6,1,1,1
.????????.?#??# 6,2,2
?????#??#?#????## 1,10,2
.?????.???????#??? 1,1,2,1,1,4
???#?#?#..??? 8,1
??##??????..?. 4,1
..#????..?#?.. 4,2
?????#.???.?.?.???# 1,3,1,1,4
#??..????#?? 2,2,1
?#??.????##??????.. 1,1,1,1,6
.#?.???.??.?##??#? 1,1,1,1,3,1
.???#?###.???#?????? 2,1,3,1,6
##?#..?.??#?????.??# 2,1,1,2,2,3
#?#???.#?.#?..#?? 3,1,2,1,3
????#???.? 2,3
.??#?????.??????. 6,2,1
?#?#??#??#???.? 4,1,3
?#???.??????.#??#? 4,2,4
?#?#.?#??#??#.??..? 1,1,1,5,1,1
#?????#????#?#?? 4,3,1,3
????##????.??#?. 3,4
???.???##??.??..? 3,6,2,1
?.??????????##???? 1,5,5,1
?#?#?..?????? 3,4
?.???#?....????#. 2,3
?.??????????#??? 1,1,2,5
?#???##.??#?.?#???.# 2,3,3,5,1
#..????.##.#? 1,2,2,1
???.?#????? 4,1
?#?.??..??#? 2,1,2
?#?.???.?#?#?#.? 2,2,6
???..???#??.# 2,1,2,1
.#?.?.#??? 2,3
???###?#??#? 1,8
?##??##?????.??? 6,2,3
.??#??#??.???????. 6,5
??.???##?.?????#.. 2,1
???#?..?#?#..? 2,3
?.?.???#?..? 1,2
?#????????????###? 10,5
?????????. 2,2
?#??##??##???? 3,7,1
.?##???##.???.?. 2,3,3,1
??.?#??.???.?. 3,1
?#????#??#? 3,2,2
??#??.????#?#?. 3,1,6
?##?#..???? 2,1,1
??.##?..????. 1,2,1,1
?.?????#.?????#??.? 1,2,2,6,1
?###.??.?? 3,1
?.#?#?#.????##? 5,7
?#??.???#?#.??#..? 4,3,1,1,1,1
?????#????#????## 1,2,8
??###?#????#???.#?.# 1,5,5,1,1,1
.?#?#????#???#.??#?? 12,3
????#?##??????###?.? 1,6,5,1
.#.????????#?????? 1,5,3
???...????#.? 2,2,1,1
#????####?????#??? 1,1,5,1,1,1
#????#????. 6,1,1
.?#??.???.?# 3,2,2
#???.?#?..?.? 4,3,1,1
.#??##?#???? 5,1,1
???##?..#??##?#. 4,7
??#???##?????? 9,2
#????.??#. 3,2
?.????#?#???#? 1,1,9
?#?#????#???#??? 6,1,4
??#.??.?#?#???????. 2,2,1,8
??.??.??..? 2,1,1
?#..#?##?..#?.#?#.?. 2,4,1,3,1
??#?????????#?? 5,8
?.????#???? 1,3,1
.????#??#?.?#####.?? 6,5
?##??????.??. 2,1,1,1
???###???..??? 6,2
?????.???..#?.? 1,1,2,1,1
??..#????? 3,1
???????.?.. 1,2,1
?.#...#??????#?.??? 1,1,8,1
.??####?#?????#?.? 10,1
?#?#.?#.##?? 4,1,4
???..??????? 1,1,5
.?#???.?.???? 3,1,2
.#?#??..?????. 5,1
?.??#??#???????? 9,1
.#..???.??.??#? 1,2,1,1,1
?#???#??#??????? 2,5,2,1
???#???.??#??##? 1,2,1,6
??????#???#???#?? 1,1,5,4
????.##.?#?.?.## 1,2,1,1,2
??#??..??? 2,1
.#?.#????? 1,4
?????.?.#?? 3,3
#????#?????..? 3,2,1
?????.?#?#??.??? 1,1,1,3,1
??#????.#.??#? 4,1,1,2
?#???..???????????? 1,1,1,1,1,3
??.???????#??????## 10,4
?????###????#?... 5,2
?.????#????#???# 1,10
.#??.?###?##????#?# 1,1,10,1,1
?????#???????????#?? 2,13
??.#?#??.?#????????? 1,1,1,1,11
#???#.?????.??? 1,1,1,2,1
?.??#?????????? 1,1,8
..??#?##???#??????. 6,2,2
???????.?.????### 1,1,6
.??#???#.???? 6,1
.??#.????#??#??????? 1,9,2
?#????????#.?. 5,4
????????##??. 2,4,1
?????.#????????. 1,2,1,2,2
??????.????#... 1,4
?.?####????.??##??? 7,6
.????#####..?????#?# 8,5,1
##???.???#? 4,2
??????#????? 1,4
??##?..??. 4,1
.??.##?.????? 1,2,1
????.#???##.?.? 1,6
?.?#???.??#??.??# 1,3,1,4,3
???#??????. 3,2
##??.?????# 2,1,2
?.??????.????????? 1,3,2,6
.??????????.???..?.? 6,1
#??????#?#?????? 1,1,6,4
#?.?#?.???? 1,2,1
???.????#?##?#??# 3,1,10
???????#?????#??. 4,3
.???##?#??? 5,2
..????#????## 1,2,4
??.???.??? 1,1,1
#?#??##??#???#?? 10,3
??#?#???#.? 4,2
???#??#?????##?? 6,4
?.????#?#??#??.???.? 11,2
##???????? 3,1
????#?.?#??????????# 2,2,2,1,1,4
?..??###?#????#?. 1,1,3,1,5
?#?#??##??#??.?.#?.? 2,5,3,1,2,1
.???.?.?.#? 2,1,1
#?##??#???????????# 12,3,1
?..?.??#???#?.?? 1,8,1
.?.?#.????????? 1,5
??.??.?#?? 1,2
??????##??#?.? 1,8,1
?.?.???.??? 1,1,2
???#?????.#?. 1,5,1
????##?..??.?? 7,2,1
???????##? 3,3
??????#???? 2,7
????????????..? 7,1,1
#.??????????#?? 1,3,2,1
.???#??#?##???????.? 9,1
????????###??.????.? 13,4
?????.#????## 1,1,3
#??##?#?#?.????# 10,2,1
?.????#???? 1,5,1
.?#?????#? 3,2
???##.?.?? 1,2,2
..?????.???.?#????? 3,1,1
???#?.???#??.?#??#?# 3,4,6
?#????.????##?#?? 4,3,5
?#?#???###?.?..?? 10,1
.???.??##??##?? 1,9
?????#.???#? 5,3
?##?????##?? 2,1,5
.??..???#?#???.???.? 1,6,2,1,1
??#??##??#?#?? 7,1,1
#?????.?##? 2,1,3
???.#???.#?##?.#?#? 3,1,1,3,3
??#??#.???.???#?? 4,2,5
???.?#???? 1,3
??#?#?.??????# 5,5,1
???.?????? 2,2
?.?????.?.??? 1,2,1,1
????????????????.?.? 1,8,1,1,1,1
#.???????##?.?.? 1,1,5
?#???????? 5,3
??#?.#????? 1,2,1
.??.##??.???#??. 1,3,6
???????.#??? 3,1,1,2
??#?#?.??.#?.? 4,1,2
??#???#??###..???. 1,1,8,1
?.??#??.#?? 4,3
.?.???#???#? 1,9
?#?.???..? 3,1
##??#???????.# 7,1,1,1
???.?#?..?.?????? 1,1
.#.??##?#???????? 1,6,1,1,1
?#???##?#???? 1,9
#??..??###?.??? 1,5,1
????????##????#? 10,3
#???#???##?? 1,3,1,3
?.??????..???????. 6,3
???#???#???.??# 8,3
??#?.??.??.??????#? 3,1,2,2,2
.????????.?#?????? 1,2,1,1,2,2
.?#?????#..???# 4,2,2,1
.???#?#??#?#??.#? 1,9,1
????#?????# 2,2,2
???#???##? 3,3
?.?#..?????#???. 1,1
??????#????# 1,1,5,1
#???.??#??##?????##? 1,2,6,7
?.???#????.?? 2,2
#.???#?#???#???#???. 1,15
???????.?#.????????? 2,2,2,1,1,5
??.?#???##????..? 1,11,1
??#?##??.#?????. 6,1,1,1
?#??#.??#? 1,1,1
??##????.?????? 5,1,1,1,1
??????????????? 6,1,1
.???##??.?#??# 5,1,1
????.??.#? 1,1,1
..#.?#?#?##??##??#? 1,13
?.???##??.???#.?# 1,7,1,1,1
?.????.??#?##?#?##.? 1,1,1,11,1
???????????? 1,6
????.?????#??#???# 1,2,1,5,1,1
?.??##???##.# 9,1
??.???#???????? 1,1,1,3,1
.??.?.????##?##..? 1,6
?#??.#?????. 2,3,1
???..#??.???.???? 3,1,3
..????#???#??? 7,1
?#????.?????.#?? 4,5,2
??#??????? 6,1
??????.#.#? 6,1,1
??.?..?##? 1,1,4
??#?.?#?.?#? 1,2,1
.?#.???????#? 2,2,6
??.?????..????#???# 2,9
???##?#.??#??? 2,2,1,5
???#??????#?????. 3,6
?.??????#?.?.???? 3,3,1
??.????.?#? 4,2
?????????.??.??? 6,2
?#..???..??#?..?. 1,2,2,1
?...???##????.??.??? 8,1
????#???#?#?????.# 5,1,1,3,1
??#??#??#??.????? 11,1,1
??#??#?#?#? 2,7
??#???????.?#??????? 1,1,1,2,7,1
?##??.????#??#?##? 4,10
?#????#.??.? 2,1,1,1
???#??.??.????.??.? 1,3,2,4,2
????#????.?.?# 4,1,2
?#?##????#.?#.??#?#? 10,1,1,1,1
???#?.??????.?? 5,2
?????????#??#? 3,5
.??.#??.??? 1,1
?####??#.#.#?.? 4,1,1,1,1
#?#??.??????. 5,3
.?#???.?.?. 4,1
..??.?#???...??#?..? 1,3
.???...???#?#?###?? 3,11
???.????#??#.???.? 1,1,5,1,2,1
??????.?..?? 1,2,1,1
??.????#?.??.#?.? 1,2,2,1,2
??#?#?????. 3,4
?#?#??#?????.. 6,3
???#??#??#????? 1,1,2,1,1
?#.??.??#???#??? 1,7,1
?.???#?#???? 3,4
???#???.????##.? 1,6
?###?#??.##????? 4,2,2,2,1
.?.??????????.# 4,3,1
????#??#???#???. 2,4,4
????.?#??? 2,4
??.?#????##???????. 1,15
?#???.??.?#????.#. 2,2,1,5,1
??????.?????# 5,1,1
??.?#.???#?. 1,2,1,2
..#?#???.??.? 6,1
.?#??...?#???? 4,3
?#..???#?... 2,5
#.?#??#????????????? 1,12,4
?.#..?.#.?###? 1,1,1,4
?#??##??.. 1,4
??##?#????#??#?. 5,7
??##??#?#?????.?.## 11,1,1,2
???##?.???. 2,3,2
?#?????#???#.##?# 2,6,1,4
????.#?#????#?? 1,2,1,4,1
#.??..?????????? 1,1,7
?.#?.?#.?????#?. 1,2,1,2,1
??????###?.? 1,5
??#???#???????? 10,1
.??#??????#?. 5,1
???#.??#?.?# 1,2,4,1
??.#???#??#?? 1,6,3
?#?#.????? 4,1,2
??##??...???# 6,1,1
???#??????. 3,1,1
?????#?#??##????. 7,2,1
???.?#??????#??#??. 1,3,3,4,1
.??????????.?????.?? 7,1,2,2
?##?..??#?.??.????#? 4,2,1,5
??##?????# 5,1,1
?..??????? 1,2,1
.??.#??.???# 1,1,1,1
????.#?????..?.?# 1,4,1,1,1
##???#..?# 6,2
??????.???? 1,1,2
?.#??###?#? 6,1
.???#???.???? 4,2
???#???.??###?#? 1,1,1,7
?#??#??.#?#??####? 2,1,9
.#??#????.?# 1,1,3,2
.???.?.???#????. 1,7
????????..#.???. 3,1,1,1,1
????##??##??? 1,6,2
?.???#????? 1,5,1
???.??#??.?.? 3,2,1,1
.??..??#??.?. 1,4,1
.#??.???????#??#?#? 1,1,10
?.??#????.?#. 6,2
????.?#??#??#??.???? 2,8,3
.????#???#.????? 9,1
??.????##.?#.??? 1,2,3,1,1
.#.??#????#????##.## 1,1,9,2,2
????#..?#? 3,1
????##.#.?##.???..? 3,2,1,3,3,1
?#.#?#..??? 1,3,1
##???#?????????##?. 8,1,6
???...#??#? 1,4
.??.?????#?#?????? 1,1,10
?.??????#?##??. 2,2,4
..??#?????? 3,1,1
??####????????.?? 7,1,1,1,1
????#?##??.????..?. 6,1
???#?#???.?# 6,2,1
????#?????#.?.?##. 1,5,1,3
?.#???.??????#. 4,3,1
?.???#??.????#. 4,5
?#?##?#??. 4,1,1
?#??##?????.?##? 7,2,4
?#??##?????????##? 2,6,2,3
.#?#?#?##??? 3,6
.##?.????.. 2,3
????????????????# 4,1,1,4,2
?????#????.????## 1,5,1,4
?.#..?#?###??#? 1,8
?????##??????.??? 1,11,2
.?#??#?????.? 8,1,1
?????#??????#?## 7,7
?..##??#?#?? 1,2,1,3
???????#.. 4,1
??.???..?????? 1,1,4
????#???#??#? 5,1,1,2
????#?????.????#? 8,1,1
????.?.????. 3,1,3
.?####?.??????????.? 4,9
#.?#?##??????. 1,4,3
#.?###?#??????..##?? 1,5,2,1,4
.?#.??????#.? 2,1,2,1
#.?.????#?? 1,1,5
?#???.?#??#? 2,1,4
?????#?#?? 2,3
??#.###???.???? 2,3,1,2
.???..#???. 1,1,1
?.?#???#??.?#. 1,1,5,1
???#???.????#??#?#?? 6,11
???#???????? 3,6
#.?.??????#?????#?? 1,1,5,5
??#?#???..??? 7,1,1
?#?#??#?##??????? 3,12
..?????.??????.?#? 4,1,3,2
?#?.#..#?#????#???#. 2,1,1,1,6
?.?.##???.?? 2,2
?.???##????###??? 1,7,6
????????##???? 1,3,3,1
.??...?#?..??#?#?? 1,5
?.#??#??.???.#??? 6,1,1,3
?.??#?????# 1,3,1
.????????#?#??#???? 1,1,1,8,1
????????.?#?? 2,2,1,1
..????????.?. 1,1,2,1
??.#.?????? 1,1,3
..?#?????####???. 1,10
?#???####????# 1,9,1
???##?#????#???? 1,10,1
?????#????#???.# 1,3,1,2,1
.#????#???.#??.?. 6,1,3
???????.????????.?? 1,4,4,1,2
?.??.#?????#. 1,3,2
.##???#?#?#?..???.. 10,2
#??..?????#?.?.?? 1,1,6,1,1
?##?##??#?? 5,1,1
???????... 2,1
#????????? 1,1,2
???.??#??#?#? 1,9
.??#?.?#?#??????? 1,9
.?##?#.?##??.?##? 3,1,4,4
?..#?????.? 1,2
?.????##?#.? 1,1,5,1
??#?????????? 3,2,1
??...?.???#???##.?. 1,6
??#?????????### 5,2,3
?#????????#?#? 2,1,2,2
??????####?????##??. 1,11
???..???#?.#?? 2,5,2
???.?????# 2,4,1
?#?#???#??..#?? 9,2
#?.??.??????#?#???? 1,2,2,8
?..??#???.?#???? 3,1,2
##?#?.##???# 4,6
??##?.????##???.. 4,6,1
????.????? 3,3,1
???????..?? 1,2,1
??????.???#?.#?.??. 4,4,1,2
??.??#??.#? 1,2,1
?..????#?????? 1,6
?????#.?..????.#?? 4,1,1,1,1,1
?.#??.#?###?????##. 1,1,5,3
.?..#?.?.?#??#???? 1,1,1,5,1
#??#?#?##????? 6,2,1,1
??####..#?? 4,3
?#??##????.?#?? 6,1,3
??#???#?#?? 3,1,1
??.##?????? 2,2,1
???????.?#?#..?#.?? 1,4,2,1,1,2
???????.#??# 4,1,1
???.?.###??#???? 1,6,2
??...?#?#? 1,4
??.#???#???.??????#? 2,3,2,3
.?###??.?.?#????. 5,5
#????##????.?????? 8,1,1,2
??.??#???? 1,1
?.?#???.#.? 2,1
?#.?.??##???.?#? 2,1,2,1,1
??????...?? 2,1,2
#???##??#????#?#.?# 14,1,1
?#?????.?# 1,1,1
?#?.#.??#???? 2,1,7
????#??..??? 1,3,1,2
?.??#?#?.?.?. 1,5,1
?..??#?#??.?#.#?..# 1,4,1,1,1,1
.?#????.????. 1,3,1,1
.#???.?.#??#???.#?# 3,4,1,3
??..?#??#???##??#?? 1,2,7,3
????.?##?????.???#. 1,1,5,1,1,1
?#?????##??.#.?.?.? 6,2,1,1,1
?#??#????.?#.???#. 8,1,1,2
#???.##?.?. 1,1,2
#.#?..?.?#?#.? 1,1,1,3
???#??.#?#???????? 5,8,2
?#???#?.??#?.???.. 3,3,2,2
.##??????.##??? 2,3,5
?#??#???#?#??##?? 4,1,1,4
???.??#?#?#?##? 1,10
????##?###??????? 1,13
????#?.??#?? 1,1,5
????##???#???# 1,6,1,1
.????.?.???????? 1,1,1,1,4
??????#?.?????? 1,1,3,2
???.??.??#??##.#. 1,1,1,7,1
??.?##???# 1,4,1
?????????. 3,1
.?????#??. 2,3
??#??###???.?.?#?#? 8,1,1,5
?#????.?.??????#???# 1,1,1,7,1,1
?#.#?##?.##? 1,5,2
?#???#??#??.?????? 1,2,1,4,1
??#??#????.##???? 6,4
.#???????#????? 3,5,2
.???.???#? 2,1,2
?#??????##???.# 2,1,6,1
?????#?#?? 1,4,2
?..#??#???? 1,4,1
.#?????#??#??#? 2,4,6
.#??.?.?????? 1,1,1,2
.?????##.??.?#??? 1,3,1,4
?.?#???#??.????.? 5,1
?#???.##?. 3,3
?????????#??.?? 4,2,1,1,1
????..?#?#?#?# 1,2,8
???????#.????.???? 5,1,1,1,2,1
??#?.?####??? 2,4,1
##??.##??#???#.??# 4,5,2,2
?##?.????##??#???#? 3,2,6,1
#???.?????????? 1,2,1,7
#?.?#??##??#??#??. 1,1,10
??#???????????# 3,1,1,1,2
.??#???#??#.? 8,1
?#?????##??. 2,6
??#??.???..?..# 2,3,1,1
????.?????#?#?. 1,2,4
??.???#?.???????#.## 2,2,4,1,1,2
??#???##.?? 1,1,2
?#??????.????##?? 5,1,3
.???#?#??.??. 3,2,1
?????#???? 1,2,1
?.?.?#??.??#?#????? 1,2,1,1,3,2
??.?????.?????##? 1,1,1,1,8
??#.??.??#?..??? 2,1,1,1,2
???#??.#?.???#?#?. 4,1,1,1,4
.?#??.??#?#?###??#.. 2,10
???.??#..?? 1,3,1
?##?#.??..#...##???? 4,1,1,6
?????##???#??.#??.. 10,3
.#.???????? 1,2
??#.?????? 2,2
#?????#?.?? 8,1
????.??##?. 1,3
#??#?#?????#?.?? 7,1,2,1
????#?.???#???##???. 1,4,1,9
?????????#? 1,4
.??#??#????????#??. 4,3,6
??#?????#????????.?? 2,2,7,1,1
#?.??#????.????.. 1,6,1,1
?????#???? 2,4,1
....???...????#.? 1,5
???????..??#?#?? 1,2,3,1,1
?#?##??#???#???????? 15,1,1
#???#?????#? 2,3,3
#????.?????????? 3,1,4,1,1
?#?????#?? 1,4,1
??.?#??#?# 1,3
.??#????.????. 6,3
?#??##.????????#?#.? 5,1,1,1,3,1
??????????.#?#? 5,3
.??????#?..? 1,1,1,1
????#?????#????##??. 1,14
????.??.??#?? 1,1,1,4
##?#???#.???.?. 6,1,1,1,1
.???..???###??? 1,1,9
??.?#????#???. 2,5
.???.??###? 1,4
??#???#?..#?????#?? 7,1,1,5
?????#.??#? 5,2
??.??#.#????#?????? 2,3,1,9
??##?#???.?? 1,7,1
??.????##?? 2,2
?.??.#?#??????????? 1,2,3,2,1,4
?#???.?????. 1,1,1,2
.?#??????? 4,1
??#?#?.???????????.? 5,1,1,1,1,1
??#?.???#???.?? 3,6
???????###?????# 4,5,1,1
???.??.??.??#???##? 1,1,1,1,2,3
??#?#????##.???#?. 5,2,2,1
?.???.??#??#.?#? 1,3,1,2
?#.?????#. 1,1,2
?.????#???????#???? 1,4,10
??.?????##?. 1,1,6
??.#.##?????#???##? 2,1,10,2
??.?????.#???.#??? 1,1,1,1,1,3
???#??##.????? 7,1
?????????????#?##? 3,7
?#?????##?#???? 5,6,1
????##????#???#?# 7,8
.?.???#???.#???? 1,6,1,1
??.#?.?.?.?? 2,1,1
???????..??? 2,2,1,1
??#???.????#. 3,2,1
?.?????????.??????.? 1,9,1,1,1,1
.?.?????.???..??? 3,1
?#.?.?##????##?.. 2,8
#.?????##????#?#.. 1,7,3
?#?????.??##??#.??? 5,6
??????.????????. 2,1,1,2,1
??#?.#?#??#? 3,1,2,1
##???.?#???.??..#?? 2,2,4,1,2
#?????##?.?????#?#? 1,1,3,8
??????.##??? 1,5
?##??.??.?? 3,2,2
????#?###?#?.?##??#? 12,3,2
...?#?..?#?#? 2,4
??????????.?#.??#?? 8,1,5
.#????#??##?.?#??? 11,3
?.##?.????????#??##. 2,9,2
??#??#?#????##????.# 13,2,1
.???###??????### 6,5
.?????##????. 1,4,1
???????.?##? 3,3
??#????.?.???????# 1,2,1,6
???????????##? 4,6
??#???#?????? 4,1,1,1
.?##??#.?#?#?##??. 2,1,8
?#??????#?#???#. 6,3,1
?????##???????.?#??# 2,2,4,1,1,2
??.???#.??? 4,1
.??????????.? 2,1
????.?.???.#? 3,1,3,1
.?#?#?###?.## 2,1,4,2
..???#?????##. 4,3
?????.?????#?#?? 1,1,1,3,1
#??##????????????#? 1,3,4,5
??????#?.?? 2,2,1
????.?.?????? 3,1,2
.?????.?#.#??### 1,3,1,1,4
??.?.??#?. 1,1,2
.?#??##?.?. 1,3
?#..??????##?? 2,1,5
????????#????????. 1,1,2,1,3
#????###???????#? 3,3,1,4
?#???????.... 1,4,1
?????.?.???## 1,1,2
?????.##?# 2,4
??????..?? 2,1,1
#??##?#?....### 1,3,1,3
.??????.?.#???.??. 5,1,2,1
##???#??.???#?????? 2,3,1,1,4,1
???????.?#??? 7,1,1
?????.?.?#. 4,1,2
??#?.?.???#?#? 2,1,5
.?.?#????? 1,4
??#??.?.??? 3,1
.#??.###???.?? 1,1,5,1
??##???#??.??# 4,5,2
?????#???#? 5,1
+122
View File
@@ -0,0 +1,122 @@
--- Day 13: Point of Incidence ---
With your help, the hot springs team locates an appropriate spring which launches you neatly and precisely up to the edge of Lava Island.
There's just one problem: you don't see any lava.
You do see a lot of ash and igneous rock; there are even what look like gray mountains scattered around. After a while, you make your way to a nearby cluster of mountains only to discover that the valley between them is completely full of large mirrors. Most of the mirrors seem to be aligned in a consistent way; perhaps you should head in that direction?
As you move through the valley of mirrors, you find that several of them have fallen from the large metal frames keeping them in place. The mirrors are extremely flat and shiny, and many of the fallen mirrors have lodged into the ash at strange angles. Because the terrain is all one color, it's hard to tell where it's safe to walk or where you're about to run into a mirror.
You note down the patterns of ash (.) and rocks (#) that you see as you walk (your puzzle input); perhaps by carefully analyzing these patterns, you can figure out where the mirrors are!
For example:
#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####.##.
#####.##.
..##..###
#....#..#
To find the reflection in each pattern, you need to find a perfect reflection across either a horizontal line between two rows or across a vertical line between two columns.
In the first pattern, the reflection is across a vertical line between two columns; arrows on each of the two columns point at the line between the columns:
123456789
><
#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
><
123456789
In this pattern, the line of reflection is the vertical line between columns 5 and 6. Because the vertical line is not perfectly in the middle of the pattern, part of the pattern (column 1) has nowhere to reflect onto and can be ignored; every other column has a reflected column within the pattern and must match exactly: column 2 matches column 9, column 3 matches 8, 4 matches 7, and 5 matches 6.
The second pattern reflects across a horizontal line instead:
1 #...##..# 1
2 #....#..# 2
3 ..##..### 3
4v#####.##.v4
5^#####.##.^5
6 ..##..### 6
7 #....#..# 7
This pattern reflects across the horizontal line between rows 4 and 5. Row 1 would reflect with a hypothetical row 8, but since that's not in the pattern, row 1 doesn't need to match anything. The remaining rows match: row 2 matches row 7, row 3 matches row 6, and row 4 matches row 5.
To summarize your pattern notes, add up the number of columns to the left of each vertical line of reflection; to that, also add 100 multiplied by the number of rows above each horizontal line of reflection. In the above example, the first pattern's vertical line has 5 columns to its left and the second pattern's horizontal line has 4 rows above it, a total of 405.
Find the line of reflection in each of the patterns in your notes. What number do you get after summarizing all of your notes?
Your puzzle answer was 30535.
--- Part Two ---
You resume walking through the valley of mirrors and - SMACK! - run directly into one. Hopefully nobody was watching, because that must have been pretty embarrassing.
Upon closer inspection, you discover that every mirror has exactly one smudge: exactly one . or # should be the opposite type.
In each pattern, you'll need to locate and fix the smudge that causes a different reflection line to be valid. (The old reflection line won't necessarily continue being valid after the smudge is fixed.)
Here's the above example again:
#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####.##.
#####.##.
..##..###
#....#..#
The first pattern's smudge is in the top-left corner. If the top-left # were instead ., it would have a different, horizontal line of reflection:
1 ..##..##. 1
2 ..#.##.#. 2
3v##......#v3
4^##......#^4
5 ..#.##.#. 5
6 ..##..##. 6
7 #.#.##.#. 7
With the smudge in thetop-left corner repaired, a new horizontal line of reflection between rows 3 and 4 now exists. Row 7 has no corresponding reflected row and can be ignored, but every other row matches exactly: row 1 matches row 6, row 2 matches row 5, and row 3 matches row 4.
In the second pattern, the smudge can be fixed by changing the fifth symbol on row 2 from . to #:
1v#...##..#v1
2^#...##..#^2
3 ..##..### 3
4 #####.##. 4
5 #####.##. 5
6 ..##..### 6
7 #....#..# 7
Now, the pattern has a different horizontal line of reflection between rows 1 and 2.
Summarize your notes as before, but instead use the new different reflection lines. In this example, the first pattern's new horizontal line has 3 rows above it and the second pattern's new horizontal line has 1 row above it, summarizing to the value 400.
In each pattern, fix the smudge and find the different line of reflection. What number do you get after summarizing the new reflection line in each pattern in your notes?
Your puzzle answer was 30844.
Both parts of this puzzle are complete! They provide two gold stars: **
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
import sys
import numpy as np
def find_reflexion(pattern):
for i in range(1, len(pattern)):
reflexion = True
for j in range(i):
if (i+i-j-1) > (len(pattern)-1): continue
if not np.array_equal(pattern[j], pattern[i+i-j-1]): reflexion = False
if reflexion: return i
return 0
def find_smudged_reflexion(pattern):
for i in range(1, len(pattern)):
smudges = 0
for j in range(i):
if (i+i-j-1) > (len(pattern)-1): continue
for p in range(len(pattern[j])):
if pattern[i+i-j-1][p] != pattern[j][p]:
smudges += 1
if smudges == 1: return i
return 0
if __name__ == '__main__':
lines = open(sys.argv[1]).read()
patterns = lines[:-1].split('\n\n')
patterns = [[list(n) for n in p.split('\n')] for p in patterns]
res1, res2 = 0, 0
for pattern in patterns:
res1 += 100 * find_reflexion(pattern)
res2 += 100 * find_smudged_reflexion(pattern)
vert = np.transpose(pattern)
res1 += find_reflexion(vert)
res2 += find_smudged_reflexion(vert)
# challenge 1
res1 = str(res1)
print(f"challenge 1:\n{res1}\n")
# challenge 2
res2 = str(res2)
print(f"challenge 2:\n{res2}\n")
+15
View File
@@ -0,0 +1,15 @@
#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####.##.
#####.##.
..##..###
#....#..#
+1387
View File
File diff suppressed because it is too large. Load diff