I'm learning a lot from the solutions people are posting on this forum. Even
when I follow the same general strategy as others do (e.g., encoding as
frequencies), I still learn from the different tactics that they employ (e.g.,
appending all the cases, counting with key, and then decrementing).
My take on Day 6 was similar to Raul's second part's solution. I did it
tacitly though:
I realised no fish would ever have an age >8, so I kept the number of
fishes for each age in an array, i.e. n{state is the number of fishes at
age n (see enc below).
Then each step rotates the fishes and adds ne
Yes, a nice insight, I suppose, but only nice, and by no means
necessary!
Many Project Euler problems require this sort of thing in the tool-box!
Also, some sort of counting of cases is often nearly essential for PE.
One of my finite arithmetic routines, written pre-{{ ... }}
NB. Matrix x t
That's a really good insight.
Conceptually, this would be
1 (<0 6)}(=/1|.])i.9
0 0 0 0 0 0 1 0 1
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
But we want to multiply on the right (for ^:) instead
Yes, a 9x9 Boolean matrix with an offset 1s diagonal and an extra 1. It might
have been worth using the high-power squaring technique, if the power were
really large, but for 256 I just took the direct 256th power.
Cheers,
Mike
Sent from my iPad
> On 27 Dec 2021, at 06:17, Raul Miller wro
https://adventofcode.com/2021/day/6
For day 6, we had a list of numbers which represented a school of fish.
sample=: 3,4,3,1,2
Because this was just a comma separated list of digits, no special
parsing routines were necessary.
The task was conceptually to generate a step function which would
de