From 2c45207f3992ee520ffa2325d4ec1dde58f5195e Mon Sep 17 00:00:00 2001 From: heeheejj Date: Sun, 22 Oct 2023 00:05:51 +0900 Subject: [PATCH] =?UTF-8?q?Week27=20PRG=2042840=20=EB=AA=A8=EC=9D=98?= =?UTF-8?q?=EA=B3=A0=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\354\235\230\352\263\240\354\202\254.py" | 29 +++++++++++++++++++ ...50\354\235\230\352\263\240\354\202\254.py" | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 "heeheej/programmers/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" create mode 100644 "heeheej/week27/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" diff --git "a/heeheej/programmers/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" "b/heeheej/programmers/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" new file mode 100644 index 0000000..244dfe7 --- /dev/null +++ "b/heeheej/programmers/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" @@ -0,0 +1,29 @@ +# 모의고사 +# 프로그래머스 코딩테스트 고득점 kit > 완전탐색 +# 1280 (+2) +# 1번부터 차례대로 1,2,3번 수포자가 맞았는지 틀렸는지 확인해서 배열에 개수 업데이트하기 +# 최대 점수와 같은 사람 번호 answer에 추가하고 정렬 + +def solution(answers): + answer = [] + first = [1, 2, 3, 4, 5]*2000 + second = [2, 1, 2, 3, 2, 4, 2, 5]*1250 + third = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]*1000 + + correctCnt = [0]*3 + N = len(answers) + for i, v in enumerate(answers): + if first[i] == v: + correctCnt[0] += 1 + if second[i] == v: + correctCnt[1] += 1 + if third[i] == v: + correctCnt[2] += 1 + + maxIdx = -1 + maxVal = max(correctCnt) + for i, v in enumerate(correctCnt): + if maxVal == v: + answer.append(i+1) + answer.sort() + return answer \ No newline at end of file diff --git "a/heeheej/week27/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" "b/heeheej/week27/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" new file mode 100644 index 0000000..244dfe7 --- /dev/null +++ "b/heeheej/week27/PRG_42840_\353\252\250\354\235\230\352\263\240\354\202\254.py" @@ -0,0 +1,29 @@ +# 모의고사 +# 프로그래머스 코딩테스트 고득점 kit > 완전탐색 +# 1280 (+2) +# 1번부터 차례대로 1,2,3번 수포자가 맞았는지 틀렸는지 확인해서 배열에 개수 업데이트하기 +# 최대 점수와 같은 사람 번호 answer에 추가하고 정렬 + +def solution(answers): + answer = [] + first = [1, 2, 3, 4, 5]*2000 + second = [2, 1, 2, 3, 2, 4, 2, 5]*1250 + third = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]*1000 + + correctCnt = [0]*3 + N = len(answers) + for i, v in enumerate(answers): + if first[i] == v: + correctCnt[0] += 1 + if second[i] == v: + correctCnt[1] += 1 + if third[i] == v: + correctCnt[2] += 1 + + maxIdx = -1 + maxVal = max(correctCnt) + for i, v in enumerate(correctCnt): + if maxVal == v: + answer.append(i+1) + answer.sort() + return answer \ No newline at end of file