From 67d4252e13283eb4d43ffaa72c7a930077868491 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Fri, 21 Aug 2020 16:48:31 +0900 Subject: [PATCH] =?UTF-8?q?complete=201918(=ED=9B=84=EC=9C=84=20=ED=91=9C?= =?UTF-8?q?=EA=B8=B0=EB=B2=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zeta_python/11726.py | 0 zeta_python/1485.py | 33 ++++++++++++++++++++++++++ zeta_python/1918.py | 44 ----------------------------------- zeta_python/completed/1918.py | 26 +++++++++++++++++++++ 4 files changed, 59 insertions(+), 44 deletions(-) create mode 100644 zeta_python/11726.py create mode 100644 zeta_python/1485.py delete mode 100644 zeta_python/1918.py create mode 100644 zeta_python/completed/1918.py diff --git a/zeta_python/11726.py b/zeta_python/11726.py new file mode 100644 index 0000000..e69de29 diff --git a/zeta_python/1485.py b/zeta_python/1485.py new file mode 100644 index 0000000..228c28b --- /dev/null +++ b/zeta_python/1485.py @@ -0,0 +1,33 @@ +N = int(input()) + + +def check90(p1, p2, p3): + if p2[0] - p1[0] == 0: + if p3[1] - p1[1] == 0: + return True + elif p3[0] - p1[0] == 0: + if p2[1] - p1[1] == 0: + return True + + return - (p3[0] - p1[0]) * (p2[1] - p1[1]) == (p3[1] - p1[1]) * (p2[0] - p1[0]) + + +for _ in range(N): + P = [(p1x, p1y), (p2x, p2y), (p3x, p3y), (p4x, p4y)] = \ + map(int, input().split()), map(int, input().split()), map(int, input().split()), map(int, input().split()) + if check90((p1x, p1y), (p2x, p2y), (p3x, p3y)): + (opox, opoy) = p4x, p4y + (remx, remy) = p3x, p3y + elif check90((p1x, p1y), (p2x, p2y), (p4x, p4y)): + (opox, opoy) = p3x, p3y + (remx, remy) = p2x, p2y + elif check90((p1x, p1y), (p3x, p3y), (p4x, p4y)): + (opox, opoy) = p2x, p2y + (remx, remy) = p4x, p4y + else: + print(0) + continue + if (opox - p1x) ** 2 + (opoy - p1y) ** 2 == 2 * (remx - p1x) ** 2 + 2 * (remy - p1y) ** 2: + print(1) + else: + print(0) diff --git a/zeta_python/1918.py b/zeta_python/1918.py deleted file mode 100644 index a702fe6..0000000 --- a/zeta_python/1918.py +++ /dev/null @@ -1,44 +0,0 @@ -import re -OUT = [] -def turn_exp(start): - t = start - first = None - second = None - op = None - if tokens[t].isalpha(): - first = tokens[t] - t += 1 - elif tokens[t] == "(": - rr = turn_exp(t+1) - first = rr[1] - t = rr[0] - if tokens[t] == ")": - t += 1 - if isinstance(first, str): - OUT.append(first) - if tokens[t] in "+-*/": - op = tokens[t] - t += 1 - - if tokens[t].isalpha(): - second = tokens[t] - t += 1 - elif tokens[t] == "(": - rr = turn_exp(t+1) - second = rr[1] - t = rr[0] - if tokens[t] == ")": - t += 1 - if isinstance(second, str): - OUT.append(second) - OUT.append(op) - return t, [first, second, op] - -tokens = input() - - - -#_, parsed = turn_exp(0) -#for o in OUT: - #print(o, end = '') -# TODO: 중위 표기식의 연산순서 A+B+C 같은거 \ No newline at end of file diff --git a/zeta_python/completed/1918.py b/zeta_python/completed/1918.py new file mode 100644 index 0000000..83dadec --- /dev/null +++ b/zeta_python/completed/1918.py @@ -0,0 +1,26 @@ +I = input() +stack = [] +priority = {"*": 3, "/": 3, "+": 2, "-": 2, "(": 1} +for i in I: + if i in "*/+-()": + if len(stack) == 0: + stack.append(i) + continue + if i == ")": + while stack[-1] != "(": + print(stack.pop(), end='') + stack.pop() + elif i == "(": + stack.append(i) + else: + while priority[stack[-1]] >= priority[i]: + print(stack.pop(), end='') + if len(stack) == 0: + break + stack.append(i) + + else: + print(i, end='') +else: + for s in stack[::-1]: + print(s, end='')