Loading...
Hristo980 avatar Hristo980 0 Точки

01. Registration - Exam Preparation - 20 March 2024

Здравейте, моля за помощ, тъй като получавам 0/100 в Judge, а в същото време успявам да принтирам отговорите които са посочени в условието правилно - https://pastebin.com/rkukwR1Z . Благодаря предварително! 

 

Problem 1 - Registration

John wants to register on a sales site, but too many people call him John. It asks you to write a program that will generate an original username.

On the first line, you will receive the username that he wants to use in the first place. On the following lines, you will be receiving commands until the "Registration" command. There are five possible commands:

  • "Letters {Lower/Upper}"
    • Replace all letters with lower case or with upper case, then print the result.
  • "Reverse {startIndex} {endIndex}"
    • Reverse the substring from the start index until the end index (both inclusive), then print it. Do NOT change it in the username.

Note: Check if the indices are valid. If they aren't - skip the command. An index is valid when it is non-negative and less than the size of the collection.

  • "Substring {substring}"
    • If the username contains the given substring, cut it out and print the result without the cut substring.
    • Otherwise, print:

"The username {string} doesn't contain {substring}."

  • "Replace {char}"
    • Replace all occurences of the given char with a dash (-) and print the result.
  • "IsValid {char}"
    • For a username to be valid, it must contain the given char. If it is, print "Valid username.".
    • Otherwise, print: "{char} must be contained in your username."

Input

  • On the first line, you are going to receive the string.
  • On the following lines, until the "Registration" command is received, you will be receiving commands.
  • All commands are case-sensitive.

Output

  • Print the output of every command in the format described above.

Examples

Input

Output

John

Letters Lower

Substring SA

IsValid @

Registration

john

The username john doesn't contain SA.

@ must be contained in your username.

ThisIsSoftUni

Reverse 1 3

Replace S

Substring hi

Registration

sih

ThisIs-oftUni

TsIs-oftUni

 

Тагове:
0
Python
icowwww avatar icowwww 2705 Точки

Здравей,

Промених следното:

1. При проверка за Registration да се проверява първия елемент command[0]

2. При Registration да не се принтира

3. При Letters, Substring и Replace да се променя и текущата стойност за username

https://pastebin.com/GZXs70Y0

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