diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-12-17 11:48:55 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-12-17 11:48:55 +0000 |
| commit | 40ecb91eca8db21fb151ad8c148dd3e3b3f877c2 (patch) | |
| tree | 5438e53f9b97a95bf82b99df8e8aacb3b41b36fc /challenge-028/paulo-custodio/python/ch-2.py | |
| parent | 8c1fdda84743187534ae4615a0dfcb41283293e4 (diff) | |
| download | perlweeklychallenge-club-40ecb91eca8db21fb151ad8c148dd3e3b3f877c2.tar.gz perlweeklychallenge-club-40ecb91eca8db21fb151ad8c148dd3e3b3f877c2.tar.bz2 perlweeklychallenge-club-40ecb91eca8db21fb151ad8c148dd3e3b3f877c2.zip | |
Add Perl and Python solutions to challenge 028
Diffstat (limited to 'challenge-028/paulo-custodio/python/ch-2.py')
| -rw-r--r-- | challenge-028/paulo-custodio/python/ch-2.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/challenge-028/paulo-custodio/python/ch-2.py b/challenge-028/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..51771c3ad9 --- /dev/null +++ b/challenge-028/paulo-custodio/python/ch-2.py @@ -0,0 +1,89 @@ +#!/usr/bin/python3 + +# Challenge 028 + +# Task #2 +# Write a script to display Digital Clock. Feel free to be as creative as you +# can when displaying digits. We expect bare minimum something like "14:10:11". + +from datetime import datetime +import time + +chars = { + ' ': [" ", + " ", + " ", + " ", + " "], + '0': [" ___ ", + " | |", + " | |", + " | |", + " |___|"], + '1': [" ", + " |", + " |", + " |", + " |"], + '2': [" ___ ", + " |", + " ___|", + " | ", + " |___ "], + '3': [" ___ ", + " |", + " ___|", + " |", + " ___|"], + '4': [" ", + " | |", + " |___|", + " |", + " |"], + '5': [" ___ ", + " | ", + " |___ ", + " |", + " ___|"], + '6': [" ___ ", + " | ", + " |___ ", + " | |", + " |___|"], + '7': [" ___ ", + " | |", + " | |", + " |", + " |"], + '8': [" ___ ", + " | |", + " |___|", + " | |", + " |___|"], + '9': [" ___ ", + " | |", + " |___|", + " |", + " ___|"], + ':': [" ", + " ", + " . ", + " . ", + " "], +} + +CLEAR = "\x1b[H\x1b[2J" +HOME = "\x1b[H" + +def banner(text): + for row in range(len(chars[' '])): + for c in text: + print(chars[c][row], end="") + print("") + +print(CLEAR, end="") +while True: + now = datetime.now() + print(HOME, end="") + banner(now.strftime("%H:%M:%S")) + time.sleep(0.5) |
