blob: 84952f60f17cc4c6df1de1ce95aceb02e67c307c (
plain)
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
|
#!/usr/bin/env python3
import sys
def main(array):
missing = None
duplicate = None
for i in range(1, len(array)+1):
# Find out how many times this number appears in the list
count = sum(1 for n in array if n == i)
if count == 0:
missing = i
elif count > 1:
duplicate = i
if missing is None:
print(-1)
else:
print(f'({duplicate or ""}, {missing})')
if __name__ == '__main__':
# Turn the strings into integers
n = [int(i) for i in sys.argv[1:]]
main(n)
|