[Programmers/프로그래머스] 2018 KAKAO BLIND RECRUITMENT [1차 코딩테스트]
- [Lv. 1] 비밀 지도
- [Lv. 1] 다트 게임
- [Lv. 2] 캐시
- [Lv. 3] 셔틀버스
- [Lv. 2] 뉴스 클러스터링
- [Lv. 2] 프렌즈4블록
- [Lv. 3] 추석 트래픽
📌 문제
📝 입력 형식
💻 출력 형식
📖 입출력 예제
📌 풀이
def convertTime(line):
date, time, elapse = line.split(' ')
hour, minute, second = time.split(':')
second, milisecond = second.split('.')
hour = int(hour) * 60 * 60 * 1000
minute = int(minute) * 60 * 1000
second = int(second) * 1000
milisecond = int(milisecond)
end_time = hour + minute + second + milisecond
start_time = end_time - (float(elapse[:-1]) * 1000) + 1
return [start_time, end_time]
def throughput(start_time, periods):
count = 0
start_range = start_time
end_range = start_time + 999
for start_point, end_point in periods:
if not (end_range < start_point or end_point < start_range):
count += 1
return count
def solution(lines):
periods = []
for log in lines:
periods.append(convertTime(log))
answer = []
for period in periods:
answer.append(throughput(period[0], periods))
answer.append(throughput(period[1], periods))
return max(answer)