Skip to content

Commit bf8a4c3

Browse files
authored
Sync docs & metadata (#2869)
1 parent 9dc8494 commit bf8a4c3

File tree

13 files changed

+134
-44
lines changed

13 files changed

+134
-44
lines changed
Lines changed: 89 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,100 @@
11
# Instructions
22

3-
A complex number is a number in the form `a + b * i` where `a` and `b` are real and `i` satisfies `i^2 = -1`.
3+
A **complex number** is expressed in the form `z = a + b * i`, where:
44

5-
`a` is called the real part and `b` is called the imaginary part of `z`.
6-
The conjugate of the number `a + b * i` is the number `a - b * i`.
7-
The absolute value of a complex number `z = a + b * i` is a real number `|z| = sqrt(a^2 + b^2)`. The square of the absolute value `|z|^2` is the result of multiplication of `z` by its complex conjugate.
5+
- `a` is the **real part** (a real number),
86

9-
The sum/difference of two complex numbers involves adding/subtracting their real and imaginary parts separately:
10-
`(a + i * b) + (c + i * d) = (a + c) + (b + d) * i`,
11-
`(a + i * b) - (c + i * d) = (a - c) + (b - d) * i`.
7+
- `b` is the **imaginary part** (also a real number), and
128

13-
Multiplication result is by definition
14-
`(a + i * b) * (c + i * d) = (a * c - b * d) + (b * c + a * d) * i`.
9+
- `i` is the **imaginary unit** satisfying `i^2 = -1`.
1510

16-
The reciprocal of a non-zero complex number is
17-
`1 / (a + i * b) = a/(a^2 + b^2) - b/(a^2 + b^2) * i`.
11+
## Operations on Complex Numbers
1812

19-
Dividing a complex number `a + i * b` by another `c + i * d` gives:
20-
`(a + i * b) / (c + i * d) = (a * c + b * d)/(c^2 + d^2) + (b * c - a * d)/(c^2 + d^2) * i`.
13+
### Conjugate
2114

22-
Raising e to a complex exponent can be expressed as `e^(a + i * b) = e^a * e^(i * b)`, the last term of which is given by Euler's formula `e^(i * b) = cos(b) + i * sin(b)`.
15+
The conjugate of the complex number `z = a + b * i` is given by:
2316

24-
Implement the following operations:
17+
```text
18+
zc = a - b * i
19+
```
2520

26-
- addition, subtraction, multiplication and division of two complex numbers,
27-
- conjugate, absolute value, exponent of a given complex number.
21+
### Absolute Value
2822

29-
Assume the programming language you are using does not have an implementation of complex numbers.
23+
The absolute value (or modulus) of `z` is defined as:
24+
25+
```text
26+
|z| = sqrt(a^2 + b^2)
27+
```
28+
29+
The square of the absolute value is computed as the product of `z` and its conjugate `zc`:
30+
31+
```text
32+
|z|^2 = z * zc = a^2 + b^2
33+
```
34+
35+
### Addition
36+
37+
The sum of two complex numbers `z1 = a + b * i` and `z2 = c + d * i` is computed by adding their real and imaginary parts separately:
38+
39+
```text
40+
z1 + z2 = (a + b * i) + (c + d * i)
41+
= (a + c) + (b + d) * i
42+
```
43+
44+
### Subtraction
45+
46+
The difference of two complex numbers is obtained by subtracting their respective parts:
47+
48+
```text
49+
z1 - z2 = (a + b * i) - (c + d * i)
50+
= (a - c) + (b - d) * i
51+
```
52+
53+
### Multiplication
54+
55+
The product of two complex numbers is defined as:
56+
57+
```text
58+
z1 * z2 = (a + b * i) * (c + d * i)
59+
= (a * c - b * d) + (b * c + a * d) * i
60+
```
61+
62+
### Reciprocal
63+
64+
The reciprocal of a non-zero complex number is given by:
65+
66+
```text
67+
1 / z = 1 / (a + b * i)
68+
= a / (a^2 + b^2) - b / (a^2 + b^2) * i
69+
```
70+
71+
### Division
72+
73+
The division of one complex number by another is given by:
74+
75+
```text
76+
z1 / z2 = z1 * (1 / z2)
77+
= (a + b * i) / (c + d * i)
78+
= (a * c + b * d) / (c^2 + d^2) + (b * c - a * d) / (c^2 + d^2) * i
79+
```
80+
81+
### Exponentiation
82+
83+
Raising _e_ (the base of the natural logarithm) to a complex exponent can be expressed using Euler's formula:
84+
85+
```text
86+
e^(a + b * i) = e^a * e^(b * i)
87+
= e^a * (cos(b) + i * sin(b))
88+
```
89+
90+
## Implementation Requirements
91+
92+
Given that you should not use built-in support for complex numbers, implement the following operations:
93+
94+
- **addition** of two complex numbers
95+
- **subtraction** of two complex numbers
96+
- **multiplication** of two complex numbers
97+
- **division** of two complex numbers
98+
- **conjugate** of a complex number
99+
- **absolute value** of a complex number
100+
- **exponentiation** of _e_ (the base of the natural logarithm) to a complex number

exercises/practice/dot-dsl/.meta/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"editor": [
1717
"src/main/java/Node.java",
1818
"src/main/java/Edge.java"
19+
],
20+
"invalidator": [
21+
"build.gradle"
1922
]
2023
},
2124
"blurb": "Write a Domain Specific Language similar to the Graphviz dot language.",

exercises/practice/hamming/.docs/instructions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Instructions
22

3-
Calculate the Hamming Distance between two DNA strands.
3+
Calculate the Hamming distance between two DNA strands.
44

55
Your body is made up of cells that contain DNA.
66
Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells.
@@ -9,18 +9,18 @@ In fact, the average human body experiences about 10 quadrillion cell divisions
99
When cells divide, their DNA replicates too.
1010
Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information.
1111
If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred.
12-
This is known as the "Hamming Distance".
12+
This is known as the "Hamming distance".
1313

14-
We read DNA using the letters C,A,G and T.
14+
We read DNA using the letters C, A, G and T.
1515
Two strands might look like this:
1616

1717
GAGCCTACTAACGGGAT
1818
CATCGTAATGACGGCCT
1919
^ ^ ^ ^ ^ ^^
2020

21-
They have 7 differences, and therefore the Hamming Distance is 7.
21+
They have 7 differences, and therefore the Hamming distance is 7.
2222

23-
The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :)
23+
The Hamming distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :)
2424

2525
## Implementation notes
2626

exercises/practice/hamming/.meta/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"build.gradle"
4444
]
4545
},
46-
"blurb": "Calculate the Hamming difference between two DNA strands.",
46+
"blurb": "Calculate the Hamming distance between two DNA strands.",
4747
"source": "The Calculating Point Mutations problem at Rosalind",
4848
"source_url": "https://rosalind.info/problems/hamm/"
4949
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ The first step of the Luhn algorithm is to double every second digit, starting f
2222
We will be doubling
2323

2424
```text
25-
4_3_ 3_9_ 0_4_ 6_6_
25+
4539 3195 0343 6467
26+
↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ (double these)
2627
```
2728

2829
If doubling the number results in a number greater than 9 then subtract 9 from the product.

exercises/practice/pov/.meta/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
},
1919
"blurb": "Reparent a graph on a selected node.",
2020
"source": "Adaptation of exercise from 4clojure",
21-
"source_url": "https://www.4clojure.com/"
21+
"source_url": "https://github.com/oxalorg/4ever-clojure"
2222
}

exercises/practice/protein-translation/.docs/instructions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
Translate RNA sequences into proteins.
44

5-
RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so:
5+
RNA can be broken into three-nucleotide sequences called codons, and then translated to a protein like so:
66

77
RNA: `"AUGUUUUCU"` => translates to
88

99
Codons: `"AUG", "UUU", "UCU"`
10-
=> which become a polypeptide with the following sequence =>
10+
=> which become a protein with the following sequence =>
1111

1212
Protein: `"Methionine", "Phenylalanine", "Serine"`
1313

@@ -27,9 +27,9 @@ Protein: `"Methionine", "Phenylalanine", "Serine"`
2727

2828
Note the stop codon `"UAA"` terminates the translation and the final methionine is not translated into the protein sequence.
2929

30-
Below are the codons and resulting Amino Acids needed for the exercise.
30+
Below are the codons and resulting amino acids needed for the exercise.
3131

32-
| Codon | Protein |
32+
| Codon | Amino Acid |
3333
| :----------------- | :------------ |
3434
| AUG | Methionine |
3535
| UUU, UUC | Phenylalanine |

exercises/practice/pythagorean-triplet/.meta/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"build.gradle"
3737
]
3838
},
39-
"blurb": "There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the triplet.",
40-
"source": "Problem 9 at Project Euler",
39+
"blurb": "Given an integer N, find all Pythagorean triplets for which a + b + c = N.",
40+
"source": "A variation of Problem 9 from Project Euler",
4141
"source_url": "https://projecteuler.net/problem=9"
4242
}

exercises/practice/rna-transcription/.docs/instructions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Instructions
22

3-
Your task is determine the RNA complement of a given DNA sequence.
3+
Your task is to determine the RNA complement of a given DNA sequence.
44

55
Both DNA and RNA strands are a sequence of nucleotides.
66

7-
The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**) and thymine (**T**).
7+
The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**), and thymine (**T**).
88

9-
The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**) and uracil (**U**).
9+
The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**), and uracil (**U**).
1010

1111
Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement:
1212

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Instructions
22

3-
Given a natural radicand, return its square root.
3+
Your task is to calculate the square root of a given number.
44

5-
Note that the term "radicand" refers to the number for which the root is to be determined.
6-
That is, it is the number under the root symbol.
5+
- Try to avoid using the pre-existing math libraries of your language.
6+
- As input you'll be given a positive whole number, i.e. 1, 2, 3, 4…
7+
- You are only required to handle cases where the result is a positive whole number.
78

8-
Check out the Wikipedia pages on [square root][square-root] and [methods of computing square roots][computing-square-roots].
9+
Some potential approaches:
910

10-
Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up).
11+
- Linear or binary search for a number that gives the input number when squared.
12+
- Successive approximation using Newton's or Heron's method.
13+
- Calculating one digit at a time or one bit at a time.
1114

12-
[square-root]: https://en.wikipedia.org/wiki/Square_root
15+
You can check out the Wikipedia pages on [integer square root][integer-square-root] and [methods of computing square roots][computing-square-roots] to help with choosing a method of calculation.
16+
17+
[integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root
1318
[computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Introduction
2+
3+
We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target.
4+
5+
As the first step in our calculation, we take a target number and find its square root (that is, the number that when multiplied by itself equals the target number).
6+
7+
The journey will be very long.
8+
To make the batteries last as long as possible, we had to make our rocket's onboard computer very power efficient.
9+
Unfortunately that means that we can't rely on fancy math libraries and functions, as they use more power.
10+
Instead we want to implement our own square root calculation.

exercises/practice/state-of-tic-tac-toe/.docs/instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
In this exercise, you're going to implement a program that determines the state of a [tic-tac-toe][] game.
44
(_You may also know the game as "noughts and crosses" or "Xs and Os"._)
55

6-
The games is played on a 3×3 grid.
6+
The game is played on a 3×3 grid.
77
Players take turns to place `X`s and `O`s on the grid.
88
The game ends when one player has won by placing three of marks in a row, column, or along a diagonal of the grid, or when the entire grid is filled up.
99

exercises/practice/sublist/.docs/instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Given any two lists `A` and `B`, determine if:
88
- None of the above is true, thus lists `A` and `B` are unequal
99

1010
Specifically, list `A` is equal to list `B` if both lists have the same values in the same order.
11-
List `A` is a superlist of `B` if `A` contains a sub-sequence of values equal to `B`.
12-
List `A` is a sublist of `B` if `B` contains a sub-sequence of values equal to `A`.
11+
List `A` is a superlist of `B` if `A` contains a contiguous sub-sequence of values equal to `B`.
12+
List `A` is a sublist of `B` if `B` contains a contiguous sub-sequence of values equal to `A`.
1313

1414
Examples:
1515

0 commit comments

Comments
 (0)