From 1e2364bb7482a112a9106c0963b4d20bcc667f2f Mon Sep 17 00:00:00 2001 From: Alvin Kristanto Date: Tue, 22 Aug 2017 11:36:34 +0700 Subject: [PATCH] feat(challenges): Updated project euler problem (#15754) added more assertion and tweaked the task feat(challenges): Added solution for project euler Added solution for project euler problem 21 --- .../project-euler-problems.json | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json b/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json index 6759752480d..8314e8941c6 100644 --- a/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json +++ b/challenges/08-coding-interview-questions-and-take-home-assignments/project-euler-problems.json @@ -672,23 +672,26 @@ "type": "bonfire", "title": "Problem 21: Amicable numbers", "tests": [ - "assert.strictEqual(euler21(), 31626, 'message: euler21() should return 31626.');" + "assert.strictEqual(sumAmicableNum(1000), 504, 'message: \u003ccode\u003esumAmicableNum(1000)\u003c/code\u003e should return 504.');", + "assert.strictEqual(sumAmicableNum(2000), 2898, 'message: \u003ccode\u003esumAmicableNum(2000)\u003c/code\u003e should return 2898.');", + "assert.strictEqual(sumAmicableNum(5000), 8442, 'message: \u003ccode\u003esumAmicableNum(5000)\u003c/code\u003e should return 8442.');", + "assert.strictEqual(sumAmicableNum(10000), 31626, 'message: \u003ccode\u003esumAmicableNum(10000)\u003c/code\u003e should return 31626.');" ], "solutions": [], "translations": {}, "challengeSeed": [ - "function euler21() {", + "function sumAmicableNum(n) {", " // Good luck!", - " return true;", + " return n;", "}", "", - "euler21();" + "sumAmicableNum(10000);" ], "description": [ "Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).", "If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.", "For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.", - "Evaluate the sum of all the amicable numbers under 10000." + "Evaluate the sum of all the amicable numbers under n." ] }, { @@ -20549,4 +20552,4 @@ ] } ] -} \ No newline at end of file +}