AdventOfCode2021 - Day 6

This is a thread to discuss Day6

It is VERY important NOT to write any public spoilers :slight_smile:
ALWAYS keep spoiler stuff hidden inside one of these


This text will be hidden

which you can obtain by clicking on the gear icon

Part 1
Duration 50 secs

part 1: 255ms
part 2: 767ms

1000 days take 2.7sec with a result : 2.4427818022208776e+40 fishs (i can't verify this result by hand...)

After 3 hours of running and only up to day 170 - I am trying to refactor my approach :slight_smile:

Yeah, if you add new records at the end of each day: it's exponential.


Keep in mind: all fish of same state are acting the same way (change state, reproduce)

Try to keep the sum of fish in a same state and make operations on these 9 records)

Just asking: Could you please keep this all in one topic? It keeps appearing in my feed, and I don't participate in this, so it's kind of annoying. Thanks. :slight_smile:

Just mute each thread once each day - job done :slight_smile:

That's what I do with all yours :slight_smile: - joke - I usually don't mute yours :slight_smile:

Each puzzle is different and one long thread would be hard to use/read for us puzzlers

Remember - it is the season for goodwill to all :slight_smile:

I'm not quite at stage of needing a hint :slight_smile:

OK Sorry

here's mine

Part 1

untitled script pic (21)

time = 64265 milliseconds, or about 1.07 min

version 2

analyze block in the "Frequency Distribution Analysis" library
and the asoc block is in the list utilities library

without warp
80 day time = 1326 milliseconds, or about 1.3 secs.
256 day time = 4247 milliseconds, or about 4.2 secs

with warp
80 days = 254 milliseconds or about 0.2 secs
256 days = 911 milliseconds or about 0.9 secs

I used @cymplecy's hint to make this one much better.

sorry, removed version 1

um, when I run your solution, it takes a lot longer than 1 minuet. Were you timing it with the example data?

Can't remember - I've been changing things around all day - maybe my earlier attempt was better :slight_smile:

Finally managed Part 2 after giving up with my own approach and looking thru reddit for hints

Took 93 ms :slight_smile:

Your hint was brilliant.
But I will first try the naive, "brute force" approach.

Part1, naive with list 26 s

Part2, with loucheman hint, 25 - 60 ms. Yes 1000 times faster then Part1 for 80 days