At a long-jump trial, each athlete's best jump is recorded in whole centimetres. The coach wants every athlete compared with every other one in a single grid, where
is how much further athlete jumped than athlete — negative if jumped shorter. Row is athlete 's view of the whole field.
Jumps only a few centimetres apart get argued over, so athlete only clearly beats athlete when is strictly greater than margin.
Task: write head_to_head(jumps, margin) returning a tuple (gaps, clear_wins):
gaps — the whole grid as a list of lists: one row per athlete and one column per athlete, both in the order given;clear_wins — for each athlete, in order, how many others they clearly beat.margin is never negative.
Example
Athlete 0 out-jumped athlete 1 by 25 cm — more than 20, so it counts — but fell 28 cm short of athlete 2. Athlete 2 clearly beat both of the others.
A grid of every sample against every other sample is the starting point whenever you ask which examples sit closest together. This is the one-feature version.