问题
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