Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Krizzon avatar Krizzon 0 Точки

Problem 1. Password Reset 50/100

 

Programming Fundamentals Final Exam 04.04.2020

Problem 1. Password Reset

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.
    • Then prints the new raw password itself on a new line.
    • 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:
    • "Your password is: {password}"

Constraints

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

Examples

Input

Output

Siiceercaroetavm!:?:ahsott.:i:nstupmomceqr

TakeOdd

Cut 15 3

Substitute :: -

Substitute | ^

Done

icecream::hot::summer

icecream::hot::mer

icecream-hot-mer

Nothing to replace!

Your password is: icecream-hot-mer

Comments

TakeOdd

Siiceercaroetavm!:?:ahsott.:i:nstupmomceqr -> icecream::hot::summer

We only take the chars at odd indices 1, 3, 5 etc.

Cut 15  3 -> icecream::hot::summer -> sum

icecream::hot::mer

We cut a substring starting at index 15 with length 3,

remove it from the raw password and print it.

Then, on a new line we print the resulting new raw password.

Substitute :: - -> icecream::hot::summer -> icream-hot-summer

We replace "::" with "-".

Substitute | ^ -> Nothing to replace!

"|" is not found anywhere in the raw password.

Finally, after receiving the "Done" command, we print the resulting password in the proper format.

Input

Output

up8rgoyg3r1atmlmpiunagt!-irs7!1fgulnnnqy

TakeOdd

Cut 18 2

Substitute ! ***

Substitute ? .!.

Done

programming!is!funny

programming!is!fun

programming***is***fun

Nothing to replace!

Your password is: programming***is***fun

 

Това е кода ми :https://pastebin.com/rgQMXrUV  

Така и не успях да я реша на изпита дава ми резултат 50/100 и грешките са от тип Timeout и не разбирам защо работи по-бавно кода.

Ще съм много благодарен ако някой сподели мнение и решение по този проблем.

 

Тагове:
0
C# Fundamentals
MihailBozov avatar MihailBozov 2 Точки

Здравейте, Аз получавам 91/100 с java. https://pastebin.com/dteE5FhY
Няхой може ли да каже къде е грешката

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.