Skip to content
Merged
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
22 changes: 22 additions & 0 deletions 190524/sony/Lv2_H-index.py
Original file line number Diff line number Diff line change
@@ -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

25 changes: 25 additions & 0 deletions 190527/sony/exam.py
Original file line number Diff line number Diff line change
@@ -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