Now how can I do the same with 's1' as I did with 's'? How to make loop within loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 15

Now how can I do the same with 's1' as I did with 's'? How to make loop within loop?

Separator of subtree https://code.sololearn.com/cAX82vMiFq3A/?ref=app

16th Mar 2019, 11:36 AM
PASHA 🇷🇺
PASHA  🇷🇺 - avatar
8 Answers
+ 9
Закольцуй в while, пока, допустим, длина строки больше или не равна 2.
16th Mar 2019, 5:22 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
16th Mar 2019, 5:27 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 10
Separating a subtree from a game tree. Game theory.
16th Mar 2019, 3:59 PM
PASHA 🇷🇺
PASHA  🇷🇺 - avatar
+ 10
Explaining: I take the first part of 's' where the number of '0' = number of '1'. Let's call this part "subtree". Next I remove from the subtree the first '0' and the last '1'. It is a new subtree, call it 's1'. I need to put this s1 into my code again. Sorry for poor English. Thank you!
16th Mar 2019, 4:39 PM
PASHA 🇷🇺
PASHA  🇷🇺 - avatar
+ 10
0000010110111101001011101 Сначала извлекаю первый отрывок, в котором число единиц равно числу нулей: 00000101101111. Затем отсекаю от полученного отрезка первый ноль и последнюю единицу. 000010110111 это результат моего кода. Потом с этим результатом мне нужно сделать то же самое, что и с первоначальным множеством. Спасибо! Николай. Павел. По сути, нужно скопировать последнюю строку вывода и вставить вместо первой строки в input.
16th Mar 2019, 5:11 PM
PASHA 🇷🇺
PASHA  🇷🇺 - avatar
+ 9
Если надо заменить часть на новую, новая_часть + старая_часть[индекс_конца_части:]. Под индексом я понимаю "расстояние" на котром мы взяли строку для замены. Может я неправильно понял. Если строка берется из середины,то складывать три части.
16th Mar 2019, 5:00 PM
Николай Шаповаленко
Николай Шаповаленко - avatar
+ 6
Can you explain what your program is supposed to do? It is not clear.
16th Mar 2019, 3:00 PM
Tibor Santa
Tibor Santa - avatar
+ 3
Sorry I am not an expert in game theory (I think very few people here might be.) Maybe if you can describe the algorithm in more detail, I can suggest how to implement it in python...
16th Mar 2019, 4:17 PM
Tibor Santa
Tibor Santa - avatar