• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 7. Two -dimensional arrays

Difficulty level:

Task«Search for an element in the matrix»

you & ndash; Biologist studying the behavior of cell colonies. You have a square mesh, which is a cell habitat. Each cage in this grid can be alive or dead. At each step of time, the condition of the cell changes depending on the state of its neighbors.
rn
rn
    rn
  1. rn
  2. a living cage with two or three living neighbors remains alive.
  3. rn
  4. a living cage with more than three living neighbors dies (from overpopulation).
  5. rn
  6. The dead cell comes to life with three living neighbors.
  7. rn rn
rn
with neighborhoods Cells are eight cells surrounding it (from below, left, right, right and diagonally).
rn
write a program that takes a program that takes The initial state of the grid and the number of steps of time that must be simulated. The program must derive the condition of the grid after the specified number of steps.

Input format

The whole number of n & nbsp; & ndash; The size of the grid (number of lines and columns).
rn
in the following n & nbsp; the rows are introduced the initial state of the grid. Each line contains & nbsp; n & nbsp; symbols where & nbsp; . & nbsp; denotes a dead cage, and & nbsp; * & nbsp; denotes lively cell.
rn
in the last line the integer stps & ndash; The number of simulation steps

Output format

get & nbsp; n & nbsp; lines, which are a state of mesh After & nbsp; stps & nbsp; steps. Each line must contain & nbsp; n & nbsp; symbols (.

Example

Input

3
.*.
*..
...
1

Output

...
...
...

Hint

There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!