diff options
Diffstat (limited to 'rust/minesweeper/README.md')
-rw-r--r-- | rust/minesweeper/README.md | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/rust/minesweeper/README.md b/rust/minesweeper/README.md new file mode 100644 index 0000000..efca354 --- /dev/null +++ b/rust/minesweeper/README.md | |||
@@ -0,0 +1,80 @@ | |||
1 | # Minesweeper | ||
2 | |||
3 | Welcome to Minesweeper on Exercism's Rust Track. | ||
4 | If you need help running the tests or submitting your code, check out `HELP.md`. | ||
5 | |||
6 | ## Instructions | ||
7 | |||
8 | Add the mine counts to a completed Minesweeper board. | ||
9 | |||
10 | Minesweeper is a popular game where the user has to find the mines using | ||
11 | numeric hints that indicate how many mines are directly adjacent | ||
12 | (horizontally, vertically, diagonally) to a square. | ||
13 | |||
14 | In this exercise you have to create some code that counts the number of | ||
15 | mines adjacent to a given empty square and replaces that square with the | ||
16 | count. | ||
17 | |||
18 | The board is a rectangle composed of blank space (' ') characters. A mine | ||
19 | is represented by an asterisk ('\*') character. | ||
20 | |||
21 | If a given space has no adjacent mines at all, leave that square blank. | ||
22 | |||
23 | ## Examples | ||
24 | |||
25 | For example you may receive a 5 x 4 board like this (empty spaces are | ||
26 | represented here with the '·' character for display on screen): | ||
27 | |||
28 | ``` | ||
29 | ·*·*· | ||
30 | ··*·· | ||
31 | ··*·· | ||
32 | ····· | ||
33 | ``` | ||
34 | |||
35 | And your code will transform it into this: | ||
36 | |||
37 | ``` | ||
38 | 1*3*1 | ||
39 | 13*31 | ||
40 | ·2*2· | ||
41 | ·111· | ||
42 | ``` | ||
43 | |||
44 | ## Performance Hint | ||
45 | |||
46 | All the inputs and outputs are in ASCII. Rust `String`s and `&str` are utf8, | ||
47 | so while one might expect "Hello".chars() to be simple, it actually has to | ||
48 | check each char to see if it's 1, 2, 3 or 4 `u8`s long. If we know a `&str` | ||
49 | is ASCII then we can call `.as_bytes()` and refer to the underlying data via a `&[u8]` slice. | ||
50 | Iterating over a u8 slice of ASCII is much quicker as there are no codepoints | ||
51 | involved - every ASCII char is one u8 long. | ||
52 | |||
53 | Can you complete the challenge without cloning the input? | ||
54 | |||
55 | ## Source | ||
56 | |||
57 | ### Created by | ||
58 | |||
59 | - @EduardoBautista | ||
60 | |||
61 | ### Contributed to by | ||
62 | |||
63 | - @ashleygwilliams | ||
64 | - @coriolinus | ||
65 | - @cwhakes | ||
66 | - @EduardoBautista | ||
67 | - @efx | ||
68 | - @ErikSchierboom | ||
69 | - @ffflorian | ||
70 | - @IanWhitney | ||
71 | - @kytrinyx | ||
72 | - @lutostag | ||
73 | - @mkantor | ||
74 | - @nfiles | ||
75 | - @petertseng | ||
76 | - @rofrol | ||
77 | - @stringparser | ||
78 | - @workingjubilee | ||
79 | - @xakon | ||
80 | - @ZapAnton \ No newline at end of file | ||