We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6a39a59 commit 24bb0a8Copy full SHA for 24bb0a8
Week6/공통/다트게임_1차/suhyun1.py
@@ -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
13
+ elif d == 'D':
14
+ n = int(n) ** 2
15
16
17
+ elif d == 'T':
18
+ n = int(n) ** 3
19
20
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
29
30
+ return sum(score)
31
32
+print(solution("1D2S#10S"))
0 commit comments