The Random Domino Automaton is a toy model for earthquakes, inspired by cellular automata. In this challenge, your task is to simulate a simplified version of this model, and collect data out of it.
The automaton is defined on an array
k bits, representing a fault line on which earthquakes may occur.
The array wraps around at its borders.
A[i] = 0 means that position
i is relaxed, and
A[i] = 1 means that it's excited, or contains stored energy.
At each time step, one position of the array is chosen uniformly at random.
If that position is relaxed, it becomes excited (potential energy is added to the system).
If that position is already excited, it triggers an earthquake, and the chosen position and all excited positions connected to it are relaxed again.
The number of excited positions that become relaxed is the magnitude of the earthquake.
Consider the array
of length 12. If the random process chooses the second bit from the left, the array is updated to
since the chosen bit (marked with
If we next choose the fourth bit from the left, which is an isolated
1, an eartquake of magnitude 1 is triggered, and the bit is set to
Next, we might choose the second bit from the right, which triggers an earthquake of magnitude 5:
Note that all
1s in the same "cluster" as the chosen one were part of the quake, and the array wraps around at the border.
You shall take as inputs two positive integers
t, and your task is to simulate the random domino automaton for
t time steps, starting from an initial length-
k array of all
Your output shall be a list
k integers, where
L[i] (with 1-based indexing) contains the number of earthquakes of magnitude
i that occurred during the simulation.
You are allowed to drop trailing zeroes from the output.
For the inputs
k = 15 and
t = 1000, some representative outputs are
[117, 97, 45, 26, 10, 5, 3, 1, 3, 0, 0, 0, 0, 0, 0] [135, 91, 58, 21, 8, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0] [142, 63, 51, 31, 17, 4, 2, 1, 1, 0, 0, 0, 0, 0, 0] [106, 75, 45, 30, 16, 8, 5, 2, 2, 0, 0, 0, 0, 0, 0] [111, 96, 61, 22, 3, 8, 3, 2, 0, 0, 0, 1, 0, 0, 0]
Both full programs and functions are allowed. The shortest byte count wins, and standard loopholes are disallowed.
Note that you are not required to simulate the automaton using any particular implementation, only the output matters.