fix(challenges): Edit Description and Add Solution for Project Euler 38 (#17086)

Updated the problem description with `<val>` tags and improved the
formatting. Also added a solution that user @elliotjz contributed to
the fCC Arcade Mode.

BREAKING CHANGE: None
pull/18182/head
Kristofer Koishigawa 2018-04-28 18:01:23 +09:00 committed by mrugesh mohapatra
parent 831c6a6e15
commit a88cdee9c3
1 changed files with 7 additions and 7 deletions

View File

@ -1410,26 +1410,26 @@
"type": "bonfire",
"title": "Problem 38: Pandigital multiples",
"tests": [
"assert.strictEqual(euler38(), 932718654, 'message: <code>euler38()</code> should return 932718654.');"
"assert.strictEqual(pandigitalMultiples(), 932718654, 'message: <code>pandigitalMultiples()</code> should return 932718654.');"
],
"solutions": [],
"solutions": ["function pandigitalMultiples() {\n\n function get9DigitConcatenatedProduct(num) {\n // returns false if concatenated product is not 9 digits\n let concatenatedProduct = num.toString();\n for (let i = 2; concatenatedProduct.length < 9; i++) {\n concatenatedProduct += num * i;\n }\n return concatenatedProduct.length === 9 ? concatenatedProduct : false;\n }\n\n function is1to9Pandigital(num) {\n const numStr = num.toString();\n\n // check if length is not 9\n if (numStr.length !== 9) {\n return false;\n }\n\n // check if pandigital\n for (let i = 9; i > 0; i--) {\n if (numStr.indexOf(i.toString()) === -1) {\n return false;\n }\n }\n return true;\n }\n\n let largestNum = 0;\n for (let i = 9999; i >= 9000; i--) {\n const concatenatedProduct = get9DigitConcatenatedProduct(i);\n if (is1to9Pandigital(concatenatedProduct) && concatenatedProduct > largestNum) {\n largestNum = parseInt(concatenatedProduct);\n break;\n }\n }\n return largestNum;\n}"],
"translations": {},
"challengeSeed": [
"function euler38() {",
"function pandigitalMultiples() {",
" // Good luck!",
" return true;",
"}",
"",
"euler38();"
"pandigitalMultiples();"
],
"description": [
"Take the number 192 and multiply it by each of 1, 2, and 3:",
"192 × 1 = 192",
"192 × 2 = 384",
"192 × 3 = 576",
"By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)",
"The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).",
"What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n > 1?"
"By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1, 2, 3).",
"The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1, 2, 3, 4, 5).",
"What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1, 2, ... , <var>n</var>) where <var>n</var> > 1?"
]
},
{