PROBLEM 86
Hard

Minutes Between Events

Programming Basics · Python

</>
STATUS Not solved

TASK

Problem

#86

Given two times `h1 m1 h2 m2`. The second event may be next day. Print non-negative minutes from first to second.

EXAMPLE

Example

Input
23 50 0 10
Output
20

LIMITS

Constraints

0≤h≤23; 0≤m≤59
📖
LEARN Theory for this problem
+

`input()` reads data entered by the user. The result of `input()` is initially a string. `split()` separates one input line into individual values using spaces. `map()` applies the specified conversion to each input value. The `+` operator adds numbers. The `-` operator subtracts one number from another. The `*` operator multiplies numbers. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `if` checks a condition and runs its block when the condition is true. `print()` displays the program result. Print only what the problem statement requires.

**Connection to this task.** An `if` statement chooses a program branch from a Boolean condition. Comparisons produce `True` or `False`, and `elif` lets you test several mutually exclusive cases in order. The expression `b - a` shows how this idea is applied to the task data.

💡
NEED HELP? Hints
+

['Convert to minutes. If the second time is smaller, add 1440.']

ANSWER Solution
+
h1, m1, h2, m2 = map(int, input().split())
a = h1 * 60 + m1
b = h2 * 60 + m2
if b < a:
    b += 1440
print(b - a)