Hi everybody!
In the code below ı M trying to write a program, that takes an integer n as command-line argument, reads
in n − 1 distinct integers between 1 and n from standard input, and writes the missing number
This is an example commend prompt(n is given 5 by user, integers are 1 3 2 5, output is 4)
$ python3 missing . py 5
1 3 2 5
<ctrl -d >
4
1
2
Traceback (most recent call last):
File "C:\Users\USER\Desktop\app\missing.py", line 15, in <module>
k += [a]
MemoryError
In the code below ı M trying to write a program, that takes an integer n as command-line argument, reads
in n − 1 distinct integers between 1 and n from standard input, and writes the missing number
This is an example commend prompt(n is given 5 by user, integers are 1 3 2 5, output is 4)
$ python3 missing . py 5
1 3 2 5
<ctrl -d >
4
n = int(sys.argv[1]) i = 1 k = [] while i < n: a = stdio.readInt() i += 1 while not stdio.isEmpty(): k += [a] if a not in range(1, n): b = stdio.readInt() while not stdio.isEmpty(): k += [b] print(k) for i in range(1, n+1): if i not in k: print(i)Unfortunately I got this error after I entered two numbers (I gave 5 as n). Can you guuys help me?
1
2
Traceback (most recent call last):
File "C:\Users\USER\Desktop\app\missing.py", line 15, in <module>
k += [a]
MemoryError