Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Let's try to golf this piece of ascii-art representing a golfing man:


      '\                   .  .                        |>18>>
        \              .         ' .                   |
       O>>         .                 'o                |
        \       .                                      |
        /\    .                                        |
       / /  .'                                         |
 jgs^^^^^^^`^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Source: JGS - http://www.retrojunkie.com/asciiart/sports/golf.htm

Rules:

  • No input allowed
  • No external resources allowed
  • The output must be exactly this text, displayed in a monospace font (OS console, JS console, HTML <pre> tag, ...), including the leading and trailing line-break.
  • Surrounding quotes or double-quotes are allowed (the JS console adds double quotes when you output a string, this is okay)

The best answer will be the one using the less characters in any language.

Have fun!

share|improve this question
1  
"exactly this text": including the empty line at the beginning? including the empty line at the end? with a trailing new-line or without? (That is, 0, 1 or 2 new-.lines at the end?) –  Martin Büttner Jul 4 at 19:21
    
@m.buettner the output should have exactly one leading line break and one trailing line break/new line. (and quotes if you can't avoid them) :) –  xem Jul 4 at 19:36
    
That ASCII looks more like a Cricket shot to me –  Mr. Alien Jul 5 at 6:26
    
@Mr.Alien I saw it in Martin Kleppe's recent talk: speakerdeck.com/aemkei/… (video: youtube.com/watch?v=zy-2ruMHdbU) –  xem Jul 5 at 6:30
add comment

20 Answers 20

up vote 12 down vote accepted

CJam, 62 characters

"Ⴀ지尦렒>Ä΀ྀ㸀⡅쇋蒧ʸ鿀ʃ케袧Ƽ蟀ʄ導뤷쀂萯Ű⋥ἀ਎밊耧台 ⢙⿶ꝍ㕟劢햟騤꩏脽啎"2G#b128b:c~

Copy from here and try it online.

Test run

$ base64 -d > golf.cjam <<< IgHhgqDsp4DlsKbroJLujJ8+w4TOgOC+gOO4gOKhheyHi+iSp8q46b+AyoPsvIDvoIPuhKvooqfGvOifgMqE5bCO66S37ICC6JCvxbDii6XhvIDgqI7rsIrvgYvogKflj7DCoOKimeK/tuqdjeOVn+WKou2Wn+mopO+em+qpj+iEve6arOWVjiIyRyNiMTI4Yjpjfg==
$ wc -m golf.cjam
62 golf.cjam
$ cjam golf.cjam

      '\                   .  .                        |>18>>
        \              .         ' .                   |
       O>>         .                 'o                |
        \       .                                      |
        /\    .                                        |
       / /  .'                                         |
 jgs^^^^^^^`^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$

How it works

2G#b converts the preceding string into an integer by considering it a base-65536 number.

128b:c converts that integer back to a string (110 bytes) by considering it a base-128 number, which ~ then executes:

"
^F'^@\^S.^B.^X|^@>^@1^@8^@>^@>^@
^H\^N.^I'^A.^S|^@
^GO^@>^@>^I.^Q'^@o^P|^@
^H\^G.&|^@
^H/^@\^D.(|^@
^G/^A/^B.^@')|^@
^A"2/{)iS*}%"jgs"'^7*'`'^51*N

(caret notation)

2/{)iS*}%

splits the string into pairs of two characters and does the following for each pair: Pop the second character of the string, convert it into an integer and repeat the string " " that many times.

For example, ".(" becomes ". ", because the ASCII character code of ( is 40.

Finally,

"jgs"'^7*'`'^51*N

pushes the string "jgs", the character ^ repeated 7 times, the character `, the character ^ repeated 51 times and a linefeed.


CJam, 70 characters

"✶埗唿❎箎ꅊꢝ玨貪䑤튢⾏颸糹ᓧᔡ䖩ᇍ䠴ꢋ亨㞨詻鳔褢ꐔﯣ풠⛵∳煒莊觗몍থ䢍ᡔꃞꑪ熙咉֣᪔⦢햟騤꩏脽啎"
2G#b128b:c~

Try it online.

How it works

2G#b converts the preceding string into an integer by considering it a base-65536 number.

128b:c converts that integer back to a string by considering it a base-128 number:

N6{S*}:T~'':A'\:BJT'.:D2TD24T"|>18>>"N8TBETD9TASDJT"|
":P7T"O>>"9TDHTA'oGTP8TB7TD38TP8T'/:FB4TD40TP7TFSF2TDA41TPS"jgs"'^7*'`'^51*N

~ executes the resulting code.

share|improve this answer
    
Really awesome, but when I take the 62char version from the pastebin and "try it online", a line break is missing before the last line "jgs..." –  xem Jul 7 at 15:00
    
@xem: Did you copy from the RAW Paste Data section? If I copy the formatted code, I get the same result. –  Dennis Jul 7 at 15:28
add comment

Ruby, 107

I thought I'd actually try to "generate" the image in code (instead of using some existing compression function):

S=?\s*351+?^*60
"⠀鰇𗀈렜렟🀸쐺⠾𗁇롖鱠롢🁶⡷𓱿뢋鲝𛲞🂯⢰𗂹룁🃨⣩볲𗃳룸🄡⤢봪봬뤯鴰🅚⥛𚥝𙵞𜵟𘅧".chars{|q|S[511&r=q.ord]=(r>>10).chr}
puts S

There are some non-printable characters in that array literal.

Here is the hex view of the file, to show the non-printable characters, too:

0000000: 533d 3f5c 732a 3335 312b 3f5e 2a36 300a  S=?\s*351+?^*60.
0000010: 22e2 a080 e9b0 87f0 9780 88eb a09c eba0  "...............
0000020: 9ff0 9f80 b8ef a0b9 ec90 baee 80bb efa0  ................
0000030: bcef a0bd e2a0 bef0 9781 87eb a196 e9b1  ................
0000040: a0eb a1a2 f09f 81b6 e2a1 b7f0 93b1 bfef  ................
0000050: a280 efa2 81eb a28b e9b2 9df0 9bb2 9ef0  ................
0000060: 9f82 afe2 a2b0 f097 82b9 eba3 81f0 9f83  ................
0000070: a8e2 a3a9 ebb3 b2f0 9783 b3eb a3b8 f09f  ................
0000080: 84a1 e2a4 a2eb b4aa ebb4 aceb a4af e9b4  ................
0000090: b0f0 9f85 9ae2 a59b f09a a59d f099 b59e  ................
00000a0: f09c b59f f098 85a7 222e 6368 6172 737b  ........".chars{
00000b0: 7c71 7c53 5b35 3131 2672 3d71 2e6f 7264  |q|S[511&r=q.ord
00000c0: 5d3d 2872 3e3e 3130 292e 6368 727d 0a70  ]=(r>>10).chr}.p
00000d0: 7574 7320 53                             uts S

Thanks to Ventero for some major improvements! (He basically reduced the code by 50%.)

share|improve this answer
    
Nice effort! I was hoping for answers like that, that don't just gzip the ASCII ;) –  xem Jul 4 at 20:14
1  
The second line could be 6.times{|i|S[i+1]=' '*55+?|} to save 2 characters. –  voidpigeon Jul 4 at 20:21
    
@voidpigeon Ah thanks. I actually started with that, but initially thought I'd need i more than once. Good catch! –  Martin Büttner Jul 4 at 20:23
2  
Hope you don't mind if I mention a few more ways to shorten this! Using S.fill{' '*55+?|} instead saves a few more characters (you'll have to define S as ['']*7, change the puts to puts p,S,p and subtract 1 from all your y coordinates though). Then, by using varargs in f (def f(*p,c)), you can save the [] in the function calls. Oh, and you can drop the () around y,x. –  Ventero Jul 4 at 21:56
1  
If you make S one-dimensional, you can save another 55 characters ;) Here's the code if you don't want to do it yourself. –  Ventero Jul 4 at 22:18
show 5 more comments

bash + iconv + DosBox/x86 machine code (104 characters)

echo ⶻ訁萷瓒뤣웶疀蘄蠎菱㿡₲웶瑀눂둞촂䏺ퟫૃ蘊尧⺓⺂粘ㄾ㸸ਾ岈⺎➉⸠粓蜊㹏褾鄮漧粐蠊蝜꘮੼⾈葜꠮੼⾇⼠⺂ꤧ੼樠獧惇૳ |iconv -futf8 -tucs2 >o.com;dosbox o*

I suggest to put this in a script in an empty directory, it's almost guaranteed that copy-pasting it in a terminal will break everything; even better, you can grab the script here ready-made.

Expected output: expected output

How it works

The bash part is just a launcher that uses iconv to "decompress" a .com file from the UTF-8 characters of the script and launches it with DosBox.

The Unicode thing is just to take advantage of the "character count" rules; the actual size (in bytes) of the script is way larger than the original .COM file.

The extracted .com file is

00000000  bb 2d 01 8a 37 84 d2 74  23 b9 01 00 f6 c6 80 75  |.-..7..t#......u|
00000010  04 86 f2 eb 0e 88 f1 83  e1 3f b2 20 f6 c6 40 74  |.........?. ..@t|
00000020  02 b2 5e b4 02 cd 21 e2  fa 43 eb d7 c3 0a 0a 86  |..^...!..C......|
00000030  27 5c 93 2e 82 2e 98 7c  3e 31 38 3e 3e 0a 88 5c  |'\.....|>18>>..\|
00000040  8e 2e 89 27 20 2e 93 7c  0a 87 4f 3e 3e 89 2e 91  |...' ..|..O>>...|
00000050  27 6f 90 7c 0a 88 5c 87  2e a6 7c 0a 88 2f 5c 84  |'o.|..\...|../\.|
00000060  2e a8 7c 0a 87 2f 20 2f  82 2e 27 a9 7c 0a 20 6a  |..|../ /..'.|. j|
00000070  67 73 c7 60 f3 0a 0a 00                           |gs.`....|

and is 120 bytes long. The NASM source for it is:

    org 100h

start:
    ; bx: pointer to current position in data
    mov bx,data
mainloop:
    ; load the character in dh; for int 21h/ax=2 it'll have to be in dl, we
    ; start with dh because it eases the work for RLE bytes to have it in a
    ; separate location
    mov dh,[bx]
    ; if we are at the end, quit
    test dl,dl
    jz end
    ; cx: repetition count (1 by default)
    mov cx,1
    ; if the high bit is set, we have a repeated byte
    test dh,80h
    jnz rle
    ; otherwise, move the character in the correct location and go to print
    xchg dh,dl
    jmp print
rle:
    ; lower 6 bits: repetition count
    mov cl,dh
    and cx,3fh
    ; space if high bit not set, caret otherwise
    mov dl,' '
    test dh,40h
    jz print
    mov dl,'^'
print:
    ; keep printing until cx is 0
    mov ah,2
    int 21h
    loop print
    ; rinse & repeat with next character
    inc bx
    jmp mainloop
end:
    ret

data:
    ; here be data
    incbin "compressed.dat"
    ; NUL terminator
    db 0

All this is just a decompressor for compressed.dat whose format is as follows:

  • if the high bit is not set, print the character as-is;
  • otherwise, the low 6 bits are the repetition count, and the second-highest bit specifies if it has to print a space (bit not set) or a caret (bit set).

compressed.dat in turn is generated using a Python script from the original text.

The whole thing can be found here.

share|improve this answer
add comment

Python, 156

print'''
%6s'\%19s.  .%24s|>18>>
%8s\%14s.%9s' .%19s|
%7sO>>%9s.%17s'o%16s|
%8s\%7s.%38s|
%8s/\%4s.%40s|
%7s/ /  .'%41s|
 jgs'''%(('',)*19)+'^'*7+'`'+'^'*51

This uses string formatting with space padding for some basic compression.

share|improve this answer
add comment

PHP, 147

This runs on the command line and outputs directly to the console:

php -r 'echo gzinflate(base64_decode("41IAA/UYBUygB0bYQY2doYWdHReMG4OhEwrUsRpRA9Pob2eHRRNccz5OjXAbcboQl0b9GBK0IWnUB0IFPXUFEjRmpRfHQUBCHOmAiwsA"));'
share|improve this answer
add comment

Perl - 127 129 130 132 135 137 145

print q(
6'\19.2.24|>18>>
8\14.9'1.19|
7O>>9.17'o16|
8\7.38|
8/\4.40|
7/1/2.'41|
1jgs^^^^^^^`0
)=~s/\d++(?!>)/$"x$&||'^'x51/reg

Thanks to Ventero and m.buettner for their help in my RegEx optimization.

share|improve this answer
    
You can save one character with s/\d+(?!8?>)/%$&s/rg –  Ventero Jul 5 at 16:59
    
@Ventero thank you for the suggestion. –  core1024 Jul 5 at 17:09
2  
You can save another one by using a possessive quantifier: /\d++(?!>)/ –  Martin Büttner Jul 5 at 17:50
    
@m.buettner I didn't know that. Learning new things every day :) –  core1024 Jul 5 at 17:59
add comment

GCC C - 203 bytes

I figured I'd have some fun with this one. This compiles on my version of MinGW and outputs the expected text.

Whitespace added for clarity.

char*v="\n ú'\\ í.  . è|>18>>\n ø\\ ò. ÷' . í|\n ùO>> ÷. ï'o ð|\n ø\\ ù. Ú|\n ø/\\ ü. Ø|\n ù/ /  .' ×|\n jgs^ù`^Í\n";
main(g,o,l){
    for(;*v;
        g=!g&*v<0&l?-*v++:g){
        v+=!(l=*v-35);
        putchar((g-=g>0)?o:(o=*v++));
    }
}

None of the online code pasting sites allow the use of single byte characters outside the ASCII range, so I had to escape them for an uploaded example. It's otherwise identical though. http://codepad.org/nQrxTBlX

You can always verify it with your own compiler, too.

share|improve this answer
add comment

Python - 205 203 197

i="""
G^y`G^MsGgGj!G
G|!o'G.!H/!G/!M
G|!n.!J\G/!N
G|!l.!M\!N
G|!VoG'!W.!O>HO!M
G|!Y.!G'!O.!T\!N
G>H8G1G>G|!^.!H.!Y\G'!L
G""".replace('!','G ')
o=''
j=140
while j:j-=2;o+=ord(i[j+1])%70*i[j]
print o

The string i interleaves the characters in the ascii art with their multiplicites, represented as characters, all in in reverse order. In addition, I save a bit of space by using '!' instead of 'G ' in i and then just replacing it.

share|improve this answer
add comment

Python (145)

'eJzjUgAB9RgFTKAHRthBjZ2hhZ0dF5SHphuhSx2rCTVQff52dlj0wPXm49IHtw+n83Do048hQRdCnz4QKuipE6sNqC8rvTgOAhLiSAdcAG/9Ri8='.decode('base64').decode('zip')

Not very original, I know.

share|improve this answer
add comment

LOLCODE, 590 characters

Cuz LOLCODE iz perfik language 4 golfin: iz easy 2 compres an obfuscate an it isnt verbose at all.

HAI
HOW DUZ I D C T
I HAZ A O
I HAZ A N ITZ 0
IM IN YR LOOP UPPIN YR N TIL BOTH SAEM N AN T
O R SMOOSH O AN C MKAY
IM OUTTA YR LOOP
FOUND YR O
IF U SAY SO
VISIBLE ""
VISIBLE SMOOSH "  '\" AN D " " 19 AN ".  ." AN D " " 24 AN "|>18>>" MKAY
VISIBLE "    \              .         ' .                   |"
VISIBLE "   O>>         .                 'o                |"
VISIBLE SMOOSH "    \       ." AN D " " 38 AN "|" MKAY
VISIBLE SMOOSH "    /\    ." AN  D " " 40 AN "|" MKAY
VISIBLE SMOOSH "   / /  .'" AN D " " 41 AN "|" MKAY
VISIBLE SMOOSH "jgs^^^^^^^`" AN D "^" 51 MKAY
VISIBLE ""
KTHXBYE

Im pritee sure dis werkz, but I doan has an LOLCODE interpretr an http://repl.it's seems 2 not liek funcshuns.

(Tranzlashun generously providd by http://speaklolcat.com's robots cuz I doan speek lolcat)


Indented, spaced, and commented version of the code (LOLCODE comments start with BTW):

HAI BTW All LOLCODE programs start with HAI
    HOW DUZ I D C T BTW Function declarations follow the form "HOW DUZ I <func-name>[ <func-arg1>[ <func arg2>[ ...]]]". In this case, D is a function that repeats a YARN C (YARN is the equivalent of string in LOLCODE) NUMBR T (NUMBR = int) times.
        I HAZ A O BTW Variable declarations follow the form "I HAZ A <var-name>"

        I HAZ A N ITZ 0 BTW Variables can be intialised when declared by appending " ITZ <init-value>" to the declaration 
        IM IN YR LOOP UPPIN YR N TIL BOTH SAEM N AN T BTW Loops follow the form "IM IN YR LOOP <action> TIL <condition>" where action and condition are "UPPIN YR N" and "BOTH SAEM N AN T", respectively, in this case
            O R SMOOSH O AN C MKAY BTW "R" assigns a new value to a variable. YARN (string) concatenation follows the form "SMOOSH <str-1> AN <str-2>[ AN <str-3>[...]] MKAY"
        IM OUTTA YR LOOP BTW "IM OUTTA YR LOOP" ends LOLCODE loops

        FOUND YR O BTW "FOUND YR <value>" returns a value
    IF U SAY SO BTW "IF U SAY SO" ends functions

    VISIBLE "" BTW "VISIBLE" prints its argument to stdout
    VISIBLE SMOOSH "  '\" AN D " " 19 AN ".  ." AN D " " 24 AN "|>18>>" MKAY BTW The function I wrote above only "pays off" in terms of characters added/saved when repeating 19 or more characters (the function call itself takes 8 characters, assuming a one-character first argument and a 2-digit second one; you need to factor in the added quotes (2 characters), spaces (4) and ANs (4) for 18 total extra characters; and possible SMOOSH/MKAY)
    VISIBLE "    \              .         ' .                   |"
    VISIBLE "   O>>         .                 'o                |"
    VISIBLE SMOOSH "    \       ." AN D " " 38 AN "|" MKAY
    VISIBLE SMOOSH "    /\    ." AN  D " " 40 AN "|" MKAY
    VISIBLE SMOOSH "   / /  .'" AN D " " 41 AN "|" MKAY
    VISIBLE SMOOSH "jgs^^^^^^^`" AN D "^" 51 MKAY
    VISIBLE ""    
KTHXBYE BTW "KTHXSBYE" ends LOLCODE programs
share|improve this answer
    
haha, nice compression, like it :D –  Joshua Jul 8 at 14:53
add comment

Javascript (ES6) 193 175 bytes

Edit: Modified RegPack v3 to maintain newlines, use a for in loop to save 3 bytes, and removed eval for implicit console output.

_="\nx'\\w{. z~|>18>>\n~\\~x.~ 'z{yx O>>~z 'owy~\\xzwxy~/\\{zw~yx / /  .'ww~ y jgs}`}}}}}}}^^\n~x  }^^^^^^^{   z .wy|\nx{{w~~";for(i of "wxyz{}~")with(_.split(i))_=join(pop())

Using xem's unicode compression: 133 characters

eval(unescape(escape('𧰽𘡜𫡸𙱜𧁷𮰮𘁺嵃🠱𞀾🡜𫡾𧁜屮𛡾𘀧𮡻𮑸𘁏🠾岍𘀧𫱷𮑾𧁜𮁺𭱸𮑾𛱜𧁻𮡷峀𮀠𛰠𛰠𘀮𙱷𭱾𘁹𘁪𩱳𯑠𯑽𯑽𯑽𯑞𧡜𫡾𮀠𘁽𧡞𧡞𧡞𧡻𘀠𘁺𘀮𭱹𯁜𫡸𮱻𭱾割𞱦𫱲𚁩𘁯𩠠𘡷𮁹𮡻𯑾𘠩𭱩𭁨𚁟𛡳𬁬𪑴𚁩𚐩𧰽𪡯𪑮𚁰𫱰𚀩𚐠').replace(/uD./g,'')))
share|improve this answer
    
great! <3 the RegPack's post-processing! psst, you can make it in 143b: xem.github.io/obfuscatweet –  xem Jul 4 at 20:11
    
@xem 143 characters, but a lot more bytes –  nderscore Jul 4 at 20:20
    
yes sorry, 143 chars. the question says that you can count chars. anyway, the regpack's approach is more interesting than the unicode-obfuscation ;) –  xem Jul 4 at 20:22
2  
FWIW, mothereff.in/byte-counter is a tool that counts both characters and bytes (as per UTF-8). –  Mathias Bynens Jul 5 at 4:57
add comment

ES6, 155 chars

Just trying anorher approach:

Run this in Firefox's JS console.

Each unicode character has the following form: \uD8[ascii charcode]\uDC[number of repeats].

"𒠁𘀆𙰁𧀁𘀓𛠁𘀂𛠁𘀘𯀁🠁𜐁𞀁🠂𒠁𘀈𧀁𘀎𛠁𘀉𙰁𘀁𛠁𘀓𯀁𒠁𘀇𣰁🠂𘀉𛠁𘀑𙰁𫰁𘀐𯀁𒠁𘀈𧀁𘀇𛠁𘀦𯀁𒠁𘀈𛰁𧀁𘀄𛠁𘀨𯀁𒠁𘀇𛰁𘀁𛰁𘀂𛠁𙰁𘀩𯀁𒠁𘀁𪠁𩰁𬰁𧠇𨀁𧠳𒠁".replace(/../g,a=>String.fromCharCode(a[c='charCodeAt']()&255).repeat(a[c](1)&255))

(Unicode string made with: http://jsfiddle.net/LeaS9/)

share|improve this answer
    
-3: .replace(/../g,a=>String.fromCharCode(a[c='charCodeAt']()&255).repeat(a[c](1)&2‌​55)) –  nderscore Jul 5 at 7:24
    
oh, great, thanks! –  xem Jul 5 at 11:02
add comment

Python - 236

s=' ';print('\n'+6*s+"'\\"+19*s+'.  .'+24*s+"|>18>>\n"+8*s+'\\'+14*s+'.'+9*s+"' ."+19*s+"|\n       O>>"+9*s+'.'+17*s+"'o"+16*s+'|\n'+8*s+"\\       ."+38*s+'|\n'+8*s+"/\\    ."+40*s+"|\n       / /  ."+42*s+"|\n jgs^^^^^^^`"+51*'^'+'\n')
share|improve this answer
add comment

JS (190b) / ES6 (146b) / ES6 packed (118chars)

Run this in the JS console:

JS:

"\n7'\\20.3.25|>18>>\n9\\15.10'2.20|\n8O>>10.9 9'o17|\n9\\8.39|\n9/\\5.41|\n8/2/3.'42|\n2jgs^^^^^^^`".replace(/\d+/g,function(a){return 18==a?a:Array(+a).join(' ')})+Array(51).join("^")+"\n"

ES6:

"\n6'\\19.2.24|>0>>\n8\\14.9'1.19|\n7O>>9.17'o16|\n8\\7.38|\n8/\\4.40|\n7/1/2.'41|\n1jgs58`101\n".replace(/\d+/g,a=>' ^'[a>51|0].repeat(a%51)||18)

ES6 packed: (http://xem.github.io/obfuscatweet/)

eval(unescape(escape('𘡜𫠶𙱜𧀱𞐮𜠮𜠴𯀾𜀾🡜𫠸𧁜𜐴𛠹𙰱𛠱𞑼𧁮𝱏🠾𞐮𜐷𙱯𜐶𯁜𫠸𧁜𝰮𜰸𯁜𫠸𛱜𧀴𛠴𜁼𧁮𝰯𜐯𜠮𙰴𜑼𧁮𜑪𩱳𝐸𨀱𜀱𧁮𘠮𬡥𬁬𨑣𩐨𛱜𩀫𛱧𛁡🐾𙰠𧠧𦱡🠵𜑼𜁝𛡲𩑰𩑡𭀨𨐥𝐱𚑼𯀱𞀩').replace(/uD./g,'')))

Thanks to @nderscore!

share|improve this answer
1  
ES6 down to 158: (goes down to 124 chars with unicode compression) "\n6'\\19.2.24|>18>>\n8\\14.9'1.19|\n7O>>9.17'o16|\n8\\7.38|\n8/\\4.40|\n7/1/2.'41|‌​\n1jgs^^^^^^^`".replace(/\d+/g,a=>18-a?' '.repeat(a):a)+"^".repeat(50)+"\n" –  nderscore Jul 5 at 6:07
    
oh, great, I didn't know repeat –  xem Jul 5 at 6:11
    
@nderscore don't be sorry it's great :) but the last line seems broken in my Firefox console –  xem Jul 5 at 6:26
    
146: "\n6'\\19.2.24|>0>>\n8\\14.9'1.19|\n7O>>9.17'o16|\n8\\7.38|\n8/\\4.40|\n7/1/2.'41|\‌​n1jgs58`101\n".replace(/\d+/g,a=>' ^'[a>51|0].repeat(a%51)||18) (stackexchange adds invisible line-breaking characters after 41|\‌) –  nderscore Jul 5 at 6:53
    
Thanks, I updated the answer and it works. :) I also added another 158b anwser, maybe you'll have an idea to improve it! –  xem Jul 5 at 7:16
add comment

ES6, 163b / 127 chars

Yet another approach, thanks to @nderscore.

Execute it in Firefox's console

JS (163b):

"\n'\\..|>18>>\n\\. '.|\nO>>    .'o|\n\\.&|\n/\\.(|\n//.')|\njgs<`h\n".replace(/[^'`Og\n>\\,-8j-|]/g,a=>" ^"[a=a.charCodeAt(),a>53|0].repeat(a%53))

Packed (127c):

eval(unescape(escape('𘡜𫠆𙱜𧀓𛠂𛠘𯀾𜐸🠾𧁮𒁜𧀎𛠉𙰁𛠓𯁜𫠇𣰾🠉𛠑𙱯𔁼𧁮𒁜𧀇𛠦𯁜𫠈𛱜𧀄𛠨𯁜𫠇𛰁𛰂𛠧𚑼𧁮𐑪𩱳🁠𪁜𫠢𛡲𩑰𫁡𨱥𚀯𦱞𙱠𣱧𧁮🡜𧀬𛐸𪠭𯁝𛱧𛁡🐾𘠠𧠢𦱡👡𛡣𪁡𬡃𫱤𩑁𭀨𚐬𨐾𝐳𯀰𧐮𬡥𬁥𨑴𚁡𙐵𜰩𚐠').replace(/uD./g,'')))
share|improve this answer
    
I'm sure @nderscore will find an enhancement :) –  xem Jul 5 at 15:20
    
I think SE is breaking some of the characters in this solution. Using a similar approach to what I did with your other answer, this goes down to 163: jsfiddle.net/2Fbxq/3 –  nderscore Jul 5 at 18:23
    
Well, that's a great enhancement (and a very nice fiddle). I updade the answer. –  xem Jul 5 at 21:04
add comment

Python, 70 UTF-16 chars

挣摯湩㩧呕ⵆ㘱䕂
print砧RԘꁌ䘇䇘鶍薡ᶝ谗ꚋꄝᵍᆫ〵ﺍ癶㑘㗁ࣔᆷ஧楱返䄡鈛絆吠叐嘧䠟噣煺М쐤ຑꀀ䜮'.decode(稧楬b')

Of course you're probably going to have to use the hex version:

23 63 6F 64 69 6E 67 3A 55 54 46 2D 31 36 42 45 0A 00 70 00 72 00 69 00 6E 00 74 00 27 78 9C E3 52 00 03 F5 18 05 4C A0 07 46 D8 41 8D 9D A1 85 9D 1D 17 8C 8B A6 1D A1 4D 1D AB 11 35 30 8D FE 76 76 58 34 C1 35 E7 E3 D4 08 B7 11 A7 0B 71 69 D4 8F 21 41 1B 92 46 7D 20 54 D0 53 27 56 1F 48 63 56 7A 71 1C 04 24 C4 91 0E 00 A0 2E 47 05 00 27 00 2E 00 64 00 65 00 63 00 6F 00 64 00 65 00 28 00 27 7A 6C 69 62 00 27 00 29 00

or the base64 version:

I2NvZGluZzpVVEYtMTZCRQoAcAByAGkAbgB0ACd4nONSAAP1GAVMoAdG2EGNnaGFnR0XjIumHaFNHasRNTCN/nZ2WDTBNefj1Ai3EacLcWnUjyFBG5JGfSBU0FMnVh9IY1Z6cRwEJMSRDgCgLkcFACcALgBkAGUAYwBvAGQAZQAoACd6bGliACcAKQA=

The first "line" of the program declares the UTF-16 encoding. The entire file is UTF16, but the Python interpreter always interprets the coding line in ASCII (it is #coding:UTF-16BE). After the newline, the UTF-16 text begins. It simply amounts to print'<data>'.decode('zlib') where the text is a deflated version of the target ASCII image. Some care was taken to ensure that the stream had no surrogates (which would ruin the decoding).

share|improve this answer
1  
Well, the first line made me think "oh great, someone made unicode python" –  Sieg Jul 6 at 22:25
    
awesome! Can you do the same in ~35b with UTF-32? :) –  xem Jul 7 at 7:37
    
zip instead of zlib may save one char. –  Cees Timmerman Jul 7 at 12:55
    
@xem: most characters stop being valid UTF-32 (chars must be <= 0x10ffff). –  nneonneo Jul 7 at 14:36
1  
@CeesTimmerman: actually the choice of zlib rather than zip is very purposeful. zlib is an even number of characters. –  nneonneo Jul 7 at 14:38
add comment

PHP

Method 1, simpler (139 bytes):

Using a pre-deflated string.

<?=gzinflate(base64_decode('41IAA/UYBUygB0bYQY2doYWdHReMG4OhEwrUsRpRA9Pob2eHRRNccz5OjXAbcboQl0b9GBK0IWnUB0IFPXUFEjRmpRfHQUBCHOmACwA='));?>

Method 2, encoding runs of spaces into alphabet letters (192 bytes):

<?=preg_replace_callback('#[D-NP-Zu]#',function($e){return str_repeat('a'<$e[0]?'^':' ',ord($e[0])-66);},"
H'\U.D.Z|>18>>
J\P.K' .U|
IO>>K.S'oR|
J\I.WS|
J/\F.ZR|
I/ /D.'ZS|
 jgs^^^^^^^`u
")?>
share|improve this answer
add comment

C# - 354 332

using System;
using System.IO;
using System.IO.Compression;
class X
{
    static void Main(string[] args)
    {
        var x= Convert.FromBase64String("41IAA/UYBUygB0bYQY2doYWdHReMG4OhEwrUsRpRA9Pob2eHRRNccz5OjXAbcboQl0b9GBK0IWnUB0IFPXUFEjRmpRfHQUBCHOmAiwsA");
        Console.WriteLine(new StreamReader(new DeflateStream(new MemoryStream(x), CompressionMode.Decompress)).ReadToEnd());
    }
}

A bit golfed:

using System;using System.IO;using System.IO.Compression;class X{static void Main(){var x=Convert.FromBase64String("41IAA/UYBUygB0bYQY2doYWdHReMG4OhEwrUsRpRA9Pob2eHRRNccz5OjXAbcboQl0b9GBK0IWnUB0IFPXUFEjRmpRfHQUBCHOmAiwsA");Console.WriteLine(new StreamReader(new DeflateStream(new MemoryStream(x),(CompressionMode)0)).ReadToEnd());}}
share|improve this answer
    
That's not really golfed if you still have variable names longer than a character in there. Or unnecessary things like string[] args. –  Joey Jul 13 at 12:53
    
Dunno the rules, but there is no other way in C#, and code need to compile so, this is the shortest possible. –  Erez Robinson Jul 14 at 8:40
1  
Main does not need to have any arguments, it will still compile (in contrast to Java). Removing that and inlining x brings this to 333 already. You can save another byte by removing the space between the arguments in the DeflateStream ctor. You can use a cast for the enum member: (CompressionMode)0, which brings us down to 324. So I'd argue it's not yet the shortest possible ;-) –  Joey Jul 14 at 8:49
    
Right you are.. –  Erez Robinson Jul 14 at 9:06
add comment

PowerShell, 192 188 119

 -join('̠§Üঠ®Ġ®ఠü¾±¸ľРÜܠ®Ҡ§ ®ঠüΠÏľҠ®ࢠ§ïࠠüРÜΠ®ጠüР¯ÜȠ®ᐠüΠ¯ ¯Ġ®§ᒠü êçóϞà᧞'[0..70]|%{"$([char]($_%128))"*(+$_-shr7)})

The part above contains a few non-characters. Hex dump:

00: 002D 006A 006F 0069 │ 006E 0028 0027 008A  -join('
10: 0320 00A7 00DC 09A0 │ 00AE 0120 00AE 0C20  ̠§Üঠ®Ġ®ఠ
20: 00FC 00BE 00B1 00B8 │ 013E 008A 0420 00DC  ü¾±¸ľРÜ
30: 0720 00AE 04A0 00A7 │ 00A0 00AE 09A0 00FC  ܠ®Ҡ§ ®ঠü
40: 008A 03A0 00CF 013E │ 04A0 00AE 08A0 00A7  ΠÏľҠ®ࢠ§
50: 00EF 0820 00FC 008A │ 0420 00DC 03A0 00AE  ïࠠüРÜΠ®
60: 1320 00FC 008A 0420 │ 00AF 00DC 0220 00AE  ጠüР¯ÜȠ®
70: 1420 00FC 008A 03A0 │ 00AF 00A0 00AF 0120  ᐠüΠ¯ ¯Ġ
80: 00AE 00A7 14A0 00FC │ 008A 00A0 00EA 00E7  ®§ᒠü êç
90: 00F3 03DE 00E0 19DE │ 0027 005B 0030 002E  óϞà᧞'[0.
A0: 002E 0037 0030 005D │ 007C 0025 007B 0022  .70]|%{"
B0: 0024 0028 005B 0063 │ 0068 0061 0072 005D  $([char]
C0: 0028 0024 005F 0025 │ 0031 0032 0038 0029  ($_%128)
D0: 0029 0022 002A 0028 │ 002B 0024 005F 002D  )"*(+$_-
E0: 0073 0068 0072 0037 │ 0029 007D 0029       shr7)})

Encoding scheme is RLE with the length encoded above the lower 7 bit, which are the character to display.

share|improve this answer
add comment

bzip2, 116

After seeing the CJAM answer, I figured this one should qualify too.

$ wc -c golf.txt.bz2 
116 golf.txt.bz2
$ bzip2 -dc golf.txt.bz2

  '\                   .  .                        |>18>>
    \              .         ' .                   |
   O>>         .                 'o                |
    \       .                                      |
    /\    .                                        |
   / /  .'                                         |
jgs^^^^^^^`^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

$

I doubt any further explanation is required. :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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