DAJE 30PKT! INFORMATYKA! PYHTON! POTRZEBUJE POMOCY! A więc muszę napisać coś takiego (po angielsku program i drugi po polsku taki sam): treść zadania jakie mam:
You and your friend invented a special code to pass secret messages to each other during classes. You chose to call it Crossout Cipher because of the way that you can decode a secret message. Say, for example, that the coded message you receive is “HWelloldor”. In the first step, you will read every second letter of the code (starting from the first): “H e l l o” and cross these letters out, leaving only “Wlodr”. Then you repeat the process with the remaining part – reading “W o r”. and leaving only “ld”. The process continues until no letters are left, in this case revealing the message to be “HelloWorld”.
Task Recently your friend decided to challenge you by sending you a very long secret message. Decoding it all on paper would be a waste of time, but you want to prove that you are up to the challenge, so you have to write a program that will do it for you. Input description The first and only line of standard input consists of a non-empty string of up to 2 million letters of the English alphabet (no spaces allowed) – the secret code you received.
Output description The standard output should contain one line – the decoded message.
Example For sample input: TohdiussLHoenogeEwxMaTmapoleeDSsheoswcsgYo the correct output is: ThisLongExampleShowsYouHowToDecodeMessages
Odpowiedź:
#WERSJA PO ANG - Hello World
napis = "HWelloldor"
print("Odkodowany napis",napis,end=": ")
while len(napis) > 0:
for i in range(0, len(napis), 2):
print(napis[i],end="")
for i in range(0, len(napis), 1):
napis = napis[:i] + napis[i+1:]
print()
#WERSJA PO POLSKU - Witaj Świat
napis = "WŚiatwatji"
print("Odkodowany napis",napis,end=": ")
while len(napis) > 0:
for i in range(0, len(napis), 2):
print(napis[i],end="")
for i in range(0, len(napis), 1):
napis = napis[:i] + napis[i+1:]
Wyjaśnienie: