diff --git a/2016-python2/output/day_11.py b/2016-python2/output/day_11.py index 39ae350..249a5f2 100644 --- a/2016-python2/output/day_11.py +++ b/2016-python2/output/day_11.py @@ -142,16 +142,6 @@ def M(s, e): if __name__ == "__main__": - # use dummy data - inp = """ - The first floor contains a hydrogen-compatible microchip and a lithium-compatible microchip. - The second floor contains a hydrogen generator. - The third floor contains a lithium generator. - The fourth floor contains nothing relevant. - """.strip() - - z, _ = solve(inp) - with open("./input/11.txt", "r") as f: inp = f.read().strip() @@ -160,6 +150,5 @@ if __name__ == "__main__": a = part_1(inp) b = part_2(inp) - assert z == 11 assert a == 37 assert b == 61 diff --git a/2016-python2/output/day_16.py b/2016-python2/output/day_16.py new file mode 100644 index 0000000..3a26bcd --- /dev/null +++ b/2016-python2/output/day_16.py @@ -0,0 +1,43 @@ +from output import answer # , matrix, D, DD, ADJ, ints, mhd, mdbg, vdbg + +n = 16 +title = "Dragon Checksum" + + +@answer(1, "The checksum to the state to fill first disc is {}") +def part_1(presolved): + return presolved[0] + + +@answer(2, "The checksum to the state to fill second disc is {}") +def part_2(presolved): + return presolved[1] + + +def solve(data): + p12 = [] + for DS in [272, 35651584]: + s = [int(c) for c in data] + while len(s) < DS: + b = [abs(int(c) - 1) for c in s[::-1]] + s = s + [0] + b + s = s[:DS] + p = len(s) + while p % 2 == 0: + s = [int(a == b) for a, b in zip(s[::2], s[1::2])] + p = len(s) + p12.append("".join(map(str, s))) + return p12 + + +if __name__ == "__main__": + with open("./input/16.txt", "r") as f: + inp = f.read().strip() + + inp = solve(inp) + + a = part_1(inp) + b = part_2(inp) + + assert a == "10011010010010010" + assert b == "10101011110100011"