Skip to content

Commit 6f1019e

Browse files
authored
Sync docs and metadata from problem-specifications (#419)
* Sync docs * Sync metadata
1 parent a203623 commit 6f1019e

File tree

15 files changed

+130
-56
lines changed

15 files changed

+130
-56
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Where:
2020

2121
- `i` is the letter's index from `0` to the length of the alphabet - 1.
2222
- `m` is the length of the alphabet.
23-
For the Roman alphabet `m` is `26`.
23+
For the Latin alphabet `m` is `26`.
2424
- `a` and `b` are integers which make up the encryption key.
2525

2626
Values `a` and `m` must be _coprime_ (or, _relatively prime_) for automatic decryption to succeed, i.e., they have number `1` as their only common factor (more information can be found in the [Wikipedia article about coprime integers][coprime-integers]).
Lines changed: 5 additions & 6 deletions
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/eliuds-eggs/.docs/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The position information encoding is calculated as follows:
5858

5959
### Decimal number on the display
6060

61-
16
61+
8
6262

6363
### Actual eggs in the coop
6464

Lines changed: 5 additions & 9 deletions
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
Lines changed: 6 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
},
2121
"blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.",
2222
"source": "The CodeRanch Cattle Drive, Assignment 6",
23-
"source_url": "https://coderanch.com/wiki/718824/Grains"
23+
"source_url": "https://web.archive.org/web/20240908084142/https://coderanch.com/wiki/718824/Grains"
2424
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
},
2323
"blurb": "Determine whether a given year is a leap year.",
2424
"source": "CodeRanch Cattle Drive, Assignment 3",
25-
"source_url": "https://coderanch.com/t/718816/Leap"
25+
"source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap"
2626
}
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,68 @@
11
# Instructions
22

3-
Given a number determine whether or not it is valid per the Luhn formula.
3+
Determine whether a 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.
1311
All other non-digit characters are disallowed.
1412

15-
### Example 1: valid credit card number
13+
## Examples
1614

17-
```text
18-
4539 3195 0343 6467
19-
```
15+
### Valid credit card number
2016

21-
The first step of the Luhn algorithm is to double every second digit, starting from the right.
22-
We will be doubling
17+
The number to be checked is `4539 3195 0343 6467`.
18+
19+
The first step of the Luhn algorithm is to start at the end of the number and double every second digit, beginning with the second digit from the right and moving left.
2320

2421
```text
2522
4539 3195 0343 6467
2623
↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ (double these)
2724
```
2825

29-
If doubling the number results in a number greater than 9 then subtract 9 from the product.
30-
The results of our doubling:
26+
If the result of doubling a digit is greater than 9, we subtract 9 from that result.
27+
We end up with:
3128

3229
```text
3330
8569 6195 0383 3437
3431
```
3532

36-
Then sum all of the digits:
33+
Finally, we sum all digits.
34+
If the sum is evenly divisible by 10, the original number is valid.
3735

3836
```text
39-
8+5+6+9+6+1+9+5+0+3+8+3+3+4+3+7 = 80
37+
8 + 5 + 6 + 9 + 6 + 1 + 9 + 5 + 0 + 3 + 8 + 3 + 3 + 4 + 3 + 7 = 80
4038
```
4139

42-
If the sum is evenly divisible by 10, then the number is valid.
43-
This number is valid!
40+
80 is evenly divisible by 10, so number `4539 3195 0343 6467` is valid!
41+
42+
### Invalid Canadian SIN
43+
44+
The number to be checked is `066 123 468`.
4445

45-
### Example 2: invalid credit card number
46+
We start at the end of the number and double every second digit, beginning with the second digit from the right and moving left.
4647

4748
```text
48-
8273 1232 7352 0569
49+
066 123 478
50+
↑ ↑ ↑ ↑ (double these)
4951
```
5052

51-
Double the second digits, starting from the right
53+
If the result of doubling a digit is greater than 9, we subtract 9 from that result.
54+
We end up with:
5255

5356
```text
54-
7253 2262 5312 0539
57+
036 226 458
5558
```
5659

57-
Sum the digits
60+
We sum the digits:
5861

5962
```text
60-
7+2+5+3+2+2+6+2+5+3+1+2+0+5+3+9 = 57
63+
0 + 3 + 6 + 2 + 2 + 6 + 4 + 5 + 8 = 36
6164
```
6265

63-
57 is not evenly divisible by 10, so this number is not valid.
66+
36 is not evenly divisible by 10, so number `066 123 478` is not valid!
6467

6568
[luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm
Lines changed: 11 additions & 0 deletions
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 help identify mistyped numbers.
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 mistakes such as incorrect transactions or failed account verifications.
10+
11+
Can you ensure this is done right? The integrity of many services depends on you.

exercises/practice/meetup/.docs/instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Your task is to find the exact date of a meetup, given a month, year, weekday and week.
44

5-
There are five week values to consider: `first`, `second`, `third`, `fourth`, `last`, `teenth`.
5+
There are six week values to consider: `first`, `second`, `third`, `fourth`, `last`, `teenth`.
66

77
For example, you might be asked to find the date for the meetup on the first Monday in January 2018 (January 1, 2018).
88

0 commit comments

Comments
 (0)