Skip to content

Commit 1ae9715

Browse files
authored
Sync problem-specifications (#366)
1 parent aeec29a commit 1ae9715

File tree

22 files changed

+208
-97
lines changed

22 files changed

+208
-97
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Instructions
22

3-
Your task is to, given a target word and a set of candidate words, to find the subset of the candidates that are anagrams of the target.
3+
Given a target word and one or more candidate words, your task is to find the candidates that are anagrams of the target.
44

55
An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`.
66
A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`.
77

8-
The target and candidates are words of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`).
9-
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `StoP` is not an anagram of `sTOp`.
10-
The anagram set is the subset of the candidate set that are anagrams of the target (in any order).
11-
Words in the anagram set should have the same letter case as in the candidate set.
8+
The target word and candidate words are made up of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`).
9+
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `"StoP"` is not an anagram of `"sTOp"`.
10+
The words you need to find should be taken from the candidate words, using the same letter case.
1211

13-
Given the target `"stone"` and candidates `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, `"Seton"`, the anagram set is `"tones"`, `"notes"`, `"Seton"`.
12+
Given the target `"stone"` and the candidate words `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, and `"Seton"`, the anagram words you need to find are `"tones"`, `"notes"`, and `"Seton"`.

exercises/practice/atbash-cipher/.docs/instructions.md

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

3-
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
3+
Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.
44

55
The Atbash cipher is a simple substitution cipher that relies on transposing all the letters in the alphabet such that the resulting alphabet is backwards.
66
The first letter is replaced with the last letter, the second with the second-last, and so on.

exercises/practice/atbash-cipher/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
".meta/example.coffee"
2020
]
2121
},
22-
"blurb": "Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.",
22+
"blurb": "Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.",
2323
"source": "Wikipedia",
2424
"source_url": "https://en.wikipedia.org/wiki/Atbash"
2525
}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
11
# Instructions
22

3-
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
4-
5-
Take any positive integer n.
6-
If n is even, divide n by 2 to get n / 2.
7-
If n is odd, multiply n by 3 and add 1 to get 3n + 1.
8-
Repeat the process indefinitely.
9-
The conjecture states that no matter which number you start with, you will always reach 1 eventually.
10-
11-
Given a number n, return the number of steps required to reach 1.
12-
13-
## Examples
14-
15-
Starting with n = 12, the steps would be as follows:
16-
17-
0. 12
18-
1. 6
19-
2. 3
20-
3. 10
21-
4. 5
22-
5. 16
23-
6. 8
24-
7. 4
25-
8. 2
26-
9. 1
27-
28-
Resulting in 9 steps.
29-
So for input n = 12, the return value would be 9.
3+
Given a positive integer, return the number of steps it takes to reach 1 according to the rules of the Collatz Conjecture.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Introduction
2+
3+
One evening, you stumbled upon an old notebook filled with cryptic scribbles, as though someone had been obsessively chasing an idea.
4+
On one page, a single question stood out: **Can every number find its way to 1?**
5+
It was tied to something called the **Collatz Conjecture**, a puzzle that has baffled thinkers for decades.
6+
7+
The rules were deceptively simple.
8+
Pick any positive integer.
9+
10+
- If it's even, divide it by 2.
11+
- If it's odd, multiply it by 3 and add 1.
12+
13+
Then, repeat these steps with the result, continuing indefinitely.
14+
15+
Curious, you picked number 12 to test and began the journey:
16+
17+
12 ➜ 6 ➜ 3 ➜ 10 ➜ 5 ➜ 16 ➜ 8 ➜ 4 ➜ 2 ➜ 1
18+
19+
Counting from the second number (6), it took 9 steps to reach 1, and each time the rules repeated, the number kept changing.
20+
At first, the sequence seemed unpredictable — jumping up, down, and all over.
21+
Yet, the conjecture claims that no matter the starting number, we'll always end at 1.
22+
23+
It was fascinating, but also puzzling.
24+
Why does this always seem to work?
25+
Could there be a number where the process breaks down, looping forever or escaping into infinity?
26+
The notebook suggested solving this could reveal something profound — and with it, fame, [fortune][collatz-prize], and a place in history awaits whoever could unlock its secrets.
27+
28+
[collatz-prize]: https://mathprize.net/posts/collatz-conjecture/

exercises/practice/collatz-conjecture/.meta/config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
]
1515
},
1616
"blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.",
17-
"source": "An unsolved problem in mathematics named after mathematician Lothar Collatz",
18-
"source_url": "https://en.wikipedia.org/wiki/3x_%2B_1_problem"
17+
"source": "Wikipedia",
18+
"source_url": "https://en.wikipedia.org/wiki/Collatz_conjecture"
1919
}

exercises/practice/eliuds-eggs/.docs/introduction.md

+33-15
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,54 @@ The position information encoding is calculated as follows:
1212
2. Convert the number from binary to decimal.
1313
3. Show the result on the display.
1414

15-
Example 1:
15+
## Example 1
16+
17+
![Seven individual nest boxes arranged in a row whose first, third, fourth and seventh nests each have a single egg.](https://assets.exercism.org/images/exercises/eliuds-eggs/example-1-coop.svg)
1618

1719
```text
18-
Chicken Coop:
1920
_ _ _ _ _ _ _
2021
|E| |E|E| | |E|
22+
```
23+
24+
### Resulting Binary
25+
26+
![1011001](https://assets.exercism.org/images/exercises/eliuds-eggs/example-1-binary.svg)
27+
28+
```text
29+
_ _ _ _ _ _ _
30+
|1|0|1|1|0|0|1|
31+
```
2132

22-
Resulting Binary:
23-
1 0 1 1 0 0 1
33+
### Decimal number on the display
2434

25-
Decimal number on the display:
2635
89
2736

28-
Actual eggs in the coop:
37+
### Actual eggs in the coop
38+
2939
4
40+
41+
## Example 2
42+
43+
![Seven individual nest boxes arranged in a row where only the fourth nest has an egg.](https://assets.exercism.org/images/exercises/eliuds-eggs/example-2-coop.svg)
44+
45+
```text
46+
_ _ _ _ _ _ _
47+
| | | |E| | | |
3048
```
3149

32-
Example 2:
50+
### Resulting Binary
51+
52+
![0001000](https://assets.exercism.org/images/exercises/eliuds-eggs/example-2-binary.svg)
3353

3454
```text
35-
Chicken Coop:
36-
_ _ _ _ _ _ _ _
37-
| | | |E| | | | |
55+
_ _ _ _ _ _ _
56+
|0|0|0|1|0|0|0|
57+
```
3858

39-
Resulting Binary:
40-
0 0 0 1 0 0 0 0
59+
### Decimal number on the display
4160

42-
Decimal number on the display:
4361
16
4462

45-
Actual eggs in the coop:
63+
### Actual eggs in the coop
64+
4665
1
47-
```
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Instructions
22

3-
Given students' names along with the grade that they are in, create a roster for the school.
3+
Given students' names along with the grade they are in, create a roster for the school.
44

55
In the end, you should be able to:
66

7-
- Add a student's name to the roster for a grade
7+
- Add a student's name to the roster for a grade:
88
- "Add Jim to grade 2."
99
- "OK."
10-
- Get a list of all students enrolled in a grade
10+
- Get a list of all students enrolled in a grade:
1111
- "Which students are in grade 2?"
12-
- "We've only got Jim just now."
12+
- "We've only got Jim right now."
1313
- Get a sorted list of all students in all grades.
14-
Grades should sort as 1, 2, 3, etc., and students within a grade should be sorted alphabetically by name.
15-
- "Who all is enrolled in school right now?"
14+
Grades should be sorted as 1, 2, 3, etc., and students within a grade should be sorted alphabetically by name.
15+
- "Who is enrolled in school right now?"
1616
- "Let me think.
17-
We have Anna, Barb, and Charlie in grade 1, Alex, Peter, and Zoe in grade 2 and Jim in grade 5.
18-
So the answer is: Anna, Barb, Charlie, Alex, Peter, Zoe and Jim"
17+
We have Anna, Barb, and Charlie in grade 1, Alex, Peter, and Zoe in grade 2, and Jim in grade 5.
18+
So the answer is: Anna, Barb, Charlie, Alex, Peter, Zoe, and Jim."
1919

20-
Note that all our students only have one name (It's a small town, what do you want?) and each student cannot be added more than once to a grade or the roster.
21-
In fact, when a test attempts to add the same student more than once, your implementation should indicate that this is incorrect.
20+
Note that all our students only have one name (it's a small town, what do you want?), and each student cannot be added more than once to a grade or the roster.
21+
If a test attempts to add the same student more than once, your implementation should indicate that this is incorrect.
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# Instructions
22

3-
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
3+
Calculate the number of grains of wheat on a chessboard.
44

5-
There once was a wise servant who saved the life of a prince.
6-
The king promised to pay whatever the servant could dream up.
7-
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat.
8-
One grain on the first square of a chess board, with the number of grains doubling on each successive square.
5+
A chessboard has 64 squares.
6+
Square 1 has one grain, square 2 has two grains, square 3 has four grains, and so on, doubling each time.
97

10-
There are 64 squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on).
8+
Write code that calculates:
119

12-
Write code that shows:
13-
14-
- how many grains were on a given square, and
10+
- the number of grains on a given square
1511
- the total number of grains on the chessboard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Introduction
2+
3+
There once was a wise servant who saved the life of a prince.
4+
The king promised to pay whatever the servant could dream up.
5+
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat.
6+
One grain on the first square of a chessboard, with the number of grains doubling on each successive square.

exercises/practice/grains/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
},
1616
"blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.",
1717
"source": "The CodeRanch Cattle Drive, Assignment 6",
18-
"source_url": "https://coderanch.com/wiki/718824/Grains"
18+
"source_url": "https://web.archive.org/web/20240908084142/https://coderanch.com/wiki/718824/Grains"
1919
}

exercises/practice/knapsack/.docs/instructions.md

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

3-
Your task is to determine which items to take so that the total value of his selection is maximized, taking into account the knapsack's carrying capacity.
3+
Your task is to determine which items to take so that the total value of her selection is maximized, taking into account the knapsack's carrying capacity.
44

55
Items will be represented as a list of items.
66
Each item will have a weight and value.
77
All values given will be strictly positive.
8-
Bob can take only one of each item.
8+
Lhakpa can take only one of each item.
99

1010
For example:
1111

@@ -21,5 +21,5 @@ Knapsack Maximum Weight: 10
2121
```
2222

2323
For the above, the first item has weight 5 and value 10, the second item has weight 4 and value 40, and so on.
24-
In this example, Bob should take the second and fourth item to maximize his value, which, in this case, is 90.
25-
He cannot get more than 90 as his knapsack has a weight limit of 10.
24+
In this example, Lhakpa should take the second and fourth item to maximize her value, which, in this case, is 90.
25+
She cannot get more than 90 as her knapsack has a weight limit of 10.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Introduction
22

3-
Bob is a thief.
4-
After months of careful planning, he finally manages to crack the security systems of a fancy store.
3+
Lhakpa is a [Sherpa][sherpa] mountain guide and porter.
4+
After months of careful planning, the expedition Lhakpa works for is about to leave.
5+
She will be paid the value she carried to the base camp.
56

6-
In front of him are many items, each with a value and weight.
7-
Bob would gladly take all of the items, but his knapsack can only hold so much weight.
8-
Bob has to carefully consider which items to take so that the total value of his selection is maximized.
7+
In front of her are many items, each with a value and weight.
8+
Lhakpa would gladly take all of the items, but her knapsack can only hold so much weight.
9+
10+
[sherpa]: https://en.wikipedia.org/wiki/Sherpa_people#Mountaineering

exercises/practice/leap/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
},
1616
"blurb": "Determine whether a given year is a leap year.",
1717
"source": "CodeRanch Cattle Drive, Assignment 3",
18-
"source_url": "https://coderanch.com/t/718816/Leap"
18+
"source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap"
1919
}

exercises/practice/luhn/.docs/instructions.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Instructions
22

3-
Given a number determine whether or not it is valid per the Luhn formula.
3+
Determine whether a credit card number is valid according to the [Luhn formula][luhn].
44

5-
The [Luhn algorithm][luhn] is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers and Canadian Social Insurance Numbers.
5+
The number will be provided as a string.
66

7-
The task is to check if a given string is valid.
8-
9-
## Validating a Number
7+
## Validating a number
108

119
Strings of length 1 or less are not valid.
1210
Spaces are allowed in the input, but they should be stripped before checking.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Introduction
2+
3+
At the Global Verification Authority, you've just been entrusted with a critical assignment.
4+
Across the city, from online purchases to secure logins, countless operations rely on the accuracy of numerical identifiers like credit card numbers, bank account numbers, transaction codes, and tracking IDs.
5+
The Luhn algorithm is a simple checksum formula used to ensure these numbers are valid and error-free.
6+
7+
A batch of identifiers has just arrived on your desk.
8+
All of them must pass the Luhn test to ensure they're legitimate.
9+
If any fail, they'll be flagged as invalid, preventing errors or fraud, such as incorrect transactions or unauthorized access.
10+
11+
Can you ensure this is done right? The integrity of many services depends on you.

exercises/practice/pascals-triangle/.docs/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Over the next hour, your teacher reveals some amazing things hidden in this tria
1313
- It contains the Fibonacci sequence.
1414
- If you color odd and even numbers differently, you get a beautiful pattern called the [Sierpiński triangle][wikipedia-sierpinski-triangle].
1515

16-
The teacher implores you and your classmates to lookup other uses, and assures you that there are lots more!
16+
The teacher implores you and your classmates to look up other uses, and assures you that there are lots more!
1717
At that moment, the school bell rings.
1818
You realize that for the past hour, you were completely absorbed in learning about Pascal's triangle.
1919
You quickly grab your laptop from your bag and go outside, ready to enjoy both the sunshine _and_ the wonders of Pascal's triangle.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Introduction
2+
3+
You've joined LinkLine, a leading communications company working to ensure reliable connections for everyone.
4+
The team faces a big challenge: users submit phone numbers in all sorts of formats — dashes, spaces, dots, parentheses, and even prefixes.
5+
Some numbers are valid, while others are impossible to use.
6+
7+
Your mission is to turn this chaos into order.
8+
You'll clean up valid numbers, formatting them appropriately for use in the system.
9+
At the same time, you'll identify and filter out any invalid entries.
10+
11+
The success of LinkLine's operations depends on your ability to separate the useful from the unusable.
12+
Are you ready to take on the challenge and keep the connections running smoothly?

exercises/practice/pig-latin/.meta/tests.toml

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ description = "first letter and ay are moved to the end of words that start with
3939
[bce94a7a-a94e-4e2b-80f4-b2bb02e40f71]
4040
description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with q without a following u"
4141

42+
[e59dbbe8-ccee-4619-a8e9-ce017489bfc0]
43+
description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with consonant and vowel containing qu"
44+
4245
[c01e049a-e3e2-451c-bf8e-e2abb7e438b8]
4346
description = "some letter clusters are treated like a single consonant -> word beginning with ch"
4447

exercises/practice/pig-latin/pig-latin.spec.coffee

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ describe 'Pig Latin', ->
5353
expected = "atqay"
5454
expect(results).toEqual expected
5555

56+
xit 'word beginning with consonant and vowel containing qu', ->
57+
results = PigLatin.translate "liquid"
58+
expected = "iquidlay"
59+
expect(results).toEqual expected
60+
5661
describe 'some letter clusters are treated as a single consonant', ->
5762
xit 'word beginning with ch', ->
5863
results = PigLatin.translate "chair"

exercises/practice/rna-transcription/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
".meta/example.coffee"
1414
]
1515
},
16-
"blurb": "Given a DNA strand, return its RNA Complement Transcription.",
16+
"blurb": "Given a DNA strand, return its RNA complement.",
1717
"source": "Hyperphysics",
1818
"source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html"
1919
}

0 commit comments

Comments
 (0)