Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

104 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 594810f028c0303b75339acc
title: ABC问题
challengeType: 5
videoUrl: ''
dashedName: abc-problem
---
# --description--
<p>您将获得ABC块的集合例如童年字母块。每个街区有20个街区两个字母。块的所有侧面都保证有完整的字母表。块的样本集合 </p><p> BO </p><p> XK </p><p> DQ </p><p> CP </p><p> NA </p><p> GT </p><p> (回覆) </p><p> TG </p><p> QD </p><p> FS </p><p> JW </p><p> HU </p><p> VI </p><p> (一个) </p><p> OB </p><p> ER </p><p> FS </p><p> LY </p><p> PC </p><p> ZM </p><p>要记住一些规则: </p>一旦使用了块上的字母,就不能再使用该块。该函数应该不区分大小写。 <p>实现一个带字符串(单词)的函数,并确定该单词是否可以与给定的块集合拼写。 </p>
# --hints--
`canMakeWord`是一个功能。
```js
assert(typeof canMakeWord === 'function');
```
`canMakeWord`应该返回一个布尔值。
```js
assert(typeof canMakeWord('hi') === 'boolean');
```
`canMakeWord("bark")`应该返回true。
```js
assert(canMakeWord(words[0]));
```
`canMakeWord("BooK")`应该返回false。
```js
assert(!canMakeWord(words[1]));
```
`canMakeWord("TReAT")`应该返回true。
```js
assert(canMakeWord(words[2]));
```
`canMakeWord("COMMON")`应返回false。
```js
assert(!canMakeWord(words[3]));
```
`canMakeWord("squAD")`应该返回true。
```js
assert(canMakeWord(words[4]));
```
`canMakeWord("conFUSE")`应该返回true。
```js
assert(canMakeWord(words[5]));
```
# --seed--
## --after-user-code--
```js
const words = ['bark', 'BooK', 'TReAT', 'COMMON', 'squAD', 'conFUSE'];
```
## --seed-contents--
```js
function canMakeWord(word) {
}
```
# --solutions--
```js
function canMakeWord(word) {
const characters = 'BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM';
const blocks = characters.split(' ').map(pair => pair.split(''));
const letters = [...word.toUpperCase()];
let length = letters.length;
const copy = new Set(blocks);
letters.forEach(letter => {
for (let block of copy) {
const index = block.indexOf(letter);
if (index !== -1) {
length--;
copy.delete(block);
break;
}
}
});
return !length;
}
```