From d2422f033337a1c1ee60ea7f6fc4d56fd534d65d Mon Sep 17 00:00:00 2001 From: Michele Sessa Date: Thu, 21 Sep 2023 15:39:07 +0100 Subject: [PATCH] feat(minesweeper): new optional exercise for rust piscine --- subjects/minesweeper/README.md | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 subjects/minesweeper/README.md diff --git a/subjects/minesweeper/README.md b/subjects/minesweeper/README.md new file mode 100644 index 00000000..2e306496 --- /dev/null +++ b/subjects/minesweeper/README.md @@ -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 { +} +``` + +### 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*", +] +$ +```