Skip to content

Sync problem-specs #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/practice/eliuds-eggs/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The position information encoding is calculated as follows:

### Decimal number on the display

16
8

### Actual eggs in the coop

Expand Down
10 changes: 10 additions & 0 deletions exercises/practice/largest-series-product/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ description = "reports zero if all spans include zero"

[5d81aaf7-4f67-4125-bf33-11493cc7eab7]
description = "rejects span longer than string length"
include = false

[0ae1ce53-d9ba-41bb-827f-2fceb64f058b]
description = "rejects span longer than string length"
reimplements = "5d81aaf7-4f67-4125-bf33-11493cc7eab7"

[06bc8b90-0c51-4c54-ac22-3ec3893a079e]
description = "reports 1 for empty string and empty product (0 span)"
Expand All @@ -49,6 +54,11 @@ include = false

[6d96c691-4374-4404-80ee-2ea8f3613dd4]
description = "rejects empty string and nonzero span"
include = false

[6cf66098-a6af-4223-aab1-26aeeefc7402]
description = "rejects empty string and nonzero span"
reimplements = "6d96c691-4374-4404-80ee-2ea8f3613dd4"

[7a38f2d6-3c35-45f6-8d6f-12e6e32d4d74]
description = "rejects invalid character in digits"
Expand Down
45 changes: 25 additions & 20 deletions exercises/practice/luhn/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions

Determine whether a credit card number is valid according to the [Luhn formula][luhn].
Determine whether a number is valid according to the [Luhn formula][luhn].

The number will be provided as a string.

Expand All @@ -10,54 +10,59 @@ Strings of length 1 or less are not valid.
Spaces are allowed in the input, but they should be stripped before checking.
All other non-digit characters are disallowed.

### Example 1: valid credit card number
## Examples

```text
4539 3195 0343 6467
```
### Valid credit card number

The first step of the Luhn algorithm is to double every second digit, starting from the right.
We will be doubling
The number to be checked is `4539 3195 0343 6467`.

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.

```text
4539 3195 0343 6467
↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ (double these)
```

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

```text
8569 6195 0383 3437
```

Then sum all of the digits:
Finally, we sum all digits.
If the sum is evenly divisible by 10, the original number is valid.

```text
8+5+6+9+6+1+9+5+0+3+8+3+3+4+3+7 = 80
8 + 5 + 6 + 9 + 6 + 1 + 9 + 5 + 0 + 3 + 8 + 3 + 3 + 4 + 3 + 7 = 80
```

If the sum is evenly divisible by 10, then the number is valid.
This number is valid!
80 is evenly divisible by 10, so number `4539 3195 0343 6467` is valid!

### Invalid Canadian SIN

The number to be checked is `066 123 468`.

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

```text
8273 1232 7352 0569
066 123 478
↑ ↑ ↑ ↑ (double these)
```

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

```text
7253 2262 5312 0539
036 226 458
```

Sum the digits
We sum the digits:

```text
7+2+5+3+2+2+6+2+5+3+1+2+0+5+3+9 = 57
0 + 3 + 6 + 2 + 2 + 6 + 4 + 5 + 8 = 36
```

57 is not evenly divisible by 10, so this number is not valid.
36 is not evenly divisible by 10, so number `066 123 478` is not valid!

[luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm
4 changes: 2 additions & 2 deletions exercises/practice/luhn/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

At the Global Verification Authority, you've just been entrusted with a critical assignment.
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.
The Luhn algorithm is a simple checksum formula used to ensure these numbers are valid and error-free.
The Luhn algorithm is a simple checksum formula used to help identify mistyped numbers.

A batch of identifiers has just arrived on your desk.
All of them must pass the Luhn test to ensure they're legitimate.
If any fail, they'll be flagged as invalid, preventing errors or fraud, such as incorrect transactions or unauthorized access.
If any fail, they'll be flagged as invalid, preventing mistakes such as incorrect transactions or failed account verifications.

Can you ensure this is done right? The integrity of many services depends on you.
2 changes: 1 addition & 1 deletion exercises/practice/phone-number/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions

Clean up user-entered phone numbers so that they can be sent SMS messages.
Clean up phone numbers so that they can be sent SMS messages.

The **North American Numbering Plan (NANP)** is a telephone numbering system used by many countries in North America like the United States, Canada or Bermuda.
All NANP-countries share the same international country code: `1`.
Expand Down
24 changes: 12 additions & 12 deletions exercises/practice/relative-distance/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Instructions

Your task is to determine the degree of separation between two individuals in a family tree.
This is similar to the pop culture idea that every Hollywood actor is [within six degrees of Kevin Bacon][six-bacons].

- You will be given an input, with all parent names and their children.
- Each name is unique, a child _can_ have one or two parents.
Expand All @@ -13,22 +14,21 @@ Your task is to determine the degree of separation between two individuals in a
Given the following family tree:

```text
┌──────────┐ ┌──────────┐ ┌───────────┐
│ Helena │ │ Erdős │ │ Shusaku │
└───┬───┬──┘ └─────┬────┘ └──────┬────┘
┌───┘ └───────┐ └──────┬──────┘
▼ ▼ ▼
┌──────────┐ ┌────────┐ ┌──────────┐
│ Isla │ │ Tariq │ │ Kevin │
└────┬─────┘ └────┬───┘ └──────────┘
▼ ▼
┌─────────┐ ┌────────┐
┌──────────┐ ┌──────────┐ ┌───────────┐
│ Helena │ │ Erdős ├─────┤ Shusaku │
└───┬───┬──┘ └─────┬────┘ └────┬──────┘
┌───┘ └───────┐ └───────┬───────┘
┌─────┴────┐ ┌────┴───┐ ┌─────┴────┐
│ Isla ├─────┤ Tariq │ │ Kevin │
└────┬─────┘ └────┬───┘ └──────────┘
│ │
┌────┴────┐ ┌────┴───┐
│ Uma │ │ Morphy │
└─────────┘ └────────┘
```

The degree of separation between Tariq and Uma is 3 (Tariq → Helena → Isla → Uma).
There's no known relationship between Isla and [Kevin][six-bacons], as there is no connection in the given data.
The degree of separation between Tariq and Uma is 2 (Tariq → Isla → Uma).
There's no known relationship between Isla and Kevin, as there is no connection in the given data.
The degree of separation between Uma and Isla is 1.

~~~~exercism/note
Expand Down