2.9 KiB
2.9 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
a7bf700cd123b9a54eef01d5 | No Repeats Please | 5 | 请不要重复 |
Description
aab
应该返回2,因为它总共有6个排列( aab
, aab
, aba
, aba
, baa
, baa
),但只有2个( aba
和aba
)没有相同的字母(在这种情况下为a
)重复。如果卡住,请记得使用Read-Search-Ask 。尝试配对程序。编写自己的代码。 Instructions
Tests
tests:
- text: <code>permAlone("aab")</code>应返回一个数字。
testString: 'assert.isNumber(permAlone("aab"), "<code>permAlone("aab")</code> should return a number.");'
- text: <code>permAlone("aab")</code>应返回2。
testString: 'assert.strictEqual(permAlone("aab"), 2, "<code>permAlone("aab")</code> should return 2.");'
- text: <code>permAlone("aaa")</code>应该返回0。
testString: 'assert.strictEqual(permAlone("aaa"), 0, "<code>permAlone("aaa")</code> should return 0.");'
- text: <code>permAlone("aabb")</code>应该返回8。
testString: 'assert.strictEqual(permAlone("aabb"), 8, "<code>permAlone("aabb")</code> should return 8.");'
- text: <code>permAlone("abcdefa")</code>应返回3600。
testString: 'assert.strictEqual(permAlone("abcdefa"), 3600, "<code>permAlone("abcdefa")</code> should return 3600.");'
- text: <code>permAlone("abfdefa")</code>应返回2640。
testString: 'assert.strictEqual(permAlone("abfdefa"), 2640, "<code>permAlone("abfdefa")</code> should return 2640.");'
- text: <code>permAlone("zzzzzzzz")</code>应该返回0。
testString: 'assert.strictEqual(permAlone("zzzzzzzz"), 0, "<code>permAlone("zzzzzzzz")</code> should return 0.");'
- text: <code>permAlone("a")</code>应返回1。
testString: 'assert.strictEqual(permAlone("a"), 1, "<code>permAlone("a")</code> should return 1.");'
- text: <code>permAlone("aaab")</code>应该返回0。
testString: 'assert.strictEqual(permAlone("aaab"), 0, "<code>permAlone("aaab")</code> should return 0.");'
- text: <code>permAlone("aaabb")</code>应该返回12。
testString: 'assert.strictEqual(permAlone("aaabb"), 12, "<code>permAlone("aaabb")</code> should return 12.");'
Challenge Seed
function permAlone(str) {
return str;
}
permAlone('aab');
Solution
// solution required