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

@ -1,58 +1,47 @@
---
title: Fibonacci word
id: 5992e222d397f00d21122931
title: Fibonacci word
challengeType: 5
forumTopicId: 302269
---
## Description
<section id='description'>
The Fibonacci Word may be created in a manner analogous to the Fibonacci Sequence <a href="https://hal.archives-ouvertes.fr/docs/00/36/79/72/PDF/The_Fibonacci_word_fractal.pdf" target="_blank">as described here</a>:
<pre>
Define F_Word<sub>1</sub> as <strong>1</strong>
# --description--
The Fibonacci Word may be created in a manner analogous to the Fibonacci Sequence [as described here](https://hal.archives-ouvertes.fr/docs/00/36/79/72/PDF/The_Fibonacci_word_fractal.pdf):
<pre>Define F_Word<sub>1</sub> as <strong>1</strong>
Define F_Word<sub>2</sub> as <strong>0</strong>
Form F_Word<sub>3</sub> as F_Word<sub>2</sub> concatenated with F_Word<sub>1</sub> i.e.: <strong>01</strong>
Form F_Word<sub>n</sub> as F_Word<sub>n-1</sub> concatenated with F_word<sub>n-2</sub>
</pre>
</section>
## Instructions
<section id='instructions'>
Write a function to return the Fibonacci Words up to <code>n</code>. <code>n</code> will be provided as a parameter to the function. The function should return an array of objects. The objects should be of the form: <code>{ N: 1, Length: 1, Entropy: 0, Word: '1' }</code>.
</section>
# --instructions--
## Tests
<section id='tests'>
Write a function to return the Fibonacci Words up to `n`. `n` will be provided as a parameter to the function. The function should return an array of objects. The objects should be of the form: `{ N: 1, Length: 1, Entropy: 0, Word: '1' }`.
```yml
tests:
- text: <code>fibWord</code> should be a function.
testString: assert(typeof fibWord === 'function');
- text: <code>fibWord(5)</code> should return an array.
testString: assert(Array.isArray(fibWord(5)));
- text: <code>fibWord(5)</code> should return <code>[{ N:1, Length:1, Entropy:0, Word:"1" },{ N:2, Length:1, Entropy:0, Word:"0" },{ N:3, Length:2, Entropy:1, Word:"01" },{ N:4, Length:3, Entropy:0.9182958340544896, Word:"010" },{ N:5, Length:5, Entropy:0.9709505944546688, Word:"01001" }]</code>.
testString: assert.deepEqual(fibWord(5),ans);
# --hints--
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
`fibWord` should be a function.
```js
function fibWord(n) {
}
assert(typeof fibWord === 'function');
```
</div>
`fibWord(5)` should return an array.
```js
assert(Array.isArray(fibWord(5)));
```
### After Test
<div id='js-teardown'>
`fibWord(5)` should return `[{ N:1, Length:1, Entropy:0, Word:"1" },{ N:2, Length:1, Entropy:0, Word:"0" },{ N:3, Length:2, Entropy:1, Word:"01" },{ N:4, Length:3, Entropy:0.9182958340544896, Word:"010" },{ N:5, Length:5, Entropy:0.9709505944546688, Word:"01001" }]`.
```js
assert.deepEqual(fibWord(5), ans);
```
# --seed--
## --after-user-code--
```js
let ans=[ { N: 1, Length: 1, Entropy: 0, Word: '1' },
@ -66,13 +55,15 @@ let ans=[ { N: 1, Length: 1, Entropy: 0, Word: '1' },
{ N: 5, Length: 5, Entropy: 0.9709505944546688, Word: '01001' }];
```
</div>
## --seed-contents--
</section>
```js
function fibWord(n) {
## Solution
<section id='solution'>
}
```
# --solutions--
```js
function fibWord(n) {
@ -109,24 +100,21 @@ function fibWord(n) {
var e = entropy(w);
if (l <= 21) {
o.push({
N: i + 1,
Length: l,
Entropy: e,
Word: w
});
o.push({
N: i + 1,
Length: l,
Entropy: e,
Word: w
});
} else {
o.push({
N: i + 1,
Length: l,
Entropy: e,
Word: "..."
});
o.push({
N: i + 1,
Length: l,
Entropy: e,
Word: "..."
});
}
}
return o;
}
```
</section>