Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Morse Clock by martin_b
# migrated from python 2.7
def checkio(time_string):
# neither very readable not optimal but does the work
return "{:02b} {:04b} : {:03b} {:04b} : {:03b} {:04b}".format(*sum([[int(i)//10,int(i)%10] for i in time_string.split(":")],[])).replace("0",".").replace("1","-")
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio("10:37:49") == ".- .... : .-- .--- : -.. -..-", "First Test"
assert checkio("21:34:56") == "-. ...- : .-- .-.. : -.- .--.", "Second Test"
assert checkio("00:1:02") == ".. .... : ... ...- : ... ..-.", "Third Test"
assert checkio("23:59:59") == "-. ..-- : -.- -..- : -.- -..-", "Fourth Test"
Dec. 3, 2015
Comments: