Python SolutionsPython Solutions
☎️
Some Mars
Week 15, 2026
All SolutionsPython two-step solution | Alexevi | Python Solutions
def main() -> None:
msg = "☀️ ❄️☀️☀️❄️ ☀️❄️ ❄️❄️ ☀️❄️❄️☀️ ☀️❄️☀️☀️ ☀️"
smsg = []
s = 0
el = ""
for c in msg:
if s == 3:
smsg.append(el)
el = c
s = 0
elif c != ' ':
el += c
s = 0
else:
s += 1
smsg.append(el)
result = ""
code_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', ".----": '1', "..---": '2', "...--": '3', "....-": '4',
".....": '5', "-....": '6', "--...": '7', "---..": '8', "----.": '9',
"-----": '0'}
for el in smsg:
if el != ' ':
result += code_morse[el.replace('❄️', '-').replace('☀️', '.')]
else:
result += ' '
print(result)
main()
Python - Morse Converter | BMC | Python Solutions
data_base = {
# data sourced from wikipedia + moratech.com/aviation/morsecode.html
# NOTE: International Morse Code
# letters
'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': '--..',
# integers
'0': '-----',
'1': '.----',
'2': '..---',
'3': '...--',
'4': '....-',
'5': '.....',
'6': '-....',
'7': '--...',
'8': '---..',
'9': '----.',
# punctuation
'.': '.-.-.-',
',': '--..--',
'?': '..--..',
"'": '.----.',
'!': '-.-.--',
'/': '-..-.',
'(': '-.--.',
')': '-.--.-',
':': '---...',
';': '-.-.-.',
'=': '-...-',
'-': '-....-',
'_': '..--.-',
'"': '.-..-.',
'@': '.--.-.'
}
def convertToMorse(aString: str) -> str:
newMsg = ""
for char in aString:
if char == " ": newMsg += " "
if char == "☀": newMsg += "."
if char == "❄": newMsg += "-"
return newMsg
def converToText(aMorseString: str) -> str:
global data_base
data_base_reverse = {v: k for k, v in data_base.items()}
morse_list = [m for m in aMorseString.split()]
words = []
temp = ""
for morse in morse_list:
if morse != "/": temp += data_base_reverse[morse]
else:
words.append(temp)
temp = ""
words.append(temp)
return " ".join(words)
# main
msg = "❄️ ☀️☀️☀️☀️ ☀️ ☀️❄️❄️ ❄️❄️❄️ ☀️❄️☀️ ☀️❄️☀️☀️ ❄️☀️☀️ ❄️☀️❄️☀️ ☀️☀️☀️☀️ ☀️❄️ ❄️☀️ ❄️❄️☀️ ☀️ ❄️☀️☀️ ☀️❄️❄️ ☀️☀️☀️☀️ ☀️ ❄️☀️ ☀️☀️☀️ ☀️❄️ ❄️❄️ ☀️☀️❄️ ☀️ ☀️❄️☀️☀️ ❄️❄️ ❄️❄️❄️ ☀️❄️☀️ ☀️☀️☀️ ☀️ ☀️☀️☀️ ☀️ ❄️☀️ ❄️ ❄️ ☀️☀️☀️☀️ ☀️ ☀️☀️❄️☀️ ☀️☀️ ☀️❄️☀️ ☀️☀️☀️ ❄️ ☀️❄️☀️☀️ ❄️❄️❄️ ❄️☀️ ❄️❄️☀️ ❄️☀️☀️ ☀️☀️ ☀️☀️☀️ ❄️ ☀️❄️ ❄️☀️ ❄️☀️❄️☀️ ☀️ ❄️❄️ ☀️ ☀️☀️☀️ ☀️☀️☀️ ☀️❄️ ❄️❄️☀️ ☀️ ☀️❄️❄️ ☀️☀️☀️☀️ ☀️❄️ ❄️ ☀️☀️☀️☀️ ☀️❄️ ❄️ ☀️☀️☀️☀️ ❄️❄️☀️ ❄️❄️❄️ ❄️☀️☀️ ☀️❄️❄️ ☀️❄️☀️ ❄️❄️❄️ ☀️☀️❄️ ❄️❄️☀️ ☀️☀️☀️☀️ ❄️ ☀️☀️☀️☀️❄️ ☀️☀️☀️☀️❄️ ❄️❄️ ☀️☀️ ☀️❄️☀️☀️ ☀️ ☀️☀️☀️ ❄️☀️☀️☀️ ☀️ ❄️ ☀️❄️❄️ ☀️ ☀️ ❄️☀️ ☀️❄️❄️ ☀️❄️ ☀️☀️☀️ ☀️☀️☀️☀️ ☀️☀️ ❄️☀️ ❄️❄️☀️ ❄️ ❄️❄️❄️ ❄️☀️ ☀️❄️ ❄️☀️ ❄️☀️☀️ ❄️☀️☀️☀️ ☀️❄️ ☀️❄️☀️☀️ ❄️ ☀️☀️ ❄️❄️ ❄️❄️❄️ ☀️❄️☀️ ☀️ ☀️❄️ ☀️❄️☀️☀️ ❄️❄️❄️ ❄️☀️ ❄️❄️☀️ ☀️❄️ ❄️ ☀️ ☀️❄️☀️☀️ ☀️ ❄️❄️☀️ ☀️❄️☀️ ☀️❄️ ☀️❄️❄️☀️ ☀️☀️☀️☀️ ☀️❄️☀️☀️ ☀️☀️ ❄️☀️ ☀️ ❄️❄️❄️ ❄️☀️ ☀️☀️❄️❄️❄️ ☀️☀️☀️☀️❄️ ❄️❄️ ☀️❄️ ❄️☀️❄️❄️ ☀️❄️❄️❄️❄️ ❄️❄️❄️☀️☀️ ☀️☀️☀️☀️❄️ ☀️☀️☀️☀️❄️ ❄️ ❄️❄️❄️ ☀️❄️ ☀️❄️☀️☀️ ☀️☀️❄️☀️ ☀️❄️☀️ ☀️ ❄️☀️☀️ ☀️☀️☀️❄️ ☀️❄️ ☀️☀️ ☀️❄️☀️☀️"
print(converToText(convertToMorse(msg)))
python | Peiran D | Python Solutions
import re
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',
'.----': '1', '..---': '2', '...--': '3', '....-': '4', '.....': '5',
'-....': '6', '--...': '7', '---..': '8', '----.': '9', '-----': '0'
}
text = (
"❄️ ☀️☀️☀️☀️ ☀️ ☀️❄️❄️ ❄️❄️❄️ ☀️❄️☀️ ☀️❄️☀️☀️ ❄️☀️☀️ "
"❄️☀️❄️☀️ ☀️☀️☀️☀️ ☀️❄️ ❄️☀️ ❄️❄️☀️ ☀️ ❄️☀️☀️ ☀️❄️❄️ ☀️☀️☀️☀️ ☀️ ❄️☀️ "
"☀️☀️☀️ ☀️❄️ ❄️❄️ ☀️☀️❄️ ☀️ ☀️❄️☀️☀️ ❄️❄️ ❄️❄️❄️ ☀️❄️☀️ ☀️☀️☀️ ☀️ "
"☀️☀️☀️ ☀️ ❄️☀️ ❄️ ❄️ ☀️☀️☀️☀️ ☀️ ☀️☀️❄️☀️ ☀️☀️ ☀️❄️☀️ ☀️☀️☀️ ❄️ "
"☀️❄️☀️☀️ ❄️❄️❄️ ❄️☀️ ❄️❄️☀️ ❄️☀️☀️ ☀️☀️ ☀️☀️☀️ ❄️ ☀️❄️ ❄️☀️ ❄️☀️❄️☀️ ☀️ "
"❄️❄️ ☀️ ☀️☀️☀️ ☀️☀️☀️ ☀️❄️ ❄️❄️☀️ ☀️ ☀️❄️❄️ ☀️☀️☀️☀️ ☀️❄️ ❄️ "
"☀️☀️☀️☀️ ☀️❄️ ❄️ ☀️☀️☀️☀️ ❄️❄️☀️ ❄️❄️❄️ ❄️☀️☀️ ☀️❄️❄️ ☀️❄️☀️ ❄️❄️❄️ ☀️☀️❄️ "
"❄️❄️☀️ ☀️☀️☀️☀️ ❄️ ☀️☀️☀️☀️❄️ ☀️☀️☀️☀️❄️ ❄️❄️ ☀️☀️ ☀️❄️☀️☀️ ☀️ ☀️☀️☀️ "
"❄️☀️☀️☀️ ☀️ ❄️ ☀️❄️❄️ ☀️ ☀️ ❄️☀️ ☀️❄️❄️ ☀️❄️ ☀️☀️☀️ ☀️☀️☀️☀️ ☀️☀️ "
"❄️☀️ ❄️❄️☀️ ❄️ ❄️❄️❄️ ❄️☀️ ☀️❄️ ❄️☀️ ❄️☀️☀️ ❄️☀️☀️☀️ ☀️❄️ ☀️❄️☀️☀️ "
"❄️ ☀️☀️ ❄️❄️ ❄️❄️❄️ ☀️❄️☀️ ☀️ ☀️❄️ ☀️❄️☀️☀️ ❄️❄️❄️ ❄️☀️ ❄️❄️☀️ "
"☀️❄️ ❄️ ☀️ ☀️❄️☀️☀️ ☀️ ❄️❄️☀️ ☀️❄️☀️ ☀️❄️ ☀️❄️❄️☀️ ☀️☀️☀️☀️ "
"☀️❄️☀️☀️ ☀️☀️ ❄️☀️ ☀️ ❄️❄️❄️ ❄️☀️ ☀️☀️❄️❄️❄️ ☀️☀️☀️☀️❄️ ❄️❄️ ☀️❄️ "
"❄️☀️❄️❄️ ☀️❄️❄️❄️❄️ ❄️❄️❄️☀️☀️ ☀️☀️☀️☀️❄️ ☀️☀️☀️☀️❄️ ❄️ ❄️❄️❄️ "
"☀️❄️ ☀️❄️☀️☀️ ☀️☀️❄️☀️ ☀️❄️☀️ ☀️ ❄️☀️☀️ ☀️☀️☀️❄️ ☀️❄️ ☀️☀️ ☀️❄️☀️☀️"
)
text = text.replace('☀️', '.').replace('❄️', '-')
text = text.replace(' ', ' / ')
text = text.replace(' ', ' ')
words = text.split(' / ')
decoded_words = []
for word in words:
letters = word.split()
decoded_letters = [MORSE[code] for code in letters if code in MORSE]
decoded_words.append(''.join(decoded_letters))
message = ' '.join(decoded_words)
print(message)