INTMTCH - Editorial

PROBLEM LINK:

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

Author: iceknight1093
Tester: iceknight1093
Editorialist: iceknight1093

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

In a football match, one team scores X goals and the other scores Y goals.
The match is interesting if they’re within two goals of each other.
Is this match interesting?

EXPLANATION:

The match is interesting if the difference between X and Y is at most 2.

There are a couple of ways to check this:

  1. Check if X-Y \le 2 and Y-X \le 2.
    Note that both checks are needed since we don’t know which of X and Y is the larger one.
  2. Alternately, use your language’s library functions. Most languages have the abs function to compute absolute difference, so just check if abs(x-y) is \le 2 or not.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
x, y = map(int, input().split())
print('Interesting' if abs(x-y) <= 2 else 'Boring')