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.

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