Advent of Code day 6 (simulating population growth) can be done with matrix multiplication on a Leslie matrix which is a transition matrix on age counts:

The Leslie matrix is a square matrix with the same number of rows and columns as the population vector has elements. The (i,j)th cell in the matrix indicates how many individuals will be in the age class i at the next time step for each individual in stage j.

Leave a comment