Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Morse Clock by U.V
def checkio(time_string: str) -> str:
h, m, s = [i.zfill(2) for i in time_string.split(':')]
t = f'{int(h[0]):02b} {int(h[1]):04b} : {int(m[0]):03b} {int(m[1]):04b} : {int(s[0]):03b} {int(s[1]):04b}'.replace('0', '.').replace('1', '-')
return t
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!")
Oct. 31, 2022
Comments: