diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2023-08-10 20:00:56 +0200 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2023-08-10 20:00:56 +0200 |
| commit | 407bdf405e1cc65708dc231c0a236d79c327e8d3 (patch) | |
| tree | e178f86a700ad09d55b0b71d64282066e6e1dd08 /challenge-200/lubos-kolouch/python/ch-2.py | |
| parent | 2cbddb9ecfe878d6e3b10d472e6647e6229ad1ce (diff) | |
| download | perlweeklychallenge-club-407bdf405e1cc65708dc231c0a236d79c327e8d3.tar.gz perlweeklychallenge-club-407bdf405e1cc65708dc231c0a236d79c327e8d3.tar.bz2 perlweeklychallenge-club-407bdf405e1cc65708dc231c0a236d79c327e8d3.zip | |
feat(challenge-200/lubos-kolouch/): Challenge 200 LK Perl Python Blog
Diffstat (limited to 'challenge-200/lubos-kolouch/python/ch-2.py')
| -rw-r--r-- | challenge-200/lubos-kolouch/python/ch-2.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-200/lubos-kolouch/python/ch-2.py b/challenge-200/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..fc111377ec --- /dev/null +++ b/challenge-200/lubos-kolouch/python/ch-2.py @@ -0,0 +1,24 @@ +truth = [ + 'abcdef', 'bc', 'abdeg', 'abcdg', 'bcfg', 'acdfg', 'acdefg', 'abc', + 'abcdefg', 'abcfg' +] + + +def draw_seven_segment(number): + lines = [""] * 5 + + for digit in str(number): + segments = truth[int(digit)] + lines[0] += ("-" * 7 if 'a' in segments else " " * 7) + " " + lines[1] += ("|" if 'f' in segments else + " ") + (" " * 6) + ("|" if 'b' in segments else " ") + " " + lines[2] += ("-" * 7 if 'g' in segments else " " * 7) + " " + lines[3] += ("|" if 'e' in segments else + " ") + (" " * 6) + ("|" if 'c' in segments else " ") + " " + lines[4] += ("-" * 7 if 'd' in segments else " " * 7) + " " + + return '\n'.join(lines) + + +number = 200 +print(draw_seven_segment(number)) |
