From 49c561a42519aa3425f3bfd946fcbe171b777ddc Mon Sep 17 00:00:00 2001 From: sonypark Date: Fri, 24 May 2019 16:16:23 +0900 Subject: [PATCH 1/2] =?UTF-8?q?190524=20H=5Findex=20=EC=95=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=EC=A6=98=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190524/sony/Lv2_H-index.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 190524/sony/Lv2_H-index.py diff --git a/190524/sony/Lv2_H-index.py b/190524/sony/Lv2_H-index.py new file mode 100644 index 0000000..c1f8f2a --- /dev/null +++ b/190524/sony/Lv2_H-index.py @@ -0,0 +1,22 @@ +def h_index(citations): + citations.sort(reverse=True) + count = 0 + for i in range(len(citations)): + count +=1 + if citations[i] <= count: + if citations[i] == count: + return citations[i] + if citations[i-1] >= count-1: + return count-1 + return len(citations) + + +## 다른 사람 풀이 +def solution(citations): + citations = sorted(citations) + l = len(citations) + for i in range(l): + if citations[i] >= l-i: + return l-i + return 0 + From 53258226d15b34d7693f8b24085e24732334841e Mon Sep 17 00:00:00 2001 From: sonypark Date: Mon, 27 May 2019 14:30:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A4=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20?= =?UTF-8?q?=EB=AA=A8=EC=9D=98=EA=B3=A0=EC=82=AC=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 190527/sony/exam.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 190527/sony/exam.py diff --git a/190527/sony/exam.py b/190527/sony/exam.py new file mode 100644 index 0000000..d5b5b4c --- /dev/null +++ b/190527/sony/exam.py @@ -0,0 +1,25 @@ +def solution(answers): + s1 = [1,2,3,4,5] # cycle : 5 + s2 = [2,1,2,3,2,4,2,5] # cycle : 8 + s3 = [3,3,1,1,2,2,4,4,5,5] # cycle : 10 + + a1 = 0 + a2 = 0 + a3 = 0 + + for i in range(len(answers)): + if(s1[i%len(s1)] == answers[i]): + a1 +=1 + if(s2[i%len(s2)] == answers[i]): + a2 +=1 + if(s3[i%len(s3)] == answers[i]): + a3 +=1 + + answer_list = [a1,a2,a3] + m = max(answer_list) + result = [] + for i in range(len(answer_list)): + if m == answer_list[i]: + result.append(i+1) + return result +