From 18ce7d384d2a04d56405dfa757ca15388ee79659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=88=98=ED=98=84?= Date: Mon, 15 Apr 2024 20:14:31 +0900 Subject: [PATCH] =?UTF-8?q?2024-04-14=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=20?= =?UTF-8?q?=EC=A0=9C=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- suhyun113/README.md | 3 ++- .../\354\212\244\355\203\235/6-suhyun113.py" | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 "suhyun113/\354\212\244\355\203\235/6-suhyun113.py" diff --git a/suhyun113/README.md b/suhyun113/README.md index d79604f..c74169e 100644 --- a/suhyun113/README.md +++ b/suhyun113/README.md @@ -6,4 +6,5 @@ | 2차시 | 2024.03.29 | 수학 | [소수 & 팰린드롬](https://www.acmicpc.net/problem/1747) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/9) | | 3차시 | 2024.04.02 | 그리디 | [거스름돈](https://www.acmicpc.net/problem/14916) | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/12) | | 4차시 | 2024.04.06 | DP | [피보나치 수 5](https://www.acmicpc.net/problem/10870) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/16) | -| 5차시 | 2024.04.10 | 스택 | [크레인 인형 뽑기 게임](https://school.programmers.co.kr/learn/courses/30/lessons/64061) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/19) | \ No newline at end of file +| 5차시 | 2024.04.10 | 스택 | [크레인 인형 뽑기 게임](https://school.programmers.co.kr/learn/courses/30/lessons/64061) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/19) | +| 6차시 | 2024.04.14 | 스택 | [컨트롤 제트](https://school.programmers.co.kr/learn/courses/30/lessons/120853) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/21) | \ No newline at end of file diff --git "a/suhyun113/\354\212\244\355\203\235/6-suhyun113.py" "b/suhyun113/\354\212\244\355\203\235/6-suhyun113.py" new file mode 100644 index 0000000..6018767 --- /dev/null +++ "b/suhyun113/\354\212\244\355\203\235/6-suhyun113.py" @@ -0,0 +1,20 @@ +def solution(s): + answer = 0 + + stack = [float("inf")] + + # 문자열을 공백 기준으로 나누어 리스트에 저장 + s_list = s.split() + + for i in s_list: # i는 s_list의 인덱스가 아닌 값 + if i != 'Z': + stack.append(i) + else: + stack.pop() # stack의 가장 위의 값 빼기 + stack.pop(0) + + # 문자를 정수로 변환하기 + for i in stack: + n = int(i) + answer += n + return answer \ No newline at end of file