03. Plant Discovery (JS)
Здравейте,
моля за помощ на следната задача:
On the first line, you will be given a string containing all of your stops. Until you receive the command "Travel", you will be given some commands to manipulate that initial string. The commands can be:
-
"Add Stop:{index}:{string}":
-
Insert the given string at that index only if the index is valid
-
-
"Remove Stop:{start_index}:{end_index}":
-
Remove the elements of the string from the starting index to the end index (inclusive) if both indices are valid
-
-
"Switch:{old_string}:{new_string}":
-
If the old string is in the initial string, replace it with the new one (all occurrences)
-
Note: After each command, print the current state of the string!
After the "Travel" command, print the following: "Ready for world tour! Planned stops: {string}"
Input / Constraints
-
JavaScript: you will receive a list of strings
-
An index is valid if it is between the first and the last element index (inclusive) (0 ….. Nth) in the sequence.
Output
-
Print the proper output messages in the proper cases as described in the problem description
https://judge.softuni.org/Contests/Practice/Index/2518#2
Ето и моете решение: https://pastebin.com/sXW7SfqN
дава ми 87/100 като гърми последния 8ми тест.
Благодаря предварително
From the problem description, it seems like you need to manipulate a string based on given commands until the "Travel" command is encountered. The commands include adding a stop at a specific index 2 player games, removing a range of elements, and replacing occurrences of a string with a new one.