r/adventofcode • • Dec 12 '16

SOLUTION MEGATHREAD --- 2016 Day 12 Solutions ---

--- Day 12: Leonardo's Monorail ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/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".


MUCH ADVENT. SUCH OF. VERY CODE. SO MANDATORY. [?]

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!

8 Upvotes

159 comments sorted by

View all comments

Show parent comment

3

u/willkill07 Dec 12 '16

No temporary files created:

awk -f day12.awk day12.txt | clang -x c - -S -O3 -o - | awk '/movl.*\$[0-9]+/{print $2}'

-x c tells the compiler to process the input from stdin as a c program and the little awk command extracts the number (plus a comma)

2

u/3urny Dec 12 '16

Nice! If you pipe to awk anyways you could get rid of the surrounding $ and ,, too:

awk -f day12.awk day12.txt | clang -x c - -S -O3 -o - | awk -F'\\$|,' '/movl.*\$([0-9]+)/{print $2}'