I am writing a program. if short matches are mixed with longer matches. the program is to see which matches will fit back in the short box. This is my code:
import math
def q2():
fin = open('input.txt','rt')
fout = open('output.txt', 'wt')
a= int(fin.readline().strip())
b = [int(b) for b in str(a)]
count = -1
nMatches = b[0]
width = b[1]
heigth = b[2]
length = width**2 + heigth**2
length = length**(.5)
while count <= nMatches:
match = int(fin.readline().strip())
count = count+ 1
if match <= length:
print('YES')
else:
print('NO')
This is the output:
YES
YES
YES
NO
NO
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
q2()
File "D:/code/Q2/q2.py", line 15, in q2
match = int(fin.readline().strip())
ValueError: invalid literal for int() with base 10: ''
Thanks for any help the content of fin is: 534 3 4 5 6 7