6
\$\begingroup\$

Introduction

Here at code colf SE, we appear to love meta-problems. Here, I've tried to compose a meta-problem that's an interesting, not-straightforward challenge.

Challenge

The answer code is allowed to read its own source code, but not allowed to use external resources.

All characters should be 5-lines tall. Characters used in the ascii representation are also not important, though they must be visible. Each visible character in the output will count as one byte, regardless of cheaty byte-values. Spaces used in the code are necessary, and may be only one byte wide if desired.

Lowest Byte Count of the output wins. Output must exist and include at least 1 visible byte.

Example Input and Output

Input:

For an example code:

print theanswer

One possible answer is:

Output:

PPPP  RRRR  III N   N TTTTTT  TTTTTT H  H EEEE   AA  N   N  SSS  W     W EEEE RRRR 
P   P R   R  I  NN  N   TT      TT   H  H E     A  A NN  N S     W     W E    R   R
PPPP  RRRR   I  N N N   TT      TT   HHHH EEE   AAAA N N N  SSS  W  W  W EEE  RRRR 
P     R R    I  N  NN   TT      TT   H  H E     A  A N  NN     S  W W W  E    R R  
P     R  RR III N   N   TT      TT   H  H EEEE  A  A N   N SSSS    W W   EEEE R  RR

The alphabet used should consist of the following patterns, the characters used are not important: :

 AA  BBBB   CCC DDD  EEEE FFFF  GGG  H  H III     J K  K L    M   M N   N  OOO  PPPP   QQQ   RRRR   SSS  TTTTTT U   U V     V W     W X   X Y   Y ZZZZZ
A  A B   B C    D  D E    F    G     H  H  I      J K K  L    MM MM NN  N O   O P   P Q   Q  R   R S       TT   U   U V     V W     W  X X   Y Y     Z 
AAAA BBBB  C    D  D EEE  FFF  G  GG HHHH  I      J KK   L    M M M N N N O   O PPPP  Q   Q  RRRR   SSS    TT   U   U  V   V  W  W  W   X     Y     Z  
A  A B   B C    D  D E    F    G   G H  H  I  J   J K K  L    M   M N  NN O   O P     Q  Q   R R       S   TT   U   U   V V    W W W   X X    Y    Z   
A  A BBBB   CCC DDD  EEEE F     GGG  H  H III  JJJ  K  K LLLL M   M N   N  OOO  P      QQ Q  R  RR SSSS    TT    UUU     V      W W   X   X   Y   ZZZZZ




 11   22  333  4  4 5555   6   77777  888   9999  000       //!!!  @@@   # #  %   %%  ^^   &&    ((  ))                                                
111  2  2    3 4  4 5     6       7  8   8 9   9 0  00     // !!! @   @ #####    %%  ^  ^ &  &  ((    ))                                              
 11    2   33  4444 555  6666    7    888   9999 0 0 0    //  !!! @  @@  # #    %%         &&& &((    ))                                         
 11   2      3    4    5 6   6   7   8   8    9  00  0   //       @     #####  %%         & & & ((    ))                                              
11l1 2222 333     4 555   666    7    888    9    000   //    !!!  @@@   # #  %%   %       &&&&  ((  ))   ____

For other characters, the equivalent produced by this generator using the 'Alphabet' font will be acceptable. If the output generated by the tool is more than 5 characters tall, use the central 5 characters for output.

Edit - I've allowed the program to read its own source code to possibly open this question up to interesting answers.

\$\endgroup\$
  • 7
    \$\begingroup\$ You should precisely describe the "font" to be used, otherwise you'll have lots of people deciding separately whether W needs to be 6 or 5 or fewer columns wide, etc. \$\endgroup\$ – Sparr May 8 '15 at 21:31
  • 1
    \$\begingroup\$ Commonly these types of problems forbid a program from reading its own source code (or external resources and such). Is this the case here, and if so can you specify so in the problem. \$\endgroup\$ – KSab May 8 '15 at 21:36
  • 2
    \$\begingroup\$ Are spaces necessary, I don't see them in the example? \$\endgroup\$ – Maltysen May 8 '15 at 21:41
  • 1
    \$\begingroup\$ @ThomasCleberg The A looks like it's missing a space on the first line (` AA ` would look better than the current AA ) \$\endgroup\$ – user34736 May 9 '15 at 8:32
  • 1
    \$\begingroup\$ Edited to include these instructions. \$\endgroup\$ – Thomas Cleberg Jul 21 '16 at 16:47
3
\$\begingroup\$

Python 2, 2142 bytes

Should work, it's pretty confusing to read the output.

n=["","","","",""]
t=["EEEE","E  E","EEE ","E   "," EE "," E "," EEE ","E   E","E    ","  EE  ","EEEE "," EEEE","   ","EEE","     ","EE EE","    "]
e=[[t[4],t[1],t[0],t[1],t[1]],[t[2],t[1],t[1],t[1],t[2]],[t[0],t[3],t[2],t[3],t[0]],[t[0],t[3],t[2],t[3],t[3]],[t[6],t[8],"E  EE",t[7],t[6]],["EEE",t[5],t[5],t[5],"EEE"],[t[3],t[3],t[3],t[3],t[0]],[t[7],"EE  E","E E E","E  EE",t[7]],[t[6],t[7],t[7],t[7],t[6]],[t[10],t[7],t[10],t[8],t[8]],[t[10],t[7],t[10],"E E  ","E  EE"],[t[6],"E    ",t[6],"    E",t[6]],["E"*6,t[9],t[9],t[9],t[9]],[t[4],t[2],t[4],t[4],t[0]],[t[4],t[1],"  E "," E  ",t[0]],[t[2],"   E",t[4],"   E",t[2]],[t[1],t[1],t[0],"   E","   E"],[t[0],t[3],t[2],"   E",t[2]],["  E  "," E   ",t[10],t[7],t[6]],["EEEEE","   E ","  E  ","  E  ","  E  "],[t[6],t[7],t[6],t[7],t[6]],[t[11],t[7],t[11],"   E ","  E  "],[t[6],"E  EE","E E E","EE  E",t[6]],["EE    "," EE   ","  EE  ","   EE ","    EE"],[t[12],t[13],t[12],t[13],t[12]],[t[0],"EE  ","EE  ","EE  ",t[0]],[t[0],"  EE","  EE","  EE",t[0]],[t[15],t[15],t[14],t[14],t[14]],["  ","  ","  ","  ","EE"],[" EE","EE ","EE ","EE "," EE"],["EE "," EE"," EE"," EE","EE "],[t[12],t[5],t[13],t[5],t[12]],[t[16],t[16],t[16],t[16],t[0]],["  ","EE","  ","EE","  "],["  ","EE","  ","EE"," E"]]
def s(i):
 if i==" ":r()
 if i=="a":g(e[0])
 if i=="d":g(e[1])
 if i=="e"or i=="E":g(e[2])
 if i=="f":g(e[3])
 if i=="g":g(e[4])
 if i=="i":g(e[5])
 if i=="l":g(e[6])
 if i=="n":g(e[7])
 if i=="o":g(e[8])
 if i=="p":g(e[9])
 if i=="r":g(e[10])
 if i=="s":g(e[11])
 if i=="t":g(e[12])
 if i=="1":g(e[13])
 if i=="2":g(e[14])
 if i=="3":g(e[15])
 if i=="4":g(e[16])
 if i=="5":g(e[17])
 if i=="6":g(e[18])
 if i=="7":g(e[19])
 if i=="8":g(e[20])
 if i=="9":g(e[21])
 if i=="0":g(e[22])
 if i=="\\":g(e[23])
 if i=="=":g(e[24])
 if i=="[":g(e[25])
 if i=="]":g(e[26])
 if i=="\"":g(e[27])
 if i==",":g(e[28])
 if i=="(":g(e[29])
 if i==")":g(e[30])
 if i=="+":g(e[31])
 if i=="_":g(e[32])
 if i==":":g(e[33])
 if i==";":g(e[34])
 r()
def g(p):
 for i in range(5):n[i]+=p[i]
def r():g([" "," "," "," "," "])
for l in open(__file__).read().split("\n"):
 for i in l:s(i)
 print"\n".join(n);n=["","","","",""]

Output is 47965 bytes.

Can probably be golfed a lot more.

The code above uses half of the alphabet, all numbers and some symbols/special characters. I used the letter E for the output.

The characters are a list of five strings, each for one line. Also, to save a few bytes, there's a list with common lines ("EEEE", "E E", etc.)

The , has two lines, and one of them is below most characters, so I only included the upper one (same for underscore).

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

Perl 5, 266

34721 bytes code, 177815 total bytes of output, 266 bytes of which are non-whitespace.

eval'                                                                                                                  	                                                                                                	                                                                                                                        	                               	                                                                                                                	                                                                                                                          	                                                                    	                                                                    	                                                                    	                                                                    	                               	                                                                                     	                               	                               	                               	                               	                               	                                                                                     	                               	                               	                                                                	                                                                	                               	                               	                                                                           	                               	                               	                               	                               	                                      	                                      	                               	                                                                                              	                               	                                      	                                      	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                                                                                  	                                                                                  	                                                                                  	                               	                               	                                      	                                      	                               	                               	                               	                               	                               	                               	                               	                               	                                      	                                      	                               	                               	                                                                  	                                                                  	                                                                  	                               	                                                                       	                               	                               	                                                                       	                               	                                                                                 	                                                                                 	                                                                                 	                                                                                 	                               	                               	                               	                                                                           	                               	                               	                               	                               	                                                                    	                                                                    	                                                                    	                                                                    	                               	                                                                             	                               	                               	                               	                                                                             	                               	                               	                                                                      	                                                                      	                                                                      	                               	                               	                                                                                   	                                                                                   	                                                                                   	                                                                                   	                                                                                   	                                                                                   	                               	                                                                       	                               	                               	                                                                       	                               	                               	                                   	                                   	                                   	                               	                               	                               	                                     	                                     	                               	                               	                               	                               	                                      	                                      	                               	                               	                                                                      	                                                                      	                                                                      	                               	                               	                                                                    	                                                                    	                                                                    	                                                                    	                               	                                                                                 	                                                                                 	                                                                                 	                                                                                 	                               	         	                                                                    	                               	                               	                               	                               	                                                                                     	                               	                               	                               	                               	                               	                                                                                     	                               	                                                                	                               	                               	                                                                	                               	                                                                           	                               	                               	                               	                               	                                      	                                      	                               	                                                                                              	                               	                                      	                                      	                               	                                                            	                                                            	                                                            	                               	                               	                                                                                                                             	                               	                                                                                                                             	                               	                                                                                  	                               	                               	                               	                               	                               	                                      	                                      	                               	                               	                               	                                          	                               	                               	                               	                               	                                      	                                      	                               	                                                                  	                               	                               	                               	                               	                                                                       	                               	                               	                                                                       	                               	                                                                                 	                               	                               	                               	                                                                                 	                               	                               	                                                                           	                               	                               	                               	                               	                                                                    	                               	                               	                               	                               	                                                                             	                                                                             	                               	                               	                                                                             	                               	                                                                      	                               	                               	                               	                               	                               	                               	                               	                                                                                   	                                                                                   	                               	                               	                               	                                                                       	                               	                               	                                                                       	                               	                                   	                               	                                   	                               	                               	                               	                                     	                               	                               	                                     	                               	                               	                               	                                      	                                      	                               	                                                                      	                               	                               	                               	                               	                               	                                                                    	                               	                               	                               	                               	                                                                                 	                               	                               	                               	                                                                                 	         	                                                                    	                                                                    	                                                                    	                               	                               	                               	                                                                                     	                               	                               	                               	                                                                                     	                               	                               	                                                                	                                                                	                                                                	                                                                	                               	                                                                           	                               	                               	                               	                               	                               	                               	                               	                                                                                              	                               	                               	                               	                               	                               	                               	                               	                               	                                                                                                                             	                               	                                                                                                                             	                               	                               	                               	                                                                                  	                                                                                  	                                                                                  	                               	                               	                               	                               	                               	                               	                                          	                                          	                                          	                               	                               	                               	                               	                               	                               	                                                                  	                               	                               	                               	                               	                                                                       	                                                                       	                                                                       	                                                                       	                               	                                                                                 	                                                                                 	                                                                                 	                                                                                 	                               	                               	                               	                                                                           	                               	                               	                               	                               	                                                                    	                                                                    	                                                                    	                               	                               	                                                                             	                               	                                                                             	                               	                                                                             	                               	                                                                      	                               	                               	                                                                      	                                                                      	                               	                               	                               	                                                                                   	                                                                                   	                               	                               	                               	                                                                       	                                                                       	                                                                       	                                                                       	                               	                               	                                   	                                   	                                   	                               	                               	                               	                                     	                                     	                                     	                               	                                     	                               	                               	                               	                               	                                                                      	                               	                               	                                                                      	                                                                      	                               	                                                                    	                                                                    	                                                                    	                               	                               	                                                                                 	                                                                                 	                                                                                 	                                                                                 	                               	         	                                                                    	                               	                               	                               	                               	                               	                               	                                                                                     	                               	                                                                                     	                               	                               	                               	                                                                	                               	                               	                                                                	                               	                                                                           	                               	                               	                               	                               	                               	                               	                               	                                                                                              	                               	                               	                               	                               	                                                            	                                                            	                                                            	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                                                                                  	                               	                               	                               	                               	                               	                               	                                          	                               	                               	                               	                               	                               	                               	                               	                                                                  	                               	                               	                               	                               	                                                                       	                               	                               	                                                                       	                               	                                                                                 	                               	                                                                                 	                               	                               	                               	                               	                                                                           	                               	                               	                               	                               	                                                                    	                               	                               	                               	                               	                                                                             	                               	                               	                                                                             	                                                                             	                               	                                                                      	                               	                               	                               	                                                                      	                               	                               	                               	                                                                                   	                                                                                   	                               	                               	                               	                                                                       	                               	                               	                                                                       	                               	                               	                               	                                   	                               	                                   	                               	                                     	                               	                                     	                               	                                     	                               	                               	                               	                               	                               	                                                                      	                               	                               	                               	                                                                      	                               	                                                                    	                               	                               	                               	                               	                                                                                 	                               	                                                                                 	                               	                               	         	                                                                    	                                                                    	                                                                    	                                                                    	                               	                               	                               	                               	                                                                                     	                               	                               	                               	                               	                                                                	                               	                               	                                                                	                               	                                                                           	                                                                           	                                                                           	                                                                           	                               	                               	                               	                               	                                                                                              	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                                                                                  	                                                                                  	                                                                                  	                                                                                  	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                               	                                                                  	                                                                  	                                                                  	                               	                                                                       	                               	                               	                                                                       	                               	                                                                                 	                               	                               	                                                                                 	                                                                                 	                               	                               	                                                                           	                                                                           	                                                                           	                                                                           	                               	                                                                    	                                                                    	                                                                    	                                                                    	                               	                                                                             	                               	                               	                               	                                                                             	                               	                               	                                                                      	                                                                      	                                                                      	                               	                               	                               	                               	                                                                                   	                                                                                   	                               	                               	                               	                                                                       	                               	                               	                                                                       	                               	                                   	                                   	                                   	                                   	                               	                               	                               	                                     	                                     	                                     	                                     	                               	                               	                               	                               	                               	                               	                                                                      	                                                                      	                                                                      	                               	                               	                                                                    	                                                                    	                                                                    	                                                                    	                               	                                                                                 	                               	                               	                                                                                 	                                                                                 	                                                                                                                            	                                                            	                                                                                                                             	                                                                                                                  	                                              	                                                                                              	                                              	                                   	                                 	                                                                                                                       	                                                  	                                                    	                                                   	                                                 	                                                	                                              	                                                                                                      	                                                                                                    	                                                                                                                 	         	'=~s' +\t'chr length$&'ger

Based on the scoring confirmed by @Thomas Cleberg, something like this is likely optimal, but feels a little cheaty. This encodes a program that prints the desired output as space and tab characters, which are replaced with the result of running ord on the length of each run (spaces, terminated by a tab). To cater for this in the output, each tab is represented with two spaces (over the five lines) and all spaces are shown as described above.

TIO limits the output to 128KiB so you can't see it all there, but if you run this program locally, it should work as expected. Something like:

perl -M5.010 metascii-code-golf.pl > metascii-code-golf.txt

and view metascii-code-golf.txt in a text editor with word-wrap disabled.

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ Better late than never! Nevertheless, very great answer! \$\endgroup\$ – Dada Aug 10 '16 at 12:29
  • \$\begingroup\$ @Dada thanks! I'm hoping to get the output down further as I've really enjoyed this challenge. Sad I missed it when it was first posted, but glad I caught it when it was updated recently! \$\endgroup\$ – Dom Hastings Aug 10 '16 at 12:39

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.