Minimum supported app versions

Backends for mobile apps Junior Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Predict the output

Which versions are supported?

Python 3.13
def parse(v: str) -> tuple[int, ...]:
    return tuple(int(p) for p in v.split("."))


MIN_SUPPORTED = parse("4.10.0")
for v in ["4.9.3", "4.10.0", "4.12.1"]:
    print(v, parse(v) >= MIN_SUPPORTED)

Options
Hint 1 of 1

Compare (4, 9, 3) with (4, 10, 0).

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A 4.9.3 False, 4.10.0 True, 4.12.1 True

Correct. Tuples compare numerically, part by part.

Splitting on dots and converting to ints makes each version a tuple, and tuples compare item by item. 9 is less than 10 in the second position, so 4.9.3 is below the minimum, while 4.10.0 equals it and 4.12.1 is above.

Why not the others?
  • B 4.9.3 True, 4.10.0 True, 4.12.1 True. That's what comparing the raw strings gives, since '9' > '1'. As tuples, (4, 9, 3) is below (4, 10, 0).
  • C 4.9.3 True, 4.10.0 True, 4.12.1 False. No comparison rule gives this: 4.12.1 is above the minimum both as strings and as numbers.
  • D 4.9.3 False, 4.10.0 False, 4.12.1 True. Equal counts as supported (>=).

30-second answer

Every request sends the app version and platform in a header. The backend keeps a minimum supported version per platform (configurable, not hard-coded) and a 'recommended' version. Below the minimum, it returns a specific error that the app knows to show as a 'please update' screen; between minimum and recommended, a soft prompt. Compare versions numerically, not as strings, and track the version distribution before raising the floor.

Practise saying it · 25 s. No recording, just a timer

Old app versions.

Say your answer out loud, then check which of these points you covered:

  • Version header
  • Configurable minimum
  • Stable force-update error
  • Numeric compare
  • Check from v1

Deep dive

Old versions can live for months on devices that don't auto-update.

The force-update check must exist from version 1; you can't add it to old builds later.

Keep the error format for force-update stable forever.

Use version-aware responses in the BFF to avoid forcing updates.

Compare versions numerically Ran on Python 3.13.5 · mypy --strict
Python 3.13
def parse(v: str) -> tuple[int, ...]:
    return tuple(int(p) for p in v.split("."))


MIN_SUPPORTED = parse("4.10.0")
for v in ["4.9.3", "4.10.0", "4.12.1"]:
    print(v, parse(v) >= MIN_SUPPORTED)

Common mistakes

  • Comparing versions as strings ('4.10' < '4.9').
  • No force-update path in the first release.
  • Raising the minimum without looking at usage.

Senior take & follow-ups

Version header, configurable minimum and recommended, a stable error, numeric comparison.

Follow-up questions

Think of your answer first, then open the hint.

  1. Why can't you add the check later?

    Show hint

    Old binaries don't contain the code to handle it.

  2. What's wrong with string comparison?

    Show hint

    '4.10.0' sorts before '4.9.3'.

Suggest a fix if something here is wrong or out of date.