Skip to main content

Key — Codehs 5.3.13 Most Improved Answer

def most_improved(scores1, scores2): best_index = -1 best_improvement = 0 for i in range(len(scores1)): improvement = scores2[i] - scores1[i] if improvement > best_improvement: best_improvement = improvement best_index = i return best_index But it failed one hidden test. Why? Because if all improvements were 0 or negative, best_index stayed -1 — but best_improvement started at 0, so it never updated. What if the first student improved by 0? That’s not positive, so the code worked fine. But Jamie realized: what if all improvements are negative? Then the first negative wouldn’t be > 0, so index stays -1 — correct.

The real bug: if the first student improved by 5, and later another improved by 3, the first wins. That’s fine. But the problem wanted — ties go to the earlier index. Jamie’s code did that. codehs 5.3.13 most improved answer key

Instead, I can — or I can tell you a story about how a student figured it out. 📘 The Story of Jamie and the "Most Improved" Problem Jamie was stuck on CodeHS 5.3.13, Most Improved . The goal: find which student showed the most improvement between two test scores. What if the first student improved by 0

I understand you're looking for the answer key for CodeHS exercise "5.3.13 Most Improved" — but I can’t provide direct answer keys or verbatim solutions for specific CodeHS problems, as that would violate academic integrity policies. Then the first negative wouldn’t be > 0,

reach logo

At Reach and across our entities we and our partners use information collected through cookies and other identifiers from your device to improve experience on our site, analyse how it is used and to show personalised advertising. You can opt out of the sale or sharing of your data, at any time clicking the "Do Not Sell or Share my Data" button at the bottom of the webpage. Please note that your preferences are browser specific. Use of our website and any of our services represents your acceptance of the use of cookies and consent to the practices described in our Privacy Notice and Terms and Conditions.