* fix(curriculum): tests quotes * fix(curriculum): fill seed-teardown * fix(curriculum): fix tests and remove unneeded seed-teardown
		
			
				
	
	
	
		
			1.6 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.6 KiB
		
	
	
	
	
	
	
	
id, challengeType, title
| id | challengeType | title | 
|---|---|---|
| 5900f38b1000cf542c50fe9e | 5 | Problem 31: Coin sums | 
Description
Instructions
Tests
tests:
  - text: <code>coinSums(50)</code> should return 451.
    testString: assert(coinSums(50) == 451, '<code>coinSums(50)</code> should return 451.');
  - text: <code>coinSums(100)</code> should return 4563.
    testString: assert(coinSums(100) == 4563, '<code>coinSums(100)</code> should return 4563.');
  - text: <code>coinSums(150)</code> should return 21873.
    testString: assert(coinSums(150) == 21873, '<code>coinSums(150)</code> should return 21873.');
  - text: <code>coinSums(200)</code> should return 73682.
    testString: assert(coinSums(200) == 73682, '<code>coinSums(200)</code> should return 73682.');
Challenge Seed
function coinSums(n) {
  // Good luck!
  return n;
}
coinSums(200);
Solution
const coinSums = (n) => {
  const getWays = (n, m=8, c=[1, 2, 5, 10, 20, 50, 100, 200]) => {
    if (n === 0) return 1;
    if (m === 0 || n < 0) return 0;
    return getWays(n - c[m - 1], m, c) + getWays(n, m - 1, c);
  };
  return getWays(n);
};