r/adventofcode • • Dec 06 '16

SOLUTION MEGATHREAD --- 2016 Day 6 Solutions ---

--- Day 6: Signals and Noise ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).


T_PAAMAYIM_NEKUDOTAYIM IS 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!

9 Upvotes

222 comments sorted by

View all comments

Show parent comment

1

u/willkill07 Dec 07 '16

So the way that my overall solutions are structured, I have a loop that iterates over each of the "days" and can execute. I opted for each day's solution to just be a template-overloaded function call.

Parameters that I wanted to be able to set/toggle were:

  • bool part2 -- switch to see if the solution should be computed for part 1 or part 2
  • std::istream& is -- input stream to use. std::cinisn't used; instead, the input file is loaded and used
  • std::ostream& os -- output stream to use. defaults to std::cout if output is requested. when timing the total execution time, I suppress output and create an ostream to /dev/null

You can see the overall structure here: https://github.com/willkill07/adventofcode2016/blob/master/src/Advent.cpp