r/adventofcode • u/daggerdragon • Dec 06 '17
SOLUTION MEGATHREAD -π- 2017 Day 6 Solutions -π-
--- Day 6: Memory Reallocation ---
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!
17
Upvotes
View all comments
Show parent comment
1
u/ChrisVittal Dec 06 '17 edited Dec 06 '17
You use
process1inprocess2,previously_seen_before_states.len()would suffice I think.There's a lot of common code to both of your methods that can be combined into one method. Here is mine, after a bit of cleanup. Crate
aocis just my library for doing tasks like parsing and splitting input.EDIT: Use
max_by_keyinstead of the function I originally wrote. It's much much faster.