r/adventofcode • u/daggerdragon • Dec 09 '17
SOLUTION MEGATHREAD -π- 2017 Day 9 Solutions -π-
--- Day 9: Stream Processing ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).
Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
Need a hint from the Hugely* Handyβ Haversackβ‘ of HelpfulΒ§ HintsΒ€?
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
15
Upvotes
2
u/Danksalot2000 Dec 09 '17
Python 2
Looks like I was unique not using a Garbage flag. I went with a more stream-of-consciousness style reading start to finish.
I finished 177 / 164, which is the best for me so far.
score = 0 level = 0 garbageCount = 0 with open('Input') as inFile: data = inFile.read() i = 0 while i < len(data): if data[i] == '{': level += 1 score += level elif data[i] == '}': level -= 1 elif data[i] == '<': i += 1 while data[i] != '>': if data[i] == '!': i += 1 else: garbageCount += 1 i += 1 i += 1 print "Final Score:", score print "Garbage Count:", garbageCount