* 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 |
---|---|---|---|---|
5900f3761000cf542c50fe88 | 问题9:特殊的毕达哥拉斯三重奏 | 5 | problem-9-special-pythagorean-triplet |
--description--
毕达哥拉斯三元组是一组三个自然数, a
< b
< c
,其中,
a
2
b
2
= c
2
例如,3
2
- 4
2
= 9 + 16 = 25 = 5
2
。恰好存在一个毕达哥拉斯三元组,其中a
+ b
+ c
= 1000.求产品abc
使得a
+ b
+ c
= n
。
--hints--
specialPythagoreanTriplet(1000)
应返回31875000。
assert.strictEqual(specialPythagoreanTriplet(1000), 31875000);
specialPythagoreanTriplet(24)
应该返回480。
assert.strictEqual(specialPythagoreanTriplet(24), 480);
specialPythagoreanTriplet(120)
应该返回49920。
assert([49920, 55080, 60000].includes(specialPythagoreanTriplet(120)));
--seed--
--seed-contents--
function specialPythagoreanTriplet(n) {
let sumOfabc = n;
return true;
}
specialPythagoreanTriplet(1000);
--solutions--
const specialPythagoreanTriplet = (n)=>{
let sumOfabc = n;
let a,b,c;
for(a = 1; a<=sumOfabc/3; a++){
for(b = a+1; b<=sumOfabc/2; b++){
c = Math.sqrt(a*a+b*b);
if((a+b+c) == sumOfabc){
return a*b*c;
}
}
}
}