diff --git a/request_test/solution.py b/request_test/solution.py index e69de29..d5c296f 100644 --- a/request_test/solution.py +++ b/request_test/solution.py @@ -0,0 +1,2 @@ +print("hello") +print("1234") \ No newline at end of file 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..9cf6959 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,20 @@ +import sys +from collections import deque + +n, m = map(int, sys.stdin.readline().split()) +to_pop_list = list(map(int, sys.stdin.readline().split())) +rotating_queue = deque([i + 1 for i in range(n)]) +cnt = 0 +for i in to_pop_list: + while True: + if rotating_queue.index(i) == 0: + rotating_queue.popleft() + break + elif rotating_queue.index(i) <= len(rotating_queue) - rotating_queue.index(i): + rotating_queue.append(rotating_queue.popleft()) + cnt += 1 + else: + rotating_queue.appendleft(rotating_queue.pop()) + cnt += 1 + +print(cnt) \ No newline at end of file diff --git "a/week1/10828\354\212\244\355\205\215/solution.py" "b/week1/10828\354\212\244\355\205\215/solution.py" index e69de29..6b99c46 100644 --- "a/week1/10828\354\212\244\355\205\215/solution.py" +++ "b/week1/10828\354\212\244\355\205\215/solution.py" @@ -0,0 +1,26 @@ +import sys + +n = int(sys.stdin.readline()) +stack = [] +for i in range(n): + inp = list(map(str, sys.stdin.readline().rstrip().split())) + if inp[0] == "push": + stack.append(inp[1]) + elif inp[0] == "pop": + if not stack: + print(-1) + continue + print(stack.pop()) + elif inp[0] == "size": + print(len(stack)) + elif inp[0] == "empty": + if not stack: + print(1) + continue + print(0) + elif inp[0] == "top": + if not stack: + print(-1) + continue + print(stack[-1]) + diff --git "a/week1/10845\355\201\220/solution.py" "b/week1/10845\355\201\220/solution.py" index e69de29..d64008c 100644 --- "a/week1/10845\355\201\220/solution.py" +++ "b/week1/10845\355\201\220/solution.py" @@ -0,0 +1,32 @@ +import sys +from collections import deque + +n = int(sys.stdin.readline()) +queue = deque([]) +for i in range(n): + inp = list(map(str, sys.stdin.readline().rstrip().split())) + if inp[0] == "push": + queue.append(int(inp[1])) + elif inp[0] == "pop": + if not queue: + print(-1) + else: + print(queue.popleft()) + elif inp[0] == "size": + print(len(queue)) + elif inp[0] == "empty": + if not queue: + print(1) + + else: + print(0) + elif inp[0] == "front": + if not queue: + print(-1) + else: + print(queue[0]) + elif inp[0] == "back": + if not queue: + print(-1) + else: + print(queue[-1]) \ No newline at end of file diff --git "a/week1/10866\353\215\261/solution.py" "b/week1/10866\353\215\261/solution.py" index e69de29..66bcba0 100644 --- "a/week1/10866\353\215\261/solution.py" +++ "b/week1/10866\353\215\261/solution.py" @@ -0,0 +1,39 @@ +import sys +from collections import deque + +d = deque() + +n = int(sys.stdin.readline()) +for i in range(n): + order = list(map(str, sys.stdin.readline().rstrip().split())) + if order[0] == "push_front": + d.appendleft(int(order[1])) + elif order[0] == "push_back": + d.append(int(order[1])) + elif order[0] == "pop_front": + try: + print(d.popleft()) + except IndexError: + print(-1) + elif order[0] == "pop_back": + try: + print(d.pop()) + except IndexError: + print(-1) + elif order[0] == "size": + print(len(d)) + elif order[0] == "empty": + if d: + print(0) + else: + print(1) + elif order[0] == "front": + try: + print(d[0]) + except IndexError: + print(-1) + elif order[0] == "back": + try: + print(d[-1]) + except IndexError: + print(-1) \ No newline at end of file diff --git "a/week1/10870\355\224\274\353\263\264\353\202\230\354\271\230\354\210\2305/solution.py" "b/week1/10870\355\224\274\353\263\264\353\202\230\354\271\230\354\210\2305/solution.py" index e69de29..f3e1205 100644 --- "a/week1/10870\355\224\274\353\263\264\353\202\230\354\271\230\354\210\2305/solution.py" +++ "b/week1/10870\355\224\274\353\263\264\353\202\230\354\271\230\354\210\2305/solution.py" @@ -0,0 +1,9 @@ +N = int(input()) + +def fibonacci(n): + if n <= 1: + return n + return fibonacci(n-1) + fibonacci(n-2) + + +print(fibonacci(N)) \ No newline at end of file diff --git "a/week1/1110\353\215\224\355\225\230\352\270\260\354\202\254\354\235\264\355\201\264/solution.py" "b/week1/1110\353\215\224\355\225\230\352\270\260\354\202\254\354\235\264\355\201\264/solution.py" index e69de29..e79c48d 100644 --- "a/week1/1110\353\215\224\355\225\230\352\270\260\354\202\254\354\235\264\355\201\264/solution.py" +++ "b/week1/1110\353\215\224\355\225\230\352\270\260\354\202\254\354\235\264\355\201\264/solution.py" @@ -0,0 +1,15 @@ +num = int(input()) +check = num +temp = 0 +count = 0 +new_num = 0 + +while True: + temp = (num//10) + (num%10) + new_num =(num%10)*10 + temp%10 + count += 1 + num = new_num + if num == check: + break + +print(count) 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..979e77d 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,20 @@ +import sys +from collections import deque + +n, k =map(int, sys.stdin.readline().split()) +queue = deque(i + 1 for i in range(n)) +res = [] +i = 0 +while queue: + if i == k - 1: + res.append(queue.popleft()) + i = 0 + continue + queue.append(queue.popleft()) + i += 1 +print("<", end="") +for i in res: + if i == res[-1]: + print("%d>" % i) + continue + print(i, end=", ") diff --git a/week1/17910jointAttack/solution.py b/week1/17910jointAttack/solution.py index e69de29..62241e8 100644 --- a/week1/17910jointAttack/solution.py +++ b/week1/17910jointAttack/solution.py @@ -0,0 +1,15 @@ +import sys +from fractions import Fraction + + +n = int(sys.stdin.readline()) +arr = list(map(int, sys.stdin.readline().split())) + +def joinAttack(i): + try: + return arr[i] + Fraction(1, joinAttack(i + 1)) + except IndexError: + return arr[i] + + +print(joinAttack(0)) \ No newline at end of file diff --git "a/week1/1934\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230/solution.py" "b/week1/1934\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230/solution.py" index e69de29..0eb87e8 100644 --- "a/week1/1934\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230/solution.py" +++ "b/week1/1934\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230/solution.py" @@ -0,0 +1,20 @@ +import sys + +def gcf(x, y): + while y: + x, y = y, x % y + + return x + +def lcm(x, y): + return x * y // gcf(x, y) + + +n = int(sys.stdin.readline()) +for i in range(n): + a, b = map(int, sys.stdin.readline().split()) + print(lcm(a, b)) + + + + diff --git "a/week1/1977\354\231\204\354\240\204\354\240\234\352\263\261\354\210\230/solution.py" "b/week1/1977\354\231\204\354\240\204\354\240\234\352\263\261\354\210\230/solution.py" index e69de29..d8f0e26 100644 --- "a/week1/1977\354\231\204\354\240\204\354\240\234\352\263\261\354\210\230/solution.py" +++ "b/week1/1977\354\231\204\354\240\204\354\240\234\352\263\261\354\210\230/solution.py" @@ -0,0 +1,25 @@ +import sys +import math + +m = int(sys.stdin.readline()) +n = int(sys.stdin.readline()) + +arr = [0] * 10001 +for i in range(1, 101): + arr[i * i] = True + +sum_ = 0 +min_ = 0 +for num in range(m, n + 1): + if arr[num]: + sum_ += num + if not min_: + min_ = num + +if min_: + print(sum_) + print(min_) +else: + print(-1) + + diff --git "a/week1/20301\353\260\230\354\240\204\354\232\224\354\204\270\355\221\270\354\212\244/solution.py" "b/week1/20301\353\260\230\354\240\204\354\232\224\354\204\270\355\221\270\354\212\244/solution.py" index e69de29..05b543a 100644 --- "a/week1/20301\353\260\230\354\240\204\354\232\224\354\204\270\355\221\270\354\212\244/solution.py" +++ "b/week1/20301\353\260\230\354\240\204\354\232\224\354\204\270\355\221\270\354\212\244/solution.py" @@ -0,0 +1,42 @@ +import sys +from collections import deque + +n, k, m = map(int, sys.stdin.readline().split()) +queue = deque([i + 1 for i in range(n)]) +# 1 2 3 4 5 6 7 +josephus = [] +i = 1 +cnt = 0 +reverse_rotate = False +while queue: + if reverse_rotate: + x = queue.pop() + if i == k: + josephus.append(x) + cnt += 1 + i = 1 + else: + queue.appendleft(x) + i += 1 + else: + x = queue.popleft() + if i == k: + josephus.append(x) + cnt += 1 + i = 1 + else: + queue.append(x) + i += 1 + if cnt == m: + cnt = 0 + if reverse_rotate: + reverse_rotate = False + else: + reverse_rotate = True + +for i in josephus: + print(i) + + +# 1 2 3 4 5 +# 2 \ No newline at end of file diff --git "a/week1/3986\354\242\213\354\235\200\353\213\250\354\226\264/solution.py" "b/week1/3986\354\242\213\354\235\200\353\213\250\354\226\264/solution.py" index e69de29..b6e76a3 100644 --- "a/week1/3986\354\242\213\354\235\200\353\213\250\354\226\264/solution.py" +++ "b/week1/3986\354\242\213\354\235\200\353\213\250\354\226\264/solution.py" @@ -0,0 +1,16 @@ +import sys + +n = int(sys.stdin.readline()) +cnt = 0 +for _ in range(n): + inp = sys.stdin.readline().rstrip() + stack = [] + for i in range(len(inp)): + if stack and stack[-1] == inp[i]: + stack.pop() + else: + stack.append(inp[i]) + if not stack: + cnt += 1 + +print(cnt) \ No newline at end of file diff --git "a/week1/9012\352\264\204\355\230\270/solution.py" "b/week1/9012\352\264\204\355\230\270/solution.py" index e69de29..93ab000 100644 --- "a/week1/9012\352\264\204\355\230\270/solution.py" +++ "b/week1/9012\352\264\204\355\230\270/solution.py" @@ -0,0 +1,21 @@ +import sys + +T = int(sys.stdin.readline()) +ps_list = [] +output_list = [] +for i in range(T): + ps_list.append(sys.stdin.readline().strip()) + + +for ps in ps_list: + i = 0 + while i < 50: + ps = ps.replace("()", "") + i += 1 + if ps == '': + output_list.append("YES") + continue + else: + output_list.append("NO") +for output in output_list: + print(output) \ No newline at end of file diff --git a/week2/10994/solution.py b/week2/10994/solution.py new file mode 100644 index 0000000..5217021 --- /dev/null +++ b/week2/10994/solution.py @@ -0,0 +1,27 @@ +import sys + +n = int(sys.stdin.readline()) +length = 4 * n - 3 +arr = [[' ' for i in range(length)] for j in range(length)] + +def dot19(n, k): + if n == 1: + arr[k][k] = '*' + return 0 + cur_len = 4 * n - 3 + for i in range(k, k + cur_len): + arr[i][k] = '*' + arr[k][i] = '*' + arr[i][k + cur_len - 1] = '*' + arr[k + cur_len - 1][i] = '*' + + return dot19(n - 1, k + 2) + + +dot19(n, 0) +for i in range(len(arr)): + for j in range(len(arr)): + print(arr[i][j], end="") + print("") + + \ No newline at end of file