Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
'{} clock'.format('morse') solution in Clear category for Morse Clock by Tical_1000
def checkio(time_string: str) -> str:
parts = ''.join(['{:02d}'.format(int(dig)) for dig in time_string.split(':')])
output = '{:02b} {:04b} : {:03b} {:04b} : {:03b} {:04b}'.format(*[int(i) for i in parts])
output = output.replace('0', '.')
output = output.replace('1', '-')
return output
if __name__ == '__main__':
print("Example:")
print(checkio("10:37:49"))
#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"
print("Coding complete? Click 'Check' to earn cool rewards!")
April 10, 2019