From 748b2572341a91a878c1d18275475f6b08fe9cdc Mon Sep 17 00:00:00 2001 From: Kristofer Koishigawa Date: Thu, 15 Feb 2018 18:02:17 +0900 Subject: [PATCH] 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: None --- .../project-euler-problems.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/seed/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json b/seed/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json index f24e8661b10..32a296f68ca 100644 --- a/seed/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json +++ b/seed/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json @@ -693,21 +693,24 @@ "type": "bonfire", "title": "Problem 15: Lattice paths", "tests": [ - "assert.strictEqual(euler15(), 137846528820, 'message: euler15() should return 137846528820.');" + "assert.strictEqual(latticePaths(4), 70, 'message: latticePaths(4) should return 70.');", + "assert.strictEqual(latticePaths(9), 48620, 'message: latticePaths(9) should return 48620.');", + "assert.strictEqual(latticePaths(20), 137846528820, 'message: latticePaths(20) 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.", "", + "\"a", "", "How many such routes are there through a 20×20 grid?" ]