Chase X70576


Statement
 

pdf   zip

thehtml

We represent using a string made up only of the characters ’+’ and ’=’ the progress of a runner in a race every second. ’+’ means that the runner advances one position, ’=’ means the runner doesn’t advance. In each second the runner advances or remains still.

Design a function persecucion(m1, m2, dini) that, given two str m1 and m2 representing the progress of two runners in a race, and an int dini > 0 indicating the starting advantage of runner 2 over runner 1, returns how many seconds it takes for the first runner to catch the second one, THAT IS, BE AT ZERO DISTANCE. If the runner doesn’t succeed the result will -1.

Sample session
>>> persecucion('++=+++++', '+++==+==++', 1)
5
>>> persecucion('++=++++++==', '+++==+==+', 17)
-1
Information
Author
InfBesos
Language
English
Translator
Original language
Spanish
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python