* 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>
1.3 KiB
1.3 KiB
id, title, challengeType, videoUrl, dashedName
id | title | challengeType | videoUrl | dashedName |
---|---|---|---|---|
5900f3a01000cf542c50feb3 | 问题52:置换倍数 | 5 | problem-52-permuted-multiples |
--description--
可以看出,数字125874及其双精度数251748包含完全相同的数字,但顺序不同。找到最小的正整数x,使得2x,3x,4x,5x和6x包含相同的数字。
--hints--
permutedMultiples()
应该返回142857。
assert.strictEqual(permutedMultiples(), 142857);
--seed--
--seed-contents--
function permutedMultiples() {
return true;
}
permutedMultiples();
--solutions--
function permutedMultiples() {
const isPermutation = (a, b) =>
a.length !== b.length
? false
: a.split('').sort().join() === b.split('').sort().join();
let start = 1;
let found = false;
let result = 0;
while (!found) {
start *= 10;
for (let i = start; i < start * 10 / 6; i++) {
found = true;
for (let j = 2; j <= 6; j++) {
if (!isPermutation(i + '', j * i + '')) {
found = false;
break;
}
}
if (found) {
result = i;
break;
}
}
}
return result;
}