-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcasamento.py
More file actions
43 lines (36 loc) · 795 Bytes
/
Copy pathcasamento.py
File metadata and controls
43 lines (36 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Integers' marriage, 2021 Brazilian Informatics Olympiad
# Available @ https://olimpiada.ic.unicamp.br/static/extras/obi2021/provas/ProvaOBI2021_f3p2.pdf
a = [int(i) for i in list(input())]
b = [int(i) for i in list(input())]
if len(a) < len(b):
for i in range(len(b) - len(a)):
a.insert(0, 0)
elif len(b) < len(a):
for i in range(len(a) - len(b)):
b.insert(0, 0)
for i in range(len(a)):
if a[i] < b[i]:
a[i] = -1
elif b[i] < a[i]:
b[i] = -1
else:
continue
try:
a = [x for x in a if x != -1]
b = [x for x in b if x != -1]
except ValueError:
pass
if not a:
a = -1
else:
a = [str(x) for x in a]
a = int(''.join(a))
if not b:
b = -1
else:
b = [str(x) for x in b]
b = int(''.join(b))
if b < a:
print(b, a)
else:
print(a, b)