fix(seed): Add tests, solution, and image for Project Euler problem 15 (#16626)
Added more tests, a solution, and an image to make the description more clear. The image is from Project Euler but is rehosted on imgur. Amend: Edited the seed so that the challenge function in the seed is called only once. BREAKING CHANGE: Nonepull/16722/head
parent
00cb394f08
commit
748b257234
|
@ -693,21 +693,24 @@
|
|||
"type": "bonfire",
|
||||
"title": "Problem 15: Lattice paths",
|
||||
"tests": [
|
||||
"assert.strictEqual(euler15(), 137846528820, 'message: <code>euler15()</code> should return 137846528820.');"
|
||||
"assert.strictEqual(latticePaths(4), 70, 'message: <code>latticePaths(4)</code> should return 70.');",
|
||||
"assert.strictEqual(latticePaths(9), 48620, 'message: <code>latticePaths(9)</code> should return 48620.');",
|
||||
"assert.strictEqual(latticePaths(20), 137846528820, 'message: <code>latticePaths(20)</code> should return 137846528820.');"
|
||||
],
|
||||
"solutions": [],
|
||||
"solutions": ["function latticePaths(gridSize) {\n let paths = 1;\n\n for (let i = 0; i < gridSize; i++) {\n paths *= (2 * gridSize) - i;\n paths /= i + 1;\n }\n return paths;\n}"],
|
||||
"translations": {},
|
||||
"challengeSeed": [
|
||||
"function euler15() {",
|
||||
"function latticePaths(gridSize) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
"}",
|
||||
"",
|
||||
"euler15();"
|
||||
"latticePaths(4);"
|
||||
],
|
||||
"description": [
|
||||
"Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.",
|
||||
"",
|
||||
"<img class=\"img-responsive center-block\" alt=\"a diagram of 6 2 by 2 grids showing all the routes to the bottom right corner\" src=\"https://i.imgur.com/1Atixoj.gif\">",
|
||||
"",
|
||||
"How many such routes are there through a 20×20 grid?"
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue