31
\$\begingroup\$

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!

\$\endgroup\$
  • 2
    \$\begingroup\$ "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?) \$\endgroup\$ – Martin Ender Jul 4 '14 at 19:21
  • \$\begingroup\$ @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) :) \$\endgroup\$ – xem Jul 4 '14 at 19:36
  • 1
    \$\begingroup\$ That ASCII looks more like a Cricket shot to me \$\endgroup\$ – Mr. Alien Jul 5 '14 at 6:26
  • \$\begingroup\$ @Mr.Alien I saw it in Martin Kleppe's recent talk: speakerdeck.com/aemkei/… (video: youtube.com/watch?v=zy-2ruMHdbU) \$\endgroup\$ – xem Jul 5 '14 at 6:30

22 Answers 22

14
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ 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..." \$\endgroup\$ – xem Jul 7 '14 at 15:00
  • \$\begingroup\$ @xem: Did you copy from the RAW Paste Data section? If I copy the formatted code, I get the same result. \$\endgroup\$ – Dennis Jul 7 '14 at 15:28
15
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ Nice effort! I was hoping for answers like that, that don't just gzip the ASCII ;) \$\endgroup\$ – xem Jul 4 '14 at 20:14
  • 1
    \$\begingroup\$ The second line could be 6.times{|i|S[i+1]=' '*55+?|} to save 2 characters. \$\endgroup\$ – afuous Jul 4 '14 at 20:21
  • \$\begingroup\$ @voidpigeon Ah thanks. I actually started with that, but initially thought I'd need i more than once. Good catch! \$\endgroup\$ – Martin Ender Jul 4 '14 at 20:23
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Ventero Jul 4 '14 at 21:56
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Ventero Jul 4 '14 at 22:18
13
\$\begingroup\$

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.

\$\endgroup\$
10
\$\begingroup\$

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.

\$\endgroup\$
7
\$\begingroup\$

PHP, 147

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

php -r 'echo gzinflate(base64_decode("41IAA/UYBUygB0bYQY2doYWdHReMG4OhEwrUsRpRA9Pob2eHRRNccz5OjXAbcboQl0b9GBK0IWnUB0IFPXUFEjRmpRfHQUBCHOmAiwsA"));'
\$\endgroup\$
6
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ You can save one character with s/\d+(?!8?>)/%$&s/rg \$\endgroup\$ – Ventero Jul 5 '14 at 16:59
  • \$\begingroup\$ @Ventero thank you for the suggestion. \$\endgroup\$ – core1024 Jul 5 '14 at 17:09
  • 2
    \$\begingroup\$ You can save another one by using a possessive quantifier: /\d++(?!>)/ \$\endgroup\$ – Martin Ender Jul 5 '14 at 17:50
  • \$\begingroup\$ @m.buettner I didn't know that. Learning new things every day :) \$\endgroup\$ – core1024 Jul 5 '14 at 17:59
4
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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
\$\endgroup\$
  • \$\begingroup\$ haha, nice compression, like it :D \$\endgroup\$ – Joshua Jul 8 '14 at 14:53
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

Python (145)

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

Not very original, I know.

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

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,'')))
\$\endgroup\$
  • \$\begingroup\$ great! <3 the RegPack's post-processing! psst, you can make it in 143b: xem.github.io/obfuscatweet \$\endgroup\$ – xem Jul 4 '14 at 20:11
  • \$\begingroup\$ @xem 143 characters, but a lot more bytes \$\endgroup\$ – nderscore Jul 4 '14 at 20:20
  • \$\begingroup\$ yes sorry, 143 chars. the question says that you can count chars. anyway, the regpack's approach is more interesting than the unicode-obfuscation ;) \$\endgroup\$ – xem Jul 4 '14 at 20:22
  • 2
    \$\begingroup\$ FWIW, mothereff.in/byte-counter is a tool that counts both characters and bytes (as per UTF-8). \$\endgroup\$ – Mathias Bynens Jul 5 '14 at 4:57
2
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ -3: .replace(/../g,a=>String.fromCharCode(a[c='charCodeAt']()&255).repeat(a[c](1)&255)) \$\endgroup\$ – nderscore Jul 5 '14 at 7:24
  • \$\begingroup\$ oh, great, thanks! \$\endgroup\$ – xem Jul 5 '14 at 11:02
2
\$\begingroup\$

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
")?>
\$\endgroup\$
2
\$\begingroup\$

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.

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

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')
\$\endgroup\$
1
\$\begingroup\$

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!

\$\endgroup\$
  • 1
    \$\begingroup\$ 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" \$\endgroup\$ – nderscore Jul 5 '14 at 6:07
  • \$\begingroup\$ oh, great, I didn't know repeat \$\endgroup\$ – xem Jul 5 '14 at 6:11
  • \$\begingroup\$ @nderscore don't be sorry it's great :) but the last line seems broken in my Firefox console \$\endgroup\$ – xem Jul 5 '14 at 6:26
  • \$\begingroup\$ 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|\‌) \$\endgroup\$ – nderscore Jul 5 '14 at 6:53
  • \$\begingroup\$ Thanks, I updated the answer and it works. :) I also added another 158b anwser, maybe you'll have an idea to improve it! \$\endgroup\$ – xem Jul 5 '14 at 7:16
1
\$\begingroup\$

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,'')))
\$\endgroup\$
  • \$\begingroup\$ I'm sure @nderscore will find an enhancement :) \$\endgroup\$ – xem Jul 5 '14 at 15:20
  • \$\begingroup\$ 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 \$\endgroup\$ – nderscore Jul 5 '14 at 18:23
  • \$\begingroup\$ Well, that's a great enhancement (and a very nice fiddle). I updade the answer. \$\endgroup\$ – xem Jul 5 '14 at 21:04
1
\$\begingroup\$

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

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

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());}}
\$\endgroup\$
  • \$\begingroup\$ That's not really golfed if you still have variable names longer than a character in there. Or unnecessary things like string[] args. \$\endgroup\$ – Joey Jul 13 '14 at 12:53
  • \$\begingroup\$ Dunno the rules, but there is no other way in C#, and code need to compile so, this is the shortest possible. \$\endgroup\$ – Erez Robinson Jul 14 '14 at 8:40
  • 1
    \$\begingroup\$ 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 ;-) \$\endgroup\$ – Joey Jul 14 '14 at 8:49
  • \$\begingroup\$ Right you are.. \$\endgroup\$ – Erez Robinson Jul 14 '14 at 9:06
1
\$\begingroup\$

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

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

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!

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

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.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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