diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-07-24 02:23:37 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-07-24 02:26:15 +0700 |
commit | ce427c0741ff51539e5410710dd04a11d8d22b4f (patch) | |
tree | 7b12163e0a665ae8d9cb3e482257062457619aa1 /others/other/cube.py | |
parent | 1ceb9227cb48d50f57343fa42c32815b94855488 (diff) | |
download | cp-ce427c0741ff51539e5410710dd04a11d8d22b4f.tar.gz |
Add others/other/{cube,kite}.py
Diffstat (limited to 'others/other/cube.py')
-rwxr-xr-x | others/other/cube.py | 26 |
1 files changed, 26 insertions, 0 deletions
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)) |