The brief
you can't edit the code — only instruct the AImedian(nums)
- Returns the median of
nums. - Even count? Return the lower of the two middle values — never average them.
- An empty list returns 0.
median([3, 1, 2]) → 2
current code — written by the AI
function median(nums) {
// Return the median value.
const s = nums.slice().sort();
return s[Math.floor(s.length / 2)];
}
6 hidden cases · 1 shown
Drive the AI
it does exactly what you sayDrive me to fix median so it passes the hidden tests. I do exactly what you tell me — nothing more — so be precise. Every message costs tokens; fewest tokens wins. Par is 500. Hit “Run tests” whenever you want to check.
token spend vs par0 / 500