views:

400

answers:

3

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
+4  A: 

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
Simon Brown
please note you need to count new lines as well. it's 168 chars with identation but w/o new lines. Need to add +5 for \n = 173
Nas Banov
I don't have Python installed on this machine so I'll take your word for it that this works, somehow. There is a voice in the back of my head telling me that you can somehow reduce your character count using a list comprehension, but of course, I may be totally wrong.
MatrixFrog
+1  A: 

Bash: 9 characters

figlet $z

;)

MiffTheFox
ewwww... this is not solution in bash but in figlet.pls no trivialisms!
Nas Banov
@EnTrr - When I got here the question was at -1 with a vote to close, I figured it was going to be closed soon and I shouldn't take it so seriously... ;)
MiffTheFox
A: 

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
######## ######## ########
.......# #....... #.......
######## ######## ########
.......# #......# .......#
######## ######## ########
Adam