From a620f94403116f3bc35583f7a227fcaaeacbfd15 Mon Sep 17 00:00:00 2001 From: a2937 Date: Fri, 7 Jul 2023 13:09:06 -0400 Subject: [PATCH] fix(curriculum): no longer use global variables (#50904) Co-authored-by: Jeremy L Thompson --- .../problem-18-maximum-path-sum-i.md | 23 ++++++++----------- .../problem-67-maximum-path-sum-ii.md | 11 ++------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-18-maximum-path-sum-i.md b/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-18-maximum-path-sum-i.md index f0d97a950b2..5658c421a53 100644 --- a/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-18-maximum-path-sum-i.md +++ b/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-18-maximum-path-sum-i.md @@ -41,22 +41,22 @@ Find the maximum total from top to bottom of the triangle below: # --hints-- -`maximumPathSumI(testTriangle)` should return a number. +`maximumPathSumI([[3, 0, 0, 0], [7, 4, 0, 0],[2, 4, 6, 0],[8, 5, 9, 3]])` should return a number. ```js -assert(typeof maximumPathSumI(testTriangle) === 'number'); +assert(typeof maximumPathSumI(_testTriangle) === 'number'); ``` -`maximumPathSumI(testTriangle)` should return 23. +`maximumPathSumI([[3, 0, 0, 0], [7, 4, 0, 0],[2, 4, 6, 0],[8, 5, 9, 3]])` should return 23. ```js -assert.strictEqual(maximumPathSumI(testTriangle), 23); +assert.strictEqual(maximumPathSumI(_testTriangle), 23); ``` -`maximumPathSumI(numTriangle)` should return 1074. +`maximumPathSumI([[75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [95, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [17, 47, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [18, 35, 87, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [20, 4, 82, 47, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [19, 1, 23, 75, 3, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0], [88, 2, 77, 73, 7, 63, 67, 0, 0, 0, 0, 0, 0, 0, 0], [99, 65, 4, 28, 6, 16, 70, 92, 0, 0, 0, 0, 0, 0, 0], [41, 41, 26, 56, 83, 40, 80, 70, 33, 0, 0, 0, 0, 0, 0], [41, 48, 72, 33, 47, 32, 37, 16, 94, 29, 0, 0, 0, 0, 0], [53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14, 0, 0, 0, 0], [70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57, 0, 0, 0], [91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48, 0, 0], [63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31, 0], [4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23]])` should return 1074. ```js -assert.strictEqual(maximumPathSumI(numTriangle), 1074); +assert.strictEqual(maximumPathSumI(_numTriangle), 1074); ``` # --seed-- @@ -64,7 +64,9 @@ assert.strictEqual(maximumPathSumI(numTriangle), 1074); ## --before-user-code-- ```js -const numTriangle = [[75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [95, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [17, 47, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [18, 35, 87, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [20, 4, 82, 47, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [19, 1, 23, 75, 3, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0], [88, 2, 77, 73, 7, 63, 67, 0, 0, 0, 0, 0, 0, 0, 0], [99, 65, 4, 28, 6, 16, 70, 92, 0, 0, 0, 0, 0, 0, 0], [41, 41, 26, 56, 83, 40, 80, 70, 33, 0, 0, 0, 0, 0, 0], [41, 48, 72, 33, 47, 32, 37, 16, 94, 29, 0, 0, 0, 0, 0], [53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14, 0, 0, 0, 0], [70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57, 0, 0, 0], [91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48, 0, 0], [63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31, 0], [4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23]]; +const _numTriangle = [[75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [95, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [17, 47, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [18, 35, 87, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [20, 4, 82, 47, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [19, 1, 23, 75, 3, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0], [88, 2, 77, 73, 7, 63, 67, 0, 0, 0, 0, 0, 0, 0, 0], [99, 65, 4, 28, 6, 16, 70, 92, 0, 0, 0, 0, 0, 0, 0], [41, 41, 26, 56, 83, 40, 80, 70, 33, 0, 0, 0, 0, 0, 0], [41, 48, 72, 33, 47, 32, 37, 16, 94, 29, 0, 0, 0, 0, 0], [53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14, 0, 0, 0, 0], [70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57, 0, 0, 0], [91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48, 0, 0], [63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31, 0], [4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23]]; + +const _testTriangle = [[3, 0, 0, 0], [7, 4, 0, 0],[2, 4, 6, 0],[8, 5, 9, 3]]; ``` ## --seed-contents-- @@ -74,13 +76,6 @@ function maximumPathSumI(triangle) { return true; } - -const testTriangle = [[3, 0, 0, 0], - [7, 4, 0, 0], - [2, 4, 6, 0], - [8, 5, 9, 3]]; - -maximumPathSumI(testTriangle); ``` # --solutions-- diff --git a/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-67-maximum-path-sum-ii.md b/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-67-maximum-path-sum-ii.md index c3aa2fb6e3b..ce1b4ca3d5d 100644 --- a/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-67-maximum-path-sum-ii.md +++ b/curriculum/challenges/english/18-project-euler/project-euler-problems-1-to-100/problem-67-maximum-path-sum-ii.md @@ -25,13 +25,13 @@ Find the maximum total from top to bottom in `numTriangle`, a 2D array defined i # --hints-- -`maximumPathSumII(testTriangle)` should return a number. +`maximumPathSumII([[3, 0, 0, 0],[7, 4, 0, 0],[2, 4, 6, 0],[8, 5, 9, 3]])` should return a number. ```js assert(typeof maximumPathSumII(_testTriangle) === 'number'); ``` -`maximumPathSumII(testTriangle)` should return 23. +`maximumPathSumII([[3, 0, 0, 0],[7, 4, 0, 0],[2, 4, 6, 0],[8, 5, 9, 3]])` should return 23. ```js assert.strictEqual(maximumPathSumII(_testTriangle), 23); @@ -62,13 +62,6 @@ function maximumPathSumII(triangle) { return true; } - -const testTriangle = [[3, 0, 0, 0], - [7, 4, 0, 0], - [2, 4, 6, 0], - [8, 5, 9, 3]]; - -maximumPathSumII(testTriangle); ``` # --solutions--