feat(euler-problem): Add Test and solution for euler problem 9 (#16029)
* feat(euler-problem): Add Test and solution for euler problem 9 * style: Fix up formating per comments
This commit is contained in:
		
				
					committed by
					
						 Ethan Arrowood
						Ethan Arrowood
					
				
			
			
				
	
			
			
			
						parent
						
							9610f1facc
						
					
				
				
					commit
					68c4485e12
				
			| @@ -248,17 +248,20 @@ | |||||||
|       "type": "bonfire", |       "type": "bonfire", | ||||||
|       "title": "Problem 9: Special Pythagorean triplet", |       "title": "Problem 9: Special Pythagorean triplet", | ||||||
|       "tests": [ |       "tests": [ | ||||||
|         "assert.strictEqual(euler9(), 31875000, 'message: <code>euler9()</code> should return 31875000.');" |         "assert.strictEqual(specialPythagoreanTriplet(1000), 31875000, 'message: <code>specialPythagoreanTriplet(1000)</code> should return 31875000.');", | ||||||
|  |         "assert.strictEqual(specialPythagoreanTriplet(24), 480, 'message: <code>specialPythagoreanTriplet(24)</code> should return 480.');", | ||||||
|  |         "assert.strictEqual(specialPythagoreanTriplet(120), 49920, 'message: <code>specialPythagoreanTriplet(120)</code> should return 49920.');" | ||||||
|  |       ], | ||||||
|  |       "solutions": [ | ||||||
|  |         "const specialPythagoreanTriplet = (n)=>{\n let sumOfabc = n;\n let a,b,c;\n for(a = 1; a<=sumOfabc/3; a++){\n for(b = a+1; b<=sumOfabc/2; b++){\n c = Math.sqrt(a*a+b*b);\n if((a+b+c) == sumOfabc){\n return a*b*c;\n }\n }\n }\n}" | ||||||
|       ], |       ], | ||||||
|       "solutions": [], |  | ||||||
|       "translations": {}, |       "translations": {}, | ||||||
|       "challengeSeed": [ |       "challengeSeed": [ | ||||||
|         "function euler9() {", |         "function specialPythagoreanTriplet(n) {", | ||||||
|         "  // Good luck!", |         " let sumOfabc = n;", " // Good luck!", | ||||||
|         "  return true;", |         " return true;", "}", | ||||||
|         "}", |  | ||||||
|         "", |         "", | ||||||
|         "euler9();" |         "specialPythagoreanTriplet(1000);" | ||||||
|       ], |       ], | ||||||
|       "description": [ |       "description": [ | ||||||
|         "A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,", |         "A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user