Back
Close

Minesweeper

Statement

 Goal

Find the hidden mines in the grid, knowing that :
. means no danger in any of the 8 spaces around that spot.
n means there are exactly n mines hidden in the 8 spaces around that spot.
? means we don't know anything about that spot.
Input
Line 1 : The size of the grid, h : height & w : width .
Line 2 : The number of hidden mines, nb.
h following lines : Content of the grid made of ., ? and n.
Output
nb lines including mine's location : col & lin separated by a space.
In column ascending order, then in line ascending order for the same column.
Constraints
3 ≤ h, w ≤ 20
1 ≤ nb ≤ 20
Example
Input
6 6
4
.1???1
.11211
11....
?2....
?2....
11....
Output
0 3
0 4
2 0
4 0

Tags
ConditionsLoops2D array

Difficulty
Medium

Test cases
Example Test
Input
6 6 4 .1???1 .11211 11.... ?2.... ?2.... 11....
Output
0 3 0 4 2 0 4 0

Validator 1 Validator
Input
7 7 5 .1???1. .12321. 11..... ?1..... ?2..... ?1..... 11.....
Output
0 3 0 5 2 0 3 0 4 0

Hidden mines Test
Input
5 5 6 ..... ..122 ..2?? ..3?? ..2??
Output
3 2 3 3 3 4 4 2 4 3 4 4

Validator 2 Validator
Input
6 6 9 ???2.. ???3.. ???2.. 2321.. ...... ......
Output
0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2

One line Test
Input
3 17 9 ................. 11112211232222211 ?????????????????
Output
1 2 4 2 5 2 8 2 9 2 10 2 12 2 13 2 15 2

Validator 3 Validator
Input
3 18 11 .................. 221123221222222211 ??????????????????
Output
0 2 1 2 4 2 5 2 6 2 8 2 10 2 11 2 13 2 14 2 16 2

Two blocks Test
Input
5 5 3 ??1.. ??1.. 11222 ..1?? ..1??
Output
1 1 3 3 4 3

Validator 4 Validator
Input
6 6 11 ??2... ??3... ??3.11 ??2.1? 22213? ..1???
Output
0 0 0 1 0 2 0 3 1 0 1 1 1 2 1 3 3 5 5 3 5 5

Final test Test
Input
9 9 12 ?1....1?? ?2....12? ?1.....11 11....... 12221..11 ????2112? ????21??? ????32??? ????2????
Output
0 0 0 2 0 5 2 5 3 5 3 6 3 8 5 8 6 6 7 0 8 1 8 5

Validator 5 Validator
Input
10 10 17 ????1????? ???211???? ?211.12??? 11....123? ........11 .......11? ....1123?? 11123????? ?43??????? ??????????
Output
0 2 0 8 0 9 1 9 2 1 2 9 3 0 3 8 4 8 5 7 6 1 7 2 7 7 8 2 8 6 8 7 9 3

Solution language

Solution

Stub generator input