From be74bf4ecd983b3b5cedc02e2b00ac0a8ddcff28 Mon Sep 17 00:00:00 2001 From: Yea Song Han <69785681+jadely-lab@users.noreply.github.com> Date: Sun, 27 Mar 2022 20:55:36 +0900 Subject: [PATCH 1/3] Create Week1_HW1 --- .../Week1_HW1" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "\355\225\234\354\230\210\354\206\241/Week1_HW1" diff --git "a/\355\225\234\354\230\210\354\206\241/Week1_HW1" "b/\355\225\234\354\230\210\354\206\241/Week1_HW1" new file mode 100644 index 0000000..2bb22eb --- /dev/null +++ "b/\355\225\234\354\230\210\354\206\241/Week1_HW1" @@ -0,0 +1,30 @@ +//220327 +//프로그래머스 코딩테스트 연습 모의고사 +//https://programmers.co.kr/learn/courses/30/lessons/42840 + +def solution(answers): + test_len = len(answers) + ans1 = [1, 2, 3, 4, 5] + ans2 = [2, 1, 2, 3, 2, 4, 2, 5] + ans3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] + a1 = [] + a2 = [] + a3 = [] + count = [0, 0, 0] + for i in range(test_len): + a1.append(ans1[i%5]) + a2.append(ans2[i%8]) + a3.append(ans3[i%10]) + + if answers[i] == a1[i]: + count[0] += 1 + if answers[i] == a2[i]: + count[1] += 1 + if answers[i] == a3[i]: + count[2] += 1 + # print(count.index(max(count))) + answer = [] + for _ in range(3): + if count[_] == max(count): + answer.append(_+1) + return answer From c0caf68150f55efe4fe697d2ca4d2e2fc2adae5a Mon Sep 17 00:00:00 2001 From: Yea Song Han <69785681+jadely-lab@users.noreply.github.com> Date: Sun, 27 Mar 2022 21:02:37 +0900 Subject: [PATCH 2/3] Update Week1_HW1 --- "\355\225\234\354\230\210\354\206\241/Week1_HW1" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/\355\225\234\354\230\210\354\206\241/Week1_HW1" "b/\355\225\234\354\230\210\354\206\241/Week1_HW1" index 2bb22eb..37dc95c 100644 --- "a/\355\225\234\354\230\210\354\206\241/Week1_HW1" +++ "b/\355\225\234\354\230\210\354\206\241/Week1_HW1" @@ -22,7 +22,7 @@ def solution(answers): count[1] += 1 if answers[i] == a3[i]: count[2] += 1 - # print(count.index(max(count))) + answer = [] for _ in range(3): if count[_] == max(count): From 5dd0299c41cf2f84f344ec7f05cdff95ef16c42e Mon Sep 17 00:00:00 2001 From: Yea Song Han <69785681+jadely-lab@users.noreply.github.com> Date: Mon, 2 May 2022 00:19:36 +0900 Subject: [PATCH 3/3] Create HW --- "\355\225\234\354\230\210\354\206\241/HW" | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "\355\225\234\354\230\210\354\206\241/HW" diff --git "a/\355\225\234\354\230\210\354\206\241/HW" "b/\355\225\234\354\230\210\354\206\241/HW" new file mode 100644 index 0000000..613aac4 --- /dev/null +++ "b/\355\225\234\354\230\210\354\206\241/HW" @@ -0,0 +1,27 @@ +//220501 +//프로그래머스 코딩테스트 연습 크레인 인형뽑기 게임 +//https://programmers.co.kr/learn/courses/30/lessons/64061 + +def solution(board, moves): + basket = [] + index = -1 + count = 0 + for i in moves: + for j in range(len(board)): + if j == len(board) - 1 and board[j][i-1] == 0: + break + elif board[j][i-1] == 0: + continue + else: + basket.append(board[j][i-1]) + board[j][i-1] = 0 + index += 1 + break + if index < 1: + continue + elif basket[index] == basket[index-1]: + basket.pop() + basket.pop() + count += 2 + index -= 2 + return count