fix(challenges): Moved challenge instructions to instructions section
This commit is contained in:
@ -7,12 +7,11 @@ challengeType: 5
|
||||
## Description
|
||||
<section id='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.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
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>
|
||||
|
||||
## Tests
|
||||
|
@ -6,14 +6,16 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
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>.
|
||||
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' target='_blank'>short story by Arthur C. Clarke</a>.
|
||||
(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”.
|
||||
<ul>
|
||||
<li>The integer 1 has 1 name “1”.</li>
|
||||
<li>The integer 2 has 2 names “1+1”, and “2”.</li>
|
||||
<li>The integer 3 has 3 names “1+1+1”, “2+1”, and “3”.</li>
|
||||
<li>The integer 4 has 5 names “1+1+1+1”, “2+1+1”, “2+2”, “3+1”, “4”.</li>
|
||||
<li>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”.</li>
|
||||
</ul>
|
||||
This can be visualized in the following form:
|
||||
<pre>
|
||||
1
|
||||
@ -25,12 +27,11 @@ This can be visualized in the following form:
|
||||
</pre>
|
||||
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 <a href="http://mathworld.wolfram.com/PartitionFunctionP.html" title="link: http://mathworld.wolfram.com/PartitionFunctionP.html">integer partition function</a>.
|
||||
Implement a function that returns the sum of the $n$-th row.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Implement a function that returns the sum of the $n$-th row.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -29,15 +29,16 @@ You are given a collection of ABC blocks (e.g., childhood alphabet blocks). Ther
|
||||
(P C)
|
||||
(Z M)
|
||||
</pre>
|
||||
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.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Implement a function that takes a string (word) and determines whether the word can be spelled with the given collection of blocks.
|
||||
Some rules to keep in mind:
|
||||
<ul>
|
||||
<li>Once a letter on a block is used, that block cannot be used again.</li>
|
||||
<li>The function should be case-insensitive.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -6,7 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
These define three classifications of positive integers based on their <a href="http://rosettacode.org/wiki/Proper divisors" title="Proper divisors">proper divisors</a>.
|
||||
These define three classifications of positive integers based on their <a href='http://rosettacode.org/wiki/Proper divisors' title='Proper divisors' target='_blank'>proper divisors</a>.
|
||||
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.
|
||||
<pre>
|
||||
If <code style='border: 1px solid #ddd;'> P(n) < n </code> then <b>n</b> is classed as <b>deficient</b>
|
||||
@ -16,12 +16,11 @@ If <code style='border: 1px solid #ddd;'> P(n) > n </code> then <b>n</b> is clas
|
||||
Example:
|
||||
<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>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
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>
|
||||
|
||||
## Tests
|
||||
|
@ -6,16 +6,16 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='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).
|
||||
<b>Rules:</b>
|
||||
Do not use global variables.
|
||||
<b>Hint:</b>
|
||||
Closures save outer state.
|
||||
A problem posed by <a href='http://en.wikipedia.org/wiki/Paul_Graham' target='_blank'>Paul Graham</a> is that of creating a function that takes a single (numeric) argument and which 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).
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Create a function that takes a number $n$ and generates accumulator functions that return the sum of every number ever passed to them.
|
||||
<b>Rules:</b>
|
||||
Do not use global variables.
|
||||
<b>Hint:</b>
|
||||
Closures save outer state.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@ -71,7 +71,7 @@ if (testFn) {
|
||||
|
||||
```js
|
||||
function accumulator(sum) {
|
||||
return function (n) {
|
||||
return function(n) {
|
||||
return sum += n;
|
||||
};
|
||||
}
|
||||
|
@ -9,12 +9,12 @@ challengeType: 5
|
||||
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.
|
||||
Its arguments are never negative and it always terminates.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function which returns the value of $A(m, n)$. Arbitrary precision is preferred (since the function grows so quickly), but not required.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -7,6 +7,10 @@ challengeType: 5
|
||||
## Description
|
||||
<section id='description'>
|
||||
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.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Use the following text to test your programs:
|
||||
<pre>
|
||||
Given$a$text$file$of$many$lines
|
||||
@ -22,20 +26,15 @@ or$center$justified$within$its$column.
|
||||
</pre>
|
||||
Note that:
|
||||
<ol>
|
||||
<li>The example input texts lines may, or may not, have trailing dollar characters.</li>
|
||||
<li>All columns should share the same alignment.</li>
|
||||
<li>Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task.</li>
|
||||
<li>Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal.</li>
|
||||
<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>
|
||||
<li>The example input texts lines may, or may not, have trailing dollar characters.</li>
|
||||
<li>All columns should share the same alignment.</li>
|
||||
<li>Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task.</li>
|
||||
<li>Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal.</li>
|
||||
<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>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
|
@ -6,19 +6,18 @@ challengeType: 5
|
||||
|
||||
## 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' target='_blank'>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$.
|
||||
<b>Example:</b>
|
||||
<b>1184</b> and <b>1210</b> are an amicable pair, with proper divisors:
|
||||
<ul>
|
||||
<li>1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 and</li>
|
||||
<li>1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605 respectively.</li>
|
||||
<li>1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 and</li>
|
||||
<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).
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Calculate and show here the Amicable pairs below 20,000 (there are eight).
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -6,7 +6,9 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
<p>Write a program to find the <a href="https://en.wikipedia.org/wiki/Mode (statistics)" title="wp: Mode (statistics)">mode</a> value of a collection.</p><p>The case where the collection is empty may be ignored. Care must be taken to handle the case where the mode is non-unique.</p><p>If it is not appropriate or possible to support a general collection, use a vector (array), if possible. If it is not appropriate or possible to support an unspecified value type, use integers.</p>
|
||||
Write a program to find the <a href='https://en.wikipedia.org/wiki/Mode (statistics)' title='wp: Mode (statistics)' target='_blank'>mode</a> value of a collection.
|
||||
The case where the collection is empty may be ignored. Care must be taken to handle the case where the mode is non-unique.
|
||||
If it is not appropriate or possible to support a general collection, use a vector (array), if possible. If it is not appropriate or possible to support an unspecified value type, use integers.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
|
@ -9,16 +9,20 @@ challengeType: 5
|
||||
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).
|
||||
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.
|
||||
<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>
|
||||
<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' target='_blank'>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>
|
||||
<li>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Geometric mean' title='wp: Geometric mean' target='_blank'>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>
|
||||
<li>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Harmonic mean' title='wp: Harmonic mean' target='_blank'>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.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
When writing your function, 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>
|
||||
{
|
||||
values: {
|
||||
Arithmetic: 5.5,
|
||||
@ -30,11 +34,6 @@ For the answer, please output an object in the following format:
|
||||
</pre>
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
|
@ -6,7 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
Compute the <a href="https://en.wikipedia.org/wiki/Root mean square" title="wp: Root mean square">Root mean square</a> of the numbers 1 through 10 inclusive.
|
||||
Compute the <a href="https://en.wikipedia.org/wiki/Root mean square" title="wp: Root mean square" target='_blank'>Root mean square</a> of the numbers 1 through 10 inclusive.
|
||||
The <i>root mean square</i> is also known by its initials RMS (or rms), and as the <b>quadratic mean</b>.
|
||||
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
|
||||
<big>$$x_{\mathrm{rms}} = \sqrt {{{x_1}^2 + {x_2}^2 + \cdots + {x_n}^2} \over n}. $$</big>
|
||||
|
@ -6,19 +6,18 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
<a href="https://en.wikipedia.org/wiki/Charles_Babbage" title="wp: Charles_Babbage">Charles Babbage</a>, looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example:
|
||||
<a href="https://en.wikipedia.org/wiki/Charles_Babbage" title="wp: Charles_Babbage" target='_blank'>Charles Babbage</a>, looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example:
|
||||
<blockquote>
|
||||
What is the smallest positive integer whose square ends in the digits 269,696?
|
||||
<footer>Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill, <i>Electronic Computers</i>, second edition, 1970, p. 125.</footer>
|
||||
</blockquote>
|
||||
He thought the answer might be 99,736, whose square is 9,947,269,696; but he couldn't be certain.
|
||||
The task is to find out if Babbage had the right answer.
|
||||
Implement a function to return the lowest integer that satisfies the Babbage problem. If Babbage was right, return Babbage's number.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Implement a function to return the lowest integer that satisfies the Babbage problem. If Babbage was right, return Babbage's number.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -7,16 +7,16 @@ challengeType: 5
|
||||
## Description
|
||||
<section id='description'>
|
||||
Determine whether a generated string of brackets is balanced; that is, whether it consists entirely of pairs of opening/closing brackets (in that order), none of which mis-nest.
|
||||
Examples:
|
||||
<pre>
|
||||
(empty) true
|
||||
<code>[]</code> true
|
||||
<code>][</code> false
|
||||
<code>[][]</code> true
|
||||
<code>][][</code> false
|
||||
<code>[]][[]</code> false
|
||||
<code>[[[[]]]]</code> true
|
||||
</pre>
|
||||
<h4><strong>Examples:</strong></h4>
|
||||
|
||||
| Input | Output |
|
||||
| --- | --- |
|
||||
| <code>[]</code> | true |
|
||||
| <code>][</code> | false |
|
||||
| <code>[][]</code> | true |
|
||||
| <code>][][</code> | false |
|
||||
| <code>[]][[]</code> | false |
|
||||
| <code>[[[[]]]]</code> | true |
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
|
@ -14,7 +14,10 @@ Given two points on a plane and a radius, usually two circles of given radius ca
|
||||
<li>If the points form a diameter then return a single circle.</li>
|
||||
<li>If the points are too far apart then no circles can be drawn.</li>
|
||||
</ul>
|
||||
<b>Task:</b>
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Implement a function that takes two points and a radius and returns the two circles through those points. For each resulting circle, provide the coordinates for the center of each circle rounded to four decimal digits. Return each coordinate as an array, and coordinates as an array of arrays.
|
||||
<b>For edge cases, return the following:</b>
|
||||
<ul>
|
||||
@ -35,11 +38,6 @@ Implement a function that takes two points and a radius and returns the two circ
|
||||
<a href="http://mathforum.org/library/drmath/view/53027.html" title="link: http://mathforum.org/library/drmath/view/53027.html">Finding the Center of a Circle from 2 Points and Radius</a> from Math forum @ Drexel
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
|
@ -6,7 +6,11 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
Comma quibbling is a task originally set by Eric Lippert in his <a href="http://blogs.msdn.com/b/ericlippert/archive/2009/04/15/comma-quibbling.aspx" title="link: http://blogs.msdn.com/b/ericlippert/archive/2009/04/15/comma-quibbling.aspx">blog</a>.
|
||||
Comma quibbling is a task originally set by Eric Lippert in his <a href="http://blogs.msdn.com/b/ericlippert/archive/2009/04/15/comma-quibbling.aspx" title="link: http://blogs.msdn.com/b/ericlippert/archive/2009/04/15/comma-quibbling.aspx" target="_blank">blog</a>.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
|
||||
<ol>
|
||||
<li>An input of no words produces the output string of just the two brace characters "{}".</li>
|
||||
@ -24,11 +28,6 @@ Test your function with the following series of inputs showing your output here
|
||||
Note: Assume words are non-empty strings of uppercase characters for this task.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
|
@ -6,7 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
Given a <a href="https://en.wikipedia.org/wiki/List_(abstract_data_type)" title="wp: List_(abstract_data_type)">list</a> of arbitrarily many strings, implement a function for each of the following conditions:
|
||||
Given a <a href="https://en.wikipedia.org/wiki/List_(abstract_data_type)" title="wp: List_(abstract_data_type)" target="_blank">list</a> of arbitrarily many strings, implement a function for each of the following conditions:
|
||||
<ul>
|
||||
<li>test if they are all lexically equal</li>
|
||||
<li>test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)</li>
|
||||
|
@ -13,64 +13,24 @@ Implement a function which:
|
||||
</ul>
|
||||
Demonstrate that it passes the following three test-cases:
|
||||
<div style="font-size:115%; font-weight: bold;">Test Cases</div>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>input number</th>
|
||||
<th>output number</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>7259</td>
|
||||
<td><code>2 hr, 59 sec</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>86400</td>
|
||||
<td><code>1 d</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6000000</td>
|
||||
<td><code>9 wk, 6 d, 10 hr, 40 min</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
| Input number | Output number |
|
||||
| --- | --- |
|
||||
| 7259 | <code>2 hr, 59 sec</code> |
|
||||
| 728640059 | <code>1 d</code> |
|
||||
| 6000000 | <code>9 wk, 6 d, 10 hr, 40 min</code> |
|
||||
<div style="font-size:115%; font-weight: bold;">Details</div>
|
||||
<ul>
|
||||
<li>
|
||||
The following five units should be used:
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>unit</th>
|
||||
<th>suffix used in output</th>
|
||||
<th>conversion</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>week</td>
|
||||
<td><code>wk</code></td>
|
||||
<td>1 week = 7 days</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>day</td>
|
||||
<td><code>d</code></td>
|
||||
<td>1 day = 24 hours</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>hour</td>
|
||||
<td><code>hr</code></td>
|
||||
<td>1 hour = 60 minutes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>minute</td>
|
||||
<td><code>min</code></td>
|
||||
<td>1 minute = 60 seconds</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>second</td>
|
||||
<td><code>sec</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
| Unit | Suffix used in Output | Conversion |
|
||||
| --- | --- | --- |
|
||||
| week | <code>wk</code> | 1 week = 7 days |
|
||||
| day | <code>d</code> | 1 day = 24 hours |
|
||||
| hour | <code>hr</code> | 1 hour = 60 minutes |
|
||||
| minute | <code>min</code> | 1 minute = 60 seconds |
|
||||
| second | <code>sec</code> | --- |
|
||||
</li>
|
||||
<li>
|
||||
However, <b>only</b> include quantities with non-zero values in the output (e.g., return <code>1 d</code> and not <code>0 wk, 1 d, 0 hr, 0 min, 0 sec</code>).
|
||||
|
@ -22,16 +22,15 @@ There are four types of common coins in <a href="https://en.wikipedia.org/wiki/U
|
||||
<li>A nickel and 10 pennies</li>
|
||||
<li>15 pennies</li>
|
||||
</ul>
|
||||
Implement a function to determine how many ways there are to make change for a dollar using these common coins? (1 dollar = 100 cents)
|
||||
<b>Reference:</b>
|
||||
<ul>
|
||||
<li><a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52" title="link: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52">an algorithm from MIT Press</a>.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Implement a function to determine how many ways there are to make change for a dollar using these common coins (1 dollar = 100 cents)
|
||||
<b>Reference:</b>
|
||||
<ul>
|
||||
<li><a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52" title="link: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_Temp_52">an algorithm from MIT Press</a>.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -19,7 +19,10 @@ Then the values of $x, y$ and $z$ can be found as follows:
|
||||
<big>
|
||||
$x = \frac{\begin{vmatrix} {\color{red}d_1} & b_1 & c_1 \\ {\color{red}d_2} & b_2 & c_2 \\ {\color{red}d_3} & b_3 & c_3 \end{vmatrix} } { \begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix}}, \quad y = \frac {\begin{vmatrix} a_1 & {\color{red}d_1} & c_1 \\ a_2 & {\color{red}d_2} & c_2 \\ a_3 & {\color{red}d_3} & c_3 \end{vmatrix}} {\begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix}}, \text{ and }z = \frac { \begin{vmatrix} a_1 & b_1 & {\color{red}d_1} \\ a_2 & b_2 & {\color{red}d_2} \\ a_3 & b_3 & {\color{red}d_3} \end{vmatrix}} {\begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix} }.$
|
||||
</big>
|
||||
<b>Task</b>
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Given the following system of equations:
|
||||
<big>
|
||||
$\begin{cases}
|
||||
@ -32,11 +35,6 @@ Given the following system of equations:
|
||||
solve for <big>$w$, $x$, $y$</big> and <big>$z$</big>, using Cramer's rule.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
|
@ -7,12 +7,11 @@ challengeType: 5
|
||||
## Description
|
||||
<section id='description'>
|
||||
A <b>CUSIP</b> is a nine-character alphanumeric code that identifies a North American financial security for the purposes of facilitating clearing and settlement of trades. The CUSIP was adopted as an American National Standard under Accredited Standards X9.6.
|
||||
Write a function that takes a string as a parameter and checks if the string is valid CUSIP.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that takes a string as a parameter and checks if the string is valid CUSIP.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -12,12 +12,11 @@ A given rectangle is made from <i>m</i> × <i>n</i> squares. If <i>m</i> and <i>
|
||||
<img src="https://rosettacode.org/mw/images/5/55/Rect-cut.svg" width="520" height="170" alt="Picture of cut rectangles">
|
||||
</a>
|
||||
</div>
|
||||
Write a function that calculates the number of different ways to cut an <i>m</i> × <i>n</i> rectangle.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that calculates the number of different ways to cut an <i>m</i> × <i>n</i> rectangle.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -7,12 +7,11 @@ challengeType: 5
|
||||
## Description
|
||||
<section id='description'>
|
||||
A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
|
||||
Write a function that takes a start year and an end year and return an array of all the years where the 25th of December will be a Sunday.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that takes a start year and an end year and return an array of all the years where the 25th of December will be a Sunday.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -56,13 +56,12 @@ The algorithm follows:
|
||||
['4S', 'TS', '2H', '5D', 'JC', '6C', 'JH', 'QH'],
|
||||
['JD', 'KS', 'KC', '4H']
|
||||
]</pre>
|
||||
Write a function to take a deal number and deal cards in the same order as this algorithm. The function must return a two dimensional array representing the FreeCell board.
|
||||
Deals can also be checked against <a href="http://freecellgamesolutions.com/" title="link: http://freecellgamesolutions.com/">FreeCell solutions to 1000000 games</a>. (Summon a video solution, and it displays the initial deal.)
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function to take a deal number and deal cards in the same order as this algorithm. The function must return a two dimensional array representing the FreeCell board.
|
||||
Deals can also be checked against <a href="http://freecellgamesolutions.com/" title="link: http://freecellgamesolutions.com/">FreeCell solutions to 1000000 games</a>. (Summon a video solution, and it displays the initial deal.)
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
@ -6,32 +6,34 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
<p>There is a highly organized city that has decided to assign a number to each of their departments:</p>
|
||||
Police department
|
||||
Sanitation department
|
||||
Fire department
|
||||
<p>Each department can have a number between 1 and 7 (inclusive).</p><p>The three department numbers are to be unique (different from each other) and must add up to the number 12.</p><p>The Chief of the Police doesn't like odd numbers and wants to have an even number for his department.</p>
|
||||
Task:
|
||||
<p>Write a program which outputs all valid combinations:</p>
|
||||
<p>[2, 3, 7]</p>
|
||||
<p>[2, 4, 6]</p>
|
||||
<p>[2, 6, 4]</p>
|
||||
<p>[2, 7, 3]</p>
|
||||
<p>[4, 1, 7]</p>
|
||||
<p>[4, 2, 6]</p>
|
||||
<p>[4, 3, 5]</p>
|
||||
<p>[4, 5, 3]</p>
|
||||
<p>[4, 6, 2]</p>
|
||||
<p>[4, 7, 1]</p>
|
||||
<p>[6, 1, 5]</p>
|
||||
<p>[6, 2, 4]</p>
|
||||
<p>[6, 4, 2]</p>
|
||||
<p>[6, 5, 1]</p>
|
||||
There is a highly organized city that has decided to assign a number to each of their departments:
|
||||
<ul>
|
||||
<li>Police department</li>
|
||||
<li>Sanitation department</li>
|
||||
<li>Fire department</li>
|
||||
</ul>
|
||||
Each department can have a number between 1 and 7 (inclusive).
|
||||
The three department numbers are to be unique (different from each other) and must add up to the number 12.
|
||||
The Chief of the Police doesn't like odd numbers and wants to have an even number for his department.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a program which outputs all valid combinations:
|
||||
[2, 3, 7]
|
||||
[2, 4, 6]
|
||||
[2, 6, 4]
|
||||
[2, 7, 3]
|
||||
[4, 1, 7]
|
||||
[4, 2, 6]
|
||||
[4, 3, 5]
|
||||
[4, 5, 3]
|
||||
[4, 6, 2]
|
||||
[4, 7, 1]
|
||||
[6, 1, 5]
|
||||
[6, 2, 4]
|
||||
[6, 4, 2]
|
||||
[6, 5, 1]
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
Reference in New Issue
Block a user