From ce427c0741ff51539e5410710dd04a11d8d22b4f Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Mon, 24 Jul 2017 02:23:37 +0700 Subject: Add others/other/{cube,kite}.py --- others/other/cube.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 others/other/cube.py (limited to 'others/other/cube.py') diff --git a/others/other/cube.py b/others/other/cube.py new file mode 100755 index 0000000..03eb30f --- /dev/null +++ b/others/other/cube.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +from collections import deque + + +def same(*a): return all(len(set(i)) == 1 for i in a) + + +def add(h, k): + d = deque(zip(h, k)) + for _ in range(3): + if same(d[1], d[2]): yield sorted((sum(d[0]), d[1][0], d[2][1])) + d.rotate() + + +def cube(d): + for _ in range(3): + for i in add(d[0], d[1]): + for j in add(i, d[2]): + if same(j): return 'TRUE' + d.rotate() + return 'FALSE' + + +for _ in range(int(input())): + d = deque(sorted(map(int, input().split())) for _ in range(3)) + print(cube(d)) -- cgit 1.4.1