Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 지게차와 크레인
- two characters
- making anagrams
- dp
- boj 6443
- PCCE
- string construction
- find the town judge
- find the running median
- pccp 기출문제 풀이
- boj 1074
- DirectX12
- 프로그래밍공부
- boj 11657
- lock free stack
- DirectX
- the longest increasing subsequence
- lock based queue
- special string again
- boj 1717
- the maximum subarray
- LCS
- pcce 기출문제 풀이
- ice cream parlor
- lock based stack
- count triplets
- 브루트포스
- gas
- c++
- 2025 프로그래머스 코딩챌린지 1차예선
Archives
- Today
- Total
오구의코딩모험
[Python] 주차 요금 계산 본문
반응형
[2022 KAKAO BLIND RECRUITMENT]
from collections import defaultdict
import math
def floor(num):
if num != int(num):
return math.ceil(num)
else:
return num
def time_cal(car_in,car_out="23:59"):
car_out_h = car_out.split(":")[0]
car_out_m = car_out.split(":")[1]
car_in_h = car_in.split(":")[0]
car_in_m = car_in.split(":")[1]
hour_diff = int(car_out_h)-int(car_in_h)
min_diff = int(car_out_m)-int(car_in_m)
return hour_diff*60 + min_diff
def solution(fees, records):
answer = []
rec_dict = defaultdict(str)
fee_dict = defaultdict(int)
for rec in records:
rec = rec.split()
if rec_dict[rec[1]] == "":
rec_dict[rec[1]] = rec[0]
else:
time_fee = time_cal(rec_dict[rec[1]], rec[0])
fee_dict[rec[1]] += time_fee
rec_dict[rec[1]] = ""
for rec in rec_dict:
if rec_dict[rec] != "":
fee_dict[rec] += time_cal(car_in=rec_dict[rec])
rec_dict[rec] = ""
fee_list = sorted(fee_dict.items(),key=lambda item:item[0])
return [fees[1]+(floor((cal_fee[1] - fees[0])/fees[2])) * fees[3] if cal_fee[1] > fees[0] else fees[1] for cal_fee in fee_list]
반응형
'프로그래밍 공부 > 프로그래머스' 카테고리의 다른 글
[Python] 더 맵게 (0) | 2022.12.30 |
---|---|
[Python] 주식가격 (0) | 2022.12.30 |
머쓱이 스탬프 획득! (0) | 2022.12.27 |
[Python] 기능개발 (1) | 2022.12.26 |
[Python] 올바른 괄호 (0) | 2022.12.24 |
Comments