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,54 +5,81 @@ challengeType: 5
forumTopicId: 385264
---
## Description
<section id='description'>
In information theory and computer science, the <strong>Levenshtein distance</strong> is a <a href="https://en.wikipedia.org/wiki/string metric">metric</a> for measuring the amount of difference between two sequences (i.e. an <a href="https://en.wikipedia.org/wiki/edit distance">edit distance</a>). The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
# --description--
In information theory and computer science, the **Levenshtein distance** is a [metric](<https://en.wikipedia.org/wiki/string metric>) for measuring the amount of difference between two sequences (i.e. an [edit distance](<https://en.wikipedia.org/wiki/edit distance>)). The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
Example:
The Levenshtein distance between "<strong>kitten</strong>" and "<strong>sitting</strong>" is 3, since the following three edits change one into the other, and there isn't a way to do it with fewer than three edits:
The Levenshtein distance between "**kitten**" and "**sitting**" is 3, since the following three edits change one into the other, and there isn't a way to do it with fewer than three edits:
<ul>
<li><strong>k</strong>itten &nbsp; <strong>s</strong>itten &nbsp;&nbsp; (substitution of 'k' with 's')</strong></li>
<li>sitt<strong>e</strong>n &nbsp; sitt<strong>i</strong>n &nbsp;&nbsp; (substitution of 'e' with 'i')</strong></li>
<li>sittin &nbsp; sittin<strong>g</strong> &nbsp;&nbsp; (insert 'g' at the end).</strong></li>
<li><strong>k</strong>itten   <strong>s</strong>itten    (substitution of 'k' with 's')</li>
<li>sitt<strong>e</strong>n   sitt<strong>i</strong>n    (substitution of 'e' with 'i')</li>
<li>sittin   sittin<strong>g</strong>    (insert 'g' at the end).</li>
</ul>
<i>The Levenshtein distance between &nbsp; "<strong>rosettacode</strong>", &nbsp; "<strong>raisethysword</strong>" &nbsp; is <strong>8</strong>.</i>
<i>The distance between two strings is same as that when both strings are reversed.</i>
</section>
## Instructions
<section id='instructions'>
*The Levenshtein distance between "**rosettacode**", "**raisethysword**" is **8**.*
*The distance between two strings is same as that when both strings are reversed.*
# --instructions--
Write a function that returns the Levenshtein distance between two strings given as parameters.
</section>
## Tests
<section id='tests'>
# --hints--
``` yml
tests:
- text: <code>levenshtein</code> should be a function.
testString: assert(typeof levenshtein == 'function');
- text: <code>levenshtein("mist", "dist")</code> should return a number.
testString: assert(typeof levenshtein("mist", "dist") == 'number');
- text: <code>levenshtein("mist", "dist")</code> should return <code>1</code>.
testString: assert.equal(levenshtein("mist", "dist"), 1);
- text: <code>levenshtein("tier", "tor")</code> should return <code>2</code>.
testString: assert.equal(levenshtein("tier", "tor"), 2);
- text: <code>levenshtein("kitten", "sitting")</code> should return <code>3</code>.
testString: assert.equal(levenshtein("kitten", "sitting"), 3);
- text: <code>levenshtein("stop", "tops")</code> should return <code>2</code>.
testString: assert.equal(levenshtein("stop", "tops"), 2);
- text: <code>levenshtein("rosettacode", "raisethysword")</code> should return <code>8</code>.
testString: assert.equal(levenshtein("rosettacode", "raisethysword"), 8);
- text: <code>levenshtein("mississippi", "swiss miss")</code> should return <code>8</code>.
testString: assert.equal(levenshtein("mississippi", "swiss miss"), 8);
`levenshtein` should be a function.
```js
assert(typeof levenshtein == 'function');
```
</section>
`levenshtein("mist", "dist")` should return a number.
## Challenge Seed
<section id='challengeSeed'>
```js
assert(typeof levenshtein('mist', 'dist') == 'number');
```
<div id='js-seed'>
`levenshtein("mist", "dist")` should return `1`.
```js
assert.equal(levenshtein('mist', 'dist'), 1);
```
`levenshtein("tier", "tor")` should return `2`.
```js
assert.equal(levenshtein('tier', 'tor'), 2);
```
`levenshtein("kitten", "sitting")` should return `3`.
```js
assert.equal(levenshtein('kitten', 'sitting'), 3);
```
`levenshtein("stop", "tops")` should return `2`.
```js
assert.equal(levenshtein('stop', 'tops'), 2);
```
`levenshtein("rosettacode", "raisethysword")` should return `8`.
```js
assert.equal(levenshtein('rosettacode', 'raisethysword'), 8);
```
`levenshtein("mississippi", "swiss miss")` should return `8`.
```js
assert.equal(levenshtein('mississippi', 'swiss miss'), 8);
```
# --seed--
## --seed-contents--
```js
function levenshtein(a, b) {
@@ -60,12 +87,7 @@ function levenshtein(a, b) {
}
```
</div>
</section>
## Solution
<section id='solution'>
# --solutions--
```js
function levenshtein(a, b) {
@@ -80,5 +102,3 @@ function levenshtein(a, b) {
} return u[n];
}
```
</section>