Eoferror: EOF when Ading a line

Asked

Viewed 2,053 times

2

I’m doing a program that’s a resolution of this issue of the Computer Olympiad.

A, B, C = input("A").split(), input("B").split(), input("C").split()
A, B, C = int(A[0]), int(B[0]), int(C[0])
if A >= 1 and A <= 300 and B >= 1 and B<= 300 and C >= 1 and C <= 300 : 
    pass
else :
    raise ValueError("Deu Erro")


H, L= int (input("Qual a altura")), int (input("Qual a Largura"))#dimensões da porta
if H >= 1 and H <= 250 and L >= 1 and L <= 250 :
    pass
else:
    raise ValueError("Deu Erro")

if (A and B) > (H and L) or (A and C) > (H and L) or (B and C) > (H and L):
    print ("N")
else :
    print("S")

It still has many flaws, but when running it I’m not having the error:

Eoferror: EOF when Ading a line

When I put it to correct him, I am. I wanted to know why.

2 answers

1


The code is a little confused, and from what we read in the statement should not ask for 3 entries and break in parts, should read an entry and break (I hate it, it usually gives problems, but we will do what the exercise asks). Then you must ask for a die to be broken in two parts. Interestingly one part of the code did one way and the other the other way, but both wrong as shown on the page.

I left the exception exposed so although this is not a code well done, but serves as exercise mainly because it does not ask to treat properly, but keep this in mind.

entrada = input("A B C").split()
A, B, C = int(entrada[0]), int(entrada[1]), int(entrada[2])
if A >= 1 and A <= 300 and B >= 1 and B <= 300 and C >= 1 and C <= 300:
    pass
else:
    raise ValueError("Deu Erro")
entrada = input("Qual a altura e largura").split()
H, L = int(entrada[0]), int(entrada[1])
if H >= 1 and H <= 250 and L >= 1 and L <= 250:
    pass
else:
    raise ValueError("Deu Erro")
if (A and B) > (H and L) or (A and C) > (H and L) or (B and C) > (H and L):
    print ("N")
else:
    print("S")

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

  • @Smaug I found myself getting lost at the time of writing, I edited.

0

This question which has as its title Colchão, was initially made available by OBI 2012 and subsequently made available by Uri Online Judge, with the same title, Colchão, and with the numbering 2409 of the category AD-HOC.

As you can see, the question asks us to check whether given the dimensions of a mattress, say whether or not it can pass through the door, with one of its faces, parallel to the floor.

Note that the question says, that the mattress should go through the door with uma of their faces parallel at the chão. Also, it tells us that the dimensions of the mattress are (1 <= A, B, C <= 300) and also, the dimensions of the door are (1 <= H, L <= 250).

To resolve this issue correctly we must realize that as the maximum dimension of the mattress is 300 and the maximum door size is 250 and that also, the mattress will always pass through the door with one of its faces paralela to the ground, we must implement the following algorithm...

colchao = sorted(list(map(int, input().split())))
porta = sorted(list(map(int, input().split())))

if (colchao[0] <= porta[0]) and (colchao[1] <= porta[1]):
    print('S')
else:
    print('N')

See how the algorithm works on repl it..

Note that when this algorithm is executed, the screen is cleared waiting for the values of dimensões do colchão. At this point we must, type all the três dimensions of the mattress, in the mesma line, separated by apenas um space and press Enter.

After we enter all the dimensions of the mattress, the values are ordenados and stored within the list colchao.

Then we insert the dimensions of the porta as we insert the mattress.

After pressing the key enter the program will check whether the menor mattress size is less than or equal to menor dimension of the door and also check whether the dimensão intermediária of the mattress (width of the mattress) is less than or equal to maior port size. If the result is positive, it will display the message S. Otherwise it will display the message N.

This question has already been testada, submetida and properly aprovada on the website URI under the programming language Python 3.

For the record, this issue has only led to 0.036 s to be executed on the URI website.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.