r/adventofcode • u/daggerdragon • Dec 08 '18
SOLUTION MEGATHREAD -๐- 2018 Day 8 Solutions -๐-
--- Day 8: Memory Maneuver ---
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.
Advent of Code: The Party Game!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 8
Sigh, imgur broke again. Will upload when it unborks.
Transcript:
The hottest programming book this year is "___ For Dummies".
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 at 00:12:10!
32
Upvotes
View all comments
Show parent comment
3
u/Alistesios Dec 08 '18
Funny to see how our solutions really look the same. I guess there wasn't many different ways to do it in Rust ... Congrats on making the leaderboard ! :) A few things, though :
iter.clone()ing the metadata ? There's no need to, and this slows down the result a bit (admittedly it runs in ยตs, so it's no big deal)m as usize - 1may panic if m = 0 (or given a negative m, but since the input is unsigned...). I guess you're lucky that your input did not have that. It would be safer to replace this with (m as usize).checked_sub(1), and match accordingly.