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,45 +5,80 @@ challengeType: 5
forumTopicId: 385269
---
## Description
<section id='description'>
Explicitly implement <a href="https://en.wikipedia.org/wiki/long multiplication">long multiplication</a>.
# --description--
Explicitly implement [long multiplication](<https://en.wikipedia.org/wiki/long multiplication>).
This is one possible approach to arbitrary-precision integer algebra.
</section>
## Instructions
<section id='instructions'>
# --instructions--
Write a function that takes two strings of large numbers as parameters. Your function should return the product of these two large numbers as a string.
<strong>Note:</strong> In JavaScript, arithmetic operations are inaccurate with large numbers, so you will have to implement precise multiplication yourself.
</section>
## Tests
<section id='tests'>
**Note:** In JavaScript, arithmetic operations are inaccurate with large numbers, so you will have to implement precise multiplication yourself.
``` yml
tests:
- text: <code>mult</code> should be a function.
testString: assert(typeof mult == 'function');
- text: <code>mult("18446744073709551616", "18446744073709551616")</code> should return a string.
testString: assert(typeof mult("18446744073709551616", "18446744073709551616") == 'string');
- text: <code>mult("18446744073709551616", "18446744073709551616")</code> should return <code>"340282366920938463463374607431768211456"</code>.
testString: assert.equal(mult("18446744073709551616", "18446744073709551616"), "340282366920938463463374607431768211456");
- text: <code>mult("31844674073709551616", "1844674407309551616")</code> should return <code>"58743055272886011737990786529368211456"</code>.
testString: assert.equal(mult("31844674073709551616", "1844674407309551616"), "58743055272886011737990786529368211456");
- text: <code>mult("1846744073709551616", "44844644073709551616")</code> should return <code>"82816580680737279241781007431768211456"</code>.
testString: assert.equal(mult("1846744073709551616", "44844644073709551616"), "82816580680737279241781007431768211456");
- text: <code>mult("1844674407370951616", "1844674407709551616")</code> should return <code>"3402823669833978308014392742590611456"</code>.
testString: assert.equal(mult("1844674407370951616", "1844674407709551616"), "3402823669833978308014392742590611456");
- text: <code>mult("2844674407370951616", "1844674407370955616")</code> should return <code>"5247498076580334548376218009219475456"</code>.
testString: assert.equal(mult("2844674407370951616", "1844674407370955616"), "5247498076580334548376218009219475456");
# --hints--
`mult` should be a function.
```js
assert(typeof mult == 'function');
```
</section>
`mult("18446744073709551616", "18446744073709551616")` should return a string.
## Challenge Seed
<section id='challengeSeed'>
```js
assert(typeof mult('18446744073709551616', '18446744073709551616') == 'string');
```
<div id='js-seed'>
`mult("18446744073709551616", "18446744073709551616")` should return `"340282366920938463463374607431768211456"`.
```js
assert.equal(
mult('18446744073709551616', '18446744073709551616'),
'340282366920938463463374607431768211456'
);
```
`mult("31844674073709551616", "1844674407309551616")` should return `"58743055272886011737990786529368211456"`.
```js
assert.equal(
mult('31844674073709551616', '1844674407309551616'),
'58743055272886011737990786529368211456'
);
```
`mult("1846744073709551616", "44844644073709551616")` should return `"82816580680737279241781007431768211456"`.
```js
assert.equal(
mult('1846744073709551616', '44844644073709551616'),
'82816580680737279241781007431768211456'
);
```
`mult("1844674407370951616", "1844674407709551616")` should return `"3402823669833978308014392742590611456"`.
```js
assert.equal(
mult('1844674407370951616', '1844674407709551616'),
'3402823669833978308014392742590611456'
);
```
`mult("2844674407370951616", "1844674407370955616")` should return `"5247498076580334548376218009219475456"`.
```js
assert.equal(
mult('2844674407370951616', '1844674407370955616'),
'5247498076580334548376218009219475456'
);
```
# --seed--
## --seed-contents--
```js
function mult(strNum1, strNum2) {
@ -51,12 +86,7 @@ function mult(strNum1, strNum2) {
}
```
</div>
</section>
## Solution
<section id='solution'>
# --solutions--
```js
function mult(strNum1, strNum2) {
@ -78,5 +108,3 @@ function mult(strNum1, strNum2) {
return aResult.reverse().join("");
}
```
</section>