2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 5900f37d1000cf542c50fe90
|
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
2020-10-01 17:54:21 +02:00
|
|
|
|
title: 问题17:数字字母计数
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
<section id="description">如果数字1到5用文字写出:一,二,三,四,五,则总共使用3 + 3 + 5 + 4 + 4 = 19个字母。如果从1到包含<code>limit</code>所有数字都用文字写出,那么会使用多少个字母? <b>注意:</b>不要计算空格或连字符。例如,342(三百四十二)包含23个字母,115(一百一十五)包含20个字母。在写出数字时使用“和”符合英国的用法。 </section>
|
|
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
|
<section id="instructions">
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
|
|
|
|
- text: <code>numberLetterCounts(5)</code>应返回19。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(numberLetterCounts(5), 19);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>numberLetterCounts(150)</code>应该返回1903。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(numberLetterCounts(150), 1903);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>numberLetterCounts(1000)</code>应该返回21124。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(numberLetterCounts(1000), 21124);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function numberLetterCounts(limit) {
|
|
|
|
|
// Good luck!
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
numberLetterCounts(5);
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
|
|
|
|
/section>
|