Skip to content

Commit 24bb0a8

Browse files
committed
feat:구현
1 parent 6a39a59 commit 24bb0a8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def solution(dartResult):
2+
answer = 0
3+
4+
n = ''
5+
score = []
6+
for d in dartResult:
7+
if d.isnumeric():
8+
n += d
9+
elif d == 'S':
10+
n = int(n) ** 1
11+
score.append(n)
12+
n = ''
13+
elif d == 'D':
14+
n = int(n) ** 2
15+
score.append(n)
16+
n = ''
17+
elif d == 'T':
18+
n = int(n) ** 3
19+
score.append(n)
20+
n = ''
21+
elif d == '#':
22+
score[-1] = -score[-1]
23+
elif d == '*':
24+
if len(score) > 1:
25+
score[-1] = score[-1] * 2
26+
score[-2] = score[-2] * 2
27+
else:
28+
score[-1] = score[-1] * 2
29+
30+
return sum(score)
31+
32+
print(solution("1D2S#10S"))

0 commit comments

Comments
 (0)