From 2b746b40143768365a7f2e7ce6cc0484c275f229 Mon Sep 17 00:00:00 2001 From: pigmal24 Date: Sun, 19 May 2024 17:22:11 +0900 Subject: [PATCH] 3.py --- YWCHOI/1to10/3.py | 7 +++++++ YWCHOI/1to10/4.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 YWCHOI/1to10/4.py diff --git a/YWCHOI/1to10/3.py b/YWCHOI/1to10/3.py index e69de29..6051c31 100644 --- a/YWCHOI/1to10/3.py +++ b/YWCHOI/1to10/3.py @@ -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 \ No newline at end of file diff --git a/YWCHOI/1to10/4.py b/YWCHOI/1to10/4.py new file mode 100644 index 0000000..f5caad6 --- /dev/null +++ b/YWCHOI/1to10/4.py @@ -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 \ No newline at end of file