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,56 +5,123 @@ challengeType: 5
forumTopicId: 302325
---
## Description
# --description--
<section id='description'>
Implement functions to encrypt and decrypt a message using the [straddling checkerboard](https://en.wikipedia.org/wiki/Straddling_checkerboard) method. The functions will take a string and an array as parameters. The array has 3 strings representing the 3 rows of the checkerboard. The output will be a series of decimal digits. Numbers should be encrypted by inserting the escape character before each digit, then including the digit unencrypted. This should be reversed for decryption.
Implement functions to encrypt and decrypt a message using the <a href="https://en.wikipedia.org/wiki/Straddling_checkerboard">straddling checkerboard</a> method. The functions will take a string and an array as parameters. The array has 3 strings representing the 3 rows of the checkerboard. The output will be a series of decimal digits.
Numbers should be encrypted by inserting the escape character before each digit, then including the digit unencrypted. This should be reversed for decryption.
# --hints--
</section>
`straddle` should be a function.
## Instructions
<section id='instructions'>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>straddle</code> should be a function.
testString: assert(typeof straddle == 'function');
- text: <code>straddle("One night-it was on the twentieth of March, 1888-I was returning.",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])</code> should return a string.
testString: assert(typeof straddle("One night-it was on the twentieth of March, 1888-I was returning.", ["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"]) == 'string');
- text: <code>straddle("One night-it was on the twentieth of March, 1888-I was returning.",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])</code> should return <code>"34045747525284613427502840425027537379697175891898898898584619028294547488"</code>.
testString: assert.equal(straddle("One night-it was on the twentieth of March, 1888-I was returning.", ["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"]), "34045747525284613427502840425027537379697175891898898898584619028294547488");
- text: <code>straddle("One night-it was on the twentieth of March, 1888-I was returning",["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"])</code> should return <code>"139539363509369743061399059745399365901344308320791798798798367430685972839363935"</code>.
testString: assert.equal(straddle("One night-it was on the twentieth of March, 1888-I was returning", ["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"]), "139539363509369743061399059745399365901344308320791798798798367430685972839363935");
- text: <code>straddle("Thecheckerboardcakerecipespecifies3largeeggsand2.25cupsofflour.",["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."])</code> should return <code>"125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769"</code>.
testString: assert.equal(straddle("Thecheckerboardcakerecipespecifies3largeeggsand2.25cupsofflour.", ["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."]), "125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769");
- text: <code>unstraddle</code> should be a function.
testString: assert(typeof unstraddle == 'function');
- text: <code>unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])</code> should return a string.
testString: assert(typeof unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488", ["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"]) == 'string');
- text: <code>unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])</code> should return <code>"ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING."</code>.
testString: assert.equal(unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488", ["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"]), "ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING.");
- text: <code>unstraddle("139539363509369743061399059745399365901344308320791798798798367430685972839363935",["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"])</code> should return <code>"ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING"</code>.
testString: assert.equal(unstraddle("139539363509369743061399059745399365901344308320791798798798367430685972839363935", ["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"]), "ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING");
- text: <code>unstraddle("125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769",["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."])</code> should return <code>"THECHECKERBOARDCAKERECIPESPECIFIES3LARGEEGGSAND2.25CUPSOFFLOUR."</code>.
testString: assert.equal(unstraddle("125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769", ["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."]), "THECHECKERBOARDCAKERECIPESPECIFIES3LARGEEGGSAND2.25CUPSOFFLOUR.");
```js
assert(typeof straddle == 'function');
```
</section>
`straddle("One night-it was on the twentieth of March, 1888-I was returning.",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` should return a string.
## Challenge Seed
```js
assert(
typeof straddle(
'One night-it was on the twentieth of March, 1888-I was returning.',
['ESTONIA R', 'BCDFGHJKLM', 'PQUVWXYZ./']
) == 'string'
);
```
<section id='challengeSeed'>
`straddle("One night-it was on the twentieth of March, 1888-I was returning.",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` should return `"34045747525284613427502840425027537379697175891898898898584619028294547488"`.
<div id='js-seed'>
```js
assert.equal(
straddle(
'One night-it was on the twentieth of March, 1888-I was returning.',
['ESTONIA R', 'BCDFGHJKLM', 'PQUVWXYZ./']
),
'34045747525284613427502840425027537379697175891898898898584619028294547488'
);
```
`straddle("One night-it was on the twentieth of March, 1888-I was returning",["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"])` should return `"139539363509369743061399059745399365901344308320791798798798367430685972839363935"`.
```js
assert.equal(
straddle('One night-it was on the twentieth of March, 1888-I was returning', [
'HOL MES RT',
'ABCDFGIJKN',
'PQUVWXYZ./'
]),
'139539363509369743061399059745399365901344308320791798798798367430685972839363935'
);
```
`straddle("Thecheckerboardcakerecipespecifies3largeeggsand2.25cupsofflour.",["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."])` should return `"125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769"`.
```js
assert.equal(
straddle('Thecheckerboardcakerecipespecifies3largeeggsand2.25cupsofflour.', [
'ET AON RIS',
'BCDFGHJKLM',
'PQ/UVWXYZ.'
]),
'125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769'
);
```
`unstraddle` should be a function.
```js
assert(typeof unstraddle == 'function');
```
`unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` should return a string.
```js
assert(
typeof unstraddle(
'34045747525284613427502840425027537379697175891898898898584619028294547488',
['ESTONIA R', 'BCDFGHJKLM', 'PQUVWXYZ./']
) == 'string'
);
```
`unstraddle("34045747525284613427502840425027537379697175891898898898584619028294547488",["ESTONIA R", "BCDFGHJKLM", "PQUVWXYZ./"])` should return `"ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING."`.
```js
assert.equal(
unstraddle(
'34045747525284613427502840425027537379697175891898898898584619028294547488',
['ESTONIA R', 'BCDFGHJKLM', 'PQUVWXYZ./']
),
'ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING.'
);
```
`unstraddle("139539363509369743061399059745399365901344308320791798798798367430685972839363935",["HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./"])` should return `"ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING"`.
```js
assert.equal(
unstraddle(
'139539363509369743061399059745399365901344308320791798798798367430685972839363935',
['HOL MES RT', 'ABCDFGIJKN', 'PQUVWXYZ./']
),
'ONENIGHTITWASONTHETWENTIETHOFMARCH1888IWASRETURNING'
);
```
`unstraddle("125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769",["ET AON RIS", "BCDFGHJKLM", "PQ/UVWXYZ."])` should return `"THECHECKERBOARDCAKERECIPESPECIFIES3LARGEEGGSAND2.25CUPSOFFLOUR."`.
```js
assert.equal(
unstraddle(
'125021250212707204372221327070218600960021823809623283724002424935226226962262521636094232328463769',
['ET AON RIS', 'BCDFGHJKLM', 'PQ/UVWXYZ.']
),
'THECHECKERBOARDCAKERECIPESPECIFIES3LARGEEGGSAND2.25CUPSOFFLOUR.'
);
```
# --seed--
## --seed-contents--
```js
function straddle(message, alphabet) {
@ -66,12 +133,7 @@ function unstraddle(message, alphabet) {
}
```
</div>
</section>
## Solution
<section id='solution'>
# --solutions--
```js
function straddle(message, alphabet) {
@ -121,5 +183,3 @@ function unstraddle(message, alphabet) {
return out;
}
```
</section>