You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/practice/affine-cipher/.docs/instructions.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Where:
20
20
21
21
-`i` is the letter's index from `0` to the length of the alphabet - 1.
22
22
-`m` is the length of the alphabet.
23
-
For the Roman alphabet `m` is `26`.
23
+
For the Latin alphabet `m` is `26`.
24
24
-`a` and `b` are integers which make up the encryption key.
25
25
26
26
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]).
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.
4
4
5
5
An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`.
6
6
A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`.
7
7
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.
12
11
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"`.
Correctly determine the fewest number of coins to be given to a customer such that the sum of the coins' value would equal the correct amount of change.
3
+
Determine the fewest number of coins to give a customer so that the sum of their values equals the correct amount of change.
4
4
5
-
## For example
5
+
## Examples
6
6
7
-
- An input of 15 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) or [5, 10]
8
-
- An input of 40 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) and one quarter (25) or [5, 10, 25]
9
-
10
-
## Edge cases
11
-
12
-
- Does your algorithm work for any given set of coins?
13
-
- Can you ask for negative change?
14
-
- Can you ask for a change value smaller than the smallest coin value?
7
+
- An amount of 15 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5 and one coin of value 10, or [5, 10].
8
+
- An amount of 40 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5, one coin of value 10, and one coin of value 25, or [5, 10, 25].
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.
Copy file name to clipboardExpand all lines: exercises/practice/dominoes/.docs/instructions.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,9 @@
2
2
3
3
Make a chain of dominoes.
4
4
5
-
Compute a way to order a given set of dominoes in such a way that they form a correct domino chain (the dots on one half of a stone match the dots on the neighboring half of an adjacent stone) and that dots on the halves of the stones which don't have a neighbor (the first and last stone) match each other.
5
+
Compute a way to order a given set of domino stones so that they form a correct domino chain.
6
+
In the chain, the dots on one half of a stone must match the dots on the neighboring half of an adjacent stone.
7
+
Additionally, the dots on the halves of the stones without neighbors (the first and last stone) must match each other.
6
8
7
9
For example given the stones `[2|1]`, `[2|3]` and `[1|3]` you should compute something
8
10
like `[1|2] [2|3] [3|1]` or `[3|2] [2|1] [1|3]` or `[1|3] [3|2] [2|1]` etc, where the first and last numbers are the same.
Copy file name to clipboardExpand all lines: exercises/practice/luhn/.docs/instructions.md
+3-5
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,10 @@
1
1
# Instructions
2
2
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].
4
4
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.
6
6
7
-
The task is to check if a given string is valid.
8
-
9
-
## Validating a Number
7
+
## Validating a number
10
8
11
9
Strings of length 1 or less are not valid.
12
10
Spaces are allowed in the input, but they should be stripped before checking.
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.
Copy file name to clipboardExpand all lines: exercises/practice/sieve/.docs/instructions.md
+67-8
Original file line number
Diff line number
Diff line change
@@ -6,37 +6,96 @@ A prime number is a number larger than 1 that is only divisible by 1 and itself.
6
6
For example, 2, 3, 5, 7, 11, and 13 are prime numbers.
7
7
By contrast, 6 is _not_ a prime number as it not only divisible by 1 and itself, but also by 2 and 3.
8
8
9
-
To use the Sieve of Eratosthenes, you first create a list of all the numbers between 2 and your given number.
10
-
Then you repeat the following steps:
9
+
To use the Sieve of Eratosthenes, first, write out all the numbers from 2 up to and including your given number.
10
+
Then, follow these steps:
11
11
12
-
1. Find the next unmarked number in your list (skipping over marked numbers).
12
+
1. Find the next unmarked number (skipping over marked numbers).
13
13
This is a prime number.
14
14
2. Mark all the multiples of that prime number as **not** prime.
15
15
16
-
You keep repeating these steps until you've gone through every number in your list.
16
+
Repeat the steps until you've gone through every number.
17
17
At the end, all the unmarked numbers are prime.
18
18
19
19
~~~~exercism/note
20
-
The tests don't check that you've implemented the algorithm, only that you've come up with the correct list of primes.
21
-
To check you are implementing the Sieve correctly, a good first test is to check that you do not use division or remainder operations.
20
+
The Sieve of Eratosthenes marks off multiples of each prime using addition (repeatedly adding the prime) or multiplication (directly computing its multiples), rather than checking each number for divisibility.
21
+
22
+
The tests don't check that you've implemented the algorithm, only that you've come up with the correct primes.
22
23
~~~~
23
24
24
25
## Example
25
26
26
27
Let's say you're finding the primes less than or equal to 10.
27
28
28
-
- List out 2, 3, 4, 5, 6, 7, 8, 9, 10, leaving them all unmarked.
29
+
- Write out 2, 3, 4, 5, 6, 7, 8, 9, 10, leaving them all unmarked.
30
+
31
+
```text
32
+
2 3 4 5 6 7 8 9 10
33
+
```
34
+
29
35
- 2 is unmarked and is therefore a prime.
30
36
Mark 4, 6, 8 and 10 as "not prime".
37
+
38
+
```text
39
+
2 3 [4] 5 [6] 7 [8] 9 [10]
40
+
↑
41
+
```
42
+
31
43
- 3 is unmarked and is therefore a prime.
32
44
Mark 6 and 9 as not prime _(marking 6 is optional - as it's already been marked)_.
45
+
46
+
```text
47
+
2 3 [4] 5 [6] 7 [8] [9] [10]
48
+
↑
49
+
```
50
+
33
51
- 4 is marked as "not prime", so we skip over it.
52
+
53
+
```text
54
+
2 3 [4] 5 [6] 7 [8] [9] [10]
55
+
↑
56
+
```
57
+
34
58
- 5 is unmarked and is therefore a prime.
35
59
Mark 10 as not prime _(optional - as it's already been marked)_.
60
+
61
+
```text
62
+
2 3 [4] 5 [6] 7 [8] [9] [10]
63
+
↑
64
+
```
65
+
36
66
- 6 is marked as "not prime", so we skip over it.
67
+
68
+
```text
69
+
2 3 [4] 5 [6] 7 [8] [9] [10]
70
+
↑
71
+
```
72
+
37
73
- 7 is unmarked and is therefore a prime.
74
+
75
+
```text
76
+
2 3 [4] 5 [6] 7 [8] [9] [10]
77
+
↑
78
+
```
79
+
38
80
- 8 is marked as "not prime", so we skip over it.
81
+
82
+
```text
83
+
2 3 [4] 5 [6] 7 [8] [9] [10]
84
+
↑
85
+
```
86
+
39
87
- 9 is marked as "not prime", so we skip over it.
88
+
89
+
```text
90
+
2 3 [4] 5 [6] 7 [8] [9] [10]
91
+
↑
92
+
```
93
+
40
94
- 10 is marked as "not prime", so we stop as there are no more numbers to check.
41
95
42
-
You've examined all numbers and found 2, 3, 5, and 7 are still unmarked, which means they're the primes less than or equal to 10.
96
+
```text
97
+
2 3 [4] 5 [6] 7 [8] [9] [10]
98
+
↑
99
+
```
100
+
101
+
You've examined all the numbers and found that 2, 3, 5, and 7 are still unmarked, meaning they're the primes less than or equal to 10.
0 commit comments