From 5bde897f48cbb6c9cf0c18abf8e9b29ad286d826 Mon Sep 17 00:00:00 2001 From: Dece Date: Mon, 16 Dec 2019 07:54:07 +0100 Subject: [PATCH] Day 16 part 2 (WIP) --- 2019/day16.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/2019/day16.py b/2019/day16.py index 80e0689..5537a5c 100644 --- a/2019/day16.py +++ b/2019/day16.py @@ -4,7 +4,19 @@ import math def main(): with open("day16.txt", "rt") as input_file: inputs = [int(i) for i in input_file.read().rstrip()] + inputs_orig = inputs.copy() + # result = phaze2phaze(inputs) + # print(f"First 8 digits: {''.join(str(int(i)) for i in result[:8])}") + + # Part 2 + offset = int(''.join(str(i) for i in inputs[:7])) + inputs = [i for _ in range(10000) for i in inputs_orig] + result = phaze2phaze(inputs) + print(f"8 digits at offset: {''.join(str(int(i)) for i in result[offset:offset + 8])}") + + +def phaze2phaze(inputs): p = [0, 1, 0, -1] for phase_id in range(100): phase_id += 1 @@ -19,7 +31,7 @@ def main(): out = sum(a * b for a, b in zip(inputs, ex_p)) outputs[index] = abs(math.fmod(out, 10)) inputs = outputs - print(f"First 8 digits: {''.join(str(int(i)) for i in inputs[:8])}") + return inputs if __name__ == "__main__":