https://www.hackerrank.com/challenges/time-conversion/problem
HackerRank - Time Conversion
#!/bin/python3import osimport sysdef timeConversion(s): hh = s[0:2] period = s[-2:] if(period == 'AM'): if(hh == '12'): output = '00' + s[2:-2] else: output = s[0:-2] elif(period == 'PM'): if(hh == '12'): output = s[0:-2] else: output = str(int(hh) + 12) + s[2:-2] return outputif __name__ == '__main__': f = open(os.environ['OUTPUT_PATH'], 'w') s = input() result = timeConversion(s) f.write(result + '\n') f.close()
'알고리즘 문제 풀기 > HackerRank' 카테고리의 다른 글
| HackerRank - Apple and Orange (0) | 2019.01.18 |
|---|---|
| HackerRank - Grading Students (0) | 2019.01.17 |
| HackerRank - Birthday Cake Candles (0) | 2019.01.15 |
| HackerRank - Mini-Max Sum (0) | 2019.01.14 |
| HackerRank - Staircase (0) | 2019.01.13 |