꽃밭

꽃밭

정원에 있는 꽃을 모두 표시해요.
꽃밭 깊이 파고들기!

중첩된 `for`문, 경계 검사를 단순하게 만드는 min/max의 영리한 활용, 함수형 파이프라인, 그리고 2차원 행렬 사용법을 살펴봐요.

지시 사항

Flower Field is a compassionate reimagining of the popular game Minesweeper. The object of the game is to find all the flowers in the garden using numeric hints that indicate how many flowers are directly adjacent (horizontally, vertically, diagonally) to a square. "Flower Field" shipped in regional versions of Microsoft Windows in Italy, Germany, South Korea, Japan and Taiwan.

Your task is to add flower counts to empty squares in a completed Flower Field garden. The garden itself is a rectangle board composed of squares that are either empty (' ') or a flower ('*').

For each empty square, count the number of flowers adjacent to it (horizontally, vertically, diagonally). If the empty square has no adjacent flowers, leave it empty. Otherwise replace it with the count of adjacent flowers.

For example, you may receive a 5 x 4 board like this (empty spaces are represented here with the '·' character for display on screen):

·*·*·
··*··
··*··
·····

Which your code should transform into this:

1*3*1
13*31
·2*2·
·111·