From 9a62625ccf1fa4565ade1d4a76bbde3ae5900d19 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Mon, 29 Jul 2024 20:32:37 -0300 Subject: [PATCH] Solve Game Time with Minutes in python --- solutions/beecrowd/1047/1047.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solutions/beecrowd/1047/1047.py diff --git a/solutions/beecrowd/1047/1047.py b/solutions/beecrowd/1047/1047.py new file mode 100644 index 00000000..0f169eaf --- /dev/null +++ b/solutions/beecrowd/1047/1047.py @@ -0,0 +1,25 @@ +import sys + +for line in sys.stdin: + + start_hours, start_minutes, end_hours, end_minutes = map(int, line.split()) + + if start_hours == end_hours and start_minutes == end_minutes: + print('O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)') + continue + + durantion_hours = end_hours - start_hours + if durantion_hours < 0: + durantion_hours += 24 + + durantion_minutes = end_minutes - start_minutes + if durantion_minutes < 0: + durantion_minutes += 60 + durantion_hours -= 1 + + if durantion_hours < 0: + durantion_hours += 24 + + print( + f'O JOGO DUROU {durantion_hours} HORA(S) E {durantion_minutes} MINUTO(S)' + )