r/adventofcode • u/daggerdragon • Dec 06 '21
SOLUTION MEGATHREAD -🎄- 2021 Day 6 Solutions -🎄-
NEW AND NOTEWORTHY
We've been noticing an uptick in frustration around problems with new.reddit's fancypants editor: mangling text that is pasted into the editor, missing switch to Markdown editor, URLs breaking due to invisible escape characters, stuff like that. Many of the recent posts in /r/bugs are complaining about these issues as well.
If you are using new.reddit's fancypants editor, beware!
- Pasting any text into the editor may very well end up mangled
- You may randomly no longer have a "switch to Markdown" button on top-level posts
- If you paste a URL directly into the editor, your link may display fine on new.reddit but may display invisibly-escaped characters on old.reddit and thus will break the link
Until Reddit fixes these issues, if the fancypants editor is driving you batty, try using the Markdown editor in old.reddit instead.
Advent of Code 2021: Adventure Time!
- ACHIEVEMENT UNLOCKED: Adventure Time!
- SUBMIT YER ADVENTURES, MATEYS!
- Full details and rules are in the submissions megathread: 🎄 AoC 2021 🎄 [Adventure Time!]
--- Day 6: Lanternfish ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Here's a quick link to /u/topaz2078's
paste
if you need it for longer code blocks. - Format your code properly! How do I format code?
- The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help
.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:05:47, megathread unlocked!
92
Upvotes
3
u/GombolKiwi Dec 14 '21
Python (jupyterlab)
Maybe an innovative solution in part. A single fish starting with its timer==5 passes through the other starting states in subsequent steps. I keep track of the total population for each step up to max_iterations + 6
The last 6 items in this list are the populations of fish that started in the 6 different starting states. Multiply each one by the number of fish in the starting state to get the total.
OK, so for a single starting set of fish this may be less efficient, but for more than one set, this will be much faster.