From 2eafac5989cfe6ca36d4ee8b136b34ea7f50d307 Mon Sep 17 00:00:00 2001 From: Kristofer Koishigawa Date: Thu, 15 Feb 2018 18:11:54 +0900 Subject: [PATCH] fix(seed): Add tests and solution for Project Euler 19 (#16694) Added additional tests and a working solution for this problem. BREAKING CHANGE: None --- .../project-euler-problems.json | 10 ++++++---- 1 file changed, 6 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 c9371abbb9..8e8b8b8dec 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 @@ -815,17 +815,19 @@ "type": "bonfire", "title": "Problem 19: Counting Sundays", "tests": [ - "assert.strictEqual(euler19(), 171, 'message: euler19() should return 171.');" + "assert.strictEqual(countingSundays(1943, 1946), 6, 'message: countingSundays(1943, 1946) should return 6.');", + "assert.strictEqual(countingSundays(1995, 2000), 9, 'message: countingSundays(1995, 2000) should return 9.');", + "assert.strictEqual(countingSundays(1901, 2000), 171, 'message: countingSundays(1901, 2000) should return 171.');" ], - "solutions": [], + "solutions": ["function countingSundays(firstYear, lastYear) {\n let sundays = 0;\n\n for (let year = firstYear; year <= lastYear; year++) {\n for (let month = 1; month <= 12; month++) {\n const thisDate = new Date(year, month, 1);\n if (thisDate.getDay() === 0) {\n sundays++;\n }\n }\n }\n return sundays;\n}"], "translations": {}, "challengeSeed": [ - "function euler19() {", + "function countingSundays(firstYear, lastYear) {", " // Good luck!", " return true;", "}", "", - "euler19();" + "countingSundays(1943, 1946);" ], "description": [ "You are given the following information, but you may prefer to do some research for yourself.",