What's new

Closed Python3: print integers as glyphs

Status
Not open for further replies.

nnivx

Addict
Joined
Mar 16, 2017
Posts
164
Reaction
88
Points
122
Share ko lang yung ginawa ko a while ago para sa assignment ng kaibigan ko. This code will print positive integers as a 3-line glyph:
Code:
# Sample output for 5674:
#  _   _   _
# |_  |_    | |_|
#  _| |_|   |   |

s = input('Enter Number: ')
STAMP = ' _ |_||_|'
NUM   = ['4', '13467', '38', '36', '167', '56', '5', '3467', '', '6']

# data
buf = []
for nc in s:
    buf.append(''.join([STAMP[x] if (str(x) not in NUM[int(nc)]) else ' ' for x in range(0, 9)]))
   
# print per line
for x in range(0, 9, 3):
    print(' '.join([c[x:x+3] for c in buf]))


Disclaimer: this is just how I did it, not sure kung may mas ez pa. Kung meron kayong better code or other ideas, share niyo rin :>

Spoiler contents are visible only to Established Members.
 
405043534677147659.png 402866237853401100.png parang nagbabasa ako ng alien language
 

Attachments

Status
Not open for further replies.
Back
Top