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,49 +5,83 @@ challengeType: 5
forumTopicId: 302335
---
## Description
# --description--
Find solutions to the *sum to one hundred* puzzle.
Add (insert) the mathematical operators **+** or **─** (plus or minus) before any of the digits in the decimal numeric string **123456789** such that the resulting mathematical expression adds up to a particular sum (in this iconic case, **100**).
<section id='description'>
Find solutions to the <i>sum to one hundred</i> puzzle.
Add (insert) the mathematical operators <b>+</b> or <b></b> (plus or minus) before any of the digits in the decimal numeric string <b>123456789</b> such that the resulting mathematical expression adds up to a particular sum (in this iconic case, <b>100</b>).
Example:
<pre><b>123 + 4 - 5 + 67 - 89 = 100</b></pre>
</section>
## Instructions
# --instructions--
<section id='instructions'>
Write a function that takes a number as parameter. The function should return an array containing all solutions for the given number. The solutions should be strings representing the expressions. For example: "1+23-456+78-9". Sort the array before returning it.
</section>
## Tests
# --hints--
<section id='tests'>
`sumTo100` should be a function.
```yml
tests:
- text: <code>sumTo100</code> should be a function.
testString: assert(typeof sumTo100 == 'function');
- text: <code>sumTo100(199)</code> should return an array.
testString: assert(Array.isArray(sumTo100(199)));
- text: <code>sumTo100(199)</code> should return <code>["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]</code>.
testString: assert.deepEqual(sumTo100(199), ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]);
- text: <code>sumTo100(209)</code> should return <code>["1+234+56+7-89"]</code>.
testString: assert.deepEqual(sumTo100(209), ["1+234+56+7-89"]);
- text: <code>sumTo100(243)</code> should return <code>["-1-234+567-89", "-12+345+6-7-89", "123+45+6+78-9"]</code>.
testString: assert.deepEqual(sumTo100(243), ["-1-234+567-89", "-12+345+6-7-89", "123+45+6+78-9"]);
- text: <code>sumTo100(199)</code> should return <code>["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]</code>.
testString: assert.deepEqual(sumTo100(199), ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]);
- text: <code>sumTo100(197)</code> should return <code>["1-2-3+45+67+89", "12+34-5+67+89", "123+4-5+6+78-9"]</code>.
testString: assert.deepEqual(sumTo100(197), ["1-2-3+45+67+89", "12+34-5+67+89", "123+4-5+6+78-9"]);
```js
assert(typeof sumTo100 == 'function');
```
</section>
`sumTo100(199)` should return an array.
## Challenge Seed
```js
assert(Array.isArray(sumTo100(199)));
```
<section id='challengeSeed'>
<div id='js-seed'>
`sumTo100(199)` should return `["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]`.
```js
assert.deepEqual(sumTo100(199), [
'-1+2-3+45+67+89',
'123-4+5+6+78-9',
'123-4+56+7+8+9'
]);
```
`sumTo100(209)` should return `["1+234+56+7-89"]`.
```js
assert.deepEqual(sumTo100(209), ['1+234+56+7-89']);
```
`sumTo100(243)` should return `["-1-234+567-89", "-12+345+6-7-89", "123+45+6+78-9"]`.
```js
assert.deepEqual(sumTo100(243), [
'-1-234+567-89',
'-12+345+6-7-89',
'123+45+6+78-9'
]);
```
`sumTo100(199)` should return `["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]`.
```js
assert.deepEqual(sumTo100(199), [
'-1+2-3+45+67+89',
'123-4+5+6+78-9',
'123-4+56+7+8+9'
]);
```
`sumTo100(197)` should return `["1-2-3+45+67+89", "12+34-5+67+89", "123+4-5+6+78-9"]`.
```js
assert.deepEqual(sumTo100(197), [
'1-2-3+45+67+89',
'12+34-5+67+89',
'123+4-5+6+78-9'
]);
```
# --seed--
## --seed-contents--
```js
function sumTo100(n) {
@ -55,12 +89,7 @@ function sumTo100(n) {
}
```
</div>
</section>
## Solution
<section id='solution'>
# --solutions--
```js
function sumTo100(n) {
@ -158,5 +187,3 @@ function sumTo100(n) {
return universe.sort();
}
```
</section>