Skip to content

Commit b100745

Browse files
committed
feat:구현
1 parent 324e3be commit b100745

File tree

3 files changed

+87
-4
lines changed

3 files changed

+87
-4
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# 딕셔너리.keys()의 반환값은 리스트가 아니다.
2+
import math
3+
def getTime(t):
4+
h, m = t.split(":")
5+
return int(h) * 60 + int(m)
6+
7+
def solution(fees, records):
8+
answer = []
9+
#누적시간을 기록하는 해시맵
10+
time = dict()
11+
#들어오는 차량을 기록하는 해시맵
12+
in_list = dict()
13+
for re in records:
14+
t, num, a = re.split(" ")
15+
t = getTime(t)
16+
if a == "IN":
17+
in_list[num] = t
18+
elif a == "OUT":
19+
if num in in_list:
20+
if num in time:
21+
time[num] = time[num] + (t - in_list[num])
22+
else:
23+
time[num] = (t - in_list[num])
24+
del in_list[num]
25+
26+
# print(time)
27+
# print(in_list)
28+
s = getTime("23:59")
29+
for n in in_list.keys():
30+
if n in time:
31+
time[n] = time[n] + (s - in_list[n])
32+
else:
33+
time[n] = s - in_list[n]
34+
35+
nums = sorted(list(time.keys()))
36+
for n in nums:
37+
if time[n] > fees[0]:
38+
fee = fees[1] + ((math.ceil((time[n] - fees[0]) / fees[2])) * fees[3])
39+
answer.append(fee)
40+
else:
41+
answer.append(fees[1])
42+
return answer
43+
44+
# fees = [1, 461, 1, 10]
45+
# records = ["00:00 1234 IN"]
46+
# fees = [180, 5000, 10, 600]
47+
# records = ["05:34 5961 IN", "06:00 0000 IN", "06:34 0000 OUT", "07:59 5961 OUT", "07:59 0148 IN", "18:59 0000 IN", "19:09 0148 OUT", "22:59 5961 IN", "23:00 5961 OUT"]
48+
fees = [120, 0, 60, 591]
49+
records = ["16:00 3961 IN", "17:00 2541 IN"]
50+
print(solution(fees, records))

Week6/공통/주차요금계산/test.java

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from itertools import combinations
2+
def calculation(eq1, eq2):
3+
x1, y1, c1 = eq1
4+
x2, y2, c2 = eq2
5+
6+
if x1 * y2 == y1 * x2:
7+
return
8+
9+
x = (y1*c2 - c1*y2) / (x1*y2 - y1 * x2)
10+
y = (c1 * x2- x1 * c2) / (x1*y2 - y1*x2)
11+
12+
if x == int(x) and y == int(y):
13+
return [int(x), int(y)]
14+
15+
def solution(line):
16+
answer = []
17+
points = []
18+
for eq1, eq2 in combinations(line, 2):
19+
point = calculation(eq1, eq2)
20+
if point:
21+
points.append(point)
22+
23+
# 그림의 시작점과 마지막점 찾기
24+
print(points)
25+
w1, w2 = min(points, key=lambda x:x[0])[0], max(points, key=lambda x:x[0])[0] + 1
26+
h1, h2 = min(points, key=lambda x:x[1])[1], max(points, key=lambda x:x[1])[1] + 1
27+
print(w1, w2, h1, h2)
28+
29+
answer = [['.'] * (w2 - w1) for _ in range(h2- h1)]
30+
31+
for x, y in points:
32+
answer[y-h1][x-w1] = '*'
33+
# print([''.join(a) for a in answer])
34+
answer.reverse()
35+
return [''.join(a) for a in answer]
36+
37+
print(solution([[2, -1, 4], [-2, -1, 4], [0, -1, 1], [5, -8, -12], [5, 8, 12]]))

0 commit comments

Comments
 (0)