Loading...

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

LilianaVelvheva avatar LilianaVelvheva 17 Точки

Къде ми е грешката в задача Secret chat и защо judge ми дава 0 точки?

Ето моя код: https://pastebin.com/he273w51

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

Programming Fundamentals Final Exam Retake 10.04.2020

Problem 1. Secret Chat

You have plenty of free time, so you decide to write a program that conceals and reveals your received messages. Go ahead and type it in!

On the first line of the input you will receive the concealed message. After that, until the "Reveal" command is given, you will be receiving strings with instructions for different operations that need to be performed upon the concealed message in order to interpret it and reveal its true content. There are several types of instructions, split by ":|:"

  • InsertSpace:|:{index}
    • Inserts a single empty space at the given index. The given index will always be valid.
  • Reverse:|:{substring}
    • If the message contains the given substring, cut it out, reverse it and add it at the end of the message.
    • If not, print "error".
    • This operation should replace only the first occurrence of the given substring if there are more than one such occurrences.
  • ChangeAll:|:{substring}:|:{replacement}
    • Changes all occurrences of the given substring with the replacement text.

Input / Constraints

  • On the first line, you will receive a string with message.
  • On the next lines, you will be receiving commands, split by ":|:".

Output

  • After each set of instructions, print the resulting string.
  • After the "Reveal" command is received, print this message:
    "You have a new text message: {message}"

Examples

Input

Output

heVVodar!gniV

ChangeAll:|:V:|:l

Reverse:|:!gnil

InsertSpace:|:5

Reveal

hellodar!gnil

hellodarling!

hello darling!

You have a new text message: hello darling!

Comments

ChangeAll:|:V:|:l
heVVodar!gniV -> hellodar!gnil (We replace all occurrences of "V" with "l")

Reverse:|:!gnil

hellodar!gnil -> !gnil -> ling! -> hellodarling! (We reverse !gnil to ling! And put it in the end of the string)

InsertSpace:|:5

hellodarling! -> hello.darling! (We insert a space at index 5)

Finally, after receiving the "Reveal" command, we print the resulting message.

Input

Output

Hiware?uiy

ChangeAll:|:i:|:o

Reverse:|:?uoy

Reverse:|:jd

InsertSpace:|:3

InsertSpace:|:7

Reveal

Howare?uoy

Howareyou?

error

How areyou?

How are you?

You have a new text message: How are you?

JS Input / Output

Input

Output

[

  'heVVodar!gniV',

  'ChangeAll:|:V:|:l',

  'Reverse:|:!gnil',

  'InsertSpace:|:5',

  'Reveal'

]

hellodar!gnil

hellodarling!

hello darling!

You have a new text message: hello darling!

Comments

ChangeAll:|:V:|:l
heVVodar!gniV -> hellodar!gnil (We replace all occurrences of "V" with "l")

Reverse:|:!gnil

hellodar!gnil -> !gnil -> ling! -> hellodarling! (We reverse !gnil to ling! And put it in the end of the string)

InsertSpace:|:5

hellodarling! -> hello.darling! (We insert a space at index 5)

Finally, after receiving the "Reveal" command, we print the resulting message.

Input

Output

[

  'Hiware?uiy',

  'ChangeAll:|:i:|:o',

  'Reverse:|:?uoy',

  'Reverse:|:jd',

  'InsertSpace:|:3',

  'InsertSpace:|:7',

  'Reveal'

]

Howare?uoy

Howareyou?

error

How areyou?

How are you?

You have a new text message: How are you?

 

Тагове:
0
Fundamentals Module
svephoto avatar svephoto 1191 Точки

Здравей, LilianaVelvheva,

 

Предполагам, че предаваш решението заедно с извикването на функцията с входни данни и затова ти гърми с 0/100. Като предадеш само кода без извикването на функцията, ще получиш 50/100, като причината за това е, че си пропуснала да подадеш с какво да бъде заместен firstArgument на ред 15. Добави заместване с празен стринг и готово - вече си на 100/100.

0
svephoto avatar svephoto 1191 Точки

Моля. yes

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