Golfing ASCII-art

31

7

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!

xem

Posted 2014-07-04T18:00:43.160

Reputation: 5 523

2"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 Ender – 2014-07-04T19:21:30.177

@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 – 2014-07-04T19:36:09.897

1That ASCII looks more like a Cricket shot to me – Mr. Alien – 2014-07-05T06:26:52.557

@Mr.Alien I saw it in Martin Kleppe's recent talk: https://speakerdeck.com/aemkei/jscamp-dot-ro-minified-javascript-craziness (video: https://www.youtube.com/watch?v=zy-2ruMHdbU)

– xem – 2014-07-05T06:30:13.667

Answers

14

CJam, 62 characters

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

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.

Dennis

Posted 2014-07-04T18:00:43.160

Reputation: 196 637

1Really 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 – 2014-07-07T15:00:06.610

@xem: Did you copy from the RAW Paste Data section? If I copy the formatted code, I get the same result. – Dennis – 2014-07-07T15:28:42.427

15

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%.)

Martin Ender

Posted 2014-07-04T18:00:43.160

Reputation: 184 808

Nice effort! I was hoping for answers like that, that don't just gzip the ASCII ;) – xem – 2014-07-04T20:14:58.590

1The second line could be 6.times{|i|S[i+1]=' '*55+?|} to save 2 characters. – afuous – 2014-07-04T20:21:40.157

@voidpigeon Ah thanks. I actually started with that, but initially thought I'd need i more than once. Good catch! – Martin Ender – 2014-07-04T20:23:02.183

2Hope 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 – 2014-07-04T21:56:53.330

@Ventero whoa, 20 characters. Thanks a lot! – Martin Ender – 2014-07-04T22:05:20.123

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 – 2014-07-04T22:18:53.813

@Ventero oh, very good idea. I'll go ahead and steal that. ;) – Martin Ender – 2014-07-04T22:20:49.733

@Ventero two more and it's half as long as the ASCII art itself ;) – Martin Ender – 2014-07-04T22:27:10.363

Done: http://fpaste.org/115666/45130641/

– Ventero – 2014-07-04T22:31:11.960

Let us continue this discussion in chat.

– Martin Ender – 2014-07-04T22:33:06.570

13

bash + iconv + DosBox/x86 machine code (104 97 96 95 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.

Notice that this poses some limitation on the content, as not all the input sequences can be interpreted as UCS-2 with iconv not complaining; for example, for some reason many operations involving the bx register broke havoc depending on the place where I used them, so I had to work around this problem several times.

Now, 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  be 21 01 ac 88 c2 a8 c0  7d 0a b2 20 7b 02 b2 5e  |.!......}.. {..^|
00000010  83 e0 3f 93 b4 02 cd 21  4b 7f f9 ac 84 c0 75 e4  |..?....!K.....u.|
00000020  c3 0a 0a 86 27 5c 93 2e  82 2e 98 7c 3e 31 38 3e  |....'\.....|>18>|
00000030  3e 0a 88 5c 8e 2e 89 27  20 2e 93 7c 0a 87 4f 3e  |>..\...' ..|..O>|
00000040  3e 89 2e 91 27 6f 90 7c  0a 88 5c 87 2e a6 7c 0a  |>...'o.|..\...|.|
00000050  88 2f 5c 84 2e a8 7c 0a  87 2f 20 2f 82 2e 27 a9  |./\...|../ /..'.|
00000060  7c 0a 20 6a 67 73 c7 60  f3 0a 0a 00              ||. jgs.`....|
0000006c

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

    org 100h

start:
    ; si: pointer to current position in data
    mov si,data
    ; load the character in al
    lodsb
mainloop:
    ; bx: repetition count
    ; - zero at startup
    ; - -1 after each RLE run
    ; - one less than each iteration after each "literal" run
    ; the constant decrement is not really a problem, as print
    ; always does at least one print, and there aren't enough
    ; consecutive literal values to have wraparound

    ; if the high bit is not set, we have a "literal" byte;
    ; we prepare it in dl just in case
    mov dl,al
    ; then check if it's not set and branch straight to print
    ; notice that bx=0 is fine, as print prints always at least one character
    ; test the top two bits (we need the 6th bit below)
    test al,0xc0
    ; to see if the top bit was set, we interpret it as the sign bit,
    ; and branch if the number is positive or zero (top bit not set)
    jge print
rle:
    ; it wasn't a literal, but a caret/space with a repetition count
    ; space if 6th bit not set, caret otherwise
    mov dl,' '
    ; exploit the parity bit to see if the 6th bit was set
    jnp nocaret
    mov dl,'^'
nocaret:
    ; lower 6 bits: repetition count
    ; and away the top bits and move in bx
    ; we and ax and not al because we have to get rid of the 02h in ah
    and ax,3fh
    xchg ax,bx
print:
    ; print bx times
    mov ah,2
    int 21h
    dec bx
    jg print
    ; read next character
    lodsb
    test al,al
    ; rinse & repeat unless we got a zero
    jnz mainloop
end:
    ret
data:
    ; here be data
    incbin "compressed.dat"
    ; NUL terminator
    db 0

All this is just a decompresser 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.

Matteo Italia

Posted 2014-07-04T18:00:43.160

Reputation: 3 669

10

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.

grc

Posted 2014-07-04T18:00:43.160

Reputation: 18 565

7

PHP, 147

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

php -r 'echo gzinflate(base64_decode("41IAA/UYBUygB0bYQY2doYWdHReMG4OhEwrUsRpRA9Pob2eHRRNccz5OjXAbcboQl0b9GBK0IWnUB0IFPXUFEjRmpRfHQUBCHOmAiwsA"));'

r3mainer

Posted 2014-07-04T18:00:43.160

Reputation: 19 135

6

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.

core1024

Posted 2014-07-04T18:00:43.160

Reputation: 1 811

You can save one character with s/\d+(?!8?>)/%$&s/rg – Ventero – 2014-07-05T16:59:19.217

@Ventero thank you for the suggestion. – core1024 – 2014-07-05T17:09:47.807

2

You can save another one by using a possessive quantifier: /\d++(?!>)/

– Martin Ender – 2014-07-05T17:50:48.767

@m.buettner I didn't know that. Learning new things every day :) – core1024 – 2014-07-05T17:59:36.677

4

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.

Kaslai

Posted 2014-07-04T18:00:43.160

Reputation: 641

4

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

wec

Posted 2014-07-04T18:00:43.160

Reputation: 661

haha, nice compression, like it :D – Joshua – 2014-07-08T14:53:14.040

3

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.

Alex L

Posted 2014-07-04T18:00:43.160

Reputation: 761

3

Python (145)

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

Not very original, I know.

ɐɔıʇǝɥʇuʎs

Posted 2014-07-04T18:00:43.160

Reputation: 4 449

2

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,'')))

nderscore

Posted 2014-07-04T18:00:43.160

Reputation: 4 912

great! <3 the RegPack's post-processing! psst, you can make it in 143b: http://xem.github.io/obfuscatweet/

– xem – 2014-07-04T20:11:08.710

@xem 143 characters, but a lot more bytes – nderscore – 2014-07-04T20:20:29.277

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 – 2014-07-04T20:22:07.810

2

FWIW, http://mothereff.in/byte-counter is a tool that counts both characters and bytes (as per UTF-8).

– Mathias Bynens – 2014-07-05T04:57:11.387

2

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/)

xem

Posted 2014-07-04T18:00:43.160

Reputation: 5 523

-3: .replace(/../g,a=>String.fromCharCode(a[c='charCodeAt']()&255).repeat(a[c](1)&255)) – nderscore – 2014-07-05T07:24:09.537

oh, great, thanks! – xem – 2014-07-05T11:02:50.213

2

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
")?>

LSerni

Posted 2014-07-04T18:00:43.160

Reputation: 121

2

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.

Joey

Posted 2014-07-04T18:00:43.160

Reputation: 12 260

1

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!

xem

Posted 2014-07-04T18:00:43.160

Reputation: 5 523

1ES6 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 – 2014-07-05T06:07:06.063

oh, great, I didn't know repeat – xem – 2014-07-05T06:11:15.463

@nderscore don't be sorry it's great :) but the last line seems broken in my Firefox console – xem – 2014-07-05T06:26:03.750

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 – 2014-07-05T06:53:13.420

Thanks, I updated the answer and it works. :) I also added another 158b anwser, maybe you'll have an idea to improve it! – xem – 2014-07-05T07:16:22.547

1

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')

Ian D. Scott

Posted 2014-07-04T18:00:43.160

Reputation: 1 841

1

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,'')))

xem

Posted 2014-07-04T18:00:43.160

Reputation: 5 523

I'm sure @nderscore will find an enhancement :) – xem – 2014-07-05T15:20:48.020

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: http://jsfiddle.net/2Fbxq/3/

– nderscore – 2014-07-05T18:23:07.873

Well, that's a great enhancement (and a very nice fiddle). I updade the answer. – xem – 2014-07-05T21:04:42.610

1

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).

nneonneo

Posted 2014-07-04T18:00:43.160

Reputation: 11 445

1Well, the first line made me think "oh great, someone made unicode python" – seequ – 2014-07-06T22:25:01.727

awesome! Can you do the same in ~35b with UTF-32? :) – xem – 2014-07-07T07:37:13.267

zip instead of zlib may save one char. – Cees Timmerman – 2014-07-07T12:55:20.787

@xem: most characters stop being valid UTF-32 (chars must be <= 0x10ffff). – nneonneo – 2014-07-07T14:36:56.937

1@CeesTimmerman: actually the choice of zlib rather than zip is very purposeful. zlib is an even number of characters. – nneonneo – 2014-07-07T14:38:07.487

1

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());}}

Erez Robinson

Posted 2014-07-04T18:00:43.160

Reputation: 151

That's not really golfed if you still have variable names longer than a character in there. Or unnecessary things like string[] args. – Joey – 2014-07-13T12:53:48.243

Dunno the rules, but there is no other way in C#, and code need to compile so, this is the shortest possible. – Erez Robinson – 2014-07-14T08:40:15.073

1Main 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 – 2014-07-14T08:49:08.467

Right you are.. – Erez Robinson – 2014-07-14T09:06:12.860

1

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. :)

Alex Mooney

Posted 2014-07-04T18:00:43.160

Reputation: 111

1

Using Bubblegum with DEFLATE gets it down to 77 bytes. Try it online!

– Miles – 2017-10-05T03:12:09.990

0

C (gcc), 190 bytes

r(n,c){while(n--)putchar(c);}f(c){for(char*s="F'\\S.B.X|>18>>\nH\\N.I' .S|\nGO>>I.Q'oP|\nH\\G.ZL|\nH/\\D.ZN|\nG/ /B.'ZN |\n jgs^^^^^^^`";c=*s++;)c>64&&c<91&&c^79?r(c-64,32):r(1,c);r(51,94);}

Try it online!

gastropner

Posted 2014-07-04T18:00:43.160

Reputation: 3 264

0

Vim, 99 keystrokes

63i^<Esc>0R jgs<C-O>7l`<Esc>O<Esc>55I <Esc>A|<Esc>Y5PA>18>><Esc>7|R'\<Down>\<Down><Left><Left>O>><Down><Left><Left>\<Down>\<Down><Left><Left><Left>/<Up>/<Down>/<Right><Right>.'<Up>.<Right><Up>.<Right><Right><Up>.<Right><Right><Right><Up>.<Right><Right><Right><Up>.<Right><Right>.<Right><Right><Down>'<Right>.<Down><Right>'o

probably golfable

Explanation:

63i^<Esc>0R jgs<C-O>7l`<Esc>
Bottom line, 63 '^'s, replace the beginning with ' jgs', then move 7 caracters to the right and replace one character with '`'

O<Esc>55I <Esc>A|<Esc>
Above current line, add one line and insert 55 spaces, then a trailing '|'

Y5PA>18>><Esc>
Copy that line and paste it above five times. Cursor ends up in topmost line. Append '>18>>'

7|R'\<Down>\<Down><Left><Left>O>><Down><Left><Left>\<Down>\<Down><Left><Left><Left>/<Up>/<Down>/<Right><Right>.'<Up>.<Right><Up>.<Right><Right><Up>.<Right><Right><Right><Up>.<Right><Right><Right><Up>.<Right><Right>.<Right><Right><Down>'<Right>.<Down><Right>'o
Go to 7th column, enter Replace-mode, and replace spaces with golfer and golf ball trail. Arrow keys are used to move around, since it uses fewer keypresses to use the arrow keys instead of <C-o>+movement for up to three keypresses.

oktupol

Posted 2014-07-04T18:00:43.160

Reputation: 697