feat(minesweeper): new optional exercise for rust piscine

This commit is contained in:
Michele Sessa 2023-09-21 15:39:07 +01:00 committed by Michele
parent ea1af07d68
commit d2422f0333
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
## minesweeper
Create a function that takes a minesweeper board as an array of strings and return the board solved.
Minesweeper is a very old game where some mines are placed in a board and you should calculate how many mines are touching every free field and write the count in the respective place.
> We will only test your function with empty and valid boards.
### Instructions
### Expected Function
```rust
pub fn solve_board(minefield: &[&str]) -> Vec<String> {
}
```
### Usage
Here is a possible program to test your function,
```rust
fn main() {
println!("{:?}", solve_board(&[]));
println!("{:?}", solve_board(&[""]));
println!("{:?}", solve_board(&["***"]));
println!("{:#?}", solve_board(&[" ", " * ", " ",]));
println!("{:#?}", solve_board(&["* ", " ", " *",]));
}
```
And its output:
```console
$ cargo run
[]
[""]
["***"]
[
"111",
"1*1",
"111",
]
[
"*1 ",
"121",
" 1*",
]
$
```