Solution to problem 6 in Python
This commit is contained in:
parent
2b40cdd77a
commit
06e45ad41b
@ -52,5 +52,34 @@ def part_1() -> None:
|
||||
print(f"The message is {message}")
|
||||
|
||||
|
||||
# --- Part Two ---
|
||||
|
||||
# Of course, that would be the message - if you hadn't agreed to use a modified
|
||||
# repetition code instead.
|
||||
|
||||
# In this modified code, the sender instead transmits what looks like random
|
||||
# data, but for each character, the character they actually want to send is
|
||||
# slightly less likely than the others. Even after signal-jamming noise, you
|
||||
# can look at the letter distributions in each column and choose the least
|
||||
# common letter to reconstruct the original message.
|
||||
|
||||
# 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.
|
||||
|
||||
# Given the recording in your puzzle input and this new decoding methodology,
|
||||
# what is the original message that Santa is trying to send?
|
||||
|
||||
|
||||
def part_2() -> None:
|
||||
_message = []
|
||||
for column in signals_transp:
|
||||
_message.append(Counter(column).most_common()[-1])
|
||||
|
||||
message = "".join((char[0][0]) for char in _message)
|
||||
print(f"The message is {message}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
part_1()
|
||||
part_2()
|
||||
|
Loading…
Reference in New Issue
Block a user