Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Morse Clock by JanD
def checkio(time_string):
h,m,s=map(int,(time_string.split(':')))
return f"{h//10:02b} {h%10:04b} : {m//10:03b} {m%10:04b} : {s//10:03b} {s%10:04b}".translate(str.maketrans("01",".-"))
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(u"10:37:49") == ".- .... : .-- .--- : -.. -..-", "First Test"
assert checkio(u"21:34:56") == "-. ...- : .-- .-.. : -.- .--.", "Second Test"
assert checkio(u"00:1:02") == ".. .... : ... ...- : ... ..-.", "Third Test"
assert checkio(u"23:59:59") == "-. ..-- : -.- -..- : -.- -..-", "Fourth Test"
March 5, 2019
Comments: