Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.1 KiB
Raw Blame History

id, title, challengeType, videoUrl, dashedName
id title challengeType videoUrl dashedName
5900f38b1000cf542c50fe9e 问题31硬币总和 5 problem-31-coin-sums

--description--

在英格兰货币由英镑英镑和便士p组成并且有八种普通硬币流通

1p2p5p10p20p50p£1100p和£2200p

可以通过以下方式赚取£2

1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p

使用任意数量的硬币可以制成多少种便士?

--hints--

digitnPowers(50)应该返回451。

assert(coinSums(50) == 451);

digitnPowers(100)应该返回4563。

assert(coinSums(100) == 4563);

digitnPowers(150)应该返回21873。

assert(coinSums(150) == 21873);

digitnPowers(200)应该返回73682。

assert(coinSums(200) == 73682);

--seed--

--seed-contents--

function coinSums(n) {

  return n;
}

coinSums(200);

--solutions--

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);
};