diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/100-doors.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/100-doors.english.md index 3eca35396b..d1ffab52d2 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/100-doors.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/100-doors.english.md @@ -6,8 +6,8 @@ challengeType: 5 ## Description
-

There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and 'toggle' the door (if the door is closed, open it; if it is open, close it). The second time, only visit every 2nd door (i.e., door #2, #4, #6, ...) and toggle it. The third time, visit every 3rd door (i.e., door #3, #6, #9, ...), etc., until you only visit the 100th door.

-

Implement a function to determine the state of the doors after the last pass. Return the final result in an array, with only the door number included in the array if it is open.

+There are 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, visit every door and 'toggle' the door (if the door is closed, open it; if it is open, close it). The second time, only visit every 2nd door (i.e., door #2, #4, #6, ...) and toggle it. The third time, visit every 3rd door (i.e., door #3, #6, #9, ...), etc., until you only visit the 100th door. +Implement a function to determine the state of the doors after the last pass. Return the final result in an array, with only the door number included in the array if it is open.
## Instructions @@ -37,7 +37,7 @@ tests:
```js -function getFinalOpenedDoors (numDoors) { +function getFinalOpenedDoors(numDoors) { // Good luck! } ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/24-game.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/24-game.english.md index 87f1b6fb67..654dc3b094 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/24-game.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/24-game.english.md @@ -170,4 +170,4 @@ function solve24(numStr) { ``` - + \ No newline at end of file diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/9-billion-names-of-god-the-integer.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/9-billion-names-of-god-the-integer.english.md index 310a9ca650..9a36ac8bf1 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/9-billion-names-of-god-the-integer.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/9-billion-names-of-god-the-integer.english.md @@ -6,15 +6,15 @@ challengeType: 5 ## Description
-

This task is a variation of the short story by Arthur C. Clarke.

-

(Solvers should be aware of the consequences of completing this task.)

-

In detail, to specify what is meant by a “name”:

-

The integer 1 has 1 name “1”.

-

The integer 2 has 2 names “1+1”, and “2”.

-

The integer 3 has 3 names “1+1+1”, “2+1”, and “3”.

-

The integer 4 has 5 names “1+1+1+1”, “2+1+1”, “2+2”, “3+1”, “4”.

-

The integer 5 has 7 names “1+1+1+1+1”, “2+1+1+1”, “2+2+1”, “3+1+1”, “3+2”, “4+1”, “5”.

-

This can be visualized in the following form:

+This task is a variation of the short story by Arthur C. Clarke. +(Solvers should be aware of the consequences of completing this task.) +In detail, to specify what is meant by a “name”: +The integer 1 has 1 name “1”. +The integer 2 has 2 names “1+1”, and “2”. +The integer 3 has 3 names “1+1+1”, “2+1”, and “3”. +The integer 4 has 5 names “1+1+1+1”, “2+1+1”, “2+2”, “3+1”, “4”. +The integer 5 has 7 names “1+1+1+1+1”, “2+1+1+1”, “2+2+1”, “3+1+1”, “3+2”, “4+1”, “5”. +This can be visualized in the following form:
           1
         1   1
@@ -23,10 +23,9 @@ challengeType: 5
   1   2   2   1   1
 1   3   3   2   1   1
 
-

Where row $n$ corresponds to integer $n$, and each column $C$ in row $m$ from left to right corresponds to the number of names beginning with $C$.

-

Optionally note that the sum of the $n$-th row $P(n)$ is the integer partition function.

-Task -

Implement a function that returns the sum of the $n$-th row.

+Where row $n$ corresponds to integer $n$, and each column $C$ in row $m$ from left to right corresponds to the number of names beginning with $C$. +Optionally note that the sum of the $n$-th row $P(n)$ is the integer partition function. +Implement a function that returns the sum of the $n$-th row.
## Instructions @@ -64,7 +63,7 @@ tests:
```js -function numberOfNames (num) { +function numberOfNames(num) { // Good luck! return true; } diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abc-problem.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abc-problem.english.md index 5cf75837f3..5502f0a812 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abc-problem.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abc-problem.english.md @@ -6,31 +6,33 @@ challengeType: 5 ## Description
-

You are given a collection of ABC blocks (e.g., childhood alphabet blocks). There are 20 blocks with two letters on each block. A complete alphabet is guaranteed amongst all sides of the blocks. The sample collection of blocks:

-

(B O)

-

(X K)

-

(D Q)

-

(C P)

-

(N A)

-

(G T)

-

(R E)

-

(T G)

-

(Q D)

-

(F S)

-

(J W)

-

(H U)

-

(V I)

-

(A N)

-

(O B)

-

(E R)

-

(F S)

-

(L Y)

-

(P C)

-

(Z M)

-

Some rules to keep in mind:

+You are given a collection of ABC blocks (e.g., childhood alphabet blocks). There are 20 blocks with two letters on each block. A complete alphabet is guaranteed amongst all sides of the blocks. The sample collection of blocks: +
+(B O)
+(X K)
+(D Q)
+(C P)
+(N A)
+(G T)
+(R E)
+(T G)
+(Q D)
+(F S)
+(J W)
+(H U)
+(V I)
+(A N)
+(O B)
+(E R)
+(F S)
+(L Y)
+(P C)
+(Z M)
+
+Some rules to keep in mind: Once a letter on a block is used, that block cannot be used again. The function should be case-insensitive. -

Implement a function that takes a string (word) and determines whether the word can be spelled with the given collection of blocks.

+Implement a function that takes a string (word) and determines whether the word can be spelled with the given collection of blocks.
## Instructions @@ -70,7 +72,7 @@ tests:
```js -function canMakeWord (word) { +function canMakeWord(word) { // Good luck! } ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abundant-deficient-and-perfect-number-classifications.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abundant-deficient-and-perfect-number-classifications.english.md index dc6284a650..f28a7a4333 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abundant-deficient-and-perfect-number-classifications.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/abundant-deficient-and-perfect-number-classifications.english.md @@ -6,15 +6,17 @@ challengeType: 5 ## Description
-

These define three classifications of positive integers based on their proper divisors.

-

Let $P(n)$ be the sum of the proper divisors of n where proper divisors are all positive integers n other than n itself.

-

If P(n) < n then n is classed as "deficient"

-

If P(n) === n then n is classed as "perfect"

-

If P(n) > n then n is classed as "abundant"

-

Example:

-

6 has proper divisors of 1, 2, and 3.

-

1 + 2 + 3 = 6, so 6 is classed as a perfect number.

-

Implement a function that calculates how many of the integers from 1 to 20,000 (inclusive) are in each of the three classes. Output the result as an array in the following format [deficient, perfect, abundant].

+These define three classifications of positive integers based on their proper divisors. +Let $P(n)$ be the sum of the proper divisors of n where proper divisors are all positive integers n other than n itself. +
+If  P(n) < n  then n is classed as deficient
+If  P(n) === n  then n is classed as perfect
+If  P(n) > n  then n is classed as abundant
+
+Example: +6 has proper divisors of 1, 2, and 3. +1 + 2 + 3 = 6, so 6 is classed as a perfect number. +Implement a function that calculates how many of the integers from 1 to 20,000 (inclusive) are in each of the three classes. Output the result as an array in the following format [deficient, perfect, abundant].
## Instructions @@ -46,7 +48,7 @@ tests:
```js -function getDPA (num) { +function getDPA(num) { // Good luck! } ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/accumulator-factory.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/accumulator-factory.english.md index cf719711cd..2d05741c00 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/accumulator-factory.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/accumulator-factory.english.md @@ -6,11 +6,11 @@ challengeType: 5 ## Description
-

Create a function that takes a single (numeric) argument and returns another function that is an accumulator. The returned accumulator function in turn also takes a single numeric argument, and returns the sum of all the numeric values passed in so far to that accumulator (including the initial value passed when the accumulator was created).

-

Rules:

-

Do not use global variables.

-

Hint:

-

Closures save outer state.

+Create a function that takes a single (numeric) argument and returns another function that is an accumulator. The returned accumulator function in turn also takes a single numeric argument, and returns the sum of all the numeric values passed in so far to that accumulator (including the initial value passed when the accumulator was created). +Rules: +Do not use global variables. +Hint: +Closures save outer state.
## Instructions @@ -42,7 +42,7 @@ tests:
```js -function accumulator (sum) { +function accumulator(sum) { // Good luck! } ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/ackermann-function.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/ackermann-function.english.md index a59a8045de..9aba6d6722 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/ackermann-function.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/ackermann-function.english.md @@ -6,15 +6,10 @@ challengeType: 5 ## Description
-

The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree.

-

The Ackermann function is usually defined as follows:

-$$A(m, n) = - \begin{cases} - n+1 & \mbox{if } m = 0 \\ - A(m-1, 1) & \mbox{if } m > 0 \mbox{ and } n = 0 \\ - A(m-1, A(m, n-1)) & \mbox{if } m > 0 \mbox{ and } n > 0. - \end{cases}$$ -

Its arguments are never negative and it always terminates. Write a function which returns the value of $A(m, n)$. Arbitrary precision is preferred (since the function grows so quickly), but not required.

+The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. +The Ackermann function is usually defined as follows: +$A(m, n) = \begin{cases} n+1 & \mbox{if } m = 0 \\ A(m-1, 1) & \mbox{if } m > 0 \mbox{ and } n = 0 \\ A(m-1, A(m, n-1)) & \mbox{if } m > 0 \mbox{ and } n > 0. \end{cases}$ +Its arguments are never negative and it always terminates. Write a function which returns the value of $A(m, n)$. Arbitrary precision is preferred (since the function grows so quickly), but not required.
## Instructions @@ -48,7 +43,7 @@ tests:
```js -function ack (m, n) { +function ack(m, n) { // Good luck! } ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md index 6d4037c0af..86b078f2ef 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md @@ -6,8 +6,8 @@ challengeType: 5 ## Description
-

Given a text file of many lines, where fields within a line are delineated by a single $ character, write a program that aligns each column of fields by ensuring that words in each column are separated by at least one space. Further, allow for each word in a column to be either left justified, right justified, or center justified within its column.

-

Use the following text to test your programs:

+Given a text file of many lines, where fields within a line are delineated by a single $ character, write a program that aligns each column of fields by ensuring that words in each column are separated by at least one space. Further, allow for each word in a column to be either left justified, right justified, or center justified within its column. +Use the following text to test your programs:
 Given$a$text$file$of$many$lines
 where$fields$within$a$line$
@@ -20,13 +20,15 @@ Further,$allow$for$each$word$in$a$column$to$be$either$left$
 justified,$right$justified
 or$center$justified$within$its$column.
 
-

Note that:

-The example input texts lines may, or may not, have trailing dollar characters. -All columns should share the same alignment. -Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task. -Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal. -The minimum space between columns should be computed from the text and not hard-coded. -It is not a requirement to add separating characters between or around columns. +Note that: +
    +
  1. The example input texts lines may, or may not, have trailing dollar characters.
  2. +
  3. All columns should share the same alignment.
  4. +
  5. Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task.
  6. +
  7. Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal.
  8. +
  9. The minimum space between columns should be computed from the text and not hard-coded.
  10. +
  11. It is not a requirement to add separating characters between or around columns.
  12. +
## Instructions @@ -71,7 +73,7 @@ const testArr = [ 'or$center$justified$within$its$column.' ]; -function formatText (input, justification) { +function formatText(input, justification) { // Good luck! } ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/amicable-pairs.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/amicable-pairs.english.md index b4431c6536..5a5ff33666 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/amicable-pairs.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/amicable-pairs.english.md @@ -7,16 +7,13 @@ challengeType: 5 ## Description
Two integers $N$ and $M$ are said to be amicable pairs if $N \neq M$ and the sum of the proper divisors of $N$ ($\mathrm{sum}(\mathrm{propDivs}(N))$) $= M$ as well as $\mathrm{sum}(\mathrm{propDivs}(M)) = N$. -Example: -1184 and 1210 are an amicable pair, with proper divisors: - 1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 and - 1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605 respectively. -Task: +Example: +1184 and 1210 are an amicable pair, with proper divisors: +
    +
  • 1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 and
  • +
  • 1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605 respectively.
  • +
Calculate and show here the Amicable pairs below 20,000 (there are eight). -Related tasks -Proper divisors -Abundant, deficient and perfect number classifications -Aliquot sequence classifications and its amicable classification.
## Instructions diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-pythagorean-means.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-pythagorean-means.english.md index bd30c31489..521f1fb0a1 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-pythagorean-means.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-pythagorean-means.english.md @@ -6,9 +6,18 @@ challengeType: 5 ## Description
-

Compute all three of the Pythagorean means of the set of integers 1 through 10 (inclusive).

Show that $A(x_1,\ldots,x_n) \geq G(x_1,\ldots,x_n) \geq H(x_1,\ldots,x_n)$ for this set of positive integers.

The most common of the three means, the arithmetic mean, is the sum of the list divided by its length: $ A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n}$The geometric mean is the $n$th root of the product of the list: $ G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} $The harmonic mean is $n$ divided by the sum of the reciprocal of each item in the list: $ H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} $ -

Assume the input is an ordered array of all inclusive numbers.

-

For the answer, please output an object in the following format:

+Compute all three of the Pythagorean means of the set of integers 1 through 10 (inclusive). +Show that $A(x_1,\ldots,x_n) \geq G(x_1,\ldots,x_n) \geq H(x_1,\ldots,x_n)$ for this set of positive integers. +
    +
  • The most common of the three means, the arithmetic mean, is the sum of the list divided by its length:
    +$ A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n}$
  • +
  • The geometric mean is the $n$th root of the product of the list:
    +$ G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} $
  • +
  • The harmonic mean is $n$ divided by the sum of the reciprocal of each item in the list:
    +$ H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} $
  • +
+Assume the input is an ordered array of all inclusive numbers. +For the answer, please output an object in the following format:
 {
   values: {