Feat: add new Markdown parser (#39800)

and change all the challenges to new `md` format.
This commit is contained in:
Oliver Eyton-Williams
2020-11-27 19:02:05 +01:00
committed by GitHub
parent a07f84c8ec
commit 0bd52f8bd1
2580 changed files with 113436 additions and 111979 deletions

View File

@ -5,60 +5,87 @@ challengeType: 5
forumTopicId: 302296
---
## Description
# --description--
A positive integer is a [Kaprekar number](<https://en.wikipedia.org/wiki/Kaprekar number>) if:
<section id='description'>
A positive integer is a <a href="https://en.wikipedia.org/wiki/Kaprekar number">Kaprekar number</a> if:
<ul>
<li>It is 1, or,</li>
<li>The decimal representation of its square may be split once into two parts consisting of positive integers which sum to the original number. </li>
</ul>
Note that a split resulting in a part consisting purely of 0s is not valid, as 0 is not considered positive.Example
Kaprekar numbers:
<ul>
<li><code>2223</code> is a Kaprekar number, as <code>2223 * 2223 = 4941729</code>, <code>4941729</code> may be split to <code>494</code> and <code>1729</code>, and <code>494 + 1729 = 2223</code></li>
<li>The series of Kaprekar numbers is known as <a href="https://oeis.org/A006886" target="_blank">A006886</a>, and begins as <code>1, 9, 45, 55, ...</code></li>
<li>The series of Kaprekar numbers is known as <a href='https://oeis.org/A006886' target='_blank'>A006886</a>, and begins as <code>1, 9, 45, 55, ...</code></li>
</ul>
</section>
## Instructions
# --instructions--
<section id='instructions'>
Write a function that takes a number $n$, a base $bs$, and returns true if the number is a Kaprekar number for the given base. Otherwise, the function returns false.
</section>
## Tests
# --hints--
<section id='tests'>
`isKaprekar` should be a function.
```yml
tests:
- text: <code>isKaprekar</code> should be a function.
testString: assert(typeof isKaprekar == 'function');
- text: <code>isKaprekar(1, 10)</code> should return a boolean.
testString: assert(typeof isKaprekar(1, 10) == 'boolean');
- text: <code>isKaprekar(1, 10)</code> should return <code>true</code>.
testString: assert.equal(isKaprekar(1, 10), true);
- text: <code>isKaprekar(9, 10)</code> should return <code>true</code>.
testString: assert.equal(isKaprekar(9, 10), true);
- text: <code>isKaprekar(2223, 10)</code> should return <code>true</code>.
testString: assert.equal(isKaprekar(2223, 10), true);
- text: <code>isKaprekar(22823, 10)</code> should return <code>false</code>.
testString: assert.equal(isKaprekar(22823, 10), false);
- text: <code>isKaprekar(9, 17)</code> should return <code>false</code>.
testString: assert.equal(isKaprekar(9, 17), false);
- text: <code>isKaprekar(225, 17)</code> should return <code>true</code>.
testString: assert.equal(isKaprekar(225, 17), true);
- text: <code>isKaprekar(999, 17)</code> should return <code>false</code>.
testString: assert.equal(isKaprekar(999, 17), false);
```js
assert(typeof isKaprekar == 'function');
```
</section>
`isKaprekar(1, 10)` should return a boolean.
## Challenge Seed
```js
assert(typeof isKaprekar(1, 10) == 'boolean');
```
<section id='challengeSeed'>
<div id='js-seed'>
`isKaprekar(1, 10)` should return `true`.
```js
assert.equal(isKaprekar(1, 10), true);
```
`isKaprekar(9, 10)` should return `true`.
```js
assert.equal(isKaprekar(9, 10), true);
```
`isKaprekar(2223, 10)` should return `true`.
```js
assert.equal(isKaprekar(2223, 10), true);
```
`isKaprekar(22823, 10)` should return `false`.
```js
assert.equal(isKaprekar(22823, 10), false);
```
`isKaprekar(9, 17)` should return `false`.
```js
assert.equal(isKaprekar(9, 17), false);
```
`isKaprekar(225, 17)` should return `true`.
```js
assert.equal(isKaprekar(225, 17), true);
```
`isKaprekar(999, 17)` should return `false`.
```js
assert.equal(isKaprekar(999, 17), false);
```
# --seed--
## --seed-contents--
```js
function isKaprekar(n, bs) {
@ -66,12 +93,7 @@ function isKaprekar(n, bs) {
}
```
</div>
</section>
## Solution
<section id='solution'>
# --solutions--
```js
function isKaprekar(n, bs) {
@ -85,5 +107,3 @@ function isKaprekar(n, bs) {
return false;
}
```
</section>