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 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..37dc95c --- /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 + + answer = [] + for _ in range(3): + if count[_] == max(count): + answer.append(_+1) + return answer