Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/daily-coding-challenges-python/697a49e6ff50d756c9b69362.md
T
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.2 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
697a49e6ff50d756c9b69362 Challenge 185: 2026 Winter Games Day 6: Figure Skating 29 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--

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

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compute_score([10, 8, 9, 6, 9, 8, 8, 9, 7, 7], 1), 64)`)
}})

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

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compute_score([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), 80)`)
}})

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

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compute_score([10, 8, 9, 10, 9, 8, 8, 9, 10, 7], 1, 2, 1), 67)`)
}})

compute_score([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.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compute_score([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)`)
}})

compute_score([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.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compute_score([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--

def compute_score(judge_scores, *penalties):

    return judge_scores

--solutions--

def compute_score(judge_scores, *penalties):
    sorted_scores = sorted(judge_scores)
    base_score = sum(sorted_scores[1:9])
    total_penalty = sum(penalties)

    return base_score - total_penalty