aboutsummaryrefslogtreecommitdiff
path: root/rust/minesweeper/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'rust/minesweeper/README.md')
-rw-r--r--rust/minesweeper/README.md80
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
3Welcome to Minesweeper on Exercism's Rust Track.
4If you need help running the tests or submitting your code, check out `HELP.md`.
5
6## Instructions
7
8Add the mine counts to a completed Minesweeper board.
9
10Minesweeper is a popular game where the user has to find the mines using
11numeric hints that indicate how many mines are directly adjacent
12(horizontally, vertically, diagonally) to a square.
13
14In this exercise you have to create some code that counts the number of
15mines adjacent to a given empty square and replaces that square with the
16count.
17
18The board is a rectangle composed of blank space (' ') characters. A mine
19is represented by an asterisk ('\*') character.
20
21If a given space has no adjacent mines at all, leave that square blank.
22
23## Examples
24
25For example you may receive a 5 x 4 board like this (empty spaces are
26represented here with the '·' character for display on screen):
27
28```
29·*·*·
30··*··
31··*··
32·····
33```
34
35And your code will transform it into this:
36
37```
381*3*1
3913*31
40·2*2·
41·111·
42```
43
44## Performance Hint
45
46All the inputs and outputs are in ASCII. Rust `String`s and `&str` are utf8,
47so while one might expect "Hello".chars() to be simple, it actually has to
48check each char to see if it's 1, 2, 3 or 4 `u8`s long. If we know a `&str`
49is ASCII then we can call `.as_bytes()` and refer to the underlying data via a `&[u8]` slice.
50Iterating over a u8 slice of ASCII is much quicker as there are no codepoints
51involved - every ASCII char is one u8 long.
52
53Can 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