Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com> Co-authored-by: Beau Carnes <beaucarnes@gmail.com>
		
			
				
	
	
		
			73 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| id: 5900f4ae1000cf542c50ffc0
 | |
| challengeType: 5
 | |
| isHidden: false
 | |
| title: 'Problem 321: Swapping Counters'
 | |
| forumTopicId: 301978
 | |
| ---
 | |
| 
 | |
| ## Description
 | |
| <section id='description'>
 | |
| A horizontal row comprising of 2n + 1 squares has n red counters placed at one end and n blue counters at the other end, being separated by a single empty square in the centre. For example, when n = 3.
 | |
| 
 | |
| 
 | |
| 
 | |
| A counter can move from one square to the next (slide) or can jump over another counter (hop) as long as the square next to that counter is unoccupied.
 | |
| 
 | |
| 
 | |
| 
 | |
| Let M(n) represent the minimum number of moves/actions to completely reverse the positions of the coloured counters; that is, move all the red counters to the right and all the blue counters to the left.
 | |
| It can be verified M(3) = 15, which also happens to be a triangle number.
 | |
| 
 | |
| If we create a sequence based on the values of n for which M(n) is a triangle number then the first five terms would be:
 | |
| 1, 3, 10, 22, and 63, and their sum would be 99.
 | |
| 
 | |
| Find the sum of the first forty terms of this sequence.
 | |
| </section>
 | |
| 
 | |
| ## Instructions
 | |
| <section id='instructions'>
 | |
| 
 | |
| </section>
 | |
| 
 | |
| ## Tests
 | |
| <section id='tests'>
 | |
| 
 | |
| ```yml
 | |
| tests:
 | |
|   - text: <code>euler321()</code> should return 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>
 |