Problem 99

Back to Problem Solutions forum

Polyakov Alexandr     2020-02-19 22:45:44

Solving the 99th problem, I get the following. If I decide in the Throny IDE, then the answer is correct. I enter each line, block heights separately.

If I copy the program to the site, the answer is incorrect. At the same time, I change the line of blocks to the:

xrockvalues = [int (i) for i in input (). split ()]

I decide in Python. At first, I thought not to write here, but this could be repeated in other tasks. Could this be? What am I doing wrong?

Rodion Go     2020-02-20 06:51:07

Alexandr, Hi!

It's not about IDE. Your code just not always gives correct results. Uncomment the line

# print(y_rock_values)

And you see - your y_rock_values is not cleared because this line doesn't work:

y_rock_values.clear

Because you forgot the parentheses on function call. It should be:

y_rock_values.clear()

P.S. Please, in future try to compose your code in several smaller functions. Don't write it "single long sheet". Don't use that much global variables. It will both prevent such errors and make your code more easy to debug (now it is painful to search for mistakes and I was just lucky to discover the problem).

Polyakov Alexandr     2020-02-20 17:34:45

Thank you Rodion. Please tell me, in your picture, the projectile is already falling and crashes into the mountain. Are there input values of the projectile’s flight when lifting a crashing into a mountain?

Rodion (admin)     2020-02-21 17:00:48
User avatar

Hi, Alexandr! I'm sorry, I didn't get your question well? Do you ask about angle and velocity for the trajectory depicted in the image of the problem page? Feel free to ask in Russian if this is more comfortable.

Polyakov Alexandr     2020-02-21 18:11:44

Интересно, если малый угол взлета снаряда. Он ударится на взлете или при падении? Возможна ситуация, когда снаряд ударяется в гору при взлете? Когда растет его высота?

Rodion (admin)     2020-02-21 18:32:23
User avatar

Good question, indeed! Really it is possible that projectile will hit vertical wall, while yet going upwards! Solution should check for such opportunity though it's not guaranteed test-cases will include such case (hm-m-m, perhaps I should improve this).

Да, хороший вопрос! Действительно снаряд может попасть в вертикальную стенку следующей "ступеньки" на взлете - и решение должно это учитывать. Хотя нет гарантии что в тесткейсах есть такой тест. Пожалуй мне следует улучшить чекер чтобы такой случай всегда попадался - спасибо за напоминание :)

Please login and solve 5 problems to be able to post at forum