fix(challenges): Fixed formatting for numbered and challenges starting with A

This commit is contained in:
Kris Koishigawa
2019-02-24 19:04:29 +09:00
committed by mrugesh
parent 81a0c0c8e0
commit 201c383148
10 changed files with 96 additions and 90 deletions

View File

@ -6,8 +6,8 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>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.</p> 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.
<p>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.</p> 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.
</section> </section>
## Instructions ## Instructions
@ -37,7 +37,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function getFinalOpenedDoors (numDoors) { function getFinalOpenedDoors(numDoors) {
// Good luck! // Good luck!
} }
``` ```

View File

@ -170,4 +170,4 @@ function solve24(numStr) {
``` ```
</section> </section>

View File

@ -6,15 +6,15 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>This task is a variation of the <a href="https://en.wikipedia.org/wiki/The Nine Billion Names of God#Plot_summary" title="wp: The Nine Billion Names of God#Plot_summary">short story by Arthur C. Clarke</a>.</p> This task is a variation of the <a href="https://en.wikipedia.org/wiki/The Nine Billion Names of God#Plot_summary" title="wp: The Nine Billion Names of God#Plot_summary">short story by Arthur C. Clarke</a>.
<p>(Solvers should be aware of the consequences of completing this task.)</p> (Solvers should be aware of the consequences of completing this task.)
<p>In detail, to specify what is meant by a “name”:</p> In detail, to specify what is meant by a “name”:
<p>The integer 1 has 1 name “1”.</p> The integer 1 has 1 name “1”.
<p>The integer 2 has 2 names “1+1”, and “2”.</p> The integer 2 has 2 names “1+1”, and “2”.
<p>The integer 3 has 3 names “1+1+1”, “2+1”, and “3”.</p> The integer 3 has 3 names “1+1+1”, “2+1”, and “3”.
<p>The integer 4 has 5 names “1+1+1+1”, “2+1+1”, “2+2”, “3+1”, “4”.</p> The integer 4 has 5 names “1+1+1+1”, “2+1+1”, “2+2”, “3+1”, “4”.
<p>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”.</p> 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”.
<p>This can be visualized in the following form:</p> This can be visualized in the following form:
<pre> <pre>
1 1
1 1 1 1
@ -23,10 +23,9 @@ challengeType: 5
1 2 2 1 1 1 2 2 1 1
1 3 3 2 1 1 1 3 3 2 1 1
</pre> </pre>
<p>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$.</p> 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$.
<p>Optionally note that the sum of the $n$-th row $P(n)$ is the <a href="http://mathworld.wolfram.com/PartitionFunctionP.html" title="link: http://mathworld.wolfram.com/PartitionFunctionP.html">integer partition function</a>.</p> Optionally note that the sum of the $n$-th row $P(n)$ is the <a href="http://mathworld.wolfram.com/PartitionFunctionP.html" title="link: http://mathworld.wolfram.com/PartitionFunctionP.html">integer partition function</a>.
Task Implement a function that returns the sum of the $n$-th row.
<p>Implement a function that returns the sum of the $n$-th row.</p>
</section> </section>
## Instructions ## Instructions
@ -64,7 +63,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function numberOfNames (num) { function numberOfNames(num) {
// Good luck! // Good luck!
return true; return true;
} }

View File

@ -6,31 +6,33 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>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:</p> 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:
<p>(B O)</p> <pre>
<p>(X K)</p> (B O)
<p>(D Q)</p> (X K)
<p>(C P)</p> (D Q)
<p>(N A)</p> (C P)
<p>(G T)</p> (N A)
<p>(R E)</p> (G T)
<p>(T G)</p> (R E)
<p>(Q D)</p> (T G)
<p>(F S)</p> (Q D)
<p>(J W)</p> (F S)
<p>(H U)</p> (J W)
<p>(V I)</p> (H U)
<p>(A N)</p> (V I)
<p>(O B)</p> (A N)
<p>(E R)</p> (O B)
<p>(F S)</p> (E R)
<p>(L Y)</p> (F S)
<p>(P C)</p> (L Y)
<p>(Z M)</p> (P C)
<p>Some rules to keep in mind:</p> (Z M)
</pre>
Some rules to keep in mind:
Once a letter on a block is used, that block cannot be used again. Once a letter on a block is used, that block cannot be used again.
The function should be case-insensitive. The function should be case-insensitive.
<p>Implement a function that takes a string (word) and determines whether the word can be spelled with the given collection of blocks.</p> Implement a function that takes a string (word) and determines whether the word can be spelled with the given collection of blocks.
</section> </section>
## Instructions ## Instructions
@ -70,7 +72,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function canMakeWord (word) { function canMakeWord(word) {
// Good luck! // Good luck!
} }
``` ```

View File

@ -6,15 +6,17 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>These define three classifications of positive integers based on their <a href="http://rosettacode.org/wiki/Proper divisors" title="Proper divisors">proper divisors</a>.</p> These define three classifications of positive integers based on their <a href="http://rosettacode.org/wiki/Proper divisors" title="Proper divisors">proper divisors</a>.
<p>Let $P(n)$ be the sum of the proper divisors of n where proper divisors are all positive integers n other than n itself.</p> Let $P(n)$ be the sum of the proper divisors of <b>n</b> where proper divisors are all positive integers <b>n</b> other than <b>n</b> itself.
<p>If <code>P(n) < n</code> then n is classed as "deficient"</p> <pre>
<p>If <code>P(n) === n</code> then n is classed as "perfect"</p> If <code style='border: 1px solid #ddd;'> P(n) < n </code> then <b>n</b> is classed as <b>deficient</b>
<p>If <code>P(n) > n</code> then n is classed as "abundant"</p> If <code style='border: 1px solid #ddd;'> P(n) === n </code> then <b>n</b> is classed as <b>perfect</b>
<p>Example:</p> If <code style='border: 1px solid #ddd;'> P(n) > n </code> then <b>n</b> is classed as <b>abundant</b>
<p>6 has proper divisors of 1, 2, and 3.</p> </pre>
<p>1 + 2 + 3 = 6, so 6 is classed as a perfect number.</p> Example:
<p>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 <code>[deficient, perfect, abundant]</code>.</p> <b>6</b> has proper divisors of <b>1</b>, <b>2</b>, and <b>3</b>.
<b>1 + 2 + 3 = 6</b>, so <b>6</b> is classed as a perfect number.
Implement a function that calculates how many of the integers from <b>1</b> to <b>20,000</b> (inclusive) are in each of the three classes. Output the result as an array in the following format <code>[deficient, perfect, abundant]</code>.
</section> </section>
## Instructions ## Instructions
@ -46,7 +48,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function getDPA (num) { function getDPA(num) {
// Good luck! // Good luck!
} }
``` ```

View File

@ -6,11 +6,11 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>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).</p> 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).
<p>Rules:</p> <b>Rules:</b>
<p>Do not use global variables.</p> Do not use global variables.
<p>Hint:</p> <b>Hint:</b>
<p>Closures save outer state.</p> Closures save outer state.
</section> </section>
## Instructions ## Instructions
@ -42,7 +42,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function accumulator (sum) { function accumulator(sum) {
// Good luck! // Good luck!
} }
``` ```

View File

@ -6,15 +6,10 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>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.</p> 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.
<p>The Ackermann function is usually defined as follows:</p> The Ackermann function is usually defined as follows:
$$A(m, n) = $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}$
\begin{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.
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}$$
<p>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.</p>
</section> </section>
## Instructions ## Instructions
@ -48,7 +43,7 @@ tests:
<div id='js-seed'> <div id='js-seed'>
```js ```js
function ack (m, n) { function ack(m, n) {
// Good luck! // Good luck!
} }
``` ```

View File

@ -6,8 +6,8 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p>Given a text file of many lines, where fields within a line are delineated by a single <code>$</code> 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.</p> Given a text file of many lines, where fields within a line are delineated by a single <code>$</code> 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.
<p>Use the following text to test your programs:</p> Use the following text to test your programs:
<pre> <pre>
Given$a$text$file$of$many$lines Given$a$text$file$of$many$lines
where$fields$within$a$line$ where$fields$within$a$line$
@ -20,13 +20,15 @@ Further,$allow$for$each$word$in$a$column$to$be$either$left$
justified,$right$justified justified,$right$justified
or$center$justified$within$its$column. or$center$justified$within$its$column.
</pre> </pre>
<p>Note that:</p> Note that:
The example input texts lines may, or may not, have trailing dollar characters. <ol>
All columns should share the same alignment. <li>The example input texts lines may, or may not, have trailing dollar characters.</li>
Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task. <li>All columns should share the same alignment.</li>
Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal. <li>Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task.</li>
The minimum space between columns should be computed from the text and not hard-coded. <li>Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal.</li>
It is not a requirement to add separating characters between or around columns. <li>The minimum space between columns should be computed from the text and not hard-coded.</li>
<li>It is not a requirement to add separating characters between or around columns.</li>
</ol>
</section> </section>
## Instructions ## Instructions
@ -71,7 +73,7 @@ const testArr = [
'or$center$justified$within$its$column.' 'or$center$justified$within$its$column.'
]; ];
function formatText (input, justification) { function formatText(input, justification) {
// Good luck! // Good luck!
} }
``` ```

View File

@ -7,16 +7,13 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
Two integers $N$ and $M$ are said to be <a href="https://en.wikipedia.org/wiki/Amicable numbers" title="wp: Amicable numbers">amicable pairs</a> if $N \neq M$ and the sum of the <a href="http://rosettacode.org/wiki/Proper divisors" title="Proper divisors">proper divisors</a> of $N$ ($\mathrm{sum}(\mathrm{propDivs}(N))$) $= M$ as well as $\mathrm{sum}(\mathrm{propDivs}(M)) = N$. Two integers $N$ and $M$ are said to be <a href="https://en.wikipedia.org/wiki/Amicable numbers" title="wp: Amicable numbers">amicable pairs</a> if $N \neq M$ and the sum of the <a href="http://rosettacode.org/wiki/Proper divisors" title="Proper divisors">proper divisors</a> of $N$ ($\mathrm{sum}(\mathrm{propDivs}(N))$) $= M$ as well as $\mathrm{sum}(\mathrm{propDivs}(M)) = N$.
Example: <b>Example:</b>
1184 and 1210 are an amicable pair, with proper divisors: <b>1184</b> and <b>1210</b> are an amicable pair, with proper divisors:
1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 and <ul>
1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605 respectively. <li>1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 and</li>
Task: <li>1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605 respectively.</li>
</ul>
Calculate and show here the Amicable pairs below 20,000 (there are eight). Calculate and show here the Amicable pairs below 20,000 (there are eight).
Related tasks
<a href="http://rosettacode.org/wiki/Proper divisors" title="Proper divisors">Proper divisors</a>
<a href="http://rosettacode.org/wiki/Abundant, deficient and perfect number classifications" title="Abundant, deficient and perfect number classifications">Abundant, deficient and perfect number classifications</a>
<a href="http://rosettacode.org/wiki/Aliquot sequence classifications" title="Aliquot sequence classifications">Aliquot sequence classifications</a> and its amicable classification.
</section> </section>
## Instructions ## Instructions

View File

@ -6,9 +6,18 @@ challengeType: 5
## Description ## Description
<section id='description'> <section id='description'>
<p class='rosetta__paragraph'>Compute all three of the <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Pythagorean means' title='wp: Pythagorean means'>Pythagorean means</a> of the set of integers <big>1</big> through <big>10</big> (inclusive).</p><p class='rosetta__paragraph'>Show that <big>$A(x_1,\ldots,x_n) \geq G(x_1,\ldots,x_n) \geq H(x_1,\ldots,x_n)$</big> for this set of positive integers.</p> The most common of the three means, the <a class='rosetta__link--rosetta' href='http://rosettacode.org/wiki/Averages/Arithmetic mean' title='Averages/Arithmetic mean'>arithmetic mean</a>, is the sum of the list divided by its length: <big>$ A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n}$</big>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Geometric mean' title='wp: Geometric mean'>geometric mean</a> is the $n$th root of the product of the list: <big>$ G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} $</big>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Harmonic mean' title='wp: Harmonic mean'>harmonic mean</a> is $n$ divided by the sum of the reciprocal of each item in the list: <big>$ H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} $</big> Compute all three of the <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Pythagorean means' title='wp: Pythagorean means'>Pythagorean means</a> of the set of integers <big>1</big> through <big>10</big> (inclusive).
<p class='rosetta__paragraph'>Assume the input is an ordered array of all inclusive numbers.</p> Show that <big>$A(x_1,\ldots,x_n) \geq G(x_1,\ldots,x_n) \geq H(x_1,\ldots,x_n)$</big> for this set of positive integers.
<p class='rosetta__paragraph'>For the answer, please output an object in the following format:</p> <ul>
<li>The most common of the three means, the <a class='rosetta__link--rosetta' href='http://rosettacode.org/wiki/Averages/Arithmetic mean' title='Averages/Arithmetic mean'>arithmetic mean</a>, is the sum of the list divided by its length:<br>
<big>$ A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n}$</big></li>
<li>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Geometric mean' title='wp: Geometric mean'>geometric mean</a> is the $n$th root of the product of the list:<br>
<big>$ G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} $</big></li>
<li>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Harmonic mean' title='wp: Harmonic mean'>harmonic mean</a> is $n$ divided by the sum of the reciprocal of each item in the list:<br>
<big>$ H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} $</big></li>
</ul>
Assume the input is an ordered array of all inclusive numbers.
For the answer, please output an object in the following format:
<pre class='rosetta__pre'> <pre class='rosetta__pre'>
{ {
values: { values: {