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

2.3 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
697a49e6ff50d756c9b69365 Challenge 188: 2026 Winter Games Day 9: Skeleton 28 challenge-188

--description--

Given a string representing the curves on a skeleton track, determine the difficulty of the track.

  • The given string will only consist of the letters:

    • "L" for a left turn
    • "R" for a right turn
    • "S" for a straight segment
  • Each direction change adds 15 points (an "L" followed by an "R" or vice versa).

  • All other curves add 5 points each (all other "L" or "R" characters).

  • Straight segments add 0 points.

The difficulty of the track is based on the total score. Return:

  • "Easy" if the total is 0 - 100
  • "Medium" if the total is 101-200
  • "Hard" if the total is over 200

--hints--

getDifficulty("SLSLLSRRLSRLRL") should return "Easy".

assert.equal(getDifficulty("SLSLLSRRLSRLRL"), "Easy");

getDifficulty("LLRSLRLRSLLRLRSLRRLRSRLLS") should return "Hard".

assert.equal(getDifficulty("LLRSLRLRSLLRLRSLRRLRSRLLS"), "Hard");

getDifficulty("SRRRRLSLLRLRSSRLSRL") should return "Medium".

assert.equal(getDifficulty("SRRRRLSLLRLRSSRLSRL"), "Medium");

getDifficulty("LSRLRLSRLRLSLRSLRLLRLSRLRLRSL") should return "Hard".

assert.equal(getDifficulty("LSRLRLSRLRLSLRSLRLLRLSRLRLRSL"), "Hard");

getDifficulty("SLLSSLRLSLSLRSLSSLRL") should return "Medium".

assert.equal(getDifficulty("SLLSSLRLSLSLRSLSSLRL"), "Medium");

getDifficulty("SRSLSRSLSRRSLSRSRSLSRLSRSR") should return "Easy".

assert.equal(getDifficulty("SRSLSRSLSRRSLSRSRSLSRLSRSR"), "Easy");

--seed--

--seed-contents--

function getDifficulty(track) {

  return track;
}

--solutions--

function getDifficulty(track) {
  let score = 0;

  for (let i = 0; i < track.length; i++) {
    const current = track[i];
    const previous = i > 0 ? track[i - 1] : null;

    if (current === 'S') {
      score += 0;
    } else if (current === 'L' || current === 'R') {
      if (previous && previous !== 'S' && previous !== current) {
        score += 15;
      } else if (previous !== 'S') {
        score += 5;
      } else {
        score += 5;
      }
    }
  }

  if (score <= 100) return 'Easy';
  if (score <= 200) return 'Medium';
  return 'Hard';
}