Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
This commit is contained in:
committed by
GitHub
parent
a07f84c8ec
commit
0bd52f8bd1
@ -5,54 +5,70 @@ challengeType: 5
|
||||
forumTopicId: 302331
|
||||
---
|
||||
|
||||
## Description
|
||||
# --description--
|
||||
|
||||
<section id='description'>
|
||||
Write a function that takes a string as a parameter. This string represents a number that can be in any base (less than 37) and return the sum of its digits.
|
||||
|
||||
<ul>
|
||||
<li><b>1</b><sub>10</sub> sums to <b>1</b></li>
|
||||
<li><b>1234</b><sub>10</sub> sums to <b>10</b></li>
|
||||
<li><b>fe</b><sub>16</sub> sums to <b>29</b></li>
|
||||
<li><b>f0e</b><sub>16</sub> sums to <b>29</b></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
# --hints--
|
||||
|
||||
<section id='instructions'>
|
||||
`sumDigits` should be a function.
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>sumDigits</code> should be a function.
|
||||
testString: assert(typeof sumDigits == 'function');
|
||||
- text: <code>sumDigits("1")</code> should return a number.
|
||||
testString: assert(typeof sumDigits("1") == 'number');
|
||||
- text: <code>sumDigits("1")</code> should return <code>1</code>.
|
||||
testString: assert.equal(sumDigits("1"), 1);
|
||||
- text: <code>sumDigits("12345")</code> should return <code>15</code>.
|
||||
testString: assert.equal(sumDigits("12345"), 15);
|
||||
- text: <code>sumDigits("254")</code> should return <code>11</code>.
|
||||
testString: assert.equal(sumDigits("254"), 11);
|
||||
- text: <code>sumDigits("fe")</code> should return <code>29</code>.
|
||||
testString: assert.equal(sumDigits("fe"), 29);
|
||||
- text: <code>sumDigits("f0e")</code> should return <code>29</code>.
|
||||
testString: assert.equal(sumDigits("f0e"), 29);
|
||||
- text: <code>sumDigits("999ABCXYZ")</code> should return <code>162</code>.
|
||||
testString: assert.equal(sumDigits("999ABCXYZ"), 162);
|
||||
```js
|
||||
assert(typeof sumDigits == 'function');
|
||||
```
|
||||
|
||||
</section>
|
||||
`sumDigits("1")` should return a number.
|
||||
|
||||
## Challenge Seed
|
||||
```js
|
||||
assert(typeof sumDigits('1') == 'number');
|
||||
```
|
||||
|
||||
<section id='challengeSeed'>
|
||||
<div id='js-seed'>
|
||||
`sumDigits("1")` should return `1`.
|
||||
|
||||
```js
|
||||
assert.equal(sumDigits('1'), 1);
|
||||
```
|
||||
|
||||
`sumDigits("12345")` should return `15`.
|
||||
|
||||
```js
|
||||
assert.equal(sumDigits('12345'), 15);
|
||||
```
|
||||
|
||||
`sumDigits("254")` should return `11`.
|
||||
|
||||
```js
|
||||
assert.equal(sumDigits('254'), 11);
|
||||
```
|
||||
|
||||
`sumDigits("fe")` should return `29`.
|
||||
|
||||
```js
|
||||
assert.equal(sumDigits('fe'), 29);
|
||||
```
|
||||
|
||||
`sumDigits("f0e")` should return `29`.
|
||||
|
||||
```js
|
||||
assert.equal(sumDigits('f0e'), 29);
|
||||
```
|
||||
|
||||
`sumDigits("999ABCXYZ")` should return `162`.
|
||||
|
||||
```js
|
||||
assert.equal(sumDigits('999ABCXYZ'), 162);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function sumDigits(n) {
|
||||
@ -60,12 +76,7 @@ function sumDigits(n) {
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
||||
<section id='solution'>
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function sumDigits(n) {
|
||||
@ -75,5 +86,3 @@ function sumDigits(n) {
|
||||
return s;
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user