Loading...

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

LilianaVelvheva avatar LilianaVelvheva 17 Точки

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

Това е моя код: https://pastebin.com/8gmwE4mv

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

Programming Fundamentals Final Exam Retake 15.08.2020

Problem 1. The Imitation Game

You are a mathematician during world war 2, who has joined the cryptography team to decipher the enemy's enigma code. Your job is to create a program to crack the codes.

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

  • Move {number of letters}
    • Moves the first n letters to the back of the string.
  • Insert {index} {value}
    • Inserts the given value before the given index in the string.
  • 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 the "Decode" command is received, print this message:
    "The decrypted message is: {message}"

Examples

Input

Output

zzHe

ChangeAll|z|l

Insert|2|o

Move|3

Decode

The decrypted message is: Hello

Comments

ChangeAll|z|l

zzHe → llHe (We replace all occurrences of 'z' with 'l')

Insert|2|o

llHe → lloHe (We add an 'o' before the character on index 2)

Move|3

lloHe → Hello (We take the first three characters and move them to the end of the string)

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

Input

Output

owyouh

Move|2

Move|3

Insert|3|are

Insert|9|?

Decode

The decrypted message is: howareyou?

 

JS Input / Output

Input

Output

[

  'zzHe',

  'ChangeAll|z|l',

  'Insert|2|o',

  'Move|3',

  'Decode'

]

The decrypted message is: Hello

Comments

ChangeAll|z|l

zzHe → llHe (We replace all occurrences of 'z' with 'l')

Insert|2|o

llHe → lloHe (We add an 'o' before the character on index 2)

Move|3

lloHe → Hello (We take the first three characters and move them to the end of the string)

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

Input    

Output

[

  'owyouh',

  'Move|2',

  'Move|3',

  'Insert|3|are',

  'Insert|9|?'

  'Decode'

]

The decrypted message is: howareyou?

 

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

Моля.

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