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 + 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 +