Skip to content

Commit 2d3000b

Browse files
committed
Day 06: Solution of part 2
1 parent 68eb71f commit 2d3000b

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

06/log.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ Given the recording in your puzzle input, what is the error-corrected version of
2828

2929
Your puzzle answer was nabgqlcw.
3030

31-
The first half of this puzzle is complete! It provides one gold star: *
32-
3331
--- Part Two ---
3432

3533
Of course, that would be the message - if you hadn't agreed to use a modified repetition code instead.
@@ -38,4 +36,8 @@ In this modified code, the sender instead transmits what looks like random data,
3836

3937
In the above example, the least common character in the first column is a; in the second, d, and so on. Repeating this process for the remaining characters produces the original message, advent.
4038

41-
Given the recording in your puzzle input and this new decoding methodology, what is the original message that Santa is trying to send?
39+
Given the recording in your puzzle input and this new decoding methodology, what is the original message that Santa is trying to send?
40+
41+
Your puzzle answer was ovtrjcjh.
42+
43+
Both parts of this puzzle are complete! They provide two gold stars: **

06/solution.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ def __init__(self, nr):
77
super().__init__(nr)
88
self.length = 1
99
self.dicts = []
10-
self.message = ""
10+
self.message1 = ""
11+
self.message2 = ""
1112

1213
def calculate(self, test=False):
1314
self.read_instructions()
@@ -28,9 +29,11 @@ def calc_message(self):
2829
for line in self.input:
2930
i = 0
3031
for char in line:
31-
if i < self.length:
32+
if char.isalpha() and i < self.length:
3233
self.dicts[i].add(char)
3334
i += 1
3435
for i in range(0, self.length):
35-
self.message += self.dicts[i].get_sorted_string_by_value_and_key(1)
36-
self.set_solution(1, self.message)
36+
self.message1 += self.dicts[i].get_sorted_string_by_value_and_key(1)
37+
self.message2 += self.dicts[i].get_sorted_string_by_value_and_key(1, True)
38+
self.set_solution(1, self.message1)
39+
self.set_solution(2, self.message2)

06/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ def test_1(self):
2525
enarar"""
2626
self.execute_test(test_input)
2727
self.assertEqual("easter", self.solution.get_solution(1))
28+
self.assertEqual("advent", self.solution.get_solution(2))

0 commit comments

Comments
 (0)