aboutsummaryrefslogtreecommitdiff
path: root/rust/bowling/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'rust/bowling/README.md')
-rw-r--r--rust/bowling/README.md141
1 files changed, 141 insertions, 0 deletions
diff --git a/rust/bowling/README.md b/rust/bowling/README.md
new file mode 100644
index 0000000..6c08b38
--- /dev/null
+++ b/rust/bowling/README.md
@@ -0,0 +1,141 @@
1# Bowling
2
3Score a bowling game.
4
5Bowling is a game where players roll a heavy ball to knock down pins
6arranged in a triangle. Write code to keep track of the score
7of a game of bowling.
8
9## Scoring Bowling
10
11The game consists of 10 frames. A frame is composed of one or two ball
12throws with 10 pins standing at frame initialization. There are three
13cases for the tabulation of a frame.
14
15* An open frame is where a score of less than 10 is recorded for the
16 frame. In this case the score for the frame is the number of pins
17 knocked down.
18
19* A spare is where all ten pins are knocked down by the second
20 throw. The total value of a spare is 10 plus the number of pins
21 knocked down in their next throw.
22
23* A strike is where all ten pins are knocked down by the first
24 throw. The total value of a strike is 10 plus the number of pins
25 knocked down in the next two throws. If a strike is immediately
26 followed by a second strike, then the value of the first strike
27 cannot be determined until the ball is thrown one more time.
28
29Here is a three frame example:
30
31| Frame 1 | Frame 2 | Frame 3 |
32| :-------------: |:-------------:| :---------------------:|
33| X (strike) | 5/ (spare) | 9 0 (open frame) |
34
35Frame 1 is (10 + 5 + 5) = 20
36
37Frame 2 is (5 + 5 + 9) = 19
38
39Frame 3 is (9 + 0) = 9
40
41This means the current running total is 48.
42
43The tenth frame in the game is a special case. If someone throws a
44strike or a spare then they get a fill ball. Fill balls exist to
45calculate the total of the 10th frame. Scoring a strike or spare on
46the fill ball does not give the player more fill balls. The total
47value of the 10th frame is the total number of pins knocked down.
48
49For a tenth frame of X1/ (strike and a spare), the total value is 20.
50
51For a tenth frame of XXX (three strikes), the total value is 30.
52
53## Requirements
54
55Write code to keep track of the score of a game of bowling. It should
56support two operations:
57
58* `roll(pins : int)` is called each time the player rolls a ball. The
59 argument is the number of pins knocked down.
60* `score() : int` is called only at the very end of the game. It
61 returns the total score for that game.
62
63## Rust Installation
64
65Refer to the [exercism help page][help-page] for Rust installation and learning
66resources.
67
68## Writing the Code
69
70Execute the tests with:
71
72```bash
73$ cargo test
74```
75
76All but the first test have been ignored. After you get the first test to
77pass, open the tests source file which is located in the `tests` directory
78and remove the `#[ignore]` flag from the next test and get the tests to pass
79again. Each separate test is a function with `#[test]` flag above it.
80Continue, until you pass every test.
81
82If you wish to run all ignored tests without editing the tests source file, use:
83
84```bash
85$ cargo test -- --ignored
86```
87
88To run a specific test, for example `some_test`, you can use:
89
90```bash
91$ cargo test some_test
92```
93
94If the specific test is ignored use:
95
96```bash
97$ cargo test some_test -- --ignored
98```
99
100To learn more about Rust tests refer to the [online test documentation][rust-tests]
101
102Make sure to read the [Modules][modules] chapter if you
103haven't already, it will help you with organizing your files.
104
105## Further improvements
106
107After you have solved the exercise, please consider using the additional utilities, described in the [installation guide](https://exercism.io/tracks/rust/installation), to further refine your final solution.
108
109To format your solution, inside the solution directory use
110
111```bash
112cargo fmt
113```
114
115To see, if your solution contains some common ineffective use cases, inside the solution directory use
116
117```bash
118cargo clippy --all-targets
119```
120
121## Submitting the solution
122
123Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer.
124
125## Feedback, Issues, Pull Requests
126
127The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
128
129If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
130
131[help-page]: https://exercism.io/tracks/rust/learning
132[modules]: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
133[cargo]: https://doc.rust-lang.org/book/ch14-00-more-about-cargo.html
134[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html
135
136## Source
137
138The Bowling Game Kata at but UncleBob [http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata](http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata)
139
140## Submitting Incomplete Solutions
141It's possible to submit an incomplete solution so you can see how others have completed the exercise.