diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hailstone-sequence.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hailstone-sequence.english.md
index 6b145fa56c..f4ddc4cda0 100644
--- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hailstone-sequence.english.md
+++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hailstone-sequence.english.md
@@ -6,21 +6,27 @@ challengeType: 5
## Description
The Hailstone sequence of numbers can be generated from a starting positive integer, n by: The (unproven) Collatz conjecture is that the hailstone sequence for any starting number always terminates. The hailstone sequence is also known as hailstone numbers (because the values are usually subject to multiple descents and ascents like hailstones in a cloud), or as the Collatz sequence. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. Implement a function that returns true if the number is happy, or false if not. = n/2
- If n is odd then the next n of the sequence = (3 * n) + 1
27, 82, 41, 124
and ending with 8, 4, 2, 1
-Show the number less than 100,000 which has the longest hailstone sequence together with that sequence's length. (But don't show the actual sequence!)See also:
- xkcd (humourous).
+The Hailstone sequence of numbers can be generated from a starting positive integer, n by:
+
+
+The (unproven) Collatz conjecture is that the hailstone sequence for any starting number always terminates.
+The hailstone sequence is also known as hailstone numbers (because the values are usually subject to multiple descents and ascents like hailstones in a cloud), or as the Collatz sequence.
= n/2
= (3 * n) + 1
+
+See also:
+27, 82, 41, 124
and ending with 8, 4, 2, 1
+
The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits.
For example, 42 is a Harshad number as 42 is divisible by (4 + 2) without remainder.
+The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits. +For example, 42 is a Harshad number as 42 is divisible by (4 + 2) without remainder. Assume that the series is defined as the numbers in increasing order. -Task: -Implement a function to generate successive members of the Harshad sequence.
Use it to list the first twenty members of the sequence and list the first Harshad number greater than 1000.
Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values)
-Related task: - Associative arrays/Creation +Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values). +Related task: +An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm.
-Implement the "hash join" algorithm, and demonstrate that it passes the test-case listed below.
You should represent the tables as data structures that feel natural in your programming language.
-The "hash join" algorithm consists of two steps:
-Hash phase: Create a multimap from one of the two tables, mapping from each join column value to all the rows that contain it. - The multimap must support hash-based lookup which scales better than a simple linear search, because that's the whole point of this algorithm. - Ideally we should create the multimap for the smaller table, thus minimizing its creation time and memory size. -Join phase: Scan the other table, and find matching rows by looking in the multimap created before. -In pseudo-code, the algorithm could be expressed as follows:
+An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. +The "hash join" algorithm consists of two steps: +-let A = the first input table (or ideally, the larger one) -let B = the second input table (or ideally, the smaller one) -let jA = the join column ID of table A -let jB = the join column ID of table B -let MB = a multimap for mapping from single values to multiple rows of table B (starts out empty) -let C = the output table (starts out empty) -for each row b in table B: - place b in multimap MB under key b(jB) -for each row a in table A: - for each row b in multimap MB under key a(jA): - let c = the concatenation of row a and row b - place row c in table C +let A = the first input table (or ideally, the larger one) +let B = the second input table (or ideally, the smaller one) +let jA = the join column ID of table A +let jB = the join column ID of table B +let MB = a multimap for mapping from single values to multiple rows of table B (starts out empty) +let C = the output table (starts out empty) +for each row b in table B: + place b in multimap MB under key b(jB) +for each row a in table A: + for each row b in multimap MB under key a(jA): + let c = the concatenation of row a and row b + place row c in table C-Test-case -
Input
+@@ -107,13 +114,13 @@ Test-case |
Output
+A.Age | -A.Name | -B.Character | -B.Nemesis + | A_age | +A_name | +B_character | +B_nemesis |
---|---|---|---|---|---|---|---|
27 | @@ -157,13 +164,7 @@ Test-caseAlan | Zombies |
The order of the rows in the output table is not significant.
-If you're using numerically indexed arrays to represent table rows (rather than referring to columns by name), you could represent the output rows in the form [[27, "Jonah"], ["Jonah", "Whales"]]
.
Hero's formula for the area of a triangle given the length of its three sides a, b, and c is given by:
$$A = \sqrt{s(s-a)(s-b)(s-c)},$$
where s is half the perimeter of the triangle; that is,
$$s=\frac{a+b+c}{2}.$$
-Heronian triangles are triangles whose sides and area are all integers.
-An example is the triangle with sides 3, 4, 5 whose area is 6 (and whose perimeter is 12).
-Note that any triangle whose sides are all an integer multiple of 3, 4, 5; such as 6, 8, 10, will also be a Heronian triangle.
Define a Primitive Heronian triangle as a Heronian triangle where the greatest common divisor
-of all three sides is 1 (unity).
This will exclude, for example, triangle 6, 8, 10.
-Task: -Implement a function based on Hero's formula that returns the first nth
ordered triangles in an array of arrays.
nth
ordered triangles in an array of arrays.
These two sequences of positive integers are defined as:
-$$R(1)=1\ ;\ S(1)=2 \\R(n)=R(n-1)+S(n-1), \quad n>1.$$
-The sequence $S(n)$ is further defined as the sequence of positive integers not present in $R(n)$.
Sequence $R$ starts:
-1, 3, 7, 12, 18, ...
-Sequence $S$ starts:
-2, 4, 5, 6, 8, ...
-Task: -Create two functions named ffr and ffs that when given n return R(n) or S(n) respectively.(Note that R(1) = 1 and S(1) = 2 to avoid off-by-one errors). -No maximum value for n should be assumed. -Sloane's A005228 and A030124. -Wolfram MathWorld -Wikipedia: Hofstadter Figure-Figure sequences. +These two sequences of positive integers are defined as: +$R(1)=1\ ;\ S(1)=2 \\R(n)=R(n-1)+S(n-1), \quad n>1.$ +The sequence $S(n)$ is further defined as the sequence of positive integers not present in $R(n)$. +Sequence $R$ starts: +1, 3, 7, 12, 18, ...+Sequence $S$ starts: +
2, 4, 5, 6, 8, ...
The Hofstadter Q sequence is defined as:
-$Q(1)=Q(2)=1, \\ Q(n)=Q\big(n-Q(n-1)\big)+Q\big(n-Q(n-2)), \quad n>2.$
-It is defined like the Fibonacci sequence, but whereas the next term in the Fibonacci sequence is the sum of the previous two terms, in the Q sequence the previous two terms tell you how far to go back in the Q sequence to find the two numbers to sum to make the next term of the sequence.
-Task: -Implement the Hofstadter Q Sequence equation into JavaScript +The Hofstadter Q sequence is defined as: +$Q(1)=Q(2)=1, \\ Q(n)=Q\big(n-Q(n-1)\big)+Q\big(n-Q(n-2)), \quad n>2.$ +It is defined like the Fibonacci sequence, but whereas the next term in the Fibonacci sequence is the sum of the previous two terms, in the Q sequence the previous two terms tell you how far to go back in the Q sequence to find the two numbers to sum to make the next term of the sequence.n
, and return an integer.