* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
72 lines
1.5 KiB
Markdown
72 lines
1.5 KiB
Markdown
---
|
||
id: 5900f4ae1000cf542c50ffc0
|
||
challengeType: 5
|
||
title: 'Problem 321: Swapping Counters'
|
||
videoUrl: ''
|
||
localeTitle: 问题321:交换计数器
|
||
---
|
||
|
||
## Description
|
||
<section id="description">
|
||
由2n + 1个正方形组成的水平行在一端有n个红色计数器,在另一端有n个蓝色计数器,中间由一个空的正方形隔开。 例如,当n = 3时。
|
||
|
||
|
||
|
||
计数器可以从一个正方形移动到下一个正方形(滑动),也可以跳过另一个计数器(跳),只要该计数器旁边的正方形未被占用即可。
|
||
|
||
|
||
|
||
令M(n)表示完全反转彩色计数器位置的最小移动/动作数; 也就是说,将所有红色计数器向右移动,并将所有蓝色计数器向左移动。
|
||
可以验证M(3)= 15,它也恰好是三角形数。
|
||
|
||
如果我们基于n的值创建一个序列,其中M(n)是一个三角形数字,那么前五个项将是:
|
||
1、3、10、22和63,它们的总和为99。
|
||
|
||
找出该序列的前四十项之和。
|
||
</section>
|
||
|
||
## Instructions
|
||
<section id="instructions">
|
||
</section>
|
||
|
||
## Tests
|
||
<section id='tests'>
|
||
|
||
```yml
|
||
tests:
|
||
- text: <code>euler321()</code>应该返回2470433131948040。
|
||
testString: assert.strictEqual(euler321(), 2470433131948040);
|
||
|
||
```
|
||
|
||
</section>
|
||
|
||
## Challenge Seed
|
||
<section id='challengeSeed'>
|
||
|
||
<div id='js-seed'>
|
||
|
||
```js
|
||
function euler321() {
|
||
// Good luck!
|
||
return true;
|
||
}
|
||
|
||
euler321();
|
||
|
||
```
|
||
|
||
</div>
|
||
|
||
|
||
|
||
</section>
|
||
|
||
## Solution
|
||
<section id='solution'>
|
||
|
||
```js
|
||
// solution required
|
||
```
|
||
</section>
|