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,61 +1,103 @@
---
title: Happy numbers
id: 594810f028c0303b75339ad1
title: Happy numbers
challengeType: 5
forumTopicId: 302280
---
## Description
<section id='description'>
A <a href="https://en.wikipedia.org/wiki/Happy_number" target="_blank">happy number</a> is defined by the following process:
Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals <code>1</code> (where it will stay), or it loops endlessly in a cycle which does not include <code>1</code>. Those numbers for which this process ends in <code>1</code> are happy numbers, while those that do not end in <code>1</code> are unhappy numbers.
</section>
# --description--
A [happy number](https://en.wikipedia.org/wiki/Happy_number) is defined by the following process:
Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals `1` (where it will stay), or it loops endlessly in a cycle which does not include `1`. Those numbers for which this process ends in `1` are happy numbers, while those that do not end in `1` are unhappy numbers.
# --instructions--
## Instructions
<section id='instructions'>
Implement a function that returns true if the number is happy, or false if not.
</section>
## Tests
<section id='tests'>
# --hints--
```yml
tests:
- text: <code>happy</code> should be a function.
testString: assert(typeof happy === 'function');
- text: <code>happy(1)</code> should return a boolean.
testString: assert(typeof happy(1) === 'boolean');
- text: <code>happy(1)</code> should return true.
testString: assert(happy(1));
- text: <code>happy(2)</code> should return false.
testString: assert(!happy(2));
- text: <code>happy(7)</code> should return true.
testString: assert(happy(7));
- text: <code>happy(10)</code> should return true.
testString: assert(happy(10));
- text: <code>happy(13)</code> should return true.
testString: assert(happy(13));
- text: <code>happy(19)</code> should return true.
testString: assert(happy(19));
- text: <code>happy(23)</code> should return true.
testString: assert(happy(23));
- text: <code>happy(28)</code> should return true.
testString: assert(happy(28));
- text: <code>happy(31)</code> should return true.
testString: assert(happy(31));
- text: <code>happy(32)</code> should return true:.
testString: assert(happy(32));
- text: <code>happy(33)</code> should return false.
testString: assert(!happy(33));
`happy` should be a function.
```js
assert(typeof happy === 'function');
```
</section>
`happy(1)` should return a boolean.
## Challenge Seed
<section id='challengeSeed'>
```js
assert(typeof happy(1) === 'boolean');
```
<div id='js-seed'>
`happy(1)` should return true.
```js
assert(happy(1));
```
`happy(2)` should return false.
```js
assert(!happy(2));
```
`happy(7)` should return true.
```js
assert(happy(7));
```
`happy(10)` should return true.
```js
assert(happy(10));
```
`happy(13)` should return true.
```js
assert(happy(13));
```
`happy(19)` should return true.
```js
assert(happy(19));
```
`happy(23)` should return true.
```js
assert(happy(23));
```
`happy(28)` should return true.
```js
assert(happy(28));
```
`happy(31)` should return true.
```js
assert(happy(31));
```
`happy(32)` should return true:.
```js
assert(happy(32));
```
`happy(33)` should return false.
```js
assert(!happy(33));
```
# --seed--
## --seed-contents--
```js
function happy(number) {
@ -63,15 +105,7 @@ function happy(number) {
}
```
</div>
</section>
## Solution
<section id='solution'>
# --solutions--
```js
function happy (number) {
@ -91,7 +125,4 @@ function happy (number) {
}
return (number === 1);
}
```
</section>