fix(seed): Add tests and solution for Project Euler 19 (#16694)
Added additional tests and a working solution for this problem. BREAKING CHANGE: None
This commit is contained in:
committed by
Stuart Taylor
parent
5d14e4bdd5
commit
0136b82c0e
@ -815,17 +815,19 @@
|
|||||||
"type": "bonfire",
|
"type": "bonfire",
|
||||||
"title": "Problem 19: Counting Sundays",
|
"title": "Problem 19: Counting Sundays",
|
||||||
"tests": [
|
"tests": [
|
||||||
"assert.strictEqual(euler19(), 171, 'message: <code>euler19()</code> should return 171.');"
|
"assert.strictEqual(countingSundays(1943, 1946), 6, 'message: <code>countingSundays(1943, 1946)</code> should return 6.');",
|
||||||
|
"assert.strictEqual(countingSundays(1995, 2000), 9, 'message: <code>countingSundays(1995, 2000)</code> should return 9.');",
|
||||||
|
"assert.strictEqual(countingSundays(1901, 2000), 171, 'message: <code>countingSundays(1901, 2000)</code> 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": {},
|
"translations": {},
|
||||||
"challengeSeed": [
|
"challengeSeed": [
|
||||||
"function euler19() {",
|
"function countingSundays(firstYear, lastYear) {",
|
||||||
" // Good luck!",
|
" // Good luck!",
|
||||||
" return true;",
|
" return true;",
|
||||||
"}",
|
"}",
|
||||||
"",
|
"",
|
||||||
"euler19();"
|
"countingSundays(1943, 1946);"
|
||||||
],
|
],
|
||||||
"description": [
|
"description": [
|
||||||
"You are given the following information, but you may prefer to do some research for yourself.",
|
"You are given the following information, but you may prefer to do some research for yourself.",
|
||||||
|
Reference in New Issue
Block a user