0

Will someone know why so happened? Кто-нибудь мне объяснит почему так происходит

Когда я ввожу / input 18 7 7 7 7 7 7 7 5 5 5 5 5 4 4 4 4 8 8 У меня выходит / Output 15 4 8 8 А когда я ввожу / and when I enter Input: 7 7 7 7 7 7 7 5 5 5 5 5 2 2 2 2 8 8 У меня выходит / I get such a Output 16 8 8 Я просто заменил число 4 на 2,а в результате такой ответ. Хотя 4 на 2 никак не связаны/ I just replaced a number 4 on 2, though these numbers have not connection https://code.sololearn.com/c0EvIzyW39eb/?ref=app https://code.sololearn.com/c0EvIzyW39eb/?ref=app

27th Sep 2019, 6:32 PM
Марсель Халимов
3 Respuestas
+ 1
Line 13 saves the 5 in x, line 19 subtracts one from x making it 4, line 15 tests x against a[i]. That test succeeds for your first input and fails for the second. Change 5s to 3s and it should run similar.
28th Sep 2019, 8:56 PM
John Wells
John Wells - avatar
+ 1
Not without a description of input, expected output, and some idea of what it is trying to do as I have no idea. I just added debugging statements telling me variable values and if statement path. Once I knew the path taken between the two runs, it was easy to figure out why. After line 6, with indenting added: print(i, a[i], k, x, lst, end = "") After lines 7, 9, 15, and 18, added print of line number like: print(" 7")
29th Sep 2019, 5:31 AM
John Wells
John Wells - avatar
0
Can you correct in my code my mistakes and past there please?
29th Sep 2019, 5:17 AM
Марсель Халимов