1package difficulty23import "math"45func CandidateCount(elo Elo) int {6 score := Score01(elo)7 if score <= 0 {8 return 19 }10 return min(8, 1+int(math.Round(score*7)))11}1213func BetterCandidate(candidate, best Report, target Elo, hasBest bool) bool {14 if !hasBest {15 return true16 }17 candidateDelta := absInt(int(candidate.ActualElo) - int(target))18 bestDelta := absInt(int(best.ActualElo) - int(target))19 if candidateDelta != bestDelta {20 return candidateDelta < bestDelta21 }22 return confidenceRank(candidate.Confidence) > confidenceRank(best.Confidence)23}2425func absInt(v int) int {26 if v < 0 {27 return -v28 }29 return v30}3132func confidenceRank(confidence Confidence) int {33 switch confidence {34 case ConfidenceHigh:35 return 336 case ConfidenceMedium:37 return 238 case ConfidenceLow:39 return 140 default:41 return 042 }43}