Skip to content

Instantly share code, notes, and snippets.

@unilecs
Created November 22, 2017 06:02
Show Gist options
  • Save unilecs/8c5b494ac038f2202e0aa17db2e6f16f to your computer and use it in GitHub Desktop.
Save unilecs/8c5b494ac038f2202e0aa17db2e6f16f to your computer and use it in GitHub Desktop.
Коробки (@sshhaaggy)
def cmp(a, b):
"""Helper, because python3 does not have cmp"""
return (a > b) - (a < b)
def task_43(A1,B1,C1, A2,B2,C2):
box1 = sorted((A1,B1,C1))
box2 = sorted((A2,B2,C2))
cmp_list = set(sorted(map(lambda el1, el2: cmp(el1, el2), box1, box2)))
cmp_list.remove(0)
if not cmp_list:
msg = "Boxes are equal"
elif len(cmp_list) == 1 and 1 in cmp_list:
msg = "The first box is larger than the second one"
elif len(cmp_list) == 1 and -1 in cmp_list:
msg = "The first box is smaller than the second one"
else:
msg = "Boxes are incomparable"
return msg
context_1 = dict(
A1 = 1, B1 = 2, C1 = 3,
A2 = 3, B2 = 2, C2 = 1)
print(task_43(**context_1))
context_2 = dict(
A1 = 2, B1 = 2, C1 = 3,
A2 = 3, B2 = 2, C2 = 1)
print(task_43(**context_2))
context_3 = dict(
A1 = 2, B1 = 2, C1 = 3,
A2 = 3, B2 = 2, C2 = 3)
print(task_43(**context_3))
context_4 = dict(
A1 = 3, B1 = 4, C1 = 5,
A2 = 2, B2 = 4, C2 = 6)
print(task_43(**context_4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment