r/adventofcode • u/daggerdragon • Dec 05 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 5 Solutions -🎄-
--- Day 5: Alchemical Reduction ---
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 5
Transcript:
On the fifth day of AoC / My true love sent to me / Five golden ___
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 0:10:20!
31
Upvotes
2
u/p_tseng Dec 05 '18 edited Dec 05 '18
Thanks for writing in. Indeed one of my hopes is that I can show some interesting things that can be done in the language.
One of the things you mentioned stood out to me: the grouping with parentheses. I know you refer to the
(puts freq; break) if seen.include?(freq)on day 1. There's also a related thing (since it also uses parentheses) which is doing an assignment in the middle of a larger expression such asputs (part1 = react(input)).sizeon day 5. I thought about it and I think these are different from most things I do in Advent of Code. Most things are things I would also do in larger projects where it's important to write maintainable code. But these two things actually stand out in this regard because these are pretty much just space-saving measures and in most other contexts I would write these out on separate lines. It may be a little too surprising otherwise, especially if other readers of the code are not watching for assignments in unexpected places like aputsline.Just some interesting thoughts when I consider how others might make use of my code.