Skip to content

Commit c438ec4

Browse files
authored
Updating docs and metadata with problem-specifications (#1045)
1 parent 3988925 commit c438ec4

File tree

9 files changed

+93
-32
lines changed

9 files changed

+93
-32
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"`.
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
@@ -28,5 +28,5 @@
2828
},
2929
"blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.",
3030
"source": "The CodeRanch Cattle Drive, Assignment 6",
31-
"source_url": "https://coderanch.com/wiki/718824/Grains"
31+
"source_url": "https://web.archive.org/web/20240908084142/https://coderanch.com/wiki/718824/Grains"
3232
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
},
3232
"blurb": "Determine whether a given year is a leap year.",
3333
"source": "CodeRanch Cattle Drive, Assignment 3",
34-
"source_url": "https://coderanch.com/t/718816/Leap"
34+
"source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap"
3535
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
".meta/example.h"
2626
]
2727
},
28-
"blurb": "Given a DNA strand, return its RNA Complement Transcription.",
28+
"blurb": "Given a DNA strand, return its RNA complement.",
2929
"source": "Hyperphysics",
3030
"source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html"
3131
}

exercises/practice/saddle-points/.docs/instructions.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ Or it might have one, or even several.
1313
Here is a grid that has exactly one candidate tree.
1414

1515
```text
16-
1 2 3 4
17-
|-----------
18-
1 | 9 8 7 8
19-
2 | 5 3 2 4 <--- potential tree house at row 2, column 1, for tree with height 5
20-
3 | 6 6 7 1
16+
17+
1 2 3 4
18+
|-----------
19+
1 | 9 8 7 8
20+
→ 2 |[5] 3 2 4
21+
3 | 6 6 7 1
2122
```
2223

2324
- Row 2 has values 5, 3, 2, and 4. The largest value is 5.

exercises/practice/say/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
},
2626
"blurb": "Given a number from 0 to 999,999,999,999, spell out that number in English.",
2727
"source": "A variation on the JavaRanch CattleDrive, Assignment 4",
28-
"source_url": "https://coderanch.com/wiki/718804"
28+
"source_url": "https://web.archive.org/web/20240907035912/https://coderanch.com/wiki/718804"
2929
}

exercises/practice/sieve/.docs/instructions.md

+67-8
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,96 @@ A prime number is a number larger than 1 that is only divisible by 1 and itself.
66
For example, 2, 3, 5, 7, 11, and 13 are prime numbers.
77
By contrast, 6 is _not_ a prime number as it not only divisible by 1 and itself, but also by 2 and 3.
88

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:
1111

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).
1313
This is a prime number.
1414
2. Mark all the multiples of that prime number as **not** prime.
1515

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.
1717
At the end, all the unmarked numbers are prime.
1818

1919
~~~~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.
2223
~~~~
2324

2425
## Example
2526

2627
Let's say you're finding the primes less than or equal to 10.
2728

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+
2935
- 2 is unmarked and is therefore a prime.
3036
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+
3143
- 3 is unmarked and is therefore a prime.
3244
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+
3351
- 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+
3458
- 5 is unmarked and is therefore a prime.
3559
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+
3666
- 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+
3773
- 7 is unmarked and is therefore a prime.
74+
75+
```text
76+
2 3 [4] 5 [6] 7 [8] [9] [10]
77+
78+
```
79+
3880
- 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+
3987
- 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+
4094
- 10 is marked as "not prime", so we stop as there are no more numbers to check.
4195

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

Comments
 (0)