Skip to content

Commit 5fdc397

Browse files
authored
Sync recent problem spec changes (#355)
* sync docs and metadata * sync protein-translation tests * sync zebra-puzzle and update example to match instructions
1 parent 63f7714 commit 5fdc397

File tree

14 files changed

+122
-48
lines changed

14 files changed

+122
-48
lines changed

exercises/practice/bank-account/.docs/instructions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Your task is to implement bank accounts supporting opening/closing, withdrawals, and deposits of money.
44

55
As bank accounts can be accessed in many different ways (internet, mobile phones, automatic charges), your bank software must allow accounts to be safely accessed from multiple threads/processes (terminology depends on your programming language) in parallel.
6-
For example, there may be many deposits and withdrawals occurring in parallel; you need to ensure there is no [race conditions][wikipedia] between when you read the account balance and set the new balance.
6+
For example, there may be many deposits and withdrawals occurring in parallel; you need to ensure there are no [race conditions][wikipedia] between when you read the account balance and set the new balance.
77

88
It should be possible to close an account; operations against a closed account must fail.
99

exercises/practice/go-counting/.docs/instructions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Empty spaces represent empty intersections.
2525

2626
To be more precise an empty intersection is part of a player's territory if all of its neighbors are either stones of that player or empty intersections that are part of that player's territory.
2727

28-
For more information see [wikipedia][go-wikipedia] or [Sensei's Library][go-sensei].
28+
For more information see [Wikipedia][go-wikipedia] or [Sensei's Library][go-sensei].
2929

3030
[go-wikipedia]: https://en.wikipedia.org/wiki/Go_%28game%29
3131
[go-sensei]: https://senseis.xmp.net/

exercises/practice/killer-sudoku-helper/.docs/instructions.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ In a 3-digit cage with a sum of 7, there is only one valid combination: 124.
2020
- 1 + 2 + 4 = 7
2121
- Any other combination that adds up to 7, e.g. 232, would violate the rule of not repeating digits within a cage.
2222

23-
![Sudoku grid, with three killer cages that are marked as grouped together. The first killer cage is in the 3×3 box in the top left corner of the grid. The middle column of that box forms the cage, with the followings cells from top to bottom: first cell contains a 1 and a pencil mark of 7, indicating a cage sum of 7, second cell contains a 2, third cell contains a 5. The numbers are highlighted in red to indicate a mistake. The second killer cage is in the central 3×3 box of the grid. The middle column of that box forms the cage, with the followings cells from top to bottom: first cell contains a 1 and a pencil mark of 7, indicating a cage sum of 7, second cell contains a 2, third cell contains a 4. None of the numbers in this cage are highlighted and therefore don't contain any mistakes. The third killer cage follows the outside corner of the central 3×3 box of the grid. It is made up of the following three cells: the top left cell of the cage contains a 2, highlighted in red, and a cage sum of 7. The top right cell of the cage contains a 3. The bottom right cell of the cage contains a 2, highlighted in red. All other cells are empty.][one-solution-img]
23+
![Sudoku grid, with three killer cages that are marked as grouped together.
24+
The first killer cage is in the 3×3 box in the top left corner of the grid.
25+
The middle column of that box forms the cage, with the followings cells from top to bottom: first cell contains a 1 and a pencil mark of 7, indicating a cage sum of 7, second cell contains a 2, third cell contains a 5.
26+
The numbers are highlighted in red to indicate a mistake.
27+
The second killer cage is in the central 3×3 box of the grid.
28+
The middle column of that box forms the cage, with the followings cells from top to bottom: first cell contains a 1 and a pencil mark of 7, indicating a cage sum of 7, second cell contains a 2, third cell contains a 4.
29+
None of the numbers in this cage are highlighted and therefore don't contain any mistakes.
30+
The third killer cage follows the outside corner of the central 3×3 box of the grid.
31+
It is made up of the following three cells: the top left cell of the cage contains a 2, highlighted in red, and a cage sum of 7.
32+
The top right cell of the cage contains a 3.
33+
The bottom right cell of the cage contains a 2, highlighted in red. All other cells are empty.][one-solution-img]
2434

2535
## Example 2: Cage with several combinations
2636

@@ -31,7 +41,13 @@ In a 2-digit cage with a sum 10, there are 4 possible combinations:
3141
- 37
3242
- 46
3343

34-
![Sudoku grid, all squares empty except for the middle column, column 5, which has 8 rows filled. Each continguous two rows form a killer cage and are marked as grouped together. From top to bottom: first group is a cell with value 1 and a pencil mark indicating a cage sum of 10, cell with value 9. Second group is a cell with value 2 and a pencil mark of 10, cell with value 8. Third group is a cell with value 3 and a pencil mark of 10, cell with value 7. Fourth group is a cell with value 4 and a pencil mark of 10, cell with value 6. The last cell in the column is empty.][four-solutions-img]
44+
![Sudoku grid, all squares empty except for the middle column, column 5, which has 8 rows filled.
45+
Each continguous two rows form a killer cage and are marked as grouped together.
46+
From top to bottom: first group is a cell with value 1 and a pencil mark indicating a cage sum of 10, cell with value 9.
47+
Second group is a cell with value 2 and a pencil mark of 10, cell with value 8.
48+
Third group is a cell with value 3 and a pencil mark of 10, cell with value 7.
49+
Fourth group is a cell with value 4 and a pencil mark of 10, cell with value 6.
50+
The last cell in the column is empty.][four-solutions-img]
3551

3652
## Example 3: Cage with several combinations that is restricted
3753

@@ -42,7 +58,13 @@ In a 2-digit cage with a sum 10, where the column already contains a 1 and a 4,
4258

4359
19 and 46 are not possible due to the 1 and 4 in the column according to standard Sudoku rules.
4460

45-
![Sudoku grid, all squares empty except for the middle column, column 5, which has 8 rows filled. The first row contains a 4, the second is empty, and the third contains a 1. The 1 is highlighted in red to indicate a mistake. The last 6 rows in the column form killer cages of two cells each. From top to bottom: first group is a cell with value 2 and a pencil mark indicating a cage sum of 10, cell with value 8. Second group is a cell with value 3 and a pencil mark of 10, cell with value 7. Third group is a cell with value 1, highlighted in red, and a pencil mark of 10, cell with value 9.][not-possible-img]
61+
![Sudoku grid, all squares empty except for the middle column, column 5, which has 8 rows filled.
62+
The first row contains a 4, the second is empty, and the third contains a 1.
63+
The 1 is highlighted in red to indicate a mistake.
64+
The last 6 rows in the column form killer cages of two cells each.
65+
From top to bottom: first group is a cell with value 2 and a pencil mark indicating a cage sum of 10, cell with value 8.
66+
Second group is a cell with value 3 and a pencil mark of 10, cell with value 7.
67+
Third group is a cell with value 1, highlighted in red, and a pencil mark of 10, cell with value 9.][not-possible-img]
4668

4769
## Trying it yourself
4870

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
# Instructions
22

3-
Compute Pascal's triangle up to a given number of rows.
3+
Your task is to output the first N rows of Pascal's triangle.
44

5-
In Pascal's Triangle each number is computed by adding the numbers to the right and left of the current position in the previous row.
5+
[Pascal's triangle][wikipedia] is a triangular array of positive integers.
6+
7+
In Pascal's triangle, the number of values in a row is equal to its row number (which starts at one).
8+
Therefore, the first row has one value, the second row has two values, and so on.
9+
10+
The first (topmost) row has a single value: `1`.
11+
Subsequent rows' values are computed by adding the numbers directly to the right and left of the current position in the previous row.
12+
13+
If the previous row does _not_ have a value to the left or right of the current position (which only happens for the leftmost and rightmost positions), treat that position's value as zero (effectively "ignoring" it in the summation).
14+
15+
## Example
16+
17+
Let's look at the first 5 rows of Pascal's Triangle:
618

719
```text
820
1
921
1 1
1022
1 2 1
1123
1 3 3 1
1224
1 4 6 4 1
13-
# ... etc
1425
```
26+
27+
The topmost row has one value, which is `1`.
28+
29+
The leftmost and rightmost values have only one preceding position to consider, which is the position to its right respectively to its left.
30+
With the topmost value being `1`, it follows from this that all the leftmost and rightmost values are also `1`.
31+
32+
The other values all have two positions to consider.
33+
For example, the fifth row's (`1 4 6 4 1`) middle value is `6`, as the values to its left and right in the preceding row are `3` and `3`:
34+
35+
[wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Introduction
2+
3+
With the weather being great, you're not looking forward to spending an hour in a classroom.
4+
Annoyed, you enter the class room, where you notice a strangely satisfying triangle shape on the blackboard.
5+
Whilst waiting for your math teacher to arrive, you can't help but notice some patterns in the triangle: the outer values are all ones, each subsequent row has one more value than its previous row and the triangle is symmetrical.
6+
Weird!
7+
8+
Not long after you sit down, your teacher enters the room and explains that this triangle is the famous [Pascal's triangle][wikipedia].
9+
10+
Over the next hour, your teacher reveals some amazing things hidden in this triangle:
11+
12+
- It can be used to compute how many ways you can pick K elements from N values.
13+
- It contains the Fibonacci sequence.
14+
- If you color odd and even numbers differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle].
15+
16+
The teacher implores you and your classmates to lookup other uses, and assures you that there are lots more!
17+
At that moment, the school bell rings.
18+
You realize that for the past hour, you were completely absorbed in learning about Pascal's triangle.
19+
You quickly grab your laptop from your bag and go outside, ready to enjoy both the sunshine _and_ the wonders of Pascal's triangle.
20+
21+
[wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle
22+
[wikipedia-sierpinski-triangle]: https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle

exercises/practice/pig-latin/.docs/instructions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For example:
1919

2020
## Rule 2
2121

22-
If a word begins with a one or more consonants, first move those consonants to the end of the word and then add an `"ay"` sound to the end of the word.
22+
If a word begins with one or more consonants, first move those consonants to the end of the word and then add an `"ay"` sound to the end of the word.
2323

2424
For example:
2525

@@ -33,7 +33,7 @@ If a word starts with zero or more consonants followed by `"qu"`, first move tho
3333

3434
For example:
3535

36-
- `"quick"` -> `"ickqu"` -> `"ay"` (starts with `"qu"`, no preceding consonants)
36+
- `"quick"` -> `"ickqu"` -> `"ickquay"` (starts with `"qu"`, no preceding consonants)
3737
- `"square"` -> `"aresqu"` -> `"aresquay"` (starts with one consonant followed by `"qu`")
3838

3939
## Rule 4

exercises/practice/poker/.docs/instructions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
Pick the best hand(s) from a list of poker hands.
44

5-
See [wikipedia][poker-hands] for an overview of poker hands.
5+
See [Wikipedia][poker-hands] for an overview of poker hands.
66

77
[poker-hands]: https://en.wikipedia.org/wiki/List_of_poker_hands

exercises/practice/protein-translation/.meta/tests.toml

+4
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ description = "Translation stops if STOP codon in middle of three-codon sequence
8787
[2c2a2a60-401f-4a80-b977-e0715b23b93d]
8888
description = "Translation stops if STOP codon in middle of six-codon sequence"
8989

90+
[f6f92714-769f-4187-9524-e353e8a41a80]
91+
description = "Sequence of two non-STOP codons does not translate to a STOP codon"
92+
9093
[1e75ea2a-f907-4994-ae5c-118632a1cb0f]
9194
description = "Non-existing codon can't translate"
9295

9396
[9eac93f3-627a-4c90-8653-6d0a0595bc6f]
9497
description = "Unknown amino acids, not part of a codon, can't translate"
98+
reimplements = "1e75ea2a-f907-4994-ae5c-118632a1cb0f"
9599

96100
[9d73899f-e68e-4291-b1e2-7bf87c00f024]
97101
description = "Incomplete RNA sequence can't translate"

exercises/practice/protein-translation/protein-translation.test

+5
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,10 @@ test proteins-30 "Incomplete RNA sequence can translate if valid until a STOP co
155155
proteins UUCUUCUAAUGGU
156156
} -returnCodes ok -result {Phenylalanine Phenylalanine}
157157

158+
skip proteins-31
159+
test proteins-31 "Sequence of two non-STOP codons does not translate to a STOP codon" -body {
160+
proteins AUGAUG
161+
} -returnCodes ok -result {Methionine Methionine}
162+
158163

159164
cleanupTests

exercises/practice/resistor-color-duo/.docs/instructions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ The band colors are encoded as follows:
2929
- White: 9
3030

3131
From the example above:
32-
brown-green should return 15
32+
brown-green should return 15, and
3333
brown-green-violet should return 15 too, ignoring the third color.

exercises/practice/yacht/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
]
1818
},
1919
"blurb": "Score a single throw of dice in the game Yacht.",
20-
"source": "James Kilfiger, using wikipedia",
20+
"source": "James Kilfiger, using Wikipedia",
2121
"source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)"
2222
}

exercises/practice/zebra-puzzle/.docs/instructions.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ The following 15 statements are all known to be true:
1212
1. There are five houses.
1313
2. The Englishman lives in the red house.
1414
3. The Spaniard owns the dog.
15-
4. Coffee is drunk in the green house.
15+
4. The person in the green house drinks coffee.
1616
5. The Ukrainian drinks tea.
1717
6. The green house is immediately to the right of the ivory house.
18-
7. The Old Gold smoker owns snails.
19-
8. Kools are smoked in the yellow house.
20-
9. Milk is drunk in the middle house.
18+
7. The snail owner likes to go dancing.
19+
8. The person in the yellow house is a painter.
20+
9. The person in the middle house drinks milk.
2121
10. The Norwegian lives in the first house.
22-
11. The man who smokes Chesterfields lives in the house next to the man with the fox.
23-
12. Kools are smoked in the house next to the house where the horse is kept.
24-
13. The Lucky Strike smoker drinks orange juice.
25-
14. The Japanese smokes Parliaments.
22+
11. The person who enjoys reading lives in the house next to the person with the fox.
23+
12. The painter's house is next to the house with the horse.
24+
13. The person who plays football drinks orange juice.
25+
14. The Japanese person plays chess.
2626
15. The Norwegian lives next to the blue house.
2727

28-
Additionally, each of the five houses is painted a different color, and their inhabitants are of different national extractions, own different pets, drink different beverages and smoke different brands of cigarettes.
28+
Additionally, each of the five houses is painted a different color, and their inhabitants are of different national extractions, own different pets, drink different beverages and engage in different hobbies.
2929

3030
~~~~exercism/note
3131
There are 24 billion (5!⁵ = 24,883,200,000) possible solutions, so try ruling out as many solutions as possible.

exercises/practice/zebra-puzzle/.docs/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Introduction
22

33
The Zebra Puzzle is a famous logic puzzle in which there are five houses, each painted a different color.
4-
The houses have different inhabitants, who have different nationalities, own different pets, drink different beverages and smoke different brands of cigarettes.
4+
The houses have different inhabitants, who have different nationalities, own different pets, drink different beverages and enjoy different hobbies.
55

66
To help you solve the puzzle, you're given 15 statements describing the solution.
77
However, only by combining the information in _all_ statements will you be able to find the solution to the puzzle.

exercises/practice/zebra-puzzle/.meta/example.tcl

+25-25
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ proc ::tcl::mathfunc::nextTo {first second} {
1818
# algorithm taken from Kotlin example solution
1919

2020
# The clues, and the method that implements them:
21-
# 1. There are five houses.
22-
# 2. The Englishman lives in the red house. (SolveForNationality)
23-
# 3. The Spaniard owns the dog. (SolveForPets)
24-
# 4. Coffee is drunk in the green house. (SolveForBeverages)
25-
# 5. The Ukrainian drinks tea. (SolveForBeverages)
26-
# 6. The green house is immediately to the right of the ivory house. (SolveForColour)
27-
# 7. The Old Gold smoker owns snails. (SolveForPets)
28-
# 8. Kools are smoked in the yellow house. (SolveForSmokes)
29-
# 9. Milk is drunk in the middle house. (SolveForBeverages)
30-
# 10.The Norwegian lives in the first house. (SolveForNationality)
31-
# 11.The man who smokes Chesterfields lives in the house next to the man with the fox. (SolveForPets)
32-
# 12.Kools are smoked in the house next to the house where the horse is kept.
33-
# 13.The Lucky Strike smoker drinks orange juice. (SolveForSmokes)
34-
# 14.The Japanese smokes Parliaments. (SolveForSmokes)
35-
# 15.The Norwegian lives next to the blue house. (SolveForNationality)
21+
# 1. There are five houses.
22+
# 2. The Englishman lives in the red house. (SolveForNationality)
23+
# 3. The Spaniard owns the dog. (SolveForPets)
24+
# 4. The person in the green house drinks coffee. (SolveForBeverages)
25+
# 5. The Ukrainian drinks tea. (SolveForBeverages)
26+
# 6. The green house is immediately to the right of the ivory house. (SolveForColour)
27+
# 7. The snail owner likes to go dancing. (SolveForPets)
28+
# 8. The person in the yellow house is a painter. (SolveForHobbies)
29+
# 9. The person in the middle house drinks milk. (SolveForBeverages)
30+
# 10. The Norwegian lives in the first house. (SolveForNationality)
31+
# 11. The person who enjoys reading lives in the house next to the person with the fox. (SolveForPets)
32+
# 12. The painter's house is next to the house with the horse. (SolveForPets)
33+
# 13. The person who plays football drinks orange juice. (SolveForHobbies)
34+
# 14. The Japanese person plays chess. (SolveForHobbies)
35+
# 15. The Norwegian lives next to the blue house. (SolveForNationality)
3636

3737
############################################################
3838
oo::class create ZebraPuzzle {
@@ -43,7 +43,7 @@ oo::class create ZebraPuzzle {
4343
variable red green ivory yellow blue
4444
variable english spanish ukranian norwegian japanese
4545
variable dog snails fox horse zebra
46-
variable oldGold kools chesterfields luckyStrike parliaments
46+
variable dancing painting reading football chess
4747
variable coffee tea milk orangeJuice water
4848

4949
variable nationalities
@@ -112,19 +112,19 @@ oo::class create ZebraPuzzle {
112112
&& $milk == $MIDDLE
113113
} {
114114
foreach p [permutations] {
115-
if {[my SolveForSmokes $p]} then {return true}
115+
if {[my SolveForHobbies $p]} then {return true}
116116
}
117117
}
118118
return false
119119
}
120120

121-
method SolveForSmokes {permutation} {
122-
lassign $permutation oldGold kools chesterfields luckyStrike parliaments
121+
method SolveForHobbies {permutation} {
122+
lassign $permutation dancing painting reading football chess
123123
# clues 8, 13, 14
124124
if {
125-
$kools == $yellow
126-
&& $luckyStrike == $orangeJuice
127-
&& $japanese == $parliaments
125+
$painting == $yellow
126+
&& $football == $orangeJuice
127+
&& $japanese == $chess
128128
} {
129129
foreach p [permutations] {
130130
if {[my SolveForPets $p]} then {return true}
@@ -138,9 +138,9 @@ oo::class create ZebraPuzzle {
138138
# clues 3, 7, 11, 12
139139
if {
140140
$spanish == $dog
141-
&& $oldGold == $snails
142-
&& nextTo($chesterfields, $fox)
143-
&& nextTo($kools, $horse)
141+
&& $dancing == $snails
142+
&& nextTo($reading, $fox)
143+
&& nextTo($painting, $horse)
144144
} {
145145
set waterDrinker [dict get $nationalities $water]
146146
set zebraOwner [dict get $nationalities $zebra]

0 commit comments

Comments
 (0)