Code Golf: ASCII Art number [duplicate]

一曲冷凌霜 提交于 2019-12-11 12:34:34

问题


Possible Duplicate:
Code Golf - Banner Generation

Post your shortest code to convert a number into a ASCII art digits.

Input - Assume that an integer variable called z has already been set containing the number.

Output - Print the output to the console.

Quality - The lower number of characters, the better.

Formatting - Flexible, providing it is ASCII art and looks like a number. There must also be some spacing between digits.

Test input: 365

GGGGGGGGGGG....GGGGGGGGGGGG...GGGGGGGGGGG
..........G....G..............G..........
..........G....G..............G..........
..GGGGGGGGG....GGGGGGGGGGGG...GGGGGGGGGGG
..........G....G..........G.............G
..........G....G..........G.............G
GGGGGGGGGGG....GGGGGGGGGGGG...GGGGGGGGGGG

回答1:


Python: 173 characters

for i in range(5):
    a=""
    for j in str(z):
        y=int("03330222220201002020330220102001030022220303003020"[int(j)*5+i])*8
        a+="."+("#"*9+"."*14+"##"+"."*6+"#")[y:y+8]
    print a



回答2:


Bash: 9 characters

figlet $z

;)




回答3:


Ruby - 139 chars

(0..4).map{|i|puts z.to_s.chars.map{|j|(?#*9+?.*14+'##'+?.*6+?#)[(?0+"ubp9x453o9jzme0cs08".to_i(36).to_s(4))[j.to_i*5+i].to_i*8,8]+' '}*''}

Output for z = 365

> asciinum.rb
######## ######## ########
.......# #....... #.......
######## ######## ########
.......# #......# .......#
######## ######## ########


来源:https://stackoverflow.com/questions/3077666/code-golf-ascii-art-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!