74 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
---
 | 
						||
id: 5900f4021000cf542c50ff13
 | 
						||
challengeType: 5
 | 
						||
title: 'Problem 149: Searching for a maximum-sum subsequence'
 | 
						||
forumTopicId: 301778
 | 
						||
---
 | 
						||
 | 
						||
## Description
 | 
						||
<section id='description'>
 | 
						||
Looking at the table below, it is easy to verify that the maximum possible sum of adjacent numbers in any direction (horizontal, vertical, diagonal or anti-diagonal) is 16 (= 8 + 7 + 1).
 | 
						||
 | 
						||
 | 
						||
−25329−6513273−18−4  8
 | 
						||
 | 
						||
Now, let us repeat the search, but on a much larger scale:
 | 
						||
 | 
						||
First, generate four million pseudo-random numbers using a specific form of what is known as a "Lagged Fibonacci Generator":
 | 
						||
 | 
						||
For 1 ≤ k ≤ 55, sk = [100003 − 200003k + 300007k3] (modulo 1000000) − 500000.
 | 
						||
For 56 ≤ k ≤ 4000000, sk = [sk−24 + sk−55 + 1000000] (modulo 1000000) − 500000.
 | 
						||
 | 
						||
Thus, s10 = −393027 and s100 = 86613.
 | 
						||
 | 
						||
The terms of s are then arranged in a 2000×2000 table, using the first 2000 numbers to fill the first row (sequentially), the next 2000 numbers to fill the second row, and so on.
 | 
						||
 | 
						||
Finally, find the greatest sum of (any number of) adjacent entries in any direction (horizontal, vertical, diagonal or anti-diagonal).
 | 
						||
</section>
 | 
						||
 | 
						||
## Instructions
 | 
						||
<section id='instructions'>
 | 
						||
 | 
						||
</section>
 | 
						||
 | 
						||
## Tests
 | 
						||
<section id='tests'>
 | 
						||
 | 
						||
```yml
 | 
						||
tests:
 | 
						||
  - text: <code>euler149()</code> should return 52852124.
 | 
						||
    testString: assert.strictEqual(euler149(), 52852124);
 | 
						||
 | 
						||
```
 | 
						||
 | 
						||
</section>
 | 
						||
 | 
						||
## Challenge Seed
 | 
						||
<section id='challengeSeed'>
 | 
						||
 | 
						||
<div id='js-seed'>
 | 
						||
 | 
						||
```js
 | 
						||
function euler149() {
 | 
						||
  // Good luck!
 | 
						||
  return true;
 | 
						||
}
 | 
						||
 | 
						||
euler149();
 | 
						||
```
 | 
						||
 | 
						||
</div>
 | 
						||
 | 
						||
 | 
						||
 | 
						||
</section>
 | 
						||
 | 
						||
## Solution
 | 
						||
<section id='solution'>
 | 
						||
 | 
						||
```js
 | 
						||
// solution required
 | 
						||
```
 | 
						||
 | 
						||
</section>
 |