Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Formatting the strings solution in Clear category for Morse Clock by Denis_Gerashchenko
def checkio(num):
[hours, minutes, seconds] = num.split(':')
#Converting single digit like "1" into two, like "01"
hours = f'{hours:0>2}'
minutes = f'{minutes:0>2}'
seconds = f'{seconds:0>2}'
#Converting digits into ints, then into needed binary format
hours = f'{int(hours[0]):0>2b}' + ' ' + f'{int(hours[1]):0>4b}' + ' '
minutes = ' ' + f'{int(minutes[0]):0>3b}' + ' ' + f'{int(minutes[1]):0>4b}' + ' '
seconds = ' ' + f'{int(seconds[0]):0>3b}' + ' ' + f'{int(seconds[1]):0>4b}'
time = ":".join([hours, minutes, seconds])
time = time.replace("1", "-")
time = time.replace("0", ".")
return time
Jan. 26, 2019
Comments: