Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.9 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
697a49e6ff50d756c9b69362 Challenge 185: 2026 Winter Games Day 6: Figure Skating 28 challenge-185

--description--

Given an array of judge scores and optional penalties, calculate the final score for a figure skating routine.

The first argument is an array of 10 judge scores, each a number from 0 to 10. Remove the highest and lowest judge scores and sum the remaining 8 scores to get the base score.

Any additional arguments passed to the function are penalties. Subtract all penalties from the base score to get the final score.

--hints--

computeScore([10, 8, 9, 6, 9, 8, 8, 9, 7, 7], 1) should return 64.

assert.equal(computeScore([10, 8, 9, 6, 9, 8, 8, 9, 7, 7], 1), 64);

computeScore([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) should return 80.

assert.equal(computeScore([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), 80);

computeScore([10, 8, 9, 10, 9, 8, 8, 9, 10, 7], 1, 2, 1) should return 67.

assert.equal(computeScore([10, 8, 9, 10, 9, 8, 8, 9, 10, 7], 1, 2, 1), 67);

computeScore([8.0, 8.5, 9.0, 8.5, 9.0, 8.0, 9.0, 8.5, 9.0, 8.5], 0.5, 1.0) should return 67.5.

assert.equal(computeScore([8.0, 8.5, 9.0, 8.5, 9.0, 8.0, 9.0, 8.5, 9.0, 8.5], 0.5, 1.0), 67.5);

computeScore([6.0, 8.5, 7.0, 9.0, 7.5, 8.0, 6.5, 9.5, 7.0, 8.0], 1.5, 0.5, 0.5) should return 59.

assert.equal(computeScore([6.0, 8.5, 7.0, 9.0, 7.5, 8.0, 6.5, 9.5, 7.0, 8.0], 1.5, 0.5, 0.5), 59);

--seed--

--seed-contents--

function computeScore(judgeScores, ...penalties) {

  return judgeScores;
}

--solutions--

function computeScore(judgeScores, ...penalties) {
  const sortedScores = [...judgeScores].sort((a, b) => a - b);
  const baseScore = sortedScores.slice(1, 9).reduce((sum, s) => sum + s, 0);
  const totalPenalty = penalties.reduce((sum, p) => sum + p, 0);

  return baseScore - totalPenalty;
}