Regular Expressions - More Exercise / 4. Santa's Secret Helper
Здравейте, изписвами това съобщение на един тест:
The process executing your submission for this test may not have received the output successfully. Please try to submit again the same solution. If the result does not change, then search the error in the submission itself.
и ми дава 88/100.
Субмитнах няколко пъти и пак същото.
Това е кода:
Това е условието на задачата.
1.Santa's Secret Helper
After the successful second Christmas, Santa needs to gather information about the behavior of children to plan the presents for next Christmas. He has a secret helper, who is sending him encrypted information. Your task is to decrypt it and create a list of the good children.
You will receive an integer, which represents a key, and afterward some messages, which you must decode by subtracting the key from the value of each character. After the decryption, to be considered a valid match, a message should:
- Have a name, which starts after '@' and contains only letters from the Latin alphabet
- Have a behavior type - "G"(good) or "N"(naughty) and must be surrounded by "!" (exclamation mark).
The order in the message should be: child’s name -> child’s behavior. They can be separated from the others by any character except: '@', '-', '!', ':' and '>'.
You will be receiving messages until you are given the “end” command. Afterward, print the names of the children, who will receive a present, each on a new line.
Input / Constraints
- The first line holds n – the number which you have to subtract from the characters – integer in the range [1…100];
- On the next lines, you will be receiving encrypted messages.
Output
Print the names of the children, each on a new line
Examples
Output |
Comments |
|
'CNdwhamigyenumje$J$', 'CEreelh-nmguuejnW$J$', 'CVwdq&gnmjkvng$Q$', 'end'] |
Kate Bobbie |
We receive three messages and to decrypt them we use the key: First message has decryption key 3. So we substract from each characters code 3 and we receive: @Kate^jfdvbkrjgb!G! @Bobbie*kjdrrbgk!G! @Stan#dkjghskd!N! They are all valid and they contain a child’s name and behavior – G for good and N for naughty. |
Input |
Output |
Comments |
['3', 'N}eideidmk$'(mnyenmCNlpamnin$J$', 'ddddkkkkmvkvmCFrqqru-nvevek$J$nmgievnge', 'ppqmkkkmnolmnnCEhq/vkievk$Q$', 'yyegiivoguCYdohqwlqh/kguimhk$J$', 'end'] |
Kim Connor Valentine |
We receive four messages. They are with key 3: Kzbfabfajh!$%jkvbkj@Kim^jkfk!G! aaaahhhhjshsj@Connor*ksbsbh!G!kjdfbskdb mmnjhhhjklijkk@Ben,shfbsh!N! vvbdffsldr@Valentine,hdrfjeh!G! |
Много благодаря :)