r/adventofcode • u/daggerdragon • Dec 18 '16
SOLUTION MEGATHREAD --- 2016 Day 18 Solutions ---
--- Day 18: Like a Rogue ---
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".
EATING YELLOW SNOW IS DEFINITELY NOT 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!
7
Upvotes
View all comments
Show parent comment
1
u/flup12 Dec 18 '16 edited Dec 18 '16
I just ran 4 million rows using Stream.iterate in a JVM with max memory 128 MB so I think your measuring is off. The elements of the stream, memoized or not, are no longer referenced and can be safely collected once they've been added to the sum, which happens before their children get generated. So I don't think there's a big difference between Iterator.iterate and Stream.iterate here. Except that Iterator.iterate probably wouldn't have caused this discussion so is definitely clearer :)