LilianaVelvheva 17 Точки

# Ето моя код: https://pastebin.com/3Wcu5HjE

Това е условието на задачата:

# Programming Fundamentals Final Exam 04.04.2020

Yet again you have forgotten your password... Naturally it`s not the first time this has happened. Actually you got so tired of it that you decided to help yourself with a smart solution.

Write a password reset program that performs a series of commands upon a predefined string. First, you will receive a string and afterwards, until the command "Done" is given, you will be receiving strings with commands split by a single space. The commands will be the following:

• TakeOdd
•  Takes only the characters at odd indices and concatenates them together to
obtain the new raw password and then prints it.
• Cut {index} {length}
• Gets the substring with the given length starting from the given index from the password and removes its first occurrence of it, then prints the password on the console.
• The given index and length will always be valid.
• Substitute {substring} {substitute}
• If the raw password contains the given substring, replaces all of its
occurrences with the substitute text given and prints the result.
• If it doesn’t, prints "Nothing to replace!"

### Input

• You will be receiving strings until the "Done" command is given.

### Output

• After the "Done" command is received, print:

### Constraints

• The indexes from the "Cut {index} {length}" command will always be valid.

### JS Input / Output

Тагове:
0
svephoto 1107 Точки

Здравей, LilianaVelvheva,

Проверката за това дали паролата съдържа подадената от отвън част не може да се направи така, както ти си я направила. Трябва да бъде

Колегата Axiomatik вече е дал решение на проблема, а аз мога да предложа алтернатива за процеса на заместването със следния израз, който също работи: