Ναρκαλιευτής

Ναρκαλιευτής

Πρόσθεσε τους αριθμούς σε ένα ταμπλό ναρκαλιευτή.
Εμβάθυνση στην άσκηση Ναρκαλιευτής!

Εξερευνούμε τους εμφωλευμένους βρόχους `for`, την έξυπνη χρήση των min/max για την απλοποίηση του ελέγχου ορίων, τα functional pipelines και τη χρήση δισδιάστατων πινάκων.

Οδηγίες

Minesweeper is a popular game where the user has to find the mines using numeric hints that indicate how many mines are directly adjacent (horizontally, vertically, diagonally) to a square.

Your task is to add the mine counts to empty squares in a completed Minesweeper board. The board itself is a rectangle composed of squares that are either empty (' ') or a mine ('*').

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

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·
Δοκίμασε την άσκηση Ναρκαλιευτής σε 6 διαφορετικές γλώσσες…

Δεν την έχεις ολοκληρώσει ακόμη σε καμία γλώσσα.

Delphi Pascal
Perl
Pharo
Unison
WebAssembly
YAMLScript