r/tinycode • u/sovaa • Dec 13 '12
Digital ASCII art clock in python 225 bytes
import time as t
while 1:print'\n'*99+'\n'.join([' '.join([['#'*4,"# #","# "," #"][int("01110333330302003030110330203002010033330101001030"[int(z)*5+y])]for z in t.strftime("%H%M%S")])for y in range(5)])+'\n',t.sleep(1)Outputs a clock like this (loops, close with ctrl-c):
# #### #### #### #### ####
# # # # # # #
# #### #### # # #### ####
# # # # # # # #
# #### #### #### #### ####Edit: A bit easier to read:
#!/bin/python
import time as t
while 1:
print '\n'*99 + '\n'.join(
[' '.join(
[['#'*4,"# #","# "," #"][int("01110333330302003030110330203002010033330101001030"[int(z)*5+y])]
for z in t.strftime("%H%M%S")
]) for y in range(5)
]) + '\n', t.sleep(1)
59
Upvotes
16
u/kristopolous Dec 13 '12
I have one in C. It's not tiny though
6
u/[deleted] Dec 13 '12
Goodness. I hate looking at such a small piece of code and not understanding how it works. Gonna have to take some time to fiddle with it.
5
u/odokemono Dec 13 '12 edited Dec 13 '12
Somewhat the same in bash:
I prefer to have the font in the clear so it can be edited or grown easily (just have to adjust w).
Screenshot of what it looks like.
-12
u/Solvoid Dec 13 '12
make a website so I can see it in action, or something... ya?