Skip to content

Commit 7230823

Browse files
committed
[BOJ] #1641. 잃어버린 괄호 / 실버2 / 24분 (성공)
1 parent 1c5d22a commit 7230823

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
nums = input()
2+
nums_list = nums.split('-') # 1. 먼저 -를 기준으로 나눈다.
3+
4+
for i, n in enumerate(nums_list):
5+
num_plus = list(map(int, n.split('+'))) # 2. +를 기준으로 나눈 후, 리스트에 int로 바꿔 저장한다.
6+
# 저장형태: [55, [50, 50]]
7+
nums_list[i] = sum(num_plus) # 3. 바꾼 int형을 더한 값을 원래의 식이 있는 리스트에 저장한다.
8+
9+
result = nums_list[0]
10+
for i in range(1, len(nums_list)): # 4. 나머지 값들을 - 연산한다.
11+
result -= nums_list[i]
12+
13+
print(result)

0 commit comments

Comments
 (0)