Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Week1_HW1 #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 한예송/HW
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions 한예송/Week1_HW1
Original file line number Diff line number Diff line change
@@ -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