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
This commit is contained in:
committed by
mrugesh mohapatra
parent
831c6a6e15
commit
a88cdee9c3
@ -1410,26 +1410,26 @@
|
|||||||
"type": "bonfire",
|
"type": "bonfire",
|
||||||
"title": "Problem 38: Pandigital multiples",
|
"title": "Problem 38: Pandigital multiples",
|
||||||
"tests": [
|
"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": {},
|
"translations": {},
|
||||||
"challengeSeed": [
|
"challengeSeed": [
|
||||||
"function euler38() {",
|
"function pandigitalMultiples() {",
|
||||||
" // Good luck!",
|
" // Good luck!",
|
||||||
" return true;",
|
" return true;",
|
||||||
"}",
|
"}",
|
||||||
"",
|
"",
|
||||||
"euler38();"
|
"pandigitalMultiples();"
|
||||||
],
|
],
|
||||||
"description": [
|
"description": [
|
||||||
"Take the number 192 and multiply it by each of 1, 2, and 3:",
|
"Take the number 192 and multiply it by each of 1, 2, and 3:",
|
||||||
"192 × 1 = 192",
|
"192 × 1 = 192",
|
||||||
"192 × 2 = 384",
|
"192 × 2 = 384",
|
||||||
"192 × 3 = 576",
|
"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)",
|
"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).",
|
"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?"
|
"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?"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user