39
\$\begingroup\$

Your goal is to write the shortest program that outputs "Hello-World!" as ASCII art.

Rules :

  • It must be human readable, I don't care about it's size (cols/rows)
  • Output must contain only spaces (" "), sharps ("#") and newlines
  • The output must work with a monospaced font (but the letters doesn't necessary use a monospaced font)
  • In the result, each character must be separated from each other by at least one space

Please add a title with the language and the number of bytes in your code.

\$\endgroup\$
16
  • 5
    \$\begingroup\$ bash: 33 characters – pastebin.com/HZ1w8z8g Is this acceptable? \$\endgroup\$
    – manatwork
    Commented Feb 6, 2014 at 13:51
  • 4
    \$\begingroup\$ Why the hyphen though?... \$\endgroup\$
    – Timwi
    Commented Feb 6, 2014 at 14:16
  • 1
    \$\begingroup\$ I suppose to make impossible or unfeasibly hard the use of something predefined like HQ9+. \$\endgroup\$
    – manatwork
    Commented Feb 6, 2014 at 14:23
  • 1
    \$\begingroup\$ @PeterTaylor: The output consisting of spaces and hashes must work with a monospaced font, but the letters represented by the plethora of hashes need not all have the same width. \$\endgroup\$
    – Timwi
    Commented Feb 6, 2014 at 14:39
  • 1
    \$\begingroup\$ Related, but different: Say “Hello” to the world in ASCII art \$\endgroup\$ Commented Feb 6, 2014 at 15:58

33 Answers 33

47
\$\begingroup\$

JavaScript, 178 bytes

c=document.createElement("canvas").getContext("2d");c.fillText("Hello-World!",0,7);d=c.getImageData(1,0,56,7).data;s="";for(i=3;i<1568;i+=4){s+=d[i]?"#":" ";s+=(i+1)%224?"":"\n"}

That works in Firefox 27 Scratchpad.

#   #        #  #          #   #   #          #     #  #
#   #        #  #          #  # #  #          #     #  #
#   #   ##   #  #   ##      # # # #   ##   ## #   ###  #
#####  #  #  #  #  #  #     # # # #  #  #  #  #  #  #  #
#   #  ####  #  #  #  # ##  # # # #  #  #  #  #  #  #  #
#   #  #     #  #  #  #     # # # #  #  #  #  #  #  #   
#   #   ###  #  #   ##       #   #    ##   #  #   ###  #
\$\endgroup\$
4
  • \$\begingroup\$ I recognise Arial :-D \$\endgroup\$
    – Timwi
    Commented Feb 6, 2014 at 14:35
  • 4
    \$\begingroup\$ This is my favourite. You've used an interesting method to arrive at the solution. Wonderful! \$\endgroup\$ Commented Feb 6, 2014 at 18:24
  • 2
    \$\begingroup\$ Ingenious, I do believe you've just created Figlet for JavaScript ;) \$\endgroup\$ Commented Feb 6, 2014 at 21:06
  • \$\begingroup\$ Dagnammit, this was my first thought too! Here's an upvote instead. :) \$\endgroup\$ Commented Feb 17, 2014 at 16:33
37
\$\begingroup\$

Mathematica 101 99 98

This rasterizes the expression, obtains the binary image data, converts each 1 to "#", each 0 to "" (empty space) and displays output in a 12 by 130 character grid.

GraphicsGrid[ImageData@ImageResize[Binarize@Rasterize@Style["Hello-World!",99],130] 
  /.{1→"",0→"#"}]

hello

One character economized thanks to Jonathan Van Matre.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Why does the thickness vary between the l's? \$\endgroup\$
    – MrZander
    Commented Feb 7, 2014 at 1:26
  • \$\begingroup\$ I did the rasterization on the expression as a single image. If I had done it letter by letter, the l's would have been identical. Also, by increasing the rasterization grid size, the output tends to approach the quality of the printed characters. But a larger grid results in relatively smaller "#", to the point that they appear to be mere pixels. The question remains: why do 2 l's in an image receive different weights? \$\endgroup\$
    – DavidC
    Commented Feb 7, 2014 at 1:41
  • 3
    \$\begingroup\$ @MrZander, that's the very reason fonts have hinting: When trying to fit fonts into a low-resolution pixel grid, like in ASCII art or on screen stem width is never really uniform because the font cannot have integral-pixel wide stems at all sizes. Here is a nice explanation with pictures. \$\endgroup\$
    – Joey
    Commented Feb 7, 2014 at 8:50
  • 1
    \$\begingroup\$ prbably the best looking \$\endgroup\$
    – TeAmEr
    Commented Feb 9, 2014 at 15:05
  • 1
    \$\begingroup\$ Jonathan Van Matre, Thanks. The first parameter could be reduced to 99 but I wouldn't want to reduce the second, due to output quality. (I realize that this is a code-golf challenge, but I do have my pride.) \$\endgroup\$
    – DavidC
    Commented Feb 12, 2014 at 17:33
26
\$\begingroup\$

Delphi 85 bytes

var s:tstringlist;begin s:=tstringlist.Create;s.LoadFromFile('\a');Write(s.Text);end.

I know, its not the prettiest solution but there was no rule that said you couldnt use external resources.
Result: Result

\$\endgroup\$
5
  • 12
    \$\begingroup\$ +1 for the creativity of using # as background rather than foreground. \$\endgroup\$
    – gerrit
    Commented Feb 7, 2014 at 12:32
  • 1
    \$\begingroup\$ You can declare s as TStrings instead. (But keep the instantiation with TStringList.) \$\endgroup\$
    – manatwork
    Commented Feb 7, 2014 at 19:58
  • \$\begingroup\$ Is the file you're loading from something that actually ships with Delphi, or did you write it yourself? If the latter, I think you'd need to count its length as part of your score. \$\endgroup\$ Commented Feb 8, 2014 at 2:36
  • \$\begingroup\$ @Ilmari, I'm sure Delphi doesn't ship with a file with "Hello-World" ASCII art :) Moreover, it's described in the answer, that it uses external resources. \$\endgroup\$
    – TLama
    Commented Feb 9, 2014 at 7:24
  • 3
    \$\begingroup\$ @TLama: I assumed so, too, I was just trying to phrase it politely. My point is that, even if external resources were allowed, this program would still fail on anyone's computer except its author's (and, in fact, we have no proof that it even works on his computer). Also, I can beat his score with the following Perl script: do X. The content of the "external resource" X is left unspecified (it works for me, isn't that enough?), but I've provided a couple of possible suggestions below... \$\endgroup\$ Commented Feb 9, 2014 at 7:44
18
\$\begingroup\$

I absolutely enjoyed this one

Perl, 126 116 114 102 98  87 (69) chars (ascii only & no external fonts)

As of now shortest ascii solution which doesn't use any external fonts.

Well, I wanted to present some elegant solution but @Ilmari Karonen challenged me with unpack... shouldn't have done that :-)

Well, this 92 88 69 chars code generates the uglish unreadable output identical to @Ilmari Karonen's:

say map{y/01/ #/r}unpack"((b6)7a)*",'eT@j@DE
UUBjdeE
wTujjTA
eUBTddE'

More elegant variant without unpack (88 chars):

map{print$"x$_,$/x/4/,"#"x!/7/}7&ord,7&ord>>3for'HRyYOKLIIjIRHBa@AJIAIIIJaQHQNSRH'=~/./g

But I think such |.|e||.-|||.,d! thing is nothing which resembles Hello-World! and shouldn't be allowed, so real solution goes here - unpack variant, 87 chars:

say map{y/01/ #/r}unpack"((b6)9a)*",'E`D@HB@Hd
EcD@HB@Hd
ggDsIbaIf
e`dDhRRHE
ECICPaQPf'

Output:

enter image description here

More elegant variant at 98 chars:

map{print$"x$_,$/x/1/,"#"x!/7/}7&ord,7&ord>>3for'PW{nw^QD[w}vK@X@PcP@jCDjXQk[rRRbSQD\CWbXeX'=~/./g

Output:

enter image description here

Older solution (114 chars), different type of coding:

print'#'x(3&ord),$"x($:=15&ord>>2),$/x!$:for'EmM}U}]MBEQSM}U}]MBOFNMQOKUMSKUOBEM]MMM]IIIMIUQIAEQWMMgFROYQOB'=~/./g

Output:

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Forgot the exclamation at the end, i.e. Hello-World! Also, should be lower-case e, but I know you did upper-case to make it readable as a five pixel high font... \$\endgroup\$
    – user15259
    Commented Feb 6, 2014 at 17:25
15
\$\begingroup\$

Perl 5, 54 bytes / 71 printable ASCII chars

Note: This is the second version of this answer. For the original 64-byte / 95-char version using PHP and gzinflate(), see the history of this answer.

Here's the 71-char printable ASCII version:

y/01/ #/,say for unpack'(B40)4',unpack u,'4I*`1`(JJI!$FFNRJU52HIJ0*))H'

The 54-byte version contains non-printable characters, so I'm providing it as a hex dump. On Unixish systems, you can use xxd -r to turn the hex dump back into an executable Perl script:

0000000: 792f 3031 2f20 232f 2c73 6179 2066 6f72  y/01/ #/,say for
0000010: 2075 6e70 6163 6b27 2842 3430 2934 272c   unpack'(B40)4',
0000020: 27a4 a011 008a aaa4 1126 9aec aad5 54a8  '........&....T.
0000030: a6a4 0a24 9a27                           ...$.'

Both need to be run with perl -M5.010 to enable the Perl 5.10+ say feature. They will produce the following output:

Screenshot of "Hello-World!" ASCII art

(Shown as a screenshot, because the huge line-height on SE makes ASCII art ugly and hard to read. The lower case "e" is kind of awkward, but I believe this qualifies as readable, if only barely so.)


Ps. If the output of the solution above feels too minimalistic for you, here's a 92-character variant that produces output similar to Tomas's solution:

y/01/ #/,say for unpack'(B56)*',unpack u,'CH!(`"(`"":,2``B``@GGDC\'(C#(YI!)("I)"2*,),`4,03D'

Here's a screenshot:

Screenshot of "Hello-World!" ASCII art


Pps. I'm pretty sure this (GolfScript, 51 chars) is the shortest printable-ASCII solution, if you don't count the ones that just call banner / FIGLet or that cheat in some other way:

'iJ@Q@HmURBIMM{JkUUJeMRAQIM'{2base(;{' #'=}/}%39/n*

The output is the same as for my 71-char Perl solution above.

\$\endgroup\$
8
  • \$\begingroup\$ I'd say you have just crossed the border of readability :-) \$\endgroup\$
    – Tomas
    Commented Feb 6, 2014 at 22:47
  • 1
    \$\begingroup\$ It's considerably more readable in my terminal than here on SE, because of the huge line spacing here. \$\endgroup\$ Commented Feb 6, 2014 at 23:09
  • \$\begingroup\$ I mean, it is unreadable anyway. BTW I can produce your output in 92 chars, with no external compression algorithm :-) \$\endgroup\$
    – Tomas
    Commented Feb 7, 2014 at 10:24
  • \$\begingroup\$ @Tomas: You're right, zipping does not seem to be the winning answer here. I'd give you a +1 for that if I hadn't already. BTW, I can do it in 71 chars; see above. :-) \$\endgroup\$ Commented Feb 7, 2014 at 13:29
  • 1
    \$\begingroup\$ Ilmari, you shouldn't have challenged me with unpack :-) Found a solution of 69 chars (87 with the nice output of mine). \$\endgroup\$
    – Tomas
    Commented Feb 9, 2014 at 16:55
8
\$\begingroup\$

Shell + Figlet (35)

$ figlet -w 90 -f banner Hello-World!
#     #                                   #     #                             ### 
#     # ###### #      #       ####        #  #  #  ####  #####  #      #####  ### 
#     # #      #      #      #    #       #  #  # #    # #    # #      #    # ### 
####### #####  #      #      #    # ##### #  #  # #    # #    # #      #    #  #  
#     # #      #      #      #    #       #  #  # #    # #####  #      #    #     
#     # #      #      #      #    #       #  #  # #    # #   #  #      #    # ### 
#     # ###### ###### ######  ####         ## ##   ####  #    # ###### #####  ### 
\$\endgroup\$
5
  • \$\begingroup\$ What kind of font is this? Those just look like smaller upper-case characters. \$\endgroup\$
    – Cruncher
    Commented Feb 6, 2014 at 19:14
  • \$\begingroup\$ it's banner -f banner It was the first font I found that used # instead of * or | and _. \$\endgroup\$
    – grim
    Commented Feb 6, 2014 at 19:39
  • \$\begingroup\$ here's the same in pure Python \$\endgroup\$
    – jfs
    Commented Feb 7, 2014 at 8:03
  • \$\begingroup\$ Changing "90" to "9" yields a tall and skinny hello world, however because the OP does not care about columns or rows, it should be acceptable. \$\endgroup\$
    – alexyorke
    Commented Feb 7, 2014 at 11:42
  • \$\begingroup\$ Sometimes voters baffle me. How come this gets a net score of +8, but the other figlet answer gets a net score of -3? \$\endgroup\$ Commented Apr 18, 2014 at 20:28
8
\$\begingroup\$

Python 260 215 186 152

>>> print'eJyNkFEKwDAIQ/93isC7/x3LyIJullHrR1BfJSIJPUHTlmiUPHbxC7L56wNCgZAxv3SjDWIxsoOb\nzMaBwyHYPJ5sVPNYxXism74vcIsFZlYyrg=='.decode('base64').decode('zip')
#   #        #  #          #   #   #          #     #  #
#   #        #  #          #  # #  #          #     #  #
#   #   ##   #  #   ##      # # # #   ##   ## #   ###  #
#####  #  #  #  #  #  #     # # # #  #  #  #  #  #  #  #
#   #  ####  #  #  #  # ##  # # # #  #  #  #  #  #  #  #
#   #  #     #  #  #  #     # # # #  #  #  #  #  #  #   
#   #   ###  #  #   ##       #   #    ##   #  #   ###  #

Python 196 183 130 114 (but uglyer)

>>> print'eJxTVlBWgCAgAQHKqBywAJeyAgJCZREcZWUYyaUMIpUVEKqRNcLEueDqEaZBLVVWQDITADIdFBw='.decode('base64').decode('zip')
# #  #  # #        # # #        #   # #
# # # # # #  #     # # #  #  ## #  ## #
### ##  # # # # ## # # # # # #  # # #
# #  ## # #  #      # #   #  #  #  ## #

I used zipped data in base64 encoding. and the code decode it from base64 encoding and then unzipping it.

\$\endgroup\$
1
  • \$\begingroup\$ Wow, that's really stretching legibility! \$\endgroup\$
    – user15259
    Commented Feb 7, 2014 at 16:19
7
\$\begingroup\$

PHP — 183 bytes

Using sebcap26's ASCII art as the source...

foreach(str_split(base64_decode('iASAERACCYgEgBKQAgmIxIwKoxo5+SSSCqSSSYnkksqkkkmJBJIKpJJIiOSMBEMSOQ'))as$i=>$j)echo strtr(sprintf("%8s%s",decbin(ord($j)),($i+1)%7?"":"\n"),'01',' #');

#   #        #  #          #   #   #          #     #  #
#   #        #  #          #  # #  #          #     #  #
#   #   ##   #  #   ##      # # # #   ##   ## #   ###  #
#####  #  #  #  #  #  #     # # # #  #  #  #  #  #  #  #
#   #  ####  #  #  #  # ##  # # # #  #  #  #  #  #  #  #
#   #  #     #  #  #  #     # # # #  #  #  #  #  #  #   
#   #   ###  #  #   ##       #   #    ##   #  #   ###  #
\$\endgroup\$
6
\$\begingroup\$

Brainfuck, 372 Byte

(I know. but just for completeness, there has to be brainfuck ^^ It'S not going to get much shorter, as there are little repetitions. First and second line loop already...)

++++++++[>++++>++++<<-]>+++>>++++++++++>>+>++[-<<<<<.>.<.>..>>>[-<<<.>>>]<[-<<<.>>>]<<..<.>>>++[-<<.<.>..........<.>....>>]<<<.>.<.>>.>+>>]<<<<<...>.<.>.<.>.<.>.<.>..<..>..<...>.<.>..<.>..<.>..<..>...<..>.<.>..<...>.<.>>.<<.>.<.>.<.>...<.>.<.>.<.>..<.>.....<.>.<...>.<.>.<.>..<.>.<.>...<.>.<.>..<.>>.<<.>.<.>.<...>.<.>.<.>..<..>.......<..>.<..>...<..>..<.>...<.>..<..>..<.

Interpreter here: http://koti.mbnet.fi/villes/php/bf.php


# #     # #          #     #          #    # #
# #  #  # #          #     #          #    # #
### # # # #  ##  ### #  #  #  ##   ## #  ### #
# # #   # # #  #     # ### # #  # #   # #  #
# # ### # #  ##       ## ##   ##  #   #  ##  #

Combining @ASKASK's number generator and image with my loops and some additional tuning, we get:

Brainfuck, 343 339 336 334 Bytes

Looks uglier than my original version though.

+++++[->++++++>+++++++>++<<<]>++>>>+>>++[-<<<<.<.>.<..>>>[-<<<.>>>]>[-<<<.>>>]<<<<..>.<.>>>++[-<<.<.........>.<...>>>]<<.<.>.>.>>+>]<<<<..<<+++++[->>.<.<]>.>.<..>...<.>.<.>.<.>.<..>.<...>..<.>.<..>..<.>.>.<.<.>.<.>.<...>.<.>.<.>.<.>.<.....<++++++[->>.<.<]>..>.<.>.<.>.>.<.<.>.<..>.<..>.<.>.<..>.<.......>...<...>.<..>.<...>.<..>.<..>.

(image see @ASKASK's Answer)

\$\endgroup\$
5
\$\begingroup\$

EcmaScript 6, 172 161

'¡I%e!c0ĄJ¥eìo0¸ËefMs0µKcÊIs0´Ê¢1éo'.split(0).map(s=>s.split('').map(c=>{for(i=8,s='';i--;)s+=(c.charCodeAt(0)-33)&(1<<i)?'#':' ';return s;}).join('')).join('\n')

Output:

#         # #        #   #   #           #    #
###   ##  # #  ##    #   #   #  ##  # ## #  ###
#  # #### # # #  #   #   #   # #  # ##   # #  #
#  # #    # # #  #    # # # #  #  # #    # #  #
#  #  ### # #  ##      #   #    ##  #    #  ###

Explanation:

The ASCII text is compacted into a string where each bit represent a pixel:

  • 0 for SPACE
  • 1 for #

An offset of 33 is applied in order to get only printable characters.

\$\endgroup\$
4
  • \$\begingroup\$ The first fat arrow function's brackets and return statement are not necessary. \$\endgroup\$
    – manatwork
    Commented Feb 7, 2014 at 8:10
  • \$\begingroup\$ @manatwork I tried to removed it but then it was no longer compiling. Are you sure about that? \$\endgroup\$
    – Florent
    Commented Feb 7, 2014 at 8:37
  • 1
    \$\begingroup\$ Firefox 27.0: i.sstatic.net/VyqnC.png \$\endgroup\$
    – manatwork
    Commented Feb 7, 2014 at 8:46
  • \$\begingroup\$ charCodeAt(0) can be reduced to charCodeAt(). \$\endgroup\$
    – Chiru
    Commented Aug 6, 2015 at 23:34
4
\$\begingroup\$

Sclipting, 38 characters (76 bytes)

갦륈똄릵꺕녔꺒녪냕녪낷뚕년꺒녦냉괄낵要감嚙긂밃⓶掘⓶終丟併껧뜴꼧밍替現겠合終

Output:

# # ## #  #   #     #   #  #  ##  #  ##  #
# # #  #  #  # #    #   # # # # # #  # # #
### ## #  #  # # ## # # # # # ##  #  # # #
# # #  #  #  # #    # # # # # # # #  # #  
# # ## ## ##  #      # #   #  # # ## ##  #
\$\endgroup\$
11
  • 4
    \$\begingroup\$ The code-golf info page says "If you use Unicode, byte count should use UTF-8." If I'm not mistaken, that makes your program-length 114 bytes. (The 76 bytes you mention would be for UTF-16 without a BOM.) \$\endgroup\$
    – r.e.s.
    Commented Feb 6, 2014 at 14:52
  • \$\begingroup\$ @r.e.s.: I changed that, as it makes no sense to require that. My Sclipting interpreter understands UTF-16 just fine, so it’s a valid program encoded as UTF-16. \$\endgroup\$
    – Timwi
    Commented Feb 6, 2014 at 16:28
  • 1
    \$\begingroup\$ Timwi, case matters \$\endgroup\$
    – Tomas
    Commented Feb 6, 2014 at 18:29
  • 3
    \$\begingroup\$ @user689 - actually "Hello-World!" with an exclamation point at the end... \$\endgroup\$
    – user15259
    Commented Feb 6, 2014 at 19:57
  • 1
    \$\begingroup\$ I suppose "accepted by the community" means "accepted, without community discussion, by a small number of people with the power to do so." \$\endgroup\$
    – r.e.s.
    Commented Feb 7, 2014 at 12:07
3
\$\begingroup\$

Brainfuck, 362 bytes

Sorry @johannes-h, I saw yours and was inspired to make my own. It uses a combination of faster number generation at the beginning and a simpler picture to generate the result in less bytes. It does not however use loops anywhere else so it is up for optimization.

+++++[->++++++>+++++++>++<<<]>++>.<.>.<.....>.<.>.<.........>.<...>.<.........>.<...>.<.>.>.<.<.>.<..>.<..>.<.>.<.........>.<...>.<.........>.<...>.<.>.>.<...<.>.<.>.<.>.<.>.<..>.<..>...<.>.<.>.<.>.<..>.<...>..<.>.<..>..<.>.>.<.<.>.<.>.<...>.<.>.<.>.<.>.<.....>.<.>.<.>.<.>.<.>.<.>.<...>.<.>.<.>.>.<.<.>.<..>.<..>.<.>.<..>.<.......>...<...>.<..>.<...>.<..>.<..>.

which generates:

pic

\$\endgroup\$
4
  • \$\begingroup\$ Hm. How much shorter is the number generation? 'cause changing the image looks like cheating to me (at least when directly comparing our solutions - perfectly valid in this contest of course) ^^ BUt I'm going to look into yours later on :) You can take my loop for the first two lines however. It's a lot shorter (was about 10-20 bytes if I remember correctly) \$\endgroup\$ Commented Feb 7, 2014 at 6:29
  • \$\begingroup\$ got your version down to 343 Byte, see my answer \$\endgroup\$ Commented Feb 7, 2014 at 7:11
  • \$\begingroup\$ and even shorter, replacing more repetitions by loops. 339 now. \$\endgroup\$ Commented Feb 7, 2014 at 7:31
  • \$\begingroup\$ I dont have neough reputation to comment on yours but if you look closely at your new version you will find a "><" in there that can be deleted to take away two bytes :) \$\endgroup\$
    – ASKASK
    Commented Feb 8, 2014 at 2:41
3
\$\begingroup\$

ImageMagick + sed, 71 bytes

I don't see any other ImageMagick entries, so here's my late stake in the ground:

convert +antialias label:Hello-World! xpm:-|sed '8,+9y/ /#/;s/[^#]/ /g'

I think the sed portion can probably be golfed some more.

Try it online.

Output:

         
  #    #          #  #            ##   #    #            #      #  #     
  #    #          #  #             #   ##  ##            #      #  #     
  #    #          #  #             #  ###  #             #      #  #     
  #    #   ####   #  #  ####       #  # #  #  ####   # # #  ### #  #     
  ######  #    #  #  # ##  ##      #  # #  # ##  ##  ##  # ##  ##  #     
  #    #  ######  #  # #    # ###   # #  # # #    #  #   # #    #  #     
  #    #  #       #  # #    #       ##   ##  #    #  #   # #    #  #     
  #    #  ##  ##  #  # ##  ##       ##   ##  ##  ##  #   # ##  ##        
  #    #   ####   #  #  ####        ##   ##   ####   #   #  ### #  #     
                                                                         
\$\endgroup\$
2
\$\begingroup\$

Postscript, 154 133

<~GasbQ8I>GO#QsOD7:?,pa&5XCgo@jeLPX:a4F9kN1nu1B@8KjD"^]WgY[MA.2VBjpTNo5$Pi%uI9Lr>,9`~>/FlateDecode filter 999 string readstring pop =

i.e.

    <~GasbQ8I>GO#QsOD7:?,pa&5XCgo@jeLPX:a4F9kN1nu1B@8KjD"^]WgY[MA.2VBjpTNo5$Pi%uI
9Lr>,9`~>
/FlateDecode filter 
999 string readstring pop 
=

ASCII-only source, inspiration for ASCII-art was Johannes H.'s answer :-)

# #     # #         #    #          #    # #
# #  #  # #         #    #          #    # #
### # # # #  ##  ## #    #  ##   ## #  ### #
# # #   # # #  #    # ## # #  # #   # #  #
# # ### # #  ##      #  #   ##  #   #  ##  #

(more readable in terminal)

Perl, 102

print$-%44?'':"\n",vec(unpack(u,'<!040`A!:4@`A`*%7918REEM1":T4)75E(#&1"0``'),$-++,1)?'#':' 'for 0..219

Same output as above. I know I lost to both Perl answers above, but I publish it anyway. At least I tried and was moving in the right direction (and hadn't seen shortest answer) :-).

\$\endgroup\$
2
\$\begingroup\$

Pure Bash, no external utilities - 133 characters:

c=" #";for x in 0x{5250088045,55520A914D,74556AAA54,535205124D};do while((s=(t=x)^(x/=2)*2,t));do L=${c:s:1}$L;done;echo "$L";L=;done

Uses right and left shift (divide and multiply by 2) and xor to find the one bits.

Font data stolen from Blender/Ilmari Karonen.

Tested in Bash 3.2 and 4.2

By the way, this is only 166 characters:

echo "# #  #  # #        #   #        #   # #
# # # # # #  #     # # #  #   # #  ## #
### #   # # # # ## # # # # # #  # # #  
# #  ## # #  #      # #   #  #  #  ## #"
\$\endgroup\$
1
\$\begingroup\$

Python 3, 114

print('\n'.join(bin(x)[2:]for x in[353530052677,366448644429,499649260116,357858349645]).translate({48:32,49:35}))

Output (4-character tall e and W stolen from @Ilmari Karonen):

# #  #  # #        #   #        #   # #
# # # # # #  #     # # #  #   # #  ## #
### #   # # # # ## # # # # # #  # # #  
# #  ## # #  #      # #   #  #  #  ## #

And a shorter one (107):

print('\n'.join(bin(x)[2:]for x in[11993933918769,16391913257513,12021315382193]).translate({48:32,49:35}))

Output:

# # ### #   #   ###   # # ### ##  #   ##   #
### ### #   #   # #   # # # # ### #   # #  #
# # ### ### ### ###   ### ### # # ### ##   #
\$\endgroup\$
4
  • \$\begingroup\$ It's mostly unreadable. Your World from 2nd output is actually Uorld. \$\endgroup\$ Commented Feb 7, 2014 at 13:39
  • \$\begingroup\$ @SilviuBurcea: It looks better on an actual terminal emulator. Also, "Human-readable" gives you a bit of wiggle room. I'm sure you can guess what `"HELLO ⊔ORLD!" means. \$\endgroup\$
    – Blender
    Commented Feb 7, 2014 at 17:35
  • \$\begingroup\$ Use hex constants and shave a few characters off \$\endgroup\$
    – Floris
    Commented Feb 8, 2014 at 13:08
  • \$\begingroup\$ @Floris: I tried that. The two-character prefix makes them just as long up until around 20 digits. \$\endgroup\$
    – Blender
    Commented Feb 9, 2014 at 0:15
1
\$\begingroup\$

Python 154 Characters, (Char 5X7 in size)

print'\n'.join(map(''.join,zip(*(''.join("# "[int(e)]for e in"{:07b}".format(ord(c))[1:])for c in"€÷÷÷€ÿñêêòÿ€ÿ€ÿñîîñÿûûÿŸáþÁ¿ÁþáŸÿñîîñÿàïÿ€ÿÿñîî€ÿ‚"))))

Output

#   #      # #         #   #   #         #     # #
#   #      # #         #  # #  #         #     # #
#   #  ##  # #  ##      # # # #   ##  ## #   ### #
##### #  # # # #  #     # # # #  #  # #  #  #  # #
#   # #### # # #  # ##  # # # #  #  # #  #  #  # #
#   # #    # # #  #     # # # #  #  # #  #  #  #  
#   #  ### # #  ##       #   #    ##  #  #   ### #
\$\endgroup\$
1
\$\begingroup\$

Bash:

(103 89 Bytes)

Code:

base64 -d<<<rohBEmRiqIihFVRS7IitVWRSqIihVVRQru5Aoldi|xxd -b|sed -e's/ //g;s/1/#/g;s/0/ /g'|cut -b'9-55'

Output:

# # ### #   #    #     #   #  #  ##  #   ##   #
# # #   #   #   # #    #   # # # # # #   # #  #
### ##  #   #   # # ## # # # # # ##  #   # #  #
# # #   #   #   # #    # # # # # # # #   # #   
# # ### ### ###  #      # #   #  # # ### ##   #

Smaller, but less readable (Based on http://mckgyver.pbworks.com/f/1240440791/3PixelFont.jpg):

Code:

base64 -d<<<V0nCLsmQdklaqslQV23BTq2Q|xxd -b|sed -e's/ //g;s/1/#/g;s/0/ /g;'|cut -c'9-52'

Output:

 # # ### #  #  ###    #   # ### ##  #  ##  #
 ### ##  #  #  # # ## # # # # # ##  #  # # #
 # # ### ## ## ###     # #  ### # # ## ##  #
\$\endgroup\$
1
\$\begingroup\$

Javascript / ES6 (108 bytes)

Copy into console:

[,0xa0a028045,0xeeae2bb5d,0xacaabaa54,0xaeae2ba5d].map(a=>a.toString(2).replace(/./g,b=>' #'[b])).join('\n')

Output:

"
# #     # #       # #        #   # #
### ### # # ###   # # ### ## # ### #
# # ##  # # # # # ### # # #  # # #  
# # ### # # ###   # # ### #  # ### #"

(Needs ECMAScript6 compatible browser ie. Firefox 22+)

Inspired by @maximeeuziere, @p01, @aemkei

\$\endgroup\$
1
  • \$\begingroup\$ .join('\n') can be reduced to .join(` `) where the space is an actual new line character. \$\endgroup\$
    – Chiru
    Commented Aug 6, 2015 at 23:36
1
\$\begingroup\$

Authors: xem, aemkei, p01, jonas

Execute this in the JS console.

JavaScript, cross-browser,133 132 126 117 bytes

for(i=s="";l=[43117609029,64070269789,46349920852,46890400349][i++];)for(j=0,s+="\n";c=l.toString(2)[j++];)s+=" #"[c]

JavaScript, ES6, works on Firefox, 108 bytes

[,0xa0a028045,0xeeae2bb5d,0xacaabaa54,0xaeae2ba5d].map(a=>a.toString(2).replace(/./g,b=>' #'[b])).join('\n')

Result:

>
# #     # #       # #        #   # #
### ### # # ###   # # ### ## # ### #
# # ##  # # # # # ### # # #  # # #  
# # ### # # ###   # # ### #  # ### #
\$\endgroup\$
1
1
\$\begingroup\$

HTML, 209 characters

<pre># #     # #                      #   # #
# #     # #        # # #         #   # #
###  ## # #  #     # # #  #  ##  #  ## #
# # ##  # # # # ## # # # # # # # # # #
# # ### # #  #      # #   #  #   # ### #</pre>

Does this count? :)

\$\endgroup\$
1
\$\begingroup\$

Shell, 20 characters:

banner Hello-world\!

For this to work, of course you need the banner program. On Debian, you can get it by installing the bsdmainutils package.

This prints a beautifully rendered version of your message, designed to be printed on one of the old continuous-feed printers, so the output of the above text is 322 lines long by 123 columns wide, and you turn the printout on its side to read the message. You could hang the resulting paper on the wall as a banner, hence the name.

http://en.wikipedia.org/wiki/Banner_%28Unix%29

EDIT: Looks like Debian also has the sysvbanner package, which installs a banner program that prints the text horizontally for display on a terminal. However, this only prints the first 10 characters of the message, so it is kind of annoying for this code-golf problem!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ I believe you meant to write banner hello-world. \$\endgroup\$
    – Floris
    Commented Feb 8, 2014 at 13:01
  • \$\begingroup\$ @Floris, thanks for the heads-up. Fixed. \$\endgroup\$
    – steveha
    Commented Feb 8, 2014 at 23:00
  • 1
    \$\begingroup\$ Note that banner appeared on Unix v7 in 1979 and is found on virtually every Unix. \$\endgroup\$
    – sch
    Commented Feb 9, 2014 at 16:33
  • \$\begingroup\$ @sch, I agree that banner is available for virtually every UNIX. I just put the Debian package as a convenient proof that I wasn't just making something up, for people who didn't know about it. These days I wouldn't expect to find banner installed by default on a UNIX, any more than I would expect to find a continuous-feed printer in a computer lab anymore. But any code golf on making banner text really ought to have the banner program in it somewhere. It's part of our rich cultural history as computer geeks. :-) \$\endgroup\$
    – steveha
    Commented Feb 9, 2014 at 21:46
1
\$\begingroup\$

bash, 175 170 bytes

You need to waste quite a few characters in order to produce a pretty output!

base64 -d<<<H4sICKaT9FICAzAxAK2RQQ7AIAgE776CZP7/x1ZjERebcJAL0QybhcV6YdWizAPNaUatQQLFpj6h+c/XA05WF9Wtk9WJcxz4oe6e1YPQa7Wiut2wfjJ16STY30lSnNIlzvdpHhd6MiTOB65NYc+LAgAA|zcat

Output:

#     #                                         #     #                                   ###
#     #  ######  #       #        ####          #  #  #   ####   #####   #       #####    ###
#     #  #       #       #       #    #         #  #  #  #    #  #    #  #       #    #   ###
#######  #####   #       #       #    #  #####  #  #  #  #    #  #    #  #       #    #    #
#     #  #       #       #       #    #         #  #  #  #    #  #####   #       #    #
#     #  #       #       #       #    #         #  #  #  #    #  #   #   #       #    #   ###
#     #  ######  ######  ######   ####           ## ##    ####   #    #  ######  #####    ###
\$\endgroup\$
1
  • \$\begingroup\$ You can make it smaller with lzma/unlzma \$\endgroup\$
    – Emmanuel
    Commented Aug 8, 2014 at 16:02
0
\$\begingroup\$

F# - 204 characters

for s in(Seq.map(Seq.unfold(function|0L->None|i->Some(" #".[int(i%2L)],i/2L)))[173948798213L;174770890021L;191304848727L;182715110773L;45277009173L;191279670629L])do printfn"%s"(new string(Seq.toArray s))

Output:

# #     # #        # #         #   # #
# #  #  # #  #     # #  #   ## #   # #
### # # # # # #    # # # # #   #  ## #
# # ### # # # # ## # # # # #   # # # #
# # #   # # # #    ### # # #   # # #  
# #  ## # #  #     # #  #  #   #  ## #
\$\endgroup\$
0
\$\begingroup\$

Python + pyfiglet -- 87 characters

from pyfiglet import figlet_format     
print(figlet_format('Hello-World!', font='banner'))

Output

#     #                                   #     #                             ### 
#     # ###### #      #       ####        #  #  #  ####  #####  #      #####  ### 
#     # #      #      #      #    #       #  #  # #    # #    # #      #    # ### 
####### #####  #      #      #    # ##### #  #  # #    # #    # #      #    #  #  
#     # #      #      #      #    #       #  #  # #    # #####  #      #    #     
#     # #      #      #      #    #       #  #  # #    # #   #  #      #    # ### 
#     # ###### ###### ######  ####         ## ##   ####  #    # ###### #####  ### 

To install pyfiglet, run:

$ pip install pyfiglet
\$\endgroup\$
0
\$\begingroup\$

Python with pyfiglet: 66 using argv, 69 without

66:

from pyfiglet import*
print(figlet_format(sys.argv[1],font='3x5'))

69:

from pyfiglet import*
print(figlet_format('Hello-World!',font='3x5'))

firs must be called as, for example:

python asciiart.py 'Hello-World!'

second:

python asciiart.py.

Output:

    # #      #   #          # #          #    #  #  
    # # ###  #   #  ###     # # ### ###  #  ###  #  
    ### ##   #   #  # # ### ### # # #    #  # #  #  
    # # ###  ##  ## ###     ### ### #    ## ###     
    # #                     # #                  #  

(Well, it looks kinda crappy with this font. Nevertheless :) )

[edit] removed obsolete dash from the argument.

\$\endgroup\$
2
  • \$\begingroup\$ Why the extra dash in front of the output? \$\endgroup\$ Commented Feb 7, 2014 at 17:32
  • \$\begingroup\$ My mistake, that's the output from the one using argv, where I used a dash before the argument (matter of habit, as I use bash all the time). I'll edit it, thank you. \$\endgroup\$
    – Taku
    Commented Feb 7, 2014 at 17:44
0
\$\begingroup\$

Javascript 137 (134)

Uses the bits of integers to represent sharps an white spaces. Tested with Firefox 27.

137 character

s="";[0xadb73eead9,g=0xa9252aaa94,0xed252aac95,g+1,0xad272aee99].map(n=>{for(;n>0;n/=2)n%2?[s="#"+s,n--]:s=" "+s;s="\n"+s});console.log(s)

# # ## #  #  ###  # # # ### ### #  ##  #
# # #  #  #  # #  # # # # # # # #  # # #
### ## #  #  # #  # # # # # ##  #  # # #
# # #  #  #  # #  # # # # # # # #  # #  
# # ## ## ## ###  ##### ### # # ## ##  #"

134 character (rotated 180°)

s="";[0xadb73eead9,g=0xa9252aaa94,0xed252aac95,g+1,0xad272aee99].map(n=>{s+="\n";for(;n>0;n/=2)n%2?[s+="#",n--]:s+=" "});console.log(s)

"
#  ## ## # # ### #####  ### ## ## ## # #
  # #  # # # # # # # #  # #  #  #  # # #
# # #  #  ## # # # # #  # #  #  # ## ###
# # #  # # # # # # # #  # #  #  #  # # #
#  ##  # ### ### # # #  ###  #  # ## # #"
\$\endgroup\$
0
\$\begingroup\$

Python3 (126)

There's an additional space between the chars to make it better readable. So technically it's a 125 character solution.

print(' '.join(['','\n'][i%40==0]+['#',' '][int('72liw1j4glyc34dum02j2a4ipxa8b7vvp65x511',36)//2**i%2==0]for i in range(200)))

Output:

#   #   # #   #     #     # # #     #   #   #   # # #   # # #   #     # #     # 
#   #   #     #     #     #   #     #   #   #   #   #   #   #   #     #   #   # 
# # #   # #   #     #     #   #     #   #   #   #   #   # #     #     #   #   # 
#   #   #     #     #     #   #     #   #   #   #   #   #   #   #     #   #     
#   #   # #   # #   # #   # # #     # # # # #   # # #   #   #   # #   # #     #
\$\endgroup\$
0
\$\begingroup\$

Bash 37, 33

toilet<<<"Hello-world"|tr \"m \#

 #    #        ###    ###                                       ###        # 
 #    #  ###     #      #     ###         #     #  ###    # ##    #     #### 
 ###### ##  #    #      #    ## ##        ## # ## ## ##   ##  #   #    ## ## 
 #    # #####    #      #    #   #   ###   #####  #   #   #       #    #   # 
 #    # #####    ###    ###  #####          # #   #####   #       ###  ##### 

Which is the same as:

echo "Hello-world" | toilet

From man toilet

TOIlet - display large colourful character

With tr "'\"m" "#" all " chars are replaced with #.

\$\endgroup\$
4
  • \$\begingroup\$ tr's parameters would be shorter escaped than quoted. I mean tr \'\"m \# instead of tr "'\"m" "#". \$\endgroup\$
    – manatwork
    Commented Feb 12, 2014 at 16:35
  • \$\begingroup\$ Oh good one, I wasn't aware of that. Thanks @manatwork \$\endgroup\$
    – fedorqui
    Commented Feb 12, 2014 at 16:38
  • \$\begingroup\$ Wait a second. The toilet output had no single quote. Why you included it in tr's 1st parameter? Just tr \"m \# is enough. \$\endgroup\$
    – manatwork
    Commented Feb 12, 2014 at 16:41
  • \$\begingroup\$ @manatwork I think I need more coffee :) \$\endgroup\$
    – fedorqui
    Commented Feb 12, 2014 at 16:44
0
\$\begingroup\$

Smalltalk, 151

although this golf game is already over, for the reference:

i:=((Form extent:115@14)displayString:'Hello world'x:0y:12;asImage).0to:13 do:[:y|i valuesAtY:y from:0to:114 do:[:x :p|({$#.$ }at:p+1)print].Stdout cr]

output:

 ***  ***             ***       ***                                                         ***           **       
  *    *                *         *                                                           *            *       
  *    *                *         *                                                           *            *       
  *    *     ***        *         *        ***              ***   ***    ***     *** ***      *        *** *       
  ******    *   *       *         *       *   *              *     *    *   *      **   *     *       *   **       
  *    *   *     *      *         *      *     *             *  *  *   *     *     *          *      *     *       
  *    *   *******      *         *      *     *              * * *    *     *     *          *      *     *       
  *    *   *            *         *      *     *              * * *    *     *     *          *      *     *       
  *    *    *    *      *         *       *   *               ** **     *   *      *          *       *   **       
 ***  ***    ****    *******   *******     ***                *   *      ***     ******    *******     *** **      
\$\endgroup\$
2
  • \$\begingroup\$ You have to only use ' '(spaces) and '#' characters(also newline characters). \$\endgroup\$ Commented Mar 7, 2014 at 3:32
  • \$\begingroup\$ my mistake; the output was from a previous run; the code is correct "{$#.$ }at:p+1". \$\endgroup\$
    – blabla999
    Commented Mar 17, 2014 at 16:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.