fix(challenges): Edit Description and Add Solution for Project Euler 45 (#17126)
Updated the problem description with an inline CSS grid, <sup>, and <var> tags. Also added a solution that user @elliotjz contributed to the fCC Arcade Mode. BREAKING CHANGE: None
This commit is contained in:
		
				
					committed by
					
						 mstellaluna
						mstellaluna
					
				
			
			
				
	
			
			
			
						parent
						
							1325cc0513
						
					
				
				
					commit
					54dbf89fd7
				
			| @@ -1604,36 +1604,24 @@ | |||||||
|       "type": "bonfire", |       "type": "bonfire", | ||||||
|       "title": "Problem 45: Triangular, pentagonal, and hexagonal", |       "title": "Problem 45: Triangular, pentagonal, and hexagonal", | ||||||
|       "tests": [ |       "tests": [ | ||||||
|         "assert.strictEqual(euler45(), 1533776805, 'message: <code>euler45()</code> should return 1533776805.');" |         "assert.strictEqual(triPentaHexa(40756), 1533776805, 'message: <code>triPentaHexa(40756)</code> should return 1533776805.');" | ||||||
|       ], |       ], | ||||||
|       "solutions": [], |       "solutions": ["function triPentaHexa(n) {\n  function triangular(num) {\n  return (num * (num + 1)) / 2;\n}\n\nfunction isPentagonal(num) {\n  // Formula found by completing the square and\n  // solving for n.\n  const n = (Math.sqrt((24 * num) + 1) + 1) / 6;\n  return n % 1 === 0;\n}\n\n  function isHexagonal(num) {\n  // Formula found by completing the square and\n  // solving for n.\n  const n = Math.sqrt(0.5 * (num + (1 / 8))) + 0.25;\n return n % 1 === 0;\n}\n\nlet iTri = n;\nlet tri;\nlet found = false;\nwhile (!found) {\n  iTri++;\n  tri = triangular(iTri);\n  if (isPentagonal(tri) && isHexagonal(tri)) {\n    found = true;\n    }\n  }\n  return tri;\n}"], | ||||||
|       "translations": {}, |       "translations": {}, | ||||||
|       "challengeSeed": [ |       "challengeSeed": [ | ||||||
|         "function euler45() {", |         "function triPentaHexa(n) {", | ||||||
|         "  // Good luck!", |         "  // Good luck!", | ||||||
|         "  return true;", |         "  return true;", | ||||||
|         "}", |         "}", | ||||||
|         "", |         "", | ||||||
|         "euler45();" |         "triPentaHexa(40756);" | ||||||
|       ], |       ], | ||||||
|       "description": [ |       "description": [ | ||||||
|         "Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:", |         "Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:", | ||||||
|         "Triangle", |         "<div style='display: inline-grid; text-align: center; grid-template-columns: repeat(3, minmax(117px, 12%)); grid-template-rows: auto;'><div>Triangle</div><div>T<sub>n</sub>=<var>n</var>(<var>n</var>+1)/2</div><div>1, 3, 6, 10, 15, ...</div></div>", | ||||||
|         "", |         "<div style='display: inline-grid; text-align: center; grid-template-columns: repeat(3, minmax(117px, 12%)); grid-template-rows: auto;'><div>Pentagonal</div><div>P<sub>n</sub>=<var>n</var>(3<var>n</var>−1)/2</div><div>1, 5, 12, 22, 35, ...</div></div>", | ||||||
|         "Tn=n(n+1)/2", |         "<div style='display: inline-grid; text-align: center; grid-template-columns: repeat(3, minmax(117px, 12%)); grid-template-rows: auto;'><div>Hexagonal</div><div>H<sub>n</sub>=<var>n</var>(2<var>n</var>−1)</div><div>1, 6, 15, 28, 45, ...</div></div>", | ||||||
|         "", |         "It can be verified that T<sub>285</sub> = P<sub>165</sub> = H<sub>143</sub> = 40755.", | ||||||
|         "1, 3, 6, 10, 15, ...", |  | ||||||
|         "Pentagonal", |  | ||||||
|         "", |  | ||||||
|         "Pn=n(3n−1)/2", |  | ||||||
|         "", |  | ||||||
|         "1, 5, 12, 22, 35, ...", |  | ||||||
|         "Hexagonal", |  | ||||||
|         "", |  | ||||||
|         "Hn=n(2n−1)", |  | ||||||
|         "", |  | ||||||
|         "1, 6, 15, 28, 45, ...", |  | ||||||
|         "It can be verified that T285 = P165 = H143 = 40755.", |  | ||||||
|         "Find the next triangle number that is also pentagonal and hexagonal." |         "Find the next triangle number that is also pentagonal and hexagonal." | ||||||
|       ] |       ] | ||||||
|     }, |     }, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user