Expand description
ยงRed-Nosed Reports
Computes boths parts simultaneously. Each pair of levels is converted into deltas of either +1, -1 or 0. For example:
1 3 6 7 9
=>+1 +1 +1 +1
9 7 6 2 1
=>-1 -1 0 -1
If the sum of all delta equals ยฑ4, then we know that all levels are increasing or decreasing. Any other value indicates either mixed up and down transitions or levels that are too far apart.
For part two we remove each pair of deltas (or single delta at each end) then replace with the sum of the delta from the new neighbors on either side.
Functionsยง
- check ๐
- delta ๐Convert each pair of levels to either +1 for increase, -1 for decrease or 0 for invalid range.
- Minimize allocation to only a single
vec
reused for each report.
Type Aliasesยง
- Input ๐