Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- Kaggle
- 편스토랑 우승상품
- ChatGPT
- 우분투
- PYTHON
- Baekjoon
- github
- 더현대서울 맛집
- 프로그래머스 파이썬
- dacon
- 캐치카페
- 파이썬
- SW Expert Academy
- gs25
- 데이콘
- Docker
- 맥북
- ubuntu
- 코로나19
- 백준
- programmers
- Git
- 금융문자분석경진대회
- Real or Not? NLP with Disaster Tweets
- 자연어처리
- hackerrank
- AI 경진대회
- 편스토랑
- leetcode
- 프로그래머스
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 1408번 : 24 (Python) 본문
728x90
반응형
코딩 1일 1문제! 오늘의 문제는 백준의 24 입니다.
👨🏻💻 코드 ( Solution )
from datetime import datetime
def convert_second_to_hour_minute_second(second):
hour = second // 3600
minute = (second // 60) - (hour * 60)
sec = second - (minute * 60) - (hour * 3600)
return hour, minute, sec
def fill_zero(num):
return str(num).zfill(2)
def twenty_four(now, nuclear):
now_time = datetime.strptime(now, '%H:%M:%S')
nuclear_time = datetime.strptime(nuclear, '%H:%M:%S')
remaining_time = nuclear_time - now_time
remaining_sec = remaining_time.seconds
hour, minute, sec = convert_second_to_hour_minute_second(remaining_sec)
return f"{fill_zero(hour)}:{fill_zero(minute)}:{fill_zero(sec)}"
if __name__ == "__main__":
now = input()
nuclear = input()
print(twenty_four(now, nuclear))
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[BaekJoon] 2748번 : 피보나치 수 2 (Python) (0) | 2022.04.18 |
---|---|
[BaekJoon] 2948번 : 2009년 (Python) (0) | 2022.04.17 |
[BaekJoon] 4299번 : AFC 윔블던 (Python) (0) | 2022.04.15 |
[BaekJoon] 2702번 : 초6 수학 (Python) (0) | 2022.04.14 |
[BaekJoon] 5522번 : 카드 게임 (Python) (0) | 2022.04.11 |
Comments