Problem 1. World Tour
Здравейте, наглед уж лесна задача, но не мога да си открия грешката 66/100 и вече ме заболяха очите да търся какъв е проблемът, доста досаден е очевидно. Ако някой по-наблюдател хвърли един поглед и помогне да го открия, ще съм му благодарен. Дава ми 66/100 judge.
https://judge.softuni.bg/Contests/Practice/Index/2518#0
Programming Fundamentals Final Exam 09.08.2020
Problem 1. World Tour
You are a world traveller and your next goal is to make a world tour. In order to do that, you have to plan out everything first. To start with, you would like to plan out all of your stops where you will have a break.
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
Output
- Print the proper output messages in the proper cases as described in the problem description
Examples
Input |
Output |
Hawai::Cyprys-Greece Add Stop:7:Rome Remove Stop:11:16 Switch:Hawai:Bulgaria Travel |
Hawai::RomeCyprys-Greece Hawai::Rome-Greece Bulgaria::Rome-Greece Ready for world tour! Planned stops: Bulgaria::Rome-Greece |
Благодаря за подробното обяснение на този проблем :)