90
\$\begingroup\$

Adam West passed away, and I'd like to honor his memory here on PPCG, though I doubt he knew of our existence. While there are many, many different things that this man is known for, none are more prominent than his role as the original batman. I'll always remember my step-father still watching the old-school Batman and Robin to this day. This challenge is simplistic in nature, not at all in line with the complicated man that was Adam West. However, it's the best I could come up with, as this is the most iconic image of the man's career.


I wanted to post this earlier, but I was waiting for someone to come up with something better.


Output the following (with or without trailing spaces/newlines):

           *                         *
       ****          *     *          ****
     ****            *******            ****
   ******            *******            ******
  *********         *********         *********
 ***********************************************
*************************************************
*************************************************
*************************************************
 ***********************************************
  *****       *********************       *****
    ****       ***    *****    ***       ****
       **       *      ***      *       **

This is , the lowest byte-count will win.

\$\endgroup\$
  • 7
    \$\begingroup\$ You should forbid encoded strings. It is really not fun! \$\endgroup\$ – sergiol Jun 13 '17 at 22:47
  • 7
    \$\begingroup\$ He wasn't the original Batman. That honour belongs to Lewis Wilson. \$\endgroup\$ – Shaggy Jun 13 '17 at 22:55
  • 42
    \$\begingroup\$ When I saw the title, I thought the output was going to be "na-na-na-na-na-na-na-na na-na-na-na-na-na-na-na". \$\endgroup\$ – D Krueger Jun 14 '17 at 2:36
  • 3
    \$\begingroup\$ @DKrueger: make it so in another question :) \$\endgroup\$ – Olivier Dulac Jun 14 '17 at 14:46
  • 4
    \$\begingroup\$ Why didn't this start last year? Carrie Fisher, Prince, David Bowie and Alan Rickman! \$\endgroup\$ – caird coinheringaahing Jun 14 '17 at 20:58

48 Answers 48

47
\$\begingroup\$

Jelly, 44 bytes

“¡©İ'¹!ðkW>ṅṙẏṙlœf:ߌÆ@Ƥ’b25o99Jx$ị⁾ *s25ŒBY

Try it online!

How it works

“¡©İ'¹!ðkW>ṅṙẏṙlœf:ߌÆ@Ƥ’

This is a numeric literal. All characters are replaced with their 1-based indices in Jelly's code page the result is interpreted as a bijective base-250 integer, yielding

58616171447449697510361193418481584558895594063391402

Next, b25 convert that integer to base 25 and o99 replaces 0 with 99, yielding

11 1 20 4 10 1 8 4 12 4 3 6 12 4 2 9 9 5 1 99 1 24 2 5 7 11 4 4 7 3 4 3 7 2 7 1 6 2

Jx$ replaces the jth base-25 digits n with n copies of j, yielding

1 1 1 1 1 1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 7 7 7 7 7 7 7 7 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 11 11 11 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 15 15 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17 18 18 18 18 18 19 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 21 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 23 23 24 24 24 24 24 25 25 25 25 25 25 25 26 26 26 26 26 26 26 26 26 26 26 27 27 27 27 28 28 28 28 29 29 29 29 29 29 29 30 30 30 31 31 31 31 32 32 32 33 33 33 33 33 33 33 34 34 35 35 35 35 35 35 35 36 37 37 37 37 37 37 38 38

Now, ị⁾ * indexes into the character pair. Indexing is 1-based and modular, so odd numbers get replaced with spaces, even ones with asterisks. This yields

           *                    ****          *        ****            ****   ******            ****  *********         ***** *************************************************************************************************** ************************  *****       ***********    ****       ***    ***       **       *      **

s25 chops the result into chunks of length 25. If we write each chunk on its own line, we get

           *             
       ****          *   
     ****            ****
   ******            ****
  *********         *****
 ************************
*************************
*************************
*************************
 ************************
  *****       ***********
    ****       ***    ***
       **       *      **

The bounce atom ŒB palindromizes each chunk by appending a reversed copy without its first character, yielding

           *                         *           
       ****          *     *          ****       
     ****            *******            ****     
   ******            *******            ******   
  *********         *********         *********  
 *********************************************** 
*************************************************
*************************************************
*************************************************
 *********************************************** 
  *****       *********************       *****  
    ****       ***    *****    ***       ****    
       **       *      ***      *       **       

Finally, Y introduces the actual linefeeds.

\$\endgroup\$
  • 1
    \$\begingroup\$ And I thought “QƤḣọḲ£¿ẆịµñẒṢƊ¬ƒỤ2ỴÐ,ịṁ&Ḅ<ḋsḳn.⁷ṛḃṡ⁾6bḋeṁ’ṃ⁾ *s25ŒBY was short enough at 53 bytes... \$\endgroup\$ – Erik the Outgolfer Jun 14 '17 at 8:04
  • \$\begingroup\$ I tried like 14 different things, then finally got to this by trial and error. Didn't understand what you meant by "replaces 0 with 99" until I tried it myself. \$\endgroup\$ – Magic Octopus Urn Jun 16 '17 at 18:41
156
\$\begingroup\$

Wordfuck, 5761 2686 bytes

I guess using his name as a source code gets Adam West some honor.

adam west adam west adam_wes t_a dam_we st_a dam_ west adam west adam west adam west_ad am_west_a dam_we st ad am we st ad am we st ad am west_a dam_we st_a dam_ west_ada m_w est ada m_w est ada m_west_ adam west_a dam_west_ adam_we st_ ad am_west ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am_wes t_ adam_w est_ adam west adam west adam west adam west adam we st_adam west_ad am we st ad am we st adam_w es t_ ad am west_ad am we st ad am we st ad am we st_ada m_ west_ad am we st ad am west_a da m_west_ ad am we st ad am we st ad am west_a da m_ we st adam_w es t_adam_ west_ad am we st ad am west_a da m_ we st adam_we st ad am we st ad am we st ad am we st_ada m_ we st ad am we st adam_we st ad am we st ad am we st ad am we st_ada m_ we st ad am_wes t_ adam_we st_adam we st ad am_wes t_ ad am we st ad am_west ad am we st ad am we st ad am we st adam_w es t_ ad am we st ad am_west ad am we st ad am we st ad am we st adam_w es t_ ad am we st adam_w es t_adam_ west_ad am we st_ada m_ we st ad am we st ad am west_ad am we st ad am we st ad am west_a da m_ we st ad am we st ad am_west ad am we st ad am we st ad am_wes t_ ad am we st ad am we st adam_w es t_adam_ west_ad am west_a da m_ we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st_ada m_ west_ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am west_a da m_west_ ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am_wes t_ adam_we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st adam_w es t_adam_ west_ad am west_a da m_ we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st ad am we st_ada m_ west_ad am_west ad am west_a da m_ we st ad am_west ad am we st ad am we st_ada m_ we st ad am we st ad am we st ad am we st ad am we st ad am west_ad am we st ad am we st adam_w es t_ ad am we st_ada m_ west_ad am_west ad am we st adam_w es t_ ad am west_ad am we st ad am we st adam_w es t_ ad am_west ad am we st adam_w es t_ ad am we st_adam we st ad am west_a da m_ we st_adam we st ad am we st ad am_wes t_ ad am we st_ada m_ west_ad am_west ad am we st ad am we st_ada m_ we st_adam we st ad am we st ad am_wes t_ adam_we st ad am we st ad am_wes t_ ad am west_ad am we st ad am we st_ada m_ west_ad am we st ad am we st adam_w es t!

Try it online! (transpiled brainfuck)

Adam West singing (thanks @carusocomputing)

\$\endgroup\$
  • 69
    \$\begingroup\$ This is terrible. I love it. \$\endgroup\$ – TheWanderer Jun 14 '17 at 0:51
  • 25
    \$\begingroup\$ Hmm. Yes. Pretty good, but I think you forgot an underscore on line 1. \$\endgroup\$ – Mateen Ulhaq Jun 14 '17 at 7:58
  • 2
    \$\begingroup\$ Is there a way we can test this? \$\endgroup\$ – Shaggy Jun 14 '17 at 10:25
  • 4
    \$\begingroup\$ @Wilf welcome to PCCG! we don't really compete on this site, of course this isn't the winning solution, but its hilarious and challenge themed, so it gets upvoted so more people can enjoy it. Hoping to upvote your answers soon! \$\endgroup\$ – Uriel Jun 15 '17 at 18:28
  • 3
    \$\begingroup\$ @Shaggy Try it online! (STDERR) \$\endgroup\$ – Adám Jun 16 '17 at 8:44
66
\$\begingroup\$

Python, 530 529 528 524 bytes

import zlib as Holy
B=list("NNAAAnAAnnAnaAannnaaaaNaAAnNanAaAanNNaNNaNaanNNANanNNANaAnAaANANAAnAaANNnAanAaNnAaAANNAaAnNANAaaANNAanAaNaNNNAaNNanAAnNNnaaaNANANANnnaaaNaaAAAANaNaNaNAnNAAAAaaaaANAaNnnAaAaNAAaANNnaaNnNnaannaaAaananannNnAAAAAanAananANAnaAAnANAAaaaAaaanaaAAaanNAnanAAnnnANAnNAnnAnnnanaNNaaaNaNNaAAnNAaaANNNANAnAaaAaNaANnNNNaaAanaaaanaaaaaAaAaNnNnnaAnANaNnnANanNA")
A=dict(N='11',A='01',n='10',a='00')   
T=""
POP=BIFF=POW=OOF=lambda:A[B.pop()]
while B:T+=chr(int(POP()+POW()+BIFF()+OOF(),2))
print Holy.decompress(T)
\$\endgroup\$
  • 4
    \$\begingroup\$ Oh lord, I haven't laughed that hard in awhile. NAanANANaNANaNAANnAnaNANanaNA \$\endgroup\$ – Magic Octopus Urn Jun 14 '17 at 19:55
  • 9
    \$\begingroup\$ In code golf, we're supposed to make the byte count small, but your entry is rather hefty. ;) \$\endgroup\$ – PM 2Ring Jun 14 '17 at 21:29
  • 33
    \$\begingroup\$ On occasion, one must make sacrifices for the greater good. \$\endgroup\$ – rrauenza Jun 14 '17 at 21:34
  • 1
    \$\begingroup\$ That sounds like something Batman would say. ;) I have to admit that I find the B.pop(0) slightly annoying. Why not reverse B so you can use the much more efficient (and shorter) B.pop()? The pop(0) has to move all the remaining list elements down one slot. Sure, it happens at C speed, but it's still less efficient than popping from the end of the string. \$\endgroup\$ – PM 2Ring Jun 15 '17 at 19:59
  • 5
    \$\begingroup\$ The aliases to POP, BIFF, POW, OOF made me spit out what I was drinking on my monitor. Thanks lol. +1. \$\endgroup\$ – rayryeng Jun 22 '17 at 20:02
21
\$\begingroup\$

JavaScript (ES6), 148 146 bytes

_=>`n2zh2
f8l2b2l8
b8pep8
7cpepc
5ijiji
3yyq
0
0
0
3yyq
5afy8fa
98f69a96f8
f4f2d6d2f4`.replace(/./g,c=>'* '[(n=parseInt(c,36))&1].repeat(n/2||49))

Demo

let f =

_=>`n2zh2
f8l2b2l8
b8pep8
7cpepc
5ijiji
3yyq
0
0
0
3yyq
5afy8fa
98f69a96f8
f4f2d6d2f4`.replace(/./g,c=>'* '[(n=parseInt(c,36))&1].repeat(n/2||49))

o.innerHTML = f()
<pre id=o></pre>

\$\endgroup\$
12
\$\begingroup\$

Python, 149 142 bytes

7 bytes saved thanks to @PM2Ring

for l in"b1d 74a13 54c4 36c4 2995 1o 0p 0p 0p 1o 257b 447343 727162".split():x=''.join(s*int(k,36)for s,k in zip(' *'*3,l));print(x+x[-2::-1])
\$\endgroup\$
  • \$\begingroup\$ Nice. You can shave off 7 bytes: x=''.join(s*int(k,36)for s,k in zip(' *'*3,l)) \$\endgroup\$ – PM 2Ring Jun 14 '17 at 6:56
  • \$\begingroup\$ No worries. I managed to write an even shorter Python version. ;) \$\endgroup\$ – PM 2Ring Jun 15 '17 at 15:35
  • 1
    \$\begingroup\$ @PM2Ring you got my +1 \$\endgroup\$ – Uriel Jun 15 '17 at 15:39
12
\$\begingroup\$

MATL, 61 59 bytes

' *'60:'*u9|K9j[~F9R,>ejc4Q,7;F\1l_=7sFR'F11:ZaY"13e)25ZvZ)

Try it online!

How it works

This uses the following, standard techniques:

  • Since the image is horizontally symmetric, only the left half (including center column) is encoded.
  • The image is linearized in column-major order (down, then across) and the resulting sequence is run-length encoded.
  • The resulting run lengths take values from 1 to 11, so the sequence of run lengths is compressed by base conversion, from base 11 to base 94 (printable ASCII chars except single quote, which would need escaping).
\$\endgroup\$
  • 1
    \$\begingroup\$ There are 60 runs in column-major order, but only 38 in row-major. Would that save any bytes? \$\endgroup\$ – Dennis Jun 14 '17 at 4:36
  • \$\begingroup\$ @Dennis The problem is that in that case the run lengths are [1:12 20 24 99], which makes compression more difficult. My best attempt is at 60 bytes \$\endgroup\$ – Luis Mendo Jun 14 '17 at 8:38
  • \$\begingroup\$ Rather than constructing the exact set, have you tried simply using base 25 and replacing 0 with 99 with, e.g., Y|? I don't know enough MATL atm to test if that's actually shorter... \$\endgroup\$ – Dennis Jun 14 '17 at 16:28
  • \$\begingroup\$ @Dennis That looks promising. Using the set [1:24 99] I removed one byte. If I use [0:24] (base 25) I don't know how to turn 0 into 99 in few bytes \$\endgroup\$ – Luis Mendo Jun 14 '17 at 17:18
  • 1
    \$\begingroup\$ Right Y| doesn't work in MATL/Octave like it does in Jelly/Python. In the latter, 0 or 99 yields 99... \$\endgroup\$ – Dennis Jun 14 '17 at 18:58
7
\$\begingroup\$

vim, 168 156 bytes

:nm N a <C-v><ESC>
:nm A a*<C-v><ESC>
:nm B aY<C-v><ESC>yyp!!rev<C-v><CR>kJh4xo<C-v><ESC>
11NA13NB7N4A10NA3NB5N4A12N4AB3N6A12N4AB2N9A9N5ABN24AB25ABkyyppjN24AB2N5A7N11AB4N4A7N3A4N3AB7N2A7NA6N2ABdd

This assumes a Unix environment, for rev. I use a fairly straightforward (count,character) encoding, with N and A appending a and * respectively, and B doing the copy and reverse.

In the actual file, the bracketed entries are replaced by the literal bytes they represent. <C-v> is 0x16, <ESC> is 0x1b, and <CR> is 0x0d.

Try it online

\$\endgroup\$
  • \$\begingroup\$ I think it would be faster to not bother making macros 'b' and 'c', and instead remap them directly. :nm N a <C-v><esc> and :nm A a*<C-v><esc> \$\endgroup\$ – DJMcMayhem Jun 14 '17 at 19:27
  • \$\begingroup\$ @DJMcMayhem So it does. For some reason, I thought it would be more difficult to store the <C-v> in a file than it is, so I used the roundabout method so I could test it with { cat foo.vim; echo ':wq'; } | vim out.txt. I'm not sure why it didn't occur to me to try <C-v><C-v> yesterday. \$\endgroup\$ – Ray Jun 14 '17 at 21:08
  • \$\begingroup\$ I'm glad to know you got it working! Another way you can test vim answers for convenience is Try it online!, which really uses an esolang I wrote, but it's (mostly) backwards compatible anyway. The -v flag lets you use vim key descriptions (like <C-v> and whatnot) \$\endgroup\$ – DJMcMayhem Jun 14 '17 at 21:28
  • \$\begingroup\$ @DJMcMayhem Very nice. Thanks. \$\endgroup\$ – Ray Jun 14 '17 at 21:35
  • \$\begingroup\$ Can't you write <NL> instead of <NEWLINE>? \$\endgroup\$ – L3viathan Jun 15 '17 at 18:26
7
\$\begingroup\$

Charcoal, 69 54 52 48 bytes

E⪪”|↖y{{﹪yc›o”n↗πf>T≔Y¿PN|ωπQβ” ⪫Eιק* μ⌕βλω‖O←

Try it online! Link is to verbose version of code. Edit: Thanks to @ASCII-only, saved 4 bytes by switching from a separate flag to looping over indices, 7 bytes by using the (undocumented?) ⸿ character, and a further 4 bytes by using the alphabet for the run length encoding. Saved a further 2 bytes because AtIndex automatically takes the modulo. Saved a further 4 bytes because Map automatically creates an index variable. Explanation:

Print(Map(

The outer Map returns an array. Print handles this by printing each element on its own line, thus avoiding having to manually Join them with \n.

Split("anb adbke eme fjj y z z z y lhf dedhe cgbhc" " "),

The string encodes all the half-rows of the output. Alternating letters refer to the number of *s and spaces (a=0 is used to handle a row that starts with a space). The space is a convenient choice of delimiter, but also turns out to compress well (x also compresses to an overall 55 bytes). Each row is processed separately. (Note: The deverbosifier fails to remove the separator between a compressed and uncompressed string, otherwise the code would have a , for readability.)

Join(Map(i, Times(AtIndex("* ", m), Find(b, l))), w)));

Loop over every letter, expanding to the appropriate number of *s or spaces. The variable m is the inner loop index for this Map, while l holds the letter. The result is then Joined into a single string using the predefined empty string w.

ReflectOverlap(:Left);

Once all the rows are printed, reflect everything to the left, overlapping the middle column.

I tried handling the newlines, spaces and stars all in one loop but it actually took two more bytes this way:

Print(Join(Map("anb adbke eme fjj y z z z y lhf dedhe cgbhc", Ternary(Equals(" ", i), "\n", Times(AtIndex("* ", k), Find(b, i)))), w));
ReflectOverlap(:Left);
\$\endgroup\$
  • 1
    \$\begingroup\$ +1 I really need to learn Charcoal (as well has Hexagony and Cubix). Three of my favorite programming languages I see here. Btw, I guess you were already planning to, but could you add an explanation? \$\endgroup\$ – Kevin Cruijssen Jun 14 '17 at 11:02
  • \$\begingroup\$ @KevinCruijssen Hmm, I guess even the verbose code needs some clarification... does this suffice? \$\endgroup\$ – Neil Jun 14 '17 at 11:43
  • \$\begingroup\$ Ah, I hadn't noticed the TIO contained the verbose version tbh. But nevertheless, an explanation in the answer itself never hurts, so thanks for taking the time to write it. \$\endgroup\$ – Kevin Cruijssen Jun 14 '17 at 12:38
  • \$\begingroup\$ I want to learn charcoal, but it needs a page like 05AB1E which explains what each char of the code-page actually does without having to dive into code. \$\endgroup\$ – Magic Octopus Urn Jun 14 '17 at 14:49
  • 2
    \$\begingroup\$ @carusocomputing It's not too bad: apart from compressed strings, you've got normal strings (ASCII characters and pilcrow), numbers (superscript digits), arrows (...arrows), commands (usually fullwidth capital letters) and operators (everything else), so you can then look them up on the appropriate page of the wiki. \$\endgroup\$ – Neil Jun 14 '17 at 15:28
6
\$\begingroup\$

05AB1E, 47 bytes

„ *19×S•«M;Ó8ζ?èYÑ?½¨/Ž´.δòÈÖ<•25вт<19ǝ×J13ä€û»

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Ported Dennis's algorithm right? \$\endgroup\$ – Erik the Outgolfer Jun 14 '17 at 11:12
  • \$\begingroup\$ @EriktheOutgolfer: Borrowed the replace 99 trick from him (saved 4 bytes over the straight forward way). Still looking for a better way though. \$\endgroup\$ – Emigna Jun 14 '17 at 11:23
  • \$\begingroup\$ -1 by using .∞ instead of €û» (mirrors implicitly join lists on newlines first in the legacy version, before applying the mirror). I've also tried to use ₂в instead of 25в, but unfortunately the compressed integer is then 1 byte longer as well, so it doesn't save anything: •2Ø°×á[1∊Œ)’˜Àå<тIÞ‡p5ÉQ•₂в. \$\endgroup\$ – Kevin Cruijssen Aug 6 at 12:09
6
\$\begingroup\$

T-SQL, 283 276 bytes

DECLARE @ CHAR(999)=REPLACE(REPLACE(REPLACE('PRINT SPACE(11#1$25#1&$7#4$10#1$5#1$10#4&$5#4$12#7$12#4&$3#6$12#7$12#6&$2#9$9#9$9#9&$1#47&#49&#49&#49&$1#47&$2#5$7#21$7#5&$4#4$7#3$4#5$4#3$7#5&$7#2$7#1$6#3$6#1$7#2)','#',')+REPLICATE(''*'','),'$',')+SPACE('),'&',')+CHAR(13')EXEC(@)

Basically I'm manually encoding a giant string that determines what to print next, using the following method:

  • #7 gets replaced by +REPLICATE('*',7)
  • $4 gets replaced by +SPACE(4)
  • & gets replaced by +CHAR(13)

After replacement, the full 958 character string looks like (with line breaks at each line in the Batman symbol:

PRINT 
SPACE(11)+REPLICATE('*',1)+SPACE(25)+REPLICATE('*',1)+CHAR(13)
+SPACE(7)+REPLICATE('*',4)+SPACE(10)+REPLICATE('*',1)+SPACE(5)+REPLICATE('*',1)+SPACE(10)+REPLICATE('*',4)+CHAR(13)
+SPACE(5)+REPLICATE('*',4)+SPACE(12)+REPLICATE('*',7)+SPACE(12)+REPLICATE('*',4)+CHAR(13)
+SPACE(3)+REPLICATE('*',6)+SPACE(12)+REPLICATE('*',7)+SPACE(12)+REPLICATE('*',6)+CHAR(13)
+SPACE(2)+REPLICATE('*',9)+SPACE(9)+REPLICATE('*',9)+SPACE(9)+REPLICATE('*',9)+CHAR(13)
+SPACE(1)+REPLICATE('*',47)+CHAR(13)
+REPLICATE('*',49)+CHAR(13)
+REPLICATE('*',49)+CHAR(13)
+REPLICATE('*',49)+CHAR(13)
+SPACE(1)+REPLICATE('*',47)+CHAR(13)
+SPACE(2)+REPLICATE('*',5)+SPACE(7)+REPLICATE('*',21)+SPACE(7)+REPLICATE('*',5)+CHAR(13)
+SPACE(4)+REPLICATE('*',4)+SPACE(7)+REPLICATE('*',3)+SPACE(4)+REPLICATE('*',5)+SPACE(4)+REPLICATE('*',3)+SPACE(7)+REPLICATE('*',5)+CHAR(13)
+SPACE(7)+REPLICATE('*',2)+SPACE(7)+REPLICATE('*',1)+SPACE(6)+REPLICATE('*',3)+SPACE(6)+REPLICATE('*',1)+SPACE(7)+REPLICATE('*',2)

Which gets executed as dynamic SQL, producing the following output:

           *                         *
       ****          *     *          ****
     ****            *******            ****
   ******            *******            ******
  *********         *********         *********
 ***********************************************
*************************************************
*************************************************
*************************************************
 ***********************************************
  *****       *********************       *****
    ****       ***    *****    ***       *****
       **       *      ***      *       **
\$\endgroup\$
6
\$\begingroup\$

Clojure, 833 437 bytes

Almost by definition Clojure will never win any prizes for brevity, but as I looked forward EVERY DARN WEEK to the TWO (count 'em - TWO) episodes of Batman (same Bat-time, same Bat-channel!) it's clear that there is no time to lose!

Quick, Robin - to the Bat-REPL!!!

(defn r[c n](clojure.string/join(repeat n c)))(defn pl[col](loop[i 0 c " "](print(r c (nth col i)))(if(< i (dec (count col)))(recur (inc i) (if (= c " ") "*" " "))(println))))(defn p[](loop[lines [[11 1 25 1][7 4 10 1 5 1 10 4][5 4 12 7 12 4][3 6 12 7 12 6][2 9 9 9 9 9][1 47][0 49][0 49][0 49][1 47][2 5 7 21 7 5][4 4 7 3 4 5 4 3 7 4][7 2 7 1 6 3 6 1 7 2]] i 0] (pl (nth lines i))(if (< i (dec (count lines)))(recur lines (inc i))nil)))

Un-golfed version:

(defn repstr [c n]
  (clojure.string/join (repeat n c)))

(defn print-bat-signal-line [col]
  (loop [i  0
         c  " "]
    (print (repstr c (nth col i)))
    (if (< i (dec (count col)))
      (recur (inc i) (if (= c " ") "*" " "))
      (println))))

(defn print-bat-signal []
  (loop [lines [[11 1 25 1]  ; spaces asterisks spaces asterisks
                [7 4 10 1 5 1 10 4]
                [5 4 12 7 12 4]
                [3 6 12 7 12 6]
                [2 9 9 9 9 9]
                [1 47]
                [0 49]
                [0 49]
                [0 49]
                [1 47]
                [2 5 7 21 7 5]
                [4 4 7 3 4 5 4 3 7 4]
                [7 2 7 1 6 3 6 1 7 2]]
        i      0]
    (print-bat-signal-line (nth lines i))
    (if (< i (dec (count lines)))
      (recur lines (inc i))
      nil)))

RIP Adam West. No matter how ridiculous those shows were, those of us who were kids salute you.

\$\endgroup\$
  • \$\begingroup\$ While not golfed, it still beats the cat answer heh. \$\endgroup\$ – Magic Octopus Urn Jun 14 '17 at 19:46
  • \$\begingroup\$ Golfed version added. I'd turn it sideways to make it look like it's climbing a wall if I could. :-) \$\endgroup\$ – Bob Jarvis Jun 15 '17 at 14:52
6
\$\begingroup\$

C (gcc), 191 bytes

#define x 16777215
char*b,*c,a[50];l[]={4096,122888,491535,2064399,4186143,x/2,x,x,x,x/2,4064255,983495,98435,0},*p=l;main(){for(;*p;p++,puts(a))for(b=c=a+23;b>=a;*p/=2)*b--=*c++=" *"[*p&1];}

Try it online!

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

Various solutions, all using Run Length Encoding, with a variety of techniques to encode the RLE data.

Python 3, 125 121 bytes

This version uses a bytes string to store the data.

s=''
for c in b'<)@4/:),0/>/,3>/*981(WYYY(W*14=./4-.-4+4)2+':s+=' *'[c%2]*(c//2-19);s*=len(s)<25or print(s+s[-2::-1])or 0

Let s be a string of stars or of spaces. Then the byte n encoding s is given by

n = 38 + 2*len(s) + (s[0]=='*')

Python 2, 133 126 bytes

This version uses alphabetic coding. The letter value determines the length of the output string, the case of the letter determines whether it's composed of spaces or stars.

s=''
for c in'kAmgDjAceDlDcFlDbIiEaXYYYaXbEgKdDgCdCgBgAfB':
 s+=' *'[c<'a']*(int(c,36)-9)
 if len(s)>24:print s+s[-2::-1];s='' 

My original 133 byte Python 2 solution.

This version uses zero-length strings so it can easily alternate between star and space strings.

s=''
for c,n in zip(24*' *','b1d074a13054c436c429951o0p0p0p1o257b447343727162'):
 s+=c*int(n,36)
 if len(s)>24:print s+s[-2::-1];s=''

Just for fun, here's a one-liner using the alphabetic coding.

Python 2, 148 bytes

print'\n'.join(''.join(s+s[-2::-1])for s in zip(*[iter(''.join(' *'[c<'a']*(int(c,36)-9)for c in'kAmgDjAceDlDcFlDbIiEaXYYYaXbEgKdDgCdCgBgAfB'))]*25))

For even more fun, here's a pattern in Conway's Game of Life that generates a version of the Batman logo. I had to double each line to keep the aspect ratio roughly the same as the text version. This pattern doesn't really compute the logo (although it is possible to do computations in Life - it's Turing-complete), it just replays it from memory loops, so I guess I can't post it as a code golfing entry (although I did create it using a Python script I wrote a few years ago). ;)

It's encoded in a fairly standard RLE format that most Life engines can load. If you don't have a GoL program (eg Golly), you can view it in action online with this online Life engine, which can import Life RLE files. Here's a PNG version of that Life pattern, some Life programs (including Golly) can load Life patterns from PNGs and various other image file formats.

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

PHP, 137 bytes

<?=gzinflate(base64_decode(U1CAAy0FXECLC8YAAnQNyAJAwIVFIYSPRYgLLkWEYrByLS10WTwiXAgmcYCLRPV00kGyN6BhgB4eyABZjgstyqAsuDpU5YjEgJIOEKoQigE));

Try it online!

PHP, 177 bytes

foreach(["9zojk",a2878,aa4nb,b7u9z,chbf3,eze2n,jz6rj,jz6rj,jz6rj,eze2n,cepdr,ako8z,a1pc1]as$v)echo$t=strtr(substr(base_convert($v,36,2),1),10,"* "),"* "[$k++<2],strrev($t),"\n";

Try it online!

PHP, 179 bytes

for(;$o=ord(kAlgDjAbeDlCcFlCbIiDaWXXXaWbEgJdDgCdBgBgAfA[$i++]);($x+=$s)%24?:print$r.("* "[$k++<2]).strrev($r)."\n".$r="")$r.=strtr(str_repeat($b=+($o>96),$s=$o-64-$b*32),10," *");

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Your first example needs quotes \$\endgroup\$ – Steven Penny Jun 14 '17 at 2:18
  • 1
    \$\begingroup\$ @StevenPenny No it doesn't. Have checked the try it online link? \$\endgroup\$ – ovs Jun 14 '17 at 5:14
  • 1
    \$\begingroup\$ @StevenPenny In this case PHP use the cast of non-existing constants to strings. I only throws a Notice Error which is allowed in Codegolf. And the missing "=" at the end of the base64 encoded string will be add automatically \$\endgroup\$ – Jörg Hülsermann Jun 14 '17 at 9:48
4
\$\begingroup\$

Java, 296 214 bytes

Golfed:

()->{String r="";boolean b=1<0;for(int a:";1I1074:151:4054<7<4036<7<6029999901_10a10a10a01_0257E570447345437407271636172".toCharArray()){for(int i=0;i<a-48;++i)r+=(b?'*':' ');if(a<49)r+='\n';else b=!b;}return r;}

Ungolfed:

public class InHonorOfAdamWest {

  public static void main(String[] args) {
    System.out.println(f(() -> {
      String r = "";
      boolean b = 1 < 0;
      for (int a : ";1I1074:151:4054<7<4036<7<6029999901_10a10a10a01_0257E570447345437407271636172".toCharArray()) {
        for (int i = 0; i < a - 48; ++i) {
          r += (b ? '*' : ' ');
        }
        if (a < 49) {
          r += '\n';
        }
        else {
          b = !b;
        }
      }
      return r;
    }));
  }

  private static String f(java.util.function.Supplier<String> f) {
    return f.get();
  }
}
\$\endgroup\$
  • \$\begingroup\$ Could use ";1I1074:151:4054<7<4036<7<6029999901_10a10a10a01_0257E570447345437407271636172" for data, and for(char a:x){a=(int)a-48; [...] basically is adding 48 to each of the numbers and converting them to their ascii char equivalent. I believe this will save you 70-80 bytes. Also I believe hardcoding the data into the lamba will reduce bytes too. \$\endgroup\$ – Magic Octopus Urn Jun 14 '17 at 19:49
  • \$\begingroup\$ Also boolean b=false; can be boolean b=1<0, or even better you could use an int and also combine the declaration for i on the same line ;). \$\endgroup\$ – Magic Octopus Urn Jun 14 '17 at 19:52
  • 1
    \$\begingroup\$ @carusocomputing thanks, I did not think about packing it in a string. Yours had some bad Unicode value in it, I had to regenerate it and the output displays correctly now. \$\endgroup\$ – user18932 Jun 15 '17 at 18:56
  • \$\begingroup\$ Since you don't use i in your for loop i think you can use for(int i=0;i++<a-48;) as for-head. \$\endgroup\$ – Roman Gräf Jun 19 '17 at 6:05
3
\$\begingroup\$

Bubblegum, 75

xxd dump:

00000000: cd92 b501 8050 1043 fb4c 91fa efbf 1f0e  .....P.C.L......
00000010: 2f87 d371 5814 37d3 7c35 4d2b 1826 64f6  /..qX.7.|5M+.&d.
00000020: d8aa 419c 2a11 3e75 ce25 6d1e ee9d 22e0  ..A.*.>u.%m...".
00000030: bb11 f04f 0d7f 2e38 dfc8 6926 3dad 0871  ...O...8..i&=..q
00000040: f316 1071 6db8 fc07 a408 f7              ...qm......

Try it online.

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

Coffeescript (282 Bytes)

t=['6bk','59mw','l2j3','2ghsf','4zg2n','9zldr','jz6rj','4u7zz','165qf','47wj']
[0,1,2,3,4,5,6,6,6,5,7,8,9].map((d)->parseInt(t[d], 36).toString(2).padStart 25, '0').forEach (d)->console.log (d+d.split('').reverse().join('').substring(1)).replace(/0/g, ' ').replace(/1/g,'*')

Explaination (using plain-ol ES6)

  • Like other's mentioned, the image is symmetric, so we can toss out half of it in the encoding
  • Several lines are also repeated, so we can toss each line in a lookup table to save a few bytes
  • We convert each half-line into binary (using 0 as space and 1 as *), and encode it at that highest radix in Javascript (36), resulting in the encoding array.
  • First map takes each line and converts it back into its final output half-line, padding it with 0s
  • Second map concatenates each line with its reversed half (tossing the middle column the second time), and replaces the 0s and 1s with spaces and *s

var t = [
    '6bk',
    '59mw',
    'l2j3',
    '2ghsf',
    '4zg2n',
    '9zldr',
    'jz6rj',
    '4u7zz',
    '165qf',
    '47wj'
];
[0,1,2,3,4,5,6,6,6,5,7,8,9].map((d) => {
    return parseInt(t[d], 36).toString(2).padStart(25, '0');
})
.forEach((d) => {
    console.log((d + d.split('').reverse().join('').substring(1))
        .replace(/0/g, ' ')
        .replace(/1/g, '*'));
});

\$\endgroup\$
  • \$\begingroup\$ Cool answer! Welcome to the site! :) \$\endgroup\$ – DJMcMayhem Jun 19 '17 at 21:07
2
\$\begingroup\$

V, 102 bytes

i±³ *±± 
³ *± ´*· 
´*±² ´*µ 
´*±² ¶*³ 
µ*¹ ¹*  
²´* Ä3o²µ*jo±±*· µ*  
³*´ ³*· ´*´ 
**¶ *· **· Îæ$vp

Try it online!

Hexdump:

00000000: 69b1 b320 2ab1 b120 0ab3 202a b120 b42a  i.. *.. .. *. .*
00000010: b720 0ab4 2ab1 b220 b42a b520 0ab4 2ab1  . ..*.. .*. ..*.
00000020: b220 b62a b320 0ab5 2ab9 20b9 2a20 200a  . .*. ..*. .*  .
00000030: b2b4 2a20 1bc4 336f b2b5 2a1b 6a6f b1b1  ..* ..3o..*.jo..
00000040: 2ab7 20b5 2a20 200a b32a b420 b32a b720  *. .*  ..*. .*. 
00000050: b42a b420 0a2a 2ab6 202a b720 2a2a b720  .*. .**. *. **. 
00000060: 1bce e624 7670                           ...$vp

This uses run-length encoding to generate the following batman half:

             *           
   *          ****       
****            ****     
****            ******   
*****         *********  
************************ 
*************************
*************************
*************************
************************ 
***********       *****  
***    ***       ****    
**      *       **      

And then reverses and duplicates each line.

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

Python 2, 134 bytes

for w in'1D 4A13 4C4 6C4 995 O P P P O 57B 47343 27162'.split():r=''.join(c*int(k,36)for c,k in zip(3*'* ',w));print'%25s'%r+r[-2::-1]

Try it online!

Run-length encodes each line from the left half in base 36. Mirrors it to make the full line, which is printed. The leading spaces are not encoded; instead, the left half is padded to length 25.

\$\endgroup\$
  • \$\begingroup\$ I wish I could use that padding trick in my version... \$\endgroup\$ – PM 2Ring Jun 15 '17 at 15:34
2
\$\begingroup\$

Mathematica 151 Bytes

Uncompress@"1:eJxTTMoPCm5iYmBQQAAtBVxAK8bA0AjGBgJ0PcgCQABXjaoWwsciBFWPXRKrEESHlha6AjwiYC1apAGQHhK10FsTOV6Chgp6CCEDZDlYdKKKw6WR+OjxD+KiJBSEQoR6AC49ZiI="

Cheap and uncreative. The string is just from the built-in Compress command used on the required output.

Update:

I think I can do better with the built-in ImportString \ ExportString functions but I can't see to copy and paste the resulting strings from ExportString correctly. E.g.

b = "           *                         *\n       ****          *     *          ****\n     ****            *******            ****\n   ******            *******            ******\n  *********         *********         *********\n ***********************************************\n*************************************************\n*************************************************\n*************************************************\n ***********************************************\n  *****       *********************       *****\n    ****       ***    *****    ***       ****\n       **       *      ***      *       **"
ExportString[b,"GZIP"]
ImportString[%,"GZIP"]

I can not seem to copy the text output from the second line to replace the % in the third line.

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

Bash, 407 322 bytes

w=`yes 1|head -30|tr -d '\n'`
for i in B1C000 74A120 54C003 36C003 299004 1C0506 0D0506 0D0506 0D0506 1C0506 257505 447342 727161
{ read a b c d e f <<<$(echo $i| fold -1| xargs)
x=`printf "%.$[0x${a}]d%.$[0x${b}]s%.$[0x${c}]d%.$[0x${d}]s%.$[0x${e}]d%.$[0x${f}]s" 0 $w 0 $w 0 $w`
echo -n $x$[f<1?0:1]
rev<<<$x
}|tr 01 \ \*

Try it online!

really awful, need more time or help to golf it. it generates the output with 0 an 1 and transliterates in the end. Encoded in hexa digits the amount of 0 and 1, taking care to make last digit 0 for the first two rows as a flag to output middle column. Uses printf pressision to either digit or string to output 0 and 1. think the %.$[0x${X}]C pattern could be used to golf it.

w=`yes 1|head -30|tr -d '\n'`  # w=111111111111111111111111111111   
for i in B1C000 74A120 54C003 36C003 299004 1C0506 0D0506 0D0506 0D0506 1C0506 257505 447342 727161
{ read a b c d e f <<<$(echo $i| fold -1| xargs)
printf "%.$[0x${a}]d
%.$[0x${b}]s
%.$[0x${c}]d
%.$[0x${d}]s
%.$[0x${e}]d
%.$[0x${f}]s" 0 $w 0 $w 0 $w
echo -n $[f<1?0:1]
printf "%.$[0x${f}]s
%.$[0x${e}]d
%.$[0x${d}]s
%.$[0x${c}]d
%.$[0x${b}]s
%.$[0x${a}]d\n" $w 0 $w 0 $w 0 
}|tr 01 \ \*
\$\endgroup\$
2
\$\begingroup\$

Python 3, 232 197 183 164 bytes

Yet Another Python Answer. No boring compression code though. Exciting compression code.

for s in map(lambda x:x+x[-2::-1],b".$; *',$' ('.* &).* %,+, $R #T #T #T $R %()8 '')&&( *%)$(&".split()):print(*((u-35)*" "+(v-35)*"*"for u,v in zip(*[iter(s)]*2)))

I'm using the magic number 35 because that way, no control characters, spaces or things that would need to be escaped occur. Sad that I have to process the spaces and stars separately, that costs me a bit.

Ungolfed:

for s in map(lambda x:x+x[-2::-1],   # map a list to the list and itself reversed,
                                     # minus the last (center) element
# magic string:
".$; *',$' ('.* &).* %,+, $R #T #T #T $R %()8 '')&&( *%)$(&"
.split()):                           # split on whitespace to divide into lines
 print(*(                            # unpack generator expression
(ord(s[i])-35)*" "                   # convert character to int, -25, times space
+(ord(s[i+1])-35)*"*"                # same thing with "*"
for i in range(0,len(s)-1,2)))       # for every pair in the list
\$\endgroup\$
  • \$\begingroup\$ That encoding method's better than base 36. I hope you don't mind that I've adapted it for my latest solution. ;) There are a few things you can do to reduce your byte count. 1 You can save a byte by putting the print call on the same line as the for. 2 If you use a bytes string you can get rid of those ord calls. 3 You can replace the range by zipping over a pair of iterators. Here's a generator that combines both those ideas: ((u-35)*" "+(v-35)*"*"for u,v in zip(*[iter(s)]*2)). Those changes will bring your count down to 164. \$\endgroup\$ – PM 2Ring Jun 16 '17 at 9:24
  • \$\begingroup\$ @PM2Ring I don't mind at all. Going on vacation for a few weeks so feel free to edit in your changes. \$\endgroup\$ – L3viathan Jun 16 '17 at 9:26
  • \$\begingroup\$ Oh, ok. But I'll let you do the new un-golfed version. \$\endgroup\$ – PM 2Ring Jun 16 '17 at 9:27
  • \$\begingroup\$ @PM2Ring in a bus already, so I'll just hope someone else will approve it \$\endgroup\$ – L3viathan Jun 16 '17 at 9:33
2
\$\begingroup\$

PowerShell, 305 bytes, 307 bytes, 316 bytes

[IO.StreamReader]::new(([IO.Compression.GZipStream]::new([IO.MemoryStream]::new(([Convert]::FromBase64String('H4sIAAAAAAAEAL1SOQ4AIAjbTfwDc///QFE8gKAJi53sNQASbYBuQC3rxfANLTBm1iaFB9JIx1Yo9Tzg7YfCBeRQS7Lwr5IfZW7Cb0VDe3I8q25TcXvrTsyXOLGTbuHBUsBqAgAA')),0,102),[IO.Compression.CompressionMode]::Decompress))).ReadToEnd()

Maybe someone else can help me shorten it further, though I can't figure out how unless there's a more concise way to define a custom type accelerator.

Edit: Shortened version (thanks @root). Encoded string (pre base64 encoding) can be trimmed by eight array positions and the range can be thus decreased. Not sure why StreamWriter is introducing this bloat into the MemoryStream. Insight into the underlying behavior would be appreciated.

[IO.StreamReader]::new(([IO.Compression.GZipStream]::new([IO.MemoryStream]::new(([Convert]::FromBase64String('H4sIAAAAAAAEAL1SOQ4AIAjbTfwDc///QFE8gKAJi53sNQASbYBuQC3rxfANLTBm1iaFB9JIx1Yo9Tzg7YfCBeRQS7Lwr5IfZW7Cb0VDe3I8q25TcXvrTsyXOLGTbg')),0,94),[IO.Compression.CompressionMode]::Decompress))).ReadToEnd()

Ungolfed:

#Read decoded stream 
[IO.StreamReader]::new(
    (
        #Reverse GZip encoding
        [IO.Compression.GZipStream]::new(
            #Load GZip encoded string into a memory stream
            [IO.MemoryStream]::new(
                (
                    # Convert Base64 back to GZip encoded string
                    [Convert]::FromBase64String('H4sIAAAAAAAEAL1SOQ4AIAjbTfwDc///QFE8gKAJi53sNQASbYBuQC3rxfANLTBm1iaFB9JIx1Yo9Tzg7YfCBeRQS7Lwr5IfZW7Cb0VDe3I8q25TcXvrTsyXOLGTbuHBUsBqAgAA')
                ),
                #Start of range
                0,
                #End of range. Stick the Memory Stream into a variable and use .Length here for non golf code
                102
            ),
            #Specify that we are decompressing
            [IO.Compression.CompressionMode]::Decompress
        )
    )
).ReadToEnd()

Compression code:

$s = '           *                         *
       ****          *     *          ****
     ****            *******            ****
   ******            *******            ******
  *********         *********         *********
 ***********************************************
*************************************************
*************************************************
*************************************************
 ***********************************************
  *****       *********************       *****
    ****       ***    *****    ***       ****
       **       *      ***      *       **'

#Create Memory Stream
$ms = [IO.MemoryStream]::new()
#Initialize a stream
$sw = [IO.StreamWriter]::new(
    #Create GZip Compression stream
    [IO.Compression.GZipStream]::new(
        #Reference Memory Stream
        $ms,
        #Set mode to compress
        [IO.Compression.CompressionMode]::Compress
    )
)
#Write input into stream
$sw.Write($s)
#Close the stream
$sw.Close()

#Convert Array to Base64 string
[Convert]::ToBase64String(
    #Retrieve Memory Stream as an array
    ($ms.ToArray() | select -SkipLast 8)
)
\$\endgroup\$
  • 1
    \$\begingroup\$ Why 102? 99 works the same, [IO.StreamReader]::new(([IO.Compression.GZipStream]::new([IO.MemoryStream]::new(([Convert]::FromBase64String('H4sIAAAAAAAEAL1SOQ4AIAjbTfwDc///QFE8gKAJi53sNQASbYBuQC3rxfANLTBm1iaFB9JIx1Yo9Tzg7YfCBeRQS7Lwr5IfZW7Cb0VDe3I8q25TcXvrTsyXOLGTbuHBUsBqAgAA')),0,102),[IO.Compression.CompressionMode]::Decompress))).ReadToEnd() \$\endgroup\$ – root Jun 16 '17 at 15:40
  • \$\begingroup\$ @root it does, I guess but i'm not sure why that works. You can actually decrease it by eight to 94 and drop the last eight characters of the encoded input string. I'm having a hard time figuring out why this works and I don't want to add it to my answer until I do. Is my compression function erroneously adding in some extraneous padding somehow? \$\endgroup\$ – Chirishman Jun 16 '17 at 16:00
  • 1
    \$\begingroup\$ From your compression code, the last two values from $ms.ToArray() are both 0. Are they necessary? \$\endgroup\$ – root Jun 16 '17 at 16:13
  • \$\begingroup\$ No. And trying different input strings it seems consistent that it's exactly two unneeded array positions on the end. I'll add a clause to skip the last two to my compress script. Still wish I knew why stream writer was adding the nulls onto the end \$\endgroup\$ – Chirishman Jun 16 '17 at 16:24
  • 1
    \$\begingroup\$ You're right, it's more than just the 2 tail characters, it's 8. The last 8 positions in the array, ('225','193','82','192','106','2','0','0'), can be removed to create H4sIAAAAAAAEAL1SOQ4AIAjbTfwDc///QFE8gKAJi53sNQASbYBuQC3rxfANLTBm1iaFB9JIx1Yo9Tzg7YfCBeRQS7Lwr5IfZW7Cb0VDe3I8q25TcXvrTsyXOLGTbg==. I don't understand where they're coming from. \$\endgroup\$ – root Jun 16 '17 at 16:29
2
\$\begingroup\$

Perl 5, 168 bytes

$_="11 *25 
7 4*10 *5 *10 4
5 4*12 7*12 4
3 6*12 7*12 6
2 9*9 9*9 9
 47
49
49
49
 47
  5*7 21*7 5
4 4*7 3*4 5*4 3*7 4
7 **7 *6 3*6 *7 *";s/$/*/gm;say s/\d+(.)/$1x$&/ger

Note the trailing space at the end of only the first line. Requires -M5.01, which is free.

Can probably be golfed quite a bit more.

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

LaTeX, 314 bytes

\documentclass{book}\begin{document}\def\r#1#2{\ifnum#2>64#1\r#1{\numexpr#2-1}\fi}\catcode`.13\catcode`!13\catcode`-13\def!#1{\r*{`#1}}\def-#1{\r~{`#1}}\let.\par\tt-K!A-Y!A.-G!D-J!A-E!A-J!D.-E!D-L!G-L!D.-C!F-L!G-L!F.-B!I-I!I-I!I.-A!o.!q.!q.!q.-A!o.-B!E-G!U-G!E.-D!D-G!C-D!E-D!C-G!D.-G!B-G!A-F!C-F!A-G!B\enddocument

The ungolfed version with explanations:

\documentclass{book}
\begin{document}
% Macro for repeating #1 (#2-64) times
\def\r#1#2{\ifnum#2>64#1\r#1{\numexpr#2-1}\fi}
% Prepare '.', '!' and '-' for usage as macro names
\catcode`.13\catcode`!13\catcode`-13
% The ASCII code of #1 (a character) is used as the number of how often '*' will be printed with \r
\def!#1{\r*{`#1}}
% Same as ! but for spaces
\def-#1{\r~{`#1}}
% . becomes a line break
\let.\par
% Set monospace font
\tt
% And finally print the whole thing
-K!A-Y!A.-G!D-J!A-E!A-J!D.-E!D-L!G-L!D.-C!F-L!G-L!F.-B!I-I!I-I!I.-A!o.
!q.!q.!q.-A!o.-B!E-G!U-G!E.-D!D-G!C-D!E-D!C-G!D.-G!B-G!A-F!C-F!A-G!B
\enddocument
\$\endgroup\$
2
\$\begingroup\$

C# (.NET Core), 342 333 328 185 175 bytes

_=>{var r="";for(int i=0,j,k=0;i<63;i++)for(j=0;j++<"-#;#4&,#'#,&.&.).&*(.).('+++++%Q#µ#Q%')7)'(&)%&'&%)&-$)#(%(#)$)"[i]-34;){r+=i%2<1?' ':'*';if(++k%49<1)r+='\n';}return r;}

Try it online!

Lots of bytes saved after changing the approach. Taking the drawing as a 2D array, I calculated the RLE encoding by files:

{ 11, 1, 25, 1, 18, 4, 10, 1, 5, 1, 10, 4, 12, 4, 12, 7, 12, 4, 8, 6, 12, 7, 12, 6, 5, 9, 9, 9, 9, 9, 3, 47, 1, 147, 1, 47, 3, 5, 7, 21, 7, 5, 6, 4, 7, 3, 4, 5, 4, 3, 7, 4, 11, 2, 7, 1, 6, 3, 6, 1, 7, 2, 7 }

Odd indices stand for s and even indices stand for *s. Then I substituted every number for a printable ASCII representation (taking the '#' character as 1), and I got:

-#;#4&,#'#,&.&.).&*(.).('+++++%Q#µ#Q%')7)'(&)%&'&%)&-$)#(%(#)$)

So the algorithm just calculates the drawing by decompressing this string and adding newlines in the proper places.

\$\endgroup\$
  • 1
    \$\begingroup\$ No need to set l to a variable just use it in the loop directly. .ToString(i, 2) -> .ToString(i,2) i.e. remove the whitespace. \$\endgroup\$ – TheLethalCoder Jun 14 '17 at 10:48
  • \$\begingroup\$ Can you save any bytes with decimal or scientific (1e10) representations for those numbers? This challenge is actually helpful here. \$\endgroup\$ – TheLethalCoder Jun 15 '17 at 15:47
  • \$\begingroup\$ @TheLethalCoder nope. I just checked (impressive challenge, by the way) and I already use the smallest representation, so no luck there. I even tried finding the greatest common divisor between them to see if I could divide the numbers by a constant, but it's obviously 1. \$\endgroup\$ – Charlie Jun 15 '17 at 19:50
2
\$\begingroup\$

PowerShell, 129 128 bytes

-join('5+C+<.4+/+4.6.616.206160/33333-Y+s*t+Y-/1?1/0.1-./.-1.5,1+0-0+1,'|% t*y|%{(' ','*')[$i++%2]*($_-42)})-split'(.{49})'-ne''

Try it online!

Ungolfed:

-join(
    '5+C+<.4+/+4.6.616.206160/33333-Y+s*t+Y-/1?1/0.1-./.-1.5,1+0-0+1,'|% toCharArray|%{
        (' ','*')[$i++%2]*($_-42)
    }
)-split'(.{49})'-ne''

Output:

           *                         *           
       ****          *     *          ****       
     ****            *******            ****     
   ******            *******            ******   
  *********         *********         *********  
 *********************************************** 
*************************************************
*************************************************
*************************************************
 *********************************************** 
  *****       *********************       *****  
    ****       ***    *****    ***       ****    
       **       *      ***      *       **

Main idea is very simple

The Emblem Coding:

  1. Concatenate all emblem lines to one string
  2. Count spaces and asterisks
  3. Encode length of each segment + 42 as a char

Decoding (this script):

  1. Get code of the char minus 42 for each char from the cripto-string. This is a length of a segment
  2. Append segment, consisting of a space or asterisk repeated Length times
  3. Insert new line each 49 symbols to split lines

Some smart things

  1. The coding algorithm suggests a symbol with code 189 to display 3 middle asterisk lines. This symbol is not ASCII. It works normal with modern environments, but there are ambiguities with script length. So, I replace non-ascii-symbol ½ to s*t (73 asterisks, 0 spaces, 74 asterisks).
  2. I cut off right spaces in the last line to save 1 byte. Sorry, Batman.
  3. Why the offset is 42? Just wanted :) And cripto-string looks nice.

Extra: Scipt for coding of the Emblem

(@"
           *                         *           
       ****          *     *          ****       
     ****            *******            ****     
   ******            *******            ******   
  *********         *********         *********  
 *********************************************** 
*************************************************
*************************************************
*************************************************
 *********************************************** 
  *****       *********************       *****  
    ****       ***    *****    ***       ****    
       **       *      ***      *       **       
"@ -replace"`n"-split'( +|\*+)'-ne''|%{[char]($_.Length+42)})-join''
\$\endgroup\$
1
\$\begingroup\$

Mathematica, 271 bytes

T=Table;f[x_]:=""<>T["*",x];m={f@49};n={f@47};g[y_]:=""<>T[" ",y];k[a_,b_,c_,d_,e_]:={(s=f@a<>g@b<>f@c<>g@d<>f@e)<>StringDrop[StringReverse@s,1]};Grid@{k[1,13,0,0,0],k[4,10,1,3,0],k[4,12,0,0,4],k[6,12,0,0,4],k[9,9,0,0,5],n,m,m,m,n,k[5,7,0,0,11],k[4,7,3,4,3],k[2,7,1,6,2]}
\$\endgroup\$
1
\$\begingroup\$

Braingolf, 590 580 579 577 428 423 312 bytes

-111 bytes because LeakyNun is a golfing god

14#
46*6394943[92+.6,5][8]#.[# ]#*[# ]#*#
[# ][#*][# ]#*[# ]#*[# ]#*...#
[# ][#*][# ][#*][# ]#*...#
# ..[#*][# ][#*][# ][#*]#
# .[#*][# ][#*][# ][#*]#
# [#*]#
&@#0[#*]#
!&@!&@# &@#.[#*]"
  "&@4645*643646366556[#*][# ][#*][# ][#*]"
    "[#*][# ]#*..# ...[#*]# ...#*..[# ][#*]#
[# ]#*.[# ]#*[# ]#*..[# ]#*[# ]#*.&@

Try it online!

Braingolf is not good at ASCII art, but dammit I tried.

No way in hell am I explaining this clusterf**k

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

///, 171 166 bytes

5 bytes saved because I was using \r\n in the source, lol.

/-/  //,/!!//'/**//&/*"//%/--//#/,,,,,!*//"/%-//!/''/"% &""" *
" !"%*% &%!
% !""!'&"!
- !*&"!'&"!'
-,&- ,&- ,*
 #'
!#
!#
!#
 #'
-!& ,,!& !*
%!" '*%!*%'& !
" *& &'&& '

Try it online!

Compressed by using successive iterations of replacing the "most economical" substrings with a single character. This is nearly optimal, though one of two things could be the case:

  1. I could get away with using some meta replacements (e.g. dynamically insert regexes)
  2. It is somehow more beneficial to replace less economical substrings first (unlikely).
\$\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.