Level 1 Parse versions, find the earliest supported one
Versions look like "major.minor.patch", e.g. "2.10.0" or "103.003.02" (leading zeros allowed). They must be compared numerically: "1.10.0" is newer than "1.9.0", and "1.02.0" equals (1, 2, 0).
parse_version(version) -> tuple[int, int, int].earliest_supported(versions, is_supported) -> str | None:versionsis a list of version strings in any order (no two parse to the same tuple).is_supported(version)is a slow API that says whether a feature works in that version; support can switch on and off arbitrarily between versions. Return the numerically smallest version for whichis_supportedisTrue, exactly as it was written in the input, orNoneif there is none. Callis_supportedat most once per version.
versions = ["1.10.0", "1.9.0", "1.2.3", "2.0.0"]
supported = {"1.10.0", "2.0.0"}
earliest_supported(versions, lambda v: v in supported) # "1.10.0"
parse_version("103.003.02") # (103, 3, 2)
The classic bug is sorting or comparing the raw strings: lexicographically "1.10.0" < "1.9.0".