Skip to content

Commit

Permalink
Update exercise docs and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras authored and loziniak committed Dec 1, 2023
1 parent a9a74c4 commit 93ab7b6
Show file tree
Hide file tree
Showing 37 changed files with 307 additions and 221 deletions.
57 changes: 26 additions & 31 deletions exercises/practice/bowling/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,30 @@

Score a bowling game.

Bowling is a game where players roll a heavy ball to knock down pins
arranged in a triangle. Write code to keep track of the score
of a game of bowling.
Bowling is a game where players roll a heavy ball to knock down pins arranged in a triangle.
Write code to keep track of the score of a game of bowling.

## Scoring Bowling

The game consists of 10 frames. A frame is composed of one or two ball
throws with 10 pins standing at frame initialization. There are three
cases for the tabulation of a frame.
The game consists of 10 frames.
A frame is composed of one or two ball throws with 10 pins standing at frame initialization.
There are three cases for the tabulation of a frame.

* An open frame is where a score of less than 10 is recorded for the
frame. In this case the score for the frame is the number of pins
knocked down.
- An open frame is where a score of less than 10 is recorded for the frame.
In this case the score for the frame is the number of pins knocked down.

* A spare is where all ten pins are knocked down by the second
throw. The total value of a spare is 10 plus the number of pins
knocked down in their next throw.
- A spare is where all ten pins are knocked down by the second throw.
The total value of a spare is 10 plus the number of pins knocked down in their next throw.

* A strike is where all ten pins are knocked down by the first
throw. The total value of a strike is 10 plus the number of pins
knocked down in the next two throws. If a strike is immediately
followed by a second strike, then the value of the first strike
cannot be determined until the ball is thrown one more time.
- A strike is where all ten pins are knocked down by the first throw.
The total value of a strike is 10 plus the number of pins knocked down in the next two throws.
If a strike is immediately followed by a second strike, then the value of the first strike cannot be determined until the ball is thrown one more time.

Here is a three frame example:

| Frame 1 | Frame 2 | Frame 3 |
| :-------------: |:-------------:| :---------------------:|
| X (strike) | 5/ (spare) | 9 0 (open frame) |
| Frame 1 | Frame 2 | Frame 3 |
| :--------: | :--------: | :--------------: |
| X (strike) | 5/ (spare) | 9 0 (open frame) |

Frame 1 is (10 + 5 + 5) = 20

Expand All @@ -40,22 +35,22 @@ Frame 3 is (9 + 0) = 9

This means the current running total is 48.

The tenth frame in the game is a special case. If someone throws a
strike or a spare then they get a fill ball. Fill balls exist to
calculate the total of the 10th frame. Scoring a strike or spare on
the fill ball does not give the player more fill balls. The total
value of the 10th frame is the total number of pins knocked down.
The tenth frame in the game is a special case.
If someone throws a spare or a strike then they get one or two fill balls respectively.
Fill balls exist to calculate the total of the 10th frame.
Scoring a strike or spare on the fill ball does not give the player more fill balls.
The total value of the 10th frame is the total number of pins knocked down.

For a tenth frame of X1/ (strike and a spare), the total value is 20.

For a tenth frame of XXX (three strikes), the total value is 30.

## Requirements

Write code to keep track of the score of a game of bowling. It should
support two operations:
Write code to keep track of the score of a game of bowling.
It should support two operations:

* `roll(pins : int)` is called each time the player rolls a ball. The
argument is the number of pins knocked down.
* `score() : int` is called only at the very end of the game. It
returns the total score for that game.
- `roll(pins : int)` is called each time the player rolls a ball.
The argument is the number of pins knocked down.
- `score() : int` is called only at the very end of the game.
It returns the total score for that game.
4 changes: 3 additions & 1 deletion exercises/practice/bowling/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
".meta/example.red"
]
},
"blurb": "Score a bowling game."
"blurb": "Score a bowling game.",
"source": "The Bowling Game Kata from UncleBob",
"source_url": "https://web.archive.org/web/20221001111000/http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata"
}
101 changes: 54 additions & 47 deletions exercises/practice/circular-buffer/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,58 @@
# Instructions

A circular buffer, cyclic buffer or ring buffer is a data structure that
uses a single, fixed-size buffer as if it were connected end-to-end.

A circular buffer first starts empty and of some predefined length. For
example, this is a 7-element buffer:
<!-- prettier-ignore -->
[ ][ ][ ][ ][ ][ ][ ]

Assume that a 1 is written into the middle of the buffer (exact starting
location does not matter in a circular buffer):
<!-- prettier-ignore -->
[ ][ ][ ][1][ ][ ][ ]

Then assume that two more elements are added — 2 & 3 — which get
appended after the 1:
<!-- prettier-ignore -->
[ ][ ][ ][1][2][3][ ]

If two elements are then removed from the buffer, the oldest values
inside the buffer are removed. The two elements removed, in this case,
are 1 & 2, leaving the buffer with just a 3:
<!-- prettier-ignore -->
[ ][ ][ ][ ][ ][3][ ]
A circular buffer, cyclic buffer or ring buffer is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end.

A circular buffer first starts empty and of some predefined length.
For example, this is a 7-element buffer:

```text
[ ][ ][ ][ ][ ][ ][ ]
```

Assume that a 1 is written into the middle of the buffer (exact starting location does not matter in a circular buffer):

```text
[ ][ ][ ][1][ ][ ][ ]
```

Then assume that two more elements are added — 2 & 3 — which get appended after the 1:

```text
[ ][ ][ ][1][2][3][ ]
```

If two elements are then removed from the buffer, the oldest values inside the buffer are removed.
The two elements removed, in this case, are 1 & 2, leaving the buffer with just a 3:

```text
[ ][ ][ ][ ][ ][3][ ]
```

If the buffer has 7 elements then it is completely full:
<!-- prettier-ignore -->
[5][6][7][8][9][3][4]

When the buffer is full an error will be raised, alerting the client
that further writes are blocked until a slot becomes free.

When the buffer is full, the client can opt to overwrite the oldest
data with a forced write. In this case, two more elements — A & B —
are added and they overwrite the 3 & 4:
<!-- prettier-ignore -->
[5][6][7][8][9][A][B]

3 & 4 have been replaced by A & B making 5 now the oldest data in the
buffer. Finally, if two elements are removed then what would be
returned is 5 & 6 yielding the buffer:
<!-- prettier-ignore -->
[ ][ ][7][8][9][A][B]

Because there is space available, if the client again uses overwrite
to store C & D then the space where 5 & 6 were stored previously will
be used not the location of 7 & 8. 7 is still the oldest element and
the buffer is once again full.
<!-- prettier-ignore -->
[C][D][7][8][9][A][B]

```text
[5][6][7][8][9][3][4]
```

When the buffer is full an error will be raised, alerting the client that further writes are blocked until a slot becomes free.

When the buffer is full, the client can opt to overwrite the oldest data with a forced write.
In this case, two more elements — A & B — are added and they overwrite the 3 & 4:

```text
[5][6][7][8][9][A][B]
```

3 & 4 have been replaced by A & B making 5 now the oldest data in the buffer.
Finally, if two elements are removed then what would be returned is 5 & 6 yielding the buffer:

```text
[ ][ ][7][8][9][A][B]
```

Because there is space available, if the client again uses overwrite to store C & D then the space where 5 & 6 were stored previously will be used not the location of 7 & 8.
7 is still the oldest element and the buffer is once again full.

```text
[C][D][7][8][9][A][B]
```
4 changes: 3 additions & 1 deletion exercises/practice/circular-buffer/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
".meta/example.red"
]
},
"blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end."
"blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.",
"source": "Wikipedia",
"source_url": "https://en.wikipedia.org/wiki/Circular_buffer"
}
32 changes: 23 additions & 9 deletions exercises/practice/darts/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@

Write a function that returns the earned points in a single toss of a Darts game.

[Darts](https://en.wikipedia.org/wiki/Darts) is a game where players
throw darts to a [target](https://en.wikipedia.org/wiki/Darts#/media/File:Darts_in_a_dartboard.jpg).
[Darts][darts] is a game where players throw darts at a [target][darts-target].

In our particular instance of the game, the target rewards with 4 different amounts of points, depending on where the dart lands:
In our particular instance of the game, the target rewards 4 different amounts of points, depending on where the dart lands:

* If the dart lands outside the target, player earns no points (0 points).
* If the dart lands in the outer circle of the target, player earns 1 point.
* If the dart lands in the middle circle of the target, player earns 5 points.
* If the dart lands in the inner circle of the target, player earns 10 points.
![Our dart scoreboard with values from a complete miss to a bullseye](https://assets.exercism.org/images/exercises/darts/darts-scoreboard.svg)

The outer circle has a radius of 10 units (This is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1. Of course, they are all centered to the same point (That is, the circles are [concentric](http://mathworld.wolfram.com/ConcentricCircles.html)) defined by the coordinates (0, 0).
- If the dart lands outside the target, player earns no points (0 points).
- If the dart lands in the outer circle of the target, player earns 1 point.
- If the dart lands in the middle circle of the target, player earns 5 points.
- If the dart lands in the inner circle of the target, player earns 10 points.

Write a function that given a point in the target (defined by its `real` cartesian coordinates `x` and `y`), returns the correct amount earned by a dart landing in that point.
The outer circle has a radius of 10 units (this is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1.
Of course, they are all centered at the same point — that is, the circles are [concentric][] defined by the coordinates (0, 0).

Write a function that given a point in the target (defined by its [Cartesian coordinates][cartesian-coordinates] `x` and `y`, where `x` and `y` are [real][real-numbers]), returns the correct amount earned by a dart landing at that point.

## Credit

The scoreboard image was created by [habere-et-dispertire][habere-et-dispertire] using [Inkscape][inkscape].

[darts]: https://en.wikipedia.org/wiki/Darts
[darts-target]: https://en.wikipedia.org/wiki/Darts#/media/File:Darts_in_a_dartboard.jpg
[concentric]: https://mathworld.wolfram.com/ConcentricCircles.html
[cartesian-coordinates]: https://www.mathsisfun.com/data/cartesian-coordinates.html
[real-numbers]: https://www.mathsisfun.com/numbers/real-numbers.html
[habere-et-dispertire]: https://exercism.org/profiles/habere-et-dispertire
[inkscape]: https://en.wikipedia.org/wiki/Inkscape
3 changes: 2 additions & 1 deletion exercises/practice/darts/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
".meta/example.red"
]
},
"blurb": "Write a function that returns the earned points in a single toss of a Darts game."
"blurb": "Write a function that returns the earned points in a single toss of a Darts game.",
"source": "Inspired by an exercise created by a professor Della Paolera in Argentina"
}
9 changes: 5 additions & 4 deletions exercises/practice/hello-world/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Instructions

The classical introductory exercise. Just say "Hello, World!".
The classical introductory exercise.
Just say "Hello, World!".

["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment.

The objectives are simple:

Expand All @@ -13,3 +12,5 @@ The objectives are simple:
- Submit your solution and check it at the website.

If everything goes well, you will be ready to fetch your first real exercise.

[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
4 changes: 3 additions & 1 deletion exercises/practice/hello-world/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
".meta/example.red"
]
},
"blurb": "The classical introductory exercise. Just say \"Hello, World!\"."
"blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".",
"source": "This is an exercise to introduce users to using Exercism",
"source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program"
}
3 changes: 2 additions & 1 deletion exercises/practice/high-scores/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

Manage a game player's High Score list.

Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the three highest scores.
Your task is to build a high-score component of the classic Frogger game, one of the highest selling and most addictive games of all time, and a classic of the arcade era.
Your task is to write methods that return the highest score from the list, the last added score and the three highest scores.
3 changes: 2 additions & 1 deletion exercises/practice/high-scores/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
".meta/example.red"
]
},
"blurb": "Manage a player's High Score list."
"blurb": "Manage a player's High Score list.",
"source": "Tribute to the eighties' arcade game Frogger"
}
4 changes: 3 additions & 1 deletion exercises/practice/largest-series-product/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
".meta/example.red"
]
},
"blurb": "Given a string of digits, calculate the largest product for a contiguous substring of digits of length n."
"blurb": "Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.",
"source": "A variation on Problem 8 at Project Euler",
"source_url": "https://projecteuler.net/problem=8"
}
25 changes: 10 additions & 15 deletions exercises/practice/pov/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

Reparent a tree on a selected node.

A [tree][wiki-tree] is a special type of [graph][wiki-graph] where all nodes
are connected but there are no cycles. That means, there is exactly one path to
get from one node to another for any pair of nodes.
A [tree][wiki-tree] is a special type of [graph][wiki-graph] where all nodes are connected but there are no cycles.
That means, there is exactly one path to get from one node to another for any pair of nodes.

This exercise is all about re-orientating a tree to see things from a different
point of view. For example family trees are usually presented from the
ancestor's perspective:
This exercise is all about re-orientating a tree to see things from a different point of view.
For example family trees are usually presented from the ancestor's perspective:

```text
+------0------+
Expand All @@ -18,10 +16,9 @@ ancestor's perspective:
4 5 6 7 8 9
```

But there is no inherent direction in a tree. The same information can be
presented from the perspective of any other node in the tree, by pulling it up
to the root and dragging its relationships along with it. So the same tree
from 6's perspective would look like:
But there is no inherent direction in a tree.
The same information can be presented from the perspective of any other node in the tree, by pulling it up to the root and dragging its relationships along with it.
So the same tree from 6's perspective would look like:

```text
6
Expand All @@ -35,12 +32,10 @@ from 6's perspective would look like:
4 5 8 9
```

This lets us more simply describe the paths between two nodes. So for example
the path from 6-9 (which in the first tree goes up to the root and then down to
a different leaf node) can be seen to follow the path 6-2-0-3-9.
This lets us more simply describe the paths between two nodes.
So for example the path from 6-9 (which in the first tree goes up to the root and then down to a different leaf node) can be seen to follow the path 6-2-0-3-9.

This exercise involves taking an input tree and re-orientating it from the point
of view of one of the nodes.
This exercise involves taking an input tree and re-orientating it from the point of view of one of the nodes.

[wiki-graph]: https://en.wikipedia.org/wiki/Tree_(graph_theory)
[wiki-tree]: https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)
4 changes: 3 additions & 1 deletion exercises/practice/pov/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
".meta/example.red"
]
},
"blurb": "Reparent a graph on a selected node."
"blurb": "Reparent a graph on a selected node.",
"source": "Adaptation of exercise from 4clojure",
"source_url": "https://www.4clojure.com/"
}
Loading

0 comments on commit 93ab7b6

Please sign in to comment.