Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Morse Clock by _Chico_
def code(d):
if d == "0":
return "...."
elif d == "1":
return "...-"
elif d == "2":
return "..-."
elif d == "3":
return "..--"
elif d == "4":
return ".-.."
elif d == "5":
return ".-.-"
elif d == "6":
return ".--."
elif d == "7":
return ".---"
elif d == "8":
return "-..."
elif d == "9":
return "-..-"
def checkio(time_string):
x = " "
time = time_string.split(":")
for p in time:
h = time[0]
m = time[1]
s = time[2]
for t in h:
if len(h) < 2:
h = "0" + h
ha = str(code(h[0]))
ha = ha[2:]
hb = str(code(h[1]))
for i in m:
if len(m) < 2:
m = "0" + m
ma = str(code(m[0]))
ma = ma[1:]
mb = str(code(m[1]))
for e in s:
if len(s) < 2:
s = "0" + s
sa = str(code(s[0]))
sa = sa[1:]
sb = str(code(s[1]))
return ha + x + hb + " : " + ma + x + mb + " : " + sa + x + sb
July 10, 2021