METAscii Code Golf

6

2

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.

Thomas Cleberg

Posted 2015-05-08T21:21:34.443

Reputation: 185

7You 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. – Sparr – 2015-05-08T21:31:34.837

1Commonly 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. – KSab – 2015-05-08T21:36:12.000

2Are spaces necessary, I don't see them in the example? – Maltysen – 2015-05-08T21:41:29.910

So we can no longer just use *? – Tim – 2015-05-08T21:44:00.033

edited for these questions- spaces existing in the code are necessary and can be as small as one bit wide. You can use any character in place of the alphanumerics used in the font. – Thomas Cleberg – 2015-05-08T21:47:55.183

1@ThomasCleberg The A looks like it's missing a space on the first line (AA would look better than the current AA) – None – 2015-05-09T08:32:21.990

Ew... the $ generated by the linked page is 7 lines tall instead of 5. :( – Jordan – 2016-07-21T16:32:03.897

Does the middle 5 lines of that character seem like a reasonable solution? – Thomas Cleberg – 2016-07-21T16:36:17.933

Seems reasonable to me! – Jordan – 2016-07-21T16:43:08.613

1Edited to include these instructions. – Thomas Cleberg – 2016-07-21T16:47:34.287

Here's another odd one: underscore is four blank lines followed by two lines of four underscores (and no trailing space). – Jordan – 2016-07-21T16:52:36.363

1Let's call that one 4 underscores at the bottom of a 5x4 block. I will edit it into the description when at a computer. – Thomas Cleberg – 2016-07-21T17:01:57.980

No- boring loopholes are boring. – Thomas Cleberg – 2016-08-09T13:16:03.897

Also, specifically has to have at least one visible character in the output as specified. – Thomas Cleberg – 2016-08-09T13:17:42.953

I didn't (and still don't) see the 1 in the output. Please note that spaces are significant characters in the output and must be represented as well :) Interesting loopholes are interesting! – Thomas Cleberg – 2016-08-09T14:08:42.473

Ah, I see it now. This is a valid answer once the spaces involved are represented in the output (by an at-least 1w,5h set of spaces per space in the source), and likely close to an optimal solution, though ^ and L use fewer characters in the output. White space is not included in the score calculation, but is required in the output. – Thomas Cleberg – 2016-08-09T14:18:12.520

Whitespace's winning – l4m2 – 2018-04-11T15:05:38.237

Answers

3

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

acrolith

Posted 2015-05-08T21:21:34.443

Reputation: 3 728

3

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!

Dom Hastings

Posted 2015-05-08T21:21:34.443

Reputation: 16 415

1Better late than never! Nevertheless, very great answer! – Dada – 2016-08-10T12:29:54.650

@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! – Dom Hastings – 2016-08-10T12:39:52.240