Prokaryote Growths (2)

A petri dish is represented as a grid of size N×MN\times{M}, where:

At each growth cycle, any bacteria spreads to its neighbouring positions in diagonal (up-left, up-right, down-left, down-right). Newborn bacteria are represented in lowercase (’b’)

Write a function growth_cycle(grid) that, given an N×MN\times{M} matrix representing the initial state of the colony, returns the state of the petri dish after one growth cycle.

EXAMPLES

Example 1
Inital state       After 1 cycle (new cells in lowercase)
. . . . . B . . . b . b B .
. . . B . . . . b . B b . b
B . . . . . . B . b . b . b
. . . . . B . . b . . . B .
. . . . . . . . . . . b . b

 

Example 2
Inital state       After 1 cycle (new cells in lowercase)
. . . . . . . . . . b . b . . .
. . . B . . . . . . . B . b . .
. . . . B . . . . b b . B . . .
B . . . . . . . B . . b . b . .

 

Example 3
Inital state       After 1 cycle (new cells in lowercase)
. . . . . . b . b . b .
. B . B . . . B . B . .
B . . . . . B . b . b .
. . . . . B . b . . . B
. . . . . B . . . . b B
. . . . . . . . . . b .

Observation

Important: Submit only the function. If you have a main program, comment it out or embed it inside a conditional clause if __name__ == "__main__":

Problem information

Author: Lluís Padró

Generation: 2026-07-03T11:14:46.720Z

© Jutge.org, 2006–2026.
https://jutge.org