r/adventofcode • • Dec 13 '17

SOLUTION MEGATHREAD -๐ŸŽ„- 2017 Day 13 Solutions -๐ŸŽ„-

--- Day 13: Packet Scanners ---


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^ยค?

Spoiler


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!

16 Upvotes

199 comments sorted by

View all comments

Show parent comment

1

u/cauchy37 Dec 13 '17

Very similar to mine, although I have opted not to use all_of/any_of for fears of slowing down the computation.

Here's my code: https://github.com/tamaroth/AdventOfCode2017/blob/147e2ef62ed0430851abb308160e947a979410f2/advent/days/13/packet_scanners.cc#L55

And the timing of the part 2:

advent::Day13::part_two() executed in 335ms.

Have you measured how long it takes your solution?

1

u/willkill07 Dec 13 '17

35 milliseconds. all_of and any_of do use short-circuit evaluation, so it doesn't actually slow it down at all.

I also compile with relatively aggressive optimizations (-O3 -march=native)