From 4b6cb2d0ef1ee55cdac14b2cb128afd0b3a105ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=88=98=ED=98=84?= Date: Mon, 8 Apr 2024 18:52:07 +0900 Subject: [PATCH 1/5] =?UTF-8?q?2024-04-06=20=ED=94=BC=EB=B3=B4=EB=82=98?= =?UTF-8?q?=EC=B9=98=20=EC=88=98=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- suhyun113/DP/4-suhyun113.py | 9 +++++++++ suhyun113/README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 suhyun113/DP/4-suhyun113.py diff --git a/suhyun113/DP/4-suhyun113.py b/suhyun113/DP/4-suhyun113.py new file mode 100644 index 0000000..183d20f --- /dev/null +++ b/suhyun113/DP/4-suhyun113.py @@ -0,0 +1,9 @@ +memo = [0, 1] + +n = int(input()) +def fibo(n): + if n >= 2 and n >= len(memo): + memo.append(fibo(n-1)+fibo(n-2)) + return memo[n] + +print(fibo(n)) \ No newline at end of file diff --git a/suhyun113/README.md b/suhyun113/README.md index b25f4a7..f3aaba3 100644 --- a/suhyun113/README.md +++ b/suhyun113/README.md @@ -4,4 +4,5 @@ |:----:|:---------:|:----:|:-----:|:----:| | 1차시 | 2024.03.25 | 그리디 | [체육복](https://school.programmers.co.kr/learn/courses/30/lessons/42862) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/2) | | 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) | \ No newline at end of file +| 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) | \ No newline at end of file From 034ac610d9fa28ebcb4a06e4bd0551cb31c77a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=88=98=ED=98=84?= Date: Fri, 12 Apr 2024 22:20:47 +0900 Subject: [PATCH 2/5] =?UTF-8?q?2024-04-10=20=ED=81=AC=EB=A0=88=EC=9D=B8=20?= =?UTF-8?q?=EC=9D=B8=ED=98=95=20=EB=BD=91=EA=B8=B0?= 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/5-suhyun113.py" | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 "suhyun113/\354\212\244\355\203\235/5-suhyun113.py" diff --git a/suhyun113/README.md b/suhyun113/README.md index f3aaba3..d79604f 100644 --- a/suhyun113/README.md +++ b/suhyun113/README.md @@ -5,4 +5,5 @@ | 1차시 | 2024.03.25 | 그리디 | [체육복](https://school.programmers.co.kr/learn/courses/30/lessons/42862) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/2) | | 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) | \ No newline at end of file +| 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 diff --git "a/suhyun113/\354\212\244\355\203\235/5-suhyun113.py" "b/suhyun113/\354\212\244\355\203\235/5-suhyun113.py" new file mode 100644 index 0000000..b07a0f8 --- /dev/null +++ "b/suhyun113/\354\212\244\355\203\235/5-suhyun113.py" @@ -0,0 +1,24 @@ +def solution(board, moves): + answer = 0 + basket = [float("inf")] # board배열에서 뽑은 인형들을 넣는 바구니 + + N = len(board) # board 2차원 배열은 N*N이므로, board의 행 또는 열의 길이를 N으로 받음. + + # moves 1차원 배열에 있는 요소에 따라 어떤 열의 인형을 뽑을 지 정함. + for move in moves: #[1 5 3 5 1 2 1 4] + move -= 1 # 1번째가 실제로 board배열에서는 0번째 이므로, 각 요소마다 1씩 빼줌. + doll = 0 # 인형이 비어있다고 가정 -> 0으로 초기화 + + for i in range(N): + if board[i][move] != 0: # 열은 move로 정해져 있고, 행이 i로 계속 변함. + doll = board[i][move] # 0이 아니라면, 인형이 있는 것이므로, 인형의 값을 변경 + board[i][move] = 0 + break + + if doll != 0: # 인형이 비어있지 않아서 doll에 새로운 인형의 값이 들어갔을 때, + if basket[-1] == doll: # 바구니 가장 위에 담긴 인형과 새로 뽑은 인형이 같다면 + basket.pop() # 바구니 가장 위의 인형 제거 + answer += 2 # 같은 인형이 바구니에 담겼으므로, 2개의 인형이 터짐 + else: + basket.append(doll) # 바구니의 가장 위의 인형과 같은 인형이 아니라면, doll을 새로 바구니에 추가하기 + return answer \ No newline at end of file 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 3/5] =?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 From c2985870e0d0005b210594a2245b0ee0590ef73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=88=98=ED=98=84?= Date: Mon, 1 Jul 2024 11:32:03 +0900 Subject: [PATCH 4/5] =?UTF-8?q?2024-05-09=20=EC=9B=90=EC=88=AD=EC=9D=B4=20?= =?UTF-8?q?=EB=A7=A4=EB=8B=AC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\355\212\270\353\246\254/7-suhyun113.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "suhyun113/\355\212\270\353\246\254/7-suhyun113.py" diff --git "a/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" "b/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" new file mode 100644 index 0000000..f12a44f --- /dev/null +++ "b/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" @@ -0,0 +1,27 @@ +# 2716 : 원숭이 매달기 + +N = int(input()) # 테스트 케이스의 개수 +results = [] + +for _ in range(N): + s = input().strip() + len_s = len(s) + + depth = 0 + max_depth = 0 + + for i in range(len_s): + if (s[i] == '['): + depth += 1 + if (depth > max_depth): + max_depth = depth + elif (s[i] == ']'): + depth -= 1 + + result = 1 #나무 꼭대기 도달위해 최소 한 마리 원숭이 필요 + for _ in range(max_depth): + result *= 2 + results.append(result) + +for result in results: + print(result) \ No newline at end of file From 8974a6876593743239eeb1f076e0ea5c93714f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=88=98=ED=98=84?= Date: Mon, 1 Jul 2024 11:34:14 +0900 Subject: [PATCH 5/5] =?UTF-8?q?Revert=20"2024-05-09=20=EC=9B=90=EC=88=AD?= =?UTF-8?q?=EC=9D=B4=20=EB=A7=A4=EB=8B=AC=EA=B8=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c2985870e0d0005b210594a2245b0ee0590ef73d. --- .../\355\212\270\353\246\254/7-suhyun113.py" | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 "suhyun113/\355\212\270\353\246\254/7-suhyun113.py" diff --git "a/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" "b/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" deleted file mode 100644 index f12a44f..0000000 --- "a/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" +++ /dev/null @@ -1,27 +0,0 @@ -# 2716 : 원숭이 매달기 - -N = int(input()) # 테스트 케이스의 개수 -results = [] - -for _ in range(N): - s = input().strip() - len_s = len(s) - - depth = 0 - max_depth = 0 - - for i in range(len_s): - if (s[i] == '['): - depth += 1 - if (depth > max_depth): - max_depth = depth - elif (s[i] == ']'): - depth -= 1 - - result = 1 #나무 꼭대기 도달위해 최소 한 마리 원숭이 필요 - for _ in range(max_depth): - result *= 2 - results.append(result) - -for result in results: - print(result) \ No newline at end of file