Functions as values and higher-order operations

F-HOF-V4-2medium

Keep each rule’s bonus

First select the highest entry using the supplied comparison callback, keeping the earlier entry on a tie. Then publish one rule at each bonus setting and evaluate those rules later, after the setting has changed. Finally normalize each heat: read fractional marks exactly, remove no-shows coded as 0, apply this meet’s below-6 adjustment and reconcile the count of adjusted marks across all heats.

What needs to change

Repair score_rules so each rule keeps the bonus it was made with.

Reproduce

  1. The starter does not compile; read the diagnostic before changing the code.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

The file contains its imports, read_lines and the complete main.

Input: up to 100 valid command lines. "bonus N" sets a signed decimal whole bonus -1000..1000, and "rule" publishes a rule; fields use ordinary spaces/tabs and leading zeros are allowed. Rules are called after command processing. The supplied reader receives valid data.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in