From 4ac65940e064c5b587699549a0c7277d2dd733a8 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Tue, 20 Jun 2017 15:11:08 +0700 Subject: Thầy Nguyễn Thanh Tùng ôn THT XXIII MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- others/other/hcn.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 others/other/hcn.py (limited to 'others/other/hcn.py') diff --git a/others/other/hcn.py b/others/other/hcn.py new file mode 100755 index 0000000..6b2fa2b --- /dev/null +++ b/others/other/hcn.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +from collections import deque + + +def not_square(A, B, C): + """Return False is ABC is a square angle, True otherwise.""" + return (B[0]-A[0])*(B[0]-C[0]) + (B[1]-A[1])*(B[1]-C[1]) + + +def parallelogram_last_point(A, B, C): + """Return the (x, y) coordinates of the point D of the parallelogram + ABCD. + """ + return A[0] - B[0] + C[0], A[1] - B[1] + C[1] + + +with open('hcn.inp') as fi, open('hcn.out', 'w') as fo: + d = deque(tuple(map(int, line.split())) for line in fi.readlines()) + while not_square(*d): d.rotate() + print(*parallelogram_last_point(*d), file=fo) -- cgit 1.4.1