Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 with open('files/puzzle10.txt') as f:
- 2 blep = f.read()
- 3 puzzle_input = [int(c) for c in blep.split(',')]
- 4 puzzle_ascii = [ord(c) for c in blep[:len(blep) - 1]]
- 5 puzzle_ascii.extend([17, 31, 73, 47, 23])
- 6
- 7 def round(this_input, this_list, skip, pos):
- 8 for length in this_input:
- 9 twist = reversed([this_list[i % len(this_list)] for i in range(pos[0], pos[0] + length)])
- 10 for i, t in zip(range(pos[0], pos[0] + length), twist):
- 11 this_list[i % len(this_list)] = t
- 12 pos[0] += length + skip[0]
- 13 skip[0] += 1
- 14
- 15 my_list = [i for i in range(256)]
- 16 round(puzzle_input, my_list, [0], [0])
- 17 print my_list[0] * my_list[1]
- 18
- 19 my_list = [i for i in range(256)]
- 20 skip, pos = [0], [0]
- 21
- 22 for i in range(64):
- 23 round(puzzle_ascii, my_list, skip, pos)
- 24
- 25 knot_hash = []
- 26
- 27 for block in [my_list[i:i + 16] for i in range(0, len(my_list), 16)]:
- 28 knot_hash.append(chr(reduce(lambda x, y: x ^ y, block)))
- 29
- 30 print "".join(knot_hash).encode("hex")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement