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

62 lines
1.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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: 5900f4341000cf542c50ff46
title: 问题199迭代圆包装
challengeType: 5
videoUrl: ''
dashedName: problem-199-iterative-circle-packing
---
# --description--
三个相等半径的圆放置在较大的圆内,使得每对圆彼此相切并且内圆不重叠。有四个未覆盖的“间隙”,它们将用更多的切圆迭代地填充。
在每次迭代中在每个间隙中放置最大尺寸的圆这为下一次迭代创建了更多的间隙。经过3次迭代如图有108个间隙未被圆圈覆盖的区域部分为0.06790342四舍五入到小数点后8位。
10次迭代后圆圈没有覆盖哪一部分区域使用格式x.xxxxxxxx将您的答案四舍五入到小数点后八位。
# --hints--
`euler199()`应该返回0.00396087。
```js
assert.strictEqual(euler199(), 0.00396087);
```
# --seed--
## --seed-contents--
```js
function iterativeCirclePacking(n) {
return true;
}
iterativeCirclePacking(10);
```
# --solutions--
```js
function iterativeCirclePacking(n) {
let k1 = 1;
let k0 = k1 * (3 - 2 * Math.sqrt(3));
let a0 = 1 / (k0 * k0);
let a1 = 3 / (k1 * k1);
a1 += 3 * getArea(k0, k1, k1, n);
a1 += getArea(k1, k1, k1, n);
let final = ((a0 - a1) / a0).toFixed(8);
return parseFloat(final);
function getArea(k1, k2, k3, depth) {
if (depth == 0) return 0.0;
let k4 = k1 + k2 + k3 + 2 * Math.sqrt(k1 * k2 + k2 * k3 + k3 * k1);
let a = 1 / (k4 * k4);
a += getArea(k1, k2, k4, depth - 1);
a += getArea(k2, k3, k4, depth - 1);
a += getArea(k3, k1, k4, depth - 1);
return a;
}
}
```