fix(challenges): Added all D problems except Department Numbers

This commit is contained in:
Kris Koishigawa 2019-02-26 16:52:55 +09:00 committed by mrugesh
parent d024b96a92
commit bc1d2be822
7 changed files with 59 additions and 61 deletions

View File

@ -6,11 +6,12 @@ challengeType: 5
## Description
<section id='description'>
Task:
<p>Return an array with the current date in the formats:</p>
<p>- 2007-11-23 and </p>
<p>- Sunday, November 23, 2007</p>
<p>Example output: <code>['2007-11-23', 'Sunday, November 23, 2007']</code></p>
Return an array with the current date in the formats:
<ul>
<li><b>2007-11-23</b> and</li>
<li><b>Sunday, November 23, 2007</b></li>
</ul>
Example output: <code>['2007-11-23', 'Sunday, November 23, 2007']</code>
</section>
## Instructions

View File

@ -6,13 +6,9 @@ challengeType: 5
## Description
<section id='description'>
Task:
<p>Given a date string in EST, output the given date as a string with 12 hours added to the time. </p>
<p>Time zone should be preserved.</p>
<p>Example input: </p>
<p><code>"March 7 2009 7:30pm EST"</code></p>
<p>Example output: </p>
<p><code>"March 8 2009 7:30am EST"</code></p>
Given a date string in EST, output the given date as a string with 12 hours added to the time. Time zone should be preserved.
Example input: <code>"March 7 2009 7:30pm EST"</code>
Example output: <code>"March 8 2009 7:30am EST"</code>
</section>
## Instructions

View File

@ -6,9 +6,8 @@ challengeType: 5
## Description
<section id='description'>
<p>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).</p>
<p>Task:</p>
<p>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.</p>
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

View File

@ -6,31 +6,38 @@ challengeType: 5
## Description
<section id='description'>
<p>Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for <a href="http://rosettacode.org/wiki/DOS" title="DOS">DOS</a>, then <a href="http://rosettacode.org/wiki/Windows" title="Windows">Windows</a>. </p>
<p>This version introduced 32000 numbered deals. (The <a href="http://www.solitairelaboratory.com/fcfaq.html" title="link: http://www.solitairelaboratory.com/fcfaq.html">FreeCell FAQ</a> tells this history.)</p><p>As the game became popular, Jim Horne disclosed <a href="http://www.solitairelaboratory.com/mshuffle.txt" title="link: http://www.solitairelaboratory.com/mshuffle.txt">the algorithm</a>, and other implementations of FreeCell began to reproduce the Microsoft deals. </p>
<p>These deals are numbered from 1 to 32000.</p>
<p>Newer versions from Microsoft have 1 million deals, numbered from 1 to 1000000; some implementations allow numbers outside that range.</p><p>The algorithm uses this <a href="http://rosettacode.org/wiki/linear congruential generator" title="linear congruential generator">linear congruential generator</a> from Microsoft C:</p>$state_{n + 1} \equiv 214013 \times state_n + 2531011 \pmod{2^{31}}$
$rand_n = state_n \div 2^{16}$
$rand_n$ is in range 0 to 32767.
<p>The algorithm follows:</p>Seed the RNG with the number of the deal.
Create an <a href="http://rosettacode.org/wiki/array" title="array">array</a> of 52 cards: Ace of Clubs, Ace of Diamonds, Ace of Hearts, Ace of Spades, 2 of Clubs, 2 of Diamonds, and so on through the ranks: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King. The array indexes are 0 to 51, with Ace of Clubs at 0, and King of Spades at 51.
Until the array is empty:
Choose a random card at index &equiv; next random number (mod array length).
Swap this random card with the last card of the array.
Remove this random card from the array. (Array length goes down by 1.)
Deal this random card.
Deal all 52 cards, face up, across 8 columns. The first 8 cards go in 8 columns, the next 8 cards go on the first 8 cards, and so on.
Example:
<p>Order to deal cards</p>
<p><pre> 1 2 3 4 5 6 7 8
<i>FreeCell</i> is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for <a href="http://rosettacode.org/wiki/DOS" title="DOS">DOS</a>, then <a href="http://rosettacode.org/wiki/Windows" title="Windows">Windows</a>. This version introduced 32000 numbered deals. (The <a href="http://www.solitairelaboratory.com/fcfaq.html" title="link: http://www.solitairelaboratory.com/fcfaq.html">FreeCell FAQ</a> tells this history.)
As the game became popular, Jim Horne disclosed <a href="http://www.solitairelaboratory.com/mshuffle.txt" title="link: http://www.solitairelaboratory.com/mshuffle.txt">the algorithm</a>, and other implementations of FreeCell began to reproduce the Microsoft deals. These deals are numbered from 1 to 32000. Newer versions from Microsoft have 1 million deals, numbered from 1 to 1000000; some implementations allow numbers outside that range.
The algorithm uses this <a href="http://rosettacode.org/wiki/linear congruential generator" title="linear congruential generator">linear congruential generator</a> from Microsoft C:
<ul>
<li>$state_{n + 1} \equiv 214013 \times state_n + 2531011 \pmod{2^{31}}$</li>
<li>$rand_n = state_n \div 2^{16}$</li>
<li>$rand_n$ is in range 0 to 32767.</li>
</ul>
The algorithm follows:
<ol>
<li>Seed the RNG with the number of the deal.
<li>Create an <a href="http://rosettacode.org/wiki/array" title="array">array</a> of 52 cards: Ace of Clubs, Ace of Diamonds, Ace of Hearts, Ace of Spades, 2 of Clubs, 2 of Diamonds, and so on through the ranks: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King. The array indexes are 0 to 51, with Ace of Clubs at 0, and King of Spades at 51.</li>
<li>Until the array is empty:</li>
<li>Choose a random card at index &equiv; next random number (mod array length).</li>
<ul>
<li>Swap this random card with the last card of the array.</li>
<li>Remove this random card from the array. (Array length goes down by 1.)</li>
<li>Deal this random card.</li>
</ul>
<li>Deal all 52 cards, face up, across 8 columns. The first 8 cards go in 8 columns, the next 8 cards go on the first 8 cards, and so on.</li>
</ol>
<b>Example:</b>
<b>Order to deal cards</b>
<pre> 1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52</pre></p>
<p>Game #1</p>
<p><pre>[
49 50 51 52</pre>
<b>Game #1</b>
<pre>[
['JD', '2D', '9H', 'JC', '5D', '7H', '7C', '5H'],
['KD', 'KC', '9S', '5S', 'AD', 'QC', 'KH', '3H'],
['2S', 'KS', '9D', 'QD', 'JS', 'AS', 'AH', '3C'],
@ -38,9 +45,9 @@ Example:
['3S', 'TD', '4S', 'TH', '8H', '2C', 'JH', '7D'],
['6D', '8S', '8D', 'QS', '6C', '3D', '8C', 'TC'],
['6S', '9C', '2H', '6H']
]</pre></p>
<p>Game #617</p>
<p><pre>[
]</pre>
<b>Game #617</b>
<pre>[
['7D', 'AD', '5C', '3S', '5S', '8C', '2D', 'AH'],
['TD', '7S', 'QD', 'AC', '6D', '8H', 'AS', 'KH'],
['TH', 'QC', '3H', '9D', '6S', '8D', '3D', 'TC'],
@ -48,12 +55,9 @@ Example:
['4C', 'QS', '9C', '9H', '7C', '6H', '2C', '2S'],
['4S', 'TS', '2H', '5D', 'JC', '6C', 'JH', 'QH'],
['JD', 'KS', 'KC', '4H']
]</pre></p>
Task:
<p>Write a function to take a deal number and deal cards in the same order as this algorithm.</p>
<p>The function must return a two dimensional array representing the FreeCell board.</p>
<p>Deals can also be checked against <a href="http://freecellgamesolutions.com/" title="link: http://freecellgamesolutions.com/">FreeCell solutions to 1000000 games</a>.</p>
<p>(Summon a video solution, and it displays the initial deal.)</p>
]</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

View File

@ -6,14 +6,14 @@ challengeType: 5
## Description
<section id='description'>
Task:
<p>Write a function that returns a deep copy of a given object.</p>
<p>The copy must not be the same object that was given.</p>
<p>This task will not test for: </p>
Objects with properties that are functions
Date objects or object with properties that are Date objects
RegEx or object with properties that are RegEx objects
Prototype copying
Write a function that returns a deep copy of a given object. The copy must not be the same object that was given.
This task will not test for:
<ul>
<li>Objects with properties that are functions</li>
<li>Date objects or object with properties that are Date objects</li>
<li>RegEx or object with properties that are RegEx objects</li>
<li>Prototype copying</li>
</ul>
</section>
## Instructions

View File

@ -6,13 +6,12 @@ challengeType: 5
## Description
<section id='description'>
Task:
<p>Define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10.</p>
Errors:
If you try to instantiate a <code>Num</code> with a value outside of 1 - 10
it should throw a <code>TypeError</code> with an error message of <code>'Out of range'</code>.
If you try to instantiate a <code>Num</code> with a value that is not a number
it should throw a <code>TypeError</code> with an error message of <code>'Not a Number'</code>.
Define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10.
Error handling:
<ul>
<li>If you try to instantiate a <code>Num</code> with a value outside of 1 - 10, it should throw a <code>TypeError</code> with an error message of <code>'Out of range'</code>.</li>
<li>If you try to instantiate a <code>Num</code> with a value that is not a number, it should throw a <code>TypeError</code> with an error message of <code>'Not a Number'</code>.</li>
</ul>
</section>
## Instructions

View File

@ -6,8 +6,7 @@ challengeType: 5
## Description
<section id='description'>
Task:
<p>Convert a given date from the <a href="https://en.wikipedia.org/wiki/Gregorian calendar" title="wp: Gregorian calendar">Gregorian calendar</a> to the <a href="https://en.wikipedia.org/wiki/Discordian calendar" title="wp: Discordian calendar">Discordian calendar</a>.</p>
Convert a given date from the <a href="https://en.wikipedia.org/wiki/Gregorian calendar" title="wp: Gregorian calendar">Gregorian calendar</a> to the <a href="https://en.wikipedia.org/wiki/Discordian calendar" title="wp: Discordian calendar">Discordian calendar</a>.
</section>
## Instructions