BETWEEN - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: am_aadvik
Tester: iceknight1093
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

Your team is ranked X and your rival’s is Y.
How many teams are strictly between you?

EXPLANATION:

If X \lt Y, there are Y-X-1 teams between your ranks.

If X \gt Y, there are X-Y-1 teams between you.

This can be combined to write |X-Y|-1.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
x, y = map(int, input().split())
print(abs(x-y)-1)