freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-149-searching-for-a-maximum-sum-subsequence.md
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

1.4 KiB
Raw Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f4021000cf542c50ff13 Problem 149: Searching for a maximum-sum subsequence 5 301778 problem-149-searching-for-a-maximum-sum-subsequence

--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).

253296513273184 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 = [sk24 + sk55 + 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).

--hints--

euler149() should return 52852124.

assert.strictEqual(euler149(), 52852124);

--seed--

--seed-contents--

function euler149() {

  return true;
}

euler149();

--solutions--

// solution required