일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- beautifulsoup
- WAS WebServer 차이
- 리눅스
- 파이썬 가상환경
- 오라클
- 리눅스 777
- Web Server란
- WAS란
- 변동성 돌파전략
- 프로그래머스 소수
- 리눅스 rwx
- Python
- 빗썸 API 사용
- pybithumb
- JSON특징
- java
- 프로그래머스 SQL
- string format
- 단순 반복 자동화
- 파이썬 주식
- JavaScript Obejct Notation
- 트레이딩 봇 만들기
- 와스 웹서버의 차이
- 파이썬
- JSON 형식
- spring
- 즐겨찾기가 가장 많은 식당 정보 출력하기
- Web Service Architecture
- 프로그래머스
- BigDecimal
- Today
- Total
IT 개발자_S
해커랭크 TIME Conversion python 본문
#!/bin/python3
import os
import sys
#
# Complete the timeConversion function below.
#
def timeConversion(s):
#
# Write your code here.
#
time =0
if 'PM' in (s) : ## PM 일경구
time = abs(int(s[0:2]) +12)
if(s[0:2] == '12') :
time =12
s = s.replace(s[0:2], str(time))
return(s[0:-2].zfill(8))
else :
if( int(s[0:2]) < 12): ## 12시 이전 값들은 동일하게
time = int(s[0:2])
else : ## 12시가 넘어가게되면 12를 빼줌
time = abs(int(s[0:2]) -12)
if(s[0:2] == '12') :
time = str(00)
s =s.replace(s[0:2], str(time))
return(s[0:-2].zfill(8)) ## 8자리로 고정
if __name__ == '__main__':
f = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = timeConversion(s)
f.write(result + '\n')
f.close()
'IT > 알고리즘_Python' 카테고리의 다른 글
해커랭크 Breaking the Records (0) | 2020.03.22 |
---|---|
해커랭크 Kangaroo PYTHON (0) | 2020.03.13 |
해커랭크 Apple and Orange (0) | 2020.03.12 |
해커랭크 Grading Strudents (0) | 2020.03.12 |
해커랭크 Birthday Cake Candles (0) | 2020.03.10 |