Skip to content

Commit

Permalink
Create 2-2_Subway.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jisunp04023 authored Oct 21, 2023
1 parent caf1c64 commit 1d38cf4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 2-2_Subway.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
def func_a(times):
hour = int(times[:2])
minute = int(times[3:])
return hour*60 + minute

def solution(subway_times, current_time):
current_minute = func_a(current_time)
INF = 1000000000
answer = INF
for s in subway_times:
subway_minute = func_a(s)
if (subway_minute - current_minute) >= 0:
answer = subway_minute - current_minute
break
if answer == INF:
return -1
return answer


subway_times1 = ["05:31", "11:59", "13:30", "23:32"]
current_time1 = "12:00"
ret1 = solution(subway_times1, current_time1)

print("solution 함수의 반환 값은", ret1, "입니다.")

subway_times2 = ["14:31", "15:31"]
current_time2 = "15:31"
ret2 = solution(subway_times2, current_time2)

print("solution 함수의 반환 값은", ret2, "입니다.")

0 comments on commit 1d38cf4

Please sign in to comment.