My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add solution for 2019/25

+64
+64
2019/day25.py
··· 1 + import sys 2 + import fileinput 3 + from collections import deque 4 + from itertools import combinations 5 + 6 + from intcode import emulate 7 + 8 + TAS = """\ 9 + south 10 + take space law space brochure 11 + south 12 + 13 + take mouse 14 + west 15 + north 16 + north 17 + take wreath 18 + south 19 + south 20 + east 21 + 22 + south 23 + take astrolabe 24 + south 25 + take mug 26 + north 27 + north 28 + 29 + north 30 + west 31 + take sand 32 + north 33 + take manifold 34 + south 35 + west 36 + take monolith 37 + west 38 + """ 39 + 40 + items = ['space law space brochure', 'mouse', 'sand', 'wreath', 'manifold', 'astrolabe', 'mug', 'monolith'] 41 + 42 + for i in range(1, len(items) + 1): 43 + for comb in combinations(items, i): 44 + for item in items: 45 + TAS += "drop {}\n".format(item) 46 + 47 + for c in comb: 48 + TAS += "take {}\n".format(c) 49 + 50 + TAS += 'west\n' 51 + 52 + 53 + TAPE = [int(x) for x in fileinput.input()[0].split(',')] 54 + TAPE += [0] * 10000 55 + inputs = deque(reversed([ord(c) for c in TAS])) 56 + 57 + vm = emulate(TAPE, inputs) 58 + try: 59 + while True: 60 + resp = chr(next(vm)) 61 + sys.stdout.write(resp) 62 + 63 + except Exception as e: 64 + pass