This exercise is a continuation of the exercise problem://problemsjutge.org:problems/p1/roura/vida-1.pbm
Let be a matrix with bacteria at the initial time, and let , , , … be the matrices at the times 1, 2, 3, … Write a program that, given , finds the cycle that is obtained starting at , that is, the first and shortest sequence of matrices such that . Suppose .
Input consists of the description of the matrix
:
two strictly positive natural numbers
and
,
followed by
lines, each one with
characters: ‘B’ if the position has a bacterium, and
‘.’ if the position is empty.
Print the matrices of the cycle separated by an empty line.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T10:41:53.332Z
© Jutge.org, 2006–2026.
https://jutge.org