From 297a5129f50934a4b66c79c764ab3cefe149804d Mon Sep 17 00:00:00 2001 From: Reoyl Date: Wed, 20 Apr 2022 22:05:57 +0900 Subject: [PATCH 1/5] =?UTF-8?q?17910=20JointAttack=20=EC=A0=95=EC=9E=AC?= =?UTF-8?q?=ED=99=8D=20-=20=EC=96=B4=EB=94=94=EA=B0=80=20=ED=8B=80?= =?UTF-8?q?=EB=A6=B0=20=EA=B1=B8=EA=B9=8C=EC=9A=94=E3=85=9C=E3=85=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week1/17910jointAttack/solution.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/week1/17910jointAttack/solution.py b/week1/17910jointAttack/solution.py index e69de29..5b0a18e 100644 --- a/week1/17910jointAttack/solution.py +++ b/week1/17910jointAttack/solution.py @@ -0,0 +1,10 @@ +def jointAttack(array): + if (len(array)<=1): + return array.pop() + + return array.pop(0) + 1 / (jointAttack(array)) + +N = int(input()) +array = [int(_) for _ in input().split()] + +print(jointAttack(array)) \ No newline at end of file From ae2fdf7bcbcb331564c4e55cf14c0a55d33c74cb Mon Sep 17 00:00:00 2001 From: Reoyl Date: Thu, 21 Apr 2022 08:45:34 +0900 Subject: [PATCH 2/5] 1021 Rotating Queue Solved --- .../solution.py" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git "a/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" "b/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" index e69de29..45e32fb 100644 --- "a/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" +++ "b/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" @@ -0,0 +1,48 @@ +class Rotate_Q: + def __init__(self, n): + self.n = n + self.data = list(range(1, self.n+1)) + self.count = 0 + + def print_Q(self): + print(self.data) + + def print_count(self): + print(self.count) + + def pop(self): + self.data.pop(0) + + def left(self): + self.data.append(self.data.pop(0)) + self.count += 1 + + def right(self): + self.data.insert(0, self.data.pop()) + self.count += 1 + + def rotate(self, pos): + if self.data.index(pos)==0: + self.pop() + + elif self.data.index(pos) <= len(self.data)//2: + while(pos in self.data): + self.left() + if(self.data.index(pos)==0): + self.pop() + break + else: + while(pos in self.data): + self.right() + if(self.data.index(pos)==0): + self.pop() + break + +N, M = map(int, input().split()) +position = list(map(int, input().split())) +myQ = Rotate_Q(N) + +for pos in position: + myQ.rotate(pos) + +myQ.print_count() \ No newline at end of file From c33e4d0370021b0702680ada6d44617c26d24b38 Mon Sep 17 00:00:00 2001 From: Reoyl Date: Sun, 24 Apr 2022 12:11:37 +0900 Subject: [PATCH 3/5] joint Attack deleted from this branch --- week1/17910jointAttack/solution.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/week1/17910jointAttack/solution.py b/week1/17910jointAttack/solution.py index 5b0a18e..e69de29 100644 --- a/week1/17910jointAttack/solution.py +++ b/week1/17910jointAttack/solution.py @@ -1,10 +0,0 @@ -def jointAttack(array): - if (len(array)<=1): - return array.pop() - - return array.pop(0) + 1 / (jointAttack(array)) - -N = int(input()) -array = [int(_) for _ in input().split()] - -print(jointAttack(array)) \ No newline at end of file From f2bc7bcb01d64e3281c1d3a5f791ed74294d2731 Mon Sep 17 00:00:00 2001 From: Reoyl Date: Sun, 24 Apr 2022 13:28:23 +0900 Subject: [PATCH 4/5] =?UTF-8?q?1158=20=EC=9A=94=EC=84=B8=ED=91=B8=EC=8A=A4?= =?UTF-8?q?=20=EB=AC=B8=EC=A0=9C=20-=20Solved=20using=20queue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solution.py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git "a/week1/1158\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234/solution.py" "b/week1/1158\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234/solution.py" index e69de29..11c11d5 100644 --- "a/week1/1158\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234/solution.py" +++ "b/week1/1158\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234/solution.py" @@ -0,0 +1,13 @@ +from collections import deque +N, k = map(int, input().split()) +queue = deque(list(range(1, N+1))) + +killed = [] +while queue: + for _ in range(k-1): + queue.append(queue.popleft()) + killed.append(queue.popleft()) + +print('<', end='') +print(*killed, sep=', ', end='') +print('>') \ No newline at end of file From 25e05bbc22e710a99cd455a0cebf3cfef14786e2 Mon Sep 17 00:00:00 2001 From: Reoyl Date: Sun, 24 Apr 2022 13:30:38 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=ED=9A=8C=EC=A0=84=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=ED=81=90=20was=20deleted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solution.py" | 48 ------------------- 1 file changed, 48 deletions(-) diff --git "a/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" "b/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" index 45e32fb..e69de29 100644 --- "a/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" +++ "b/week1/1021\355\232\214\354\240\204\355\225\230\353\212\224\355\201\220/solution.py" @@ -1,48 +0,0 @@ -class Rotate_Q: - def __init__(self, n): - self.n = n - self.data = list(range(1, self.n+1)) - self.count = 0 - - def print_Q(self): - print(self.data) - - def print_count(self): - print(self.count) - - def pop(self): - self.data.pop(0) - - def left(self): - self.data.append(self.data.pop(0)) - self.count += 1 - - def right(self): - self.data.insert(0, self.data.pop()) - self.count += 1 - - def rotate(self, pos): - if self.data.index(pos)==0: - self.pop() - - elif self.data.index(pos) <= len(self.data)//2: - while(pos in self.data): - self.left() - if(self.data.index(pos)==0): - self.pop() - break - else: - while(pos in self.data): - self.right() - if(self.data.index(pos)==0): - self.pop() - break - -N, M = map(int, input().split()) -position = list(map(int, input().split())) -myQ = Rotate_Q(N) - -for pos in position: - myQ.rotate(pos) - -myQ.print_count() \ No newline at end of file