Skip to content

Commit

Permalink
3.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pigmal24 committed May 19, 2024
1 parent e0b3840 commit 2b746b4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
7 changes: 7 additions & 0 deletions YWCHOI/1to10/3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def solution(ary) :
rary = []
for i in range (0, len(ary)) :
for j in range (i + 1, len(ary)) :
rary.append(ary[i] + ary[j])
rary.sorted(set(rary))
return rary
40 changes: 40 additions & 0 deletions YWCHOI/1to10/4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'''
def solution(answers) :
b = [[1, 2, 3, 4, 5],
[2, 1, 2, 3, 2, 4, 2, 5],
[3, 3, 1, 1, 2, 2, 4, 4, 5, 5]]
s = [0] * 3 # 이거랑 s = [[0],[0],[0]] 이거랑 다른건가..?
for i, answer in enumerate(answers) :
for j, b in enumerate(b) :
if answer == b[i % len(b)] :
s[j] += 1
max = max(s)
ss = []
for i, sc in enumerate(s) : # 갑자기 다른 변수가..?
if sc == max :
ss.append(i + 1)
return ss
'''

def solution(answers) :
betting = [[1, 2, 3, 4, 5],
[2, 1, 2, 3, 2, 4, 2, 5],
[3, 3, 1, 1, 2, 2, 4, 4, 5, 5]]
scores = [0, 0, 0]
res = []

for i, a in enumerate(answers) :
for j, b in enumerate(betting) :
if a == betting[j][i % len(betting[j])] :
scores[j] += 1


for i, s in enumerate(scores) :
if s == max(scores) :
res.append(i + 1)

return res

0 comments on commit 2b746b4

Please sign in to comment.