90
\$\begingroup\$

The challenge is actually extremely simple. Pick 5 distinct letters (you can just pick the 5 that allow you the shortest code if you like) and output them to the console. However, the twist is that they must be from the following list:

 AAA      BBBB       CCCC     DDDD      EEEEE     FFFFF      GGG      H   H
A   A     B   B     C         D   D     E         F         G         H   H
AAAAA     BBBB      C         D   D     EEEE      FFFF      G  GG     HHHHH
A   A     B   B     C         D   D     E         F         G   G     H   H
A   A     BBBB       CCCC     DDDD      EEEEE     F          GGG      H   H


IIIII         J     K   K     L         M   M     N   N      OOO 
  I           J     K  K      L         MM MM     NN  N     O   O
  I           J     KKK       L         M M M     N N N     O   O
  I       J   J     K  K      L         M   M     N  NN     O   O
IIIII      JJJ      K   K     LLLLL     M   M     N   N      OOO 


PPPP       QQQ      RRRR       SSSS     TTTTT     U   U     V   V     W   W
P   P     Q   Q     R   R     S           T       U   U     V   V     W   W
PPPP      Q   Q     RRRR       SSS        T       U   U     V   V     W   W
P         Q  QQ     R  R          S       T       U   U      V V      W W W
P          QQQQ     R   R     SSSS        T        UUU        V        W W 


X   X     Y   Y     ZZZZZ
 X X       Y Y         Z 
  X         Y         Z  
 X X        Y        Z   
X   X       Y       ZZZZZ

Additional Rules:

  • 5 of the same letter is not allowed, no repeat choices.
  • Each letter must use the capital of itself as the ascii-character to draw it.
  • Each letter output must be on the "same line" and have 5 spaces between each letter.
  • You may choose any 5 letters that you want, this will allow you to reuse some code and lower your byte count. Figuring out which letters will allow you to do this most efficiently is part of the challenge.
  • Trailing spaces are acceptable.
  • A single trailing newline is acceptable, no more than one trailing newline though.
  • This is code-golf, lowest byte-count wins.

Examples:

A B C D E

 AAA      BBBB       CCCC     DDDD      EEEEE
A   A     B   B     C         D   D     E    
AAAAA     BBBB      C         D   D     EEEE 
A   A     B   B     C         D   D     E    
A   A     BBBB       CCCC     DDDD      EEEEE

E F L I P

EEEEE     FFFFF     L         IIIII     PPPP 
E         F         L           I       P   P
EEEE      FFFF      L           I       PPPP 
E         F         L           I       P    
EEEEE     F         LLLLL     IIIII     P    

C R A Z Y

 CCCC     RRRR       AAA      ZZZZZ     Y   Y
C         R   R     A   A        Z       Y Y 
C         RRRR      AAAAA       Z         Y  
C         R  R      A   A      Z          Y  
 CCCC     R   R     A   A     ZZZZZ       Y  

Don't be afraid to submit more than one answer with different letters or different strategies each time, this can be accomplished various different ways.

\$\endgroup\$
  • 21
    \$\begingroup\$ I like that you get to choose which letters to output; that adds another layer to the golfing. Minor issues with the ASCII art: there's a ton of trailing spaces, and two Js. \$\endgroup\$ – ETHproductions Nov 15 '16 at 15:16
  • 2
    \$\begingroup\$ Can you add a bonus for taking 5 letters as input? \$\endgroup\$ – Mukul Kumar Nov 15 '16 at 18:22
  • 5
    \$\begingroup\$ Bonuses are frowned upon and there are too many answers to make a drastic change such as that. But I will give you an upvote ;). \$\endgroup\$ – Magic Octopus Urn Nov 15 '16 at 19:05
  • 1
    \$\begingroup\$ @Titus I don't know why you'd need them; trailing makes more sense. If you can logically explain how a limitation of the language you are using and not the logic you've written is causing a leading \n, I will allow it. \$\endgroup\$ – Magic Octopus Urn Nov 18 '16 at 14:26
  • 1
    \$\begingroup\$ @Titus then no. The trailing newlines and spaces are due to programmatic limitations of certain languages. \$\endgroup\$ – Magic Octopus Urn Nov 18 '16 at 17:31

46 Answers 46

1
\$\begingroup\$

PHP, 246 bytes (EFOIH)

$q='~([A-Z';$r='preg_replace';$c=$r.'_callback';$m=' 7I 7O"';$v='E 9F 9H"'.$m;echo $r("$q])\"~", '$1   $1', $c("$q\s])([1-9])~",function($m){return str_repeat($m[1],$m[2]);},'E5 5F5 5H" 5I5 6O3
'.$v.'
E4 6F4 6H5'.$m.'
'.$v.'
E5 5F 9H" 5I5 6O3'));

Which prints:

EEEEE     FFFFF     H   H     IIIII      OOO
E         F         H   H       I       O   O
EEEE      FFFF      HHHHH       I       O   O
E         F         H   H       I       O   O
EEEEE     F         H   H     IIIII      OOO
\$\endgroup\$
1
\$\begingroup\$

Scala, 122 bytes (DIOCL)

()=>{val t="DDDDgIIIIIgOOOhCCCCfL"
val m="DdDhIhOdOfCjL\n"
t+"\n"+m+m+m+t+"L"*4 map(c=>if(c<90)c else " "*(c-97))mkString}

Explanation:

()=>{                          //define an anonymous function with no args
  val t="DDDDgIIIIIgOOOhCCCCfL"  //define these strings
  val m="DdDhIhOdOfCjL\n"
  t+"\n"+m+m+m+t+"L"*4           //return this string
    map(c=>                        //map each char...
      if(c<90)                       //if it's an uppercase letter
        c                              //...to itself
      else                           //else
        " "*(c-97)                     //...to a space repeated (the index of c in the latin alphabet) times
    )mkString}                     //and join the mix of chars and strings together
\$\endgroup\$
1
\$\begingroup\$

PHP, 124 bytes (ABCDE+FHOPSTU)

This version works for all characters where the middle three pixels are either all set or all empty, except for J, which would require an additional case for the ternary mapping.

for(;$x="2636755454764565545456367"[$i];)echo strtr(sprintf("%5b     ",($x&7)+($x>5?24:12)),[" ",ABCDE[$i%5]]),"\n"[++$i%5];

The string contains octal representations of the character lines; the middle bit is used three times: ($x&7)+($x>5?24:12) is short for (4&$x)*4|($x&2)*7|$x&1, but that does not work for 001.

sprintf converts to binary (it is shorter here to add the 5 spaces literally than shifting the number (that would require additional parentheses);
and strtr replaces 0 with space and 1 with the letter, like in my other answer.


Again, looping through a string saves a couple of bytes from looping through an array of integers,
in this case 20 bytes.

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

PHP, 123 bytes (TIDOC)

I wanted a purely calculating variant ... ITDOC would have cost another 7 bytes, unfortunately.

for(;$i<25;)echo strtr(sprintf("%10b",$i>4&$i<21?$p>1?18.5-$p/2:4:($p>2?$p+11:31.5-$p/2)),[" ",TIDOC[$p]]),"\n"[$p=++$i%5];

the .5s ruin it all ... nothing saved from the partly mapping version:

for(;$i<25;)echo strtr(sprintf("%10b",($i>4&$i<21?[4,4,17,17,16]:[31,31,30,14,15])[$p=$i++%5]),[" ",TIDOC[$p]]),"\n"[$p<4];
\$\endgroup\$
1
\$\begingroup\$

PHP, 109 bytes (LHKNM+BDEFP)

Talking about looping over a single value ... take a hex string as value (LHKNM):

for(;$i<25;)echo strtr(decbin(16+hexdec("011110129b0fc5501231f1111"[$i])<<5),[" ",LHKNN[$i%5]]),"\n"[++$i%5];

PHP, 122 bytes

foreach([4369,4763,64597,4657,987409]as$x)for($i=5;$i--;$x>>=4)echo strtr(decbin(512|32*$x&480),[" ",LHKMN[$i]]),"\n"[$i];

This exploits that all used letters have all pixels set in the first column:

The integer array holds the values for the other pixels converted from binary to decimal.
I didn´t test, but I think I have the shortest decimals possible.

In the loop body, the missing first column and the 5 spaces are added to the value before converting it back to binary; after that, 0 is replaced with space and 1 with space the letter (MNKHL).


I just noticed: If I had a 128 bit system; I could do a single loop over just one value :D

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

CJam, 46 bytes, FPLHB

"\x1ca-8
6"512b4b{2bEbG+32*2b}%5/"FPLHB"f.f{S?}N*

Replace \x1c with the actual byte.

Try it online!

Output:

DDDDD     PPPP      L         H   H     BBBB      
D         P   P     L         H   H     B   B     
DDDD      PPPP      L         HHHHH     BBBB      
D         P         L         H   H     B   B     
D         P         LLLLL     H   H     BBBB      

This seems golfable.

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

Python 3, 153 138 136 133 130 bytes

for l in"ffffbjfff blbhblbhb eibhblbhe blbhblbhb bjfffhbhf".split():print("".join("F I L T E"[i]*(ord(l[i])-97)for i in range(9)))

or for 128 bytes

for l in"           ".split(" "):print("".join("F I L T E"[i]*ord(l[i])for i in range(9)))

this uses the first 11 characters instead, which don't show up on stackoverflow, this does compile and run though.

Output:

FFFFF     IIIII     L         TTTTT     EEEEE
F           I       L           T       E
FFFF        I       L           T       EEEE
F           I       L           T       E
F         IIIII     LLLLL       T       EEEEE

This is a quick attempt, I was thinking of seeing if I could generate the numbers in the list without just writing them out. I picked letters which didn't had any "gaps" horizontally (e.g. H wouldn't work) which are FILTECZ.

Annoyingly it's lengthened by some of the gaps being 11 (two characters), not sure if there's a combination with makes it only gaps 9 and less, would shorten it to 125 chars

saved some bytes by using adding i%2*3

saved 2 bytes by using split() instead of a list

saved 3 bytes by using ord instead of i%2*3, would be great if I didn't have to -97 but using the first characters doesn't seem to work with split() well

saved 2 bytes by using range instead of enumerate

can save 2 bytes by using the first characters, to generate the string required you can use the following code snippet, but I'm not sure if this is allowed!

alpha="".join(chr(i) for i in range(20))
def convert(s):
    new_s = ""
    for c in s:
        if c == " ":
            new_s += c
        else:
            n = 11
            if c != "x": n = int(c)
            new_s += alpha[n]
    return new_s
print(convert("555519555 1x171x171 48171x174 1x171x171 195557175"))
\$\endgroup\$
  • \$\begingroup\$ L before Move L after T and all 11 gaps are removed. \$\endgroup\$ – Magic Octopus Urn Nov 21 '16 at 14:32
  • \$\begingroup\$ @carusocomputing second row F to I would still be 11 \$\endgroup\$ – Billyoyo Nov 21 '16 at 17:08
  • \$\begingroup\$ Errr, I know there's a combination of those letters that does accomplish it. My initial strategy was the exact same as yours. \$\endgroup\$ – Magic Octopus Urn Nov 21 '16 at 17:11
  • \$\begingroup\$ there are combinations that would allow for this, but due to the way I've done it, the first character has to have a straight vertical edge at the start, so there are no leading spaces (like F). Because of this I don't think it's possible to get below 11. \$\endgroup\$ – Billyoyo Nov 21 '16 at 18:27
1
\$\begingroup\$

Jelly, 43 bytes

Bs5ŒḄ;ÆP$×
“BỊ“z£“qġ“z¤“Eḃ’ç"5R¤o-51+83ỌẎZY

Try it online!

Maybe this could be shorter, I'm not good at compressing stuff in Jelly.

Bs5                   Convert to binary, split into three 5-bit chunks.
   ŒḄ                 Bounce: turn [α, β, γ] into [α, β, γ, β, α].
     ;ÆP$             Concat by is-prime. This turns our 5×5 binary matrix
                        into a 10×5 binary matrix, padding with zeroes.
         ×            Multiply by the right argument.

“BỊ“z£“qġ“z¤“Eḃ’      The list 16927,30753,28737,30754,17732.

…ç"5R¤                Do the above with those numbers and [1, 2, 3, 4, 5].
      o-51+83Ọ        Map the resulting matrices to spaces and “TUVWX”.
              ẎZY     Stitch them together, and join by newlines.

I thought to make use of the fact that TUVWX is an adjacent run of letters where each letter has horizontal symmetry, making it easy to encode (15 bits per letter).

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

brainfuck, 380 371 bytes

Edit: -9 bytes by switching to multiples of 17 and combining printing the first line with correcting the offsets

+[>-[-<]>>]>+[>++++>+++++>++>++++>+++++>++++>+[<]>-]>+.....>->--.....<.....>......>-....<......>>--....<<.....>>>++.....>-------.[<]>.>>...........<.>....... >.<.........>>.<<.........>>>.>.[<]>....>>........<.>.......>.<..........>>...<<......>>>....>.[<]>.>>...........<.>.......>.<.............>>.<<.....>>>.>.[<]>.....>>.......<.>........>....<.....>>....<<......>>>.

Try it online!

Output:

EEEEE     TTTTT      CCCC      SSSS     FFFFF
E           T       C         S         F
EEEE        T       C          SSS      FFFF
E           T       C             S     F
EEEEE       T        CCCC     SSSS      F

The best thing about this code is that it vaguely represents the actual letter themselves. The letters FIZEL ETCSF were chosen because each line of the letters were continuous (e.g. A is disqualified because the second line is A A). Other candidates were the letters ILZ, which weren't chosen because it was shorter to generate letters with character codes close to multiples of 18 17.

How It Works

Sets up the tape in the format:
 10  76 69 90 32   73 70
(\n  L  E  Z  " "  I  F )
+[>-[-<]>>]>+[>++++>+++++>++>++++>+++++>++++>+[<]>-]
Ending on the first letter "F". The order of the letters are largely arbitrary, as long as the last letter is F (saves on printing trailing spaces. This isn't L because it saves more than 3 bytes in producing F) and the first letter is E or F (saves on printing leading spaces). The tape is actually initialised to multiples of 17 and are corrected on the first line

+.....>->--.....<.....>......>-....<......>>--....<<.....>>>++.....>-------.[<]> Fixes offsets in the letters
 .>>....   .......<.>....... >.<.........  >>.<<.........>>>.>.[<]>
 ....>>.   .......<.>....... >.<..........  >>...<<......>>>....>.[<]> Extra 3 bytes from F instead of L made up by F being closer to a multiple of 17
 .>>....   .......<.>....... >.<.............  >>.<<.....>>>.>.[<]>
 .....>>   .......<.>........ >....<.....  >>....<<......>>>.
\$\endgroup\$
1
\$\begingroup\$

C (gcc), 124 bytes

Chose symmetrical letters to try and exploit that somehow. Haven't quite found a way yet.

f(i,j){for(i=0;i<25;printf("%5c",++i%5?32:10))for(j=5;j--;)printf("%c",("QQQQQQQQJJQQQDDQJUJDNDJQD"[i]-64>>j&1)?85+i%5:32);}

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Suggest putchar() for the second printf() and you can ditch the parens before the ?: \$\endgroup\$ – ceilingcat Aug 6 '18 at 7:40
1
\$\begingroup\$

Jelly, 40 bytes (FSLIC)

- Yep, the United States' Federal Savings & Loan Insurance Corporation!

“Ƭß»Kż
“=;⁻ʋ®Ʋ\⁸d°5ġ$SƲ!ėɠẈvr’ḃ13s9Ç€ŒṙY

Try it online!

How?

A similar method to my other answer (LICTE) but "FSLIC" is in Jelly's dictionary*, making up for the lack of vertical symmetry of the three middle rows which I made use of there.

“Ƭß»Kż - Link 1, make a run length encoding for a row of the output: row's run lengths
“Ƭß»    - list of characters "FSLIC"
    K   - join with spaces   "F S L I C"
     ż  - zip with input     e.g. [['F',5],[' ',6],['S',4],[' ',5],['L',1],[' ',9],['I',5],[' ',6],['C',4]]

“...’ḃ13s9Ç€ŒṙY - Main link
“...’           - literal 56608997404020628145427517841908851108342355529865
     ḃ13        - to bjective base 13 -> [5,6,4,5,1,9,5,6,4,1,9,1,9,1,11,1,7,1,4,7,3,6,1,11,1,7,1,1,13,1,5,1,11,1,7,1,1,9,4,6,5,5,5,6,4]
        s9      - split into nines -> [[5,6,4,5,1,9,5,6,4],[1,9,1,9,1,11,1,7,1],[4,7,3,6,1,11,1,7,1],[1,13,1,5,1,11,1,7,1],[1,9,4,6,5,5,5,6,4]]
          Ç€    - call last link (1) as a monad for €ach
            Œṙ  - run-length decode e.g. [['F',5],[' ',6],['S',4],...]
                                      -> "FFFFF      SSSS..."
              Y - join with line feeds

* In fact it is the only dictionary entry with five (or more) distinct capital letters with single runs on every row (CDEFHILSTZ, as required by the method), and it also happens to start with a flat-left letter (DEFHL, again as required for the method).

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

Stax, 48 45 44 bytes(DOXHI)

ü⌠_Δs☺₧╞i╥⌂6⌂╤°qû╬╛∟|▀Ig‼£=U╣♪'q÷k╘îî♀P<ç)n½

Run and debug it

Thanks @recursive for -1 byte.

Chosen letters have two (in-plane) 2-fold axes except for "D". If there were another letter with two 2-fold axes the answer would be shorter.

\$\endgroup\$
  • 1
    \$\begingroup\$ 0]5* is z5(, which saves a byte even after packing. \$\endgroup\$ – recursive Mar 25 '18 at 18:44
  • \$\begingroup\$ This actually exposes a bug. If I assign the D after palindromizing, it still works while it shouldn't. Maybe the subarrays aren't copied properly upon palindromization. I think we had this issue with transposition, I don't know whether there are more instructions with this issue. \$\endgroup\$ – Weijun Zhou Mar 26 '18 at 1:02
  • 1
    \$\begingroup\$ I've found a bunch of inappropriate mutation bugs so far. There are probably many more to go. \$\endgroup\$ – recursive Mar 26 '18 at 1:45
1
\$\begingroup\$

R, 175 or 215

The size to beat is 9×5×5=225 bytes, so...

The obvious (and... surprisingly efficient!) solution in 175 bytes is just to hard-code the lines, noticing that two are identical:

e="        "
y=c(" T",e,"I        C",e,"E",e,"L    \n")
cat(gsub(0,s,c("TTTTT0IIIII0 CCCC0EEEEE0L    \n",y," T    0I  0C    0EEEE 0L    \n",y," T0  IIIII0 CCCC0EEEEE0LLLLL")))

If one needs to prove that he has a Ph.D. in programming, (s)he may use the slightly longer version, still beating the original string length, with the help of run-length encoding (215 bytes).

v=el(strsplit(" T I C E L \n",""))
j=c(2,1,9,1,7,1,9)
f=rep(5,3)
m=matrix(c(0,f,6,4,f,1,4,1,j,1,9,1,4,1,j,4,6,1,4,1,2,1,7,5,6,4,f,5,0,1),4,,T)
m=m[c(1:3,2,4),]
for(r in 1:5)for(i in 1:12)cat(rep(v[i],m[r,i]),sep="")

Premature optimisation is the root of all evil. (D. E. K.)

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

Python 2, 171 bytes

Best I could get after 2 hours:

E,s,I,L,T,U,n="E ILTU\n"
S,b,B,D,u=s*5,s*11,s*9,s*7,"U   U"
C,Z=u+n+E,I+D+L+b+T+D
print E*5+S+I*5+S+L+B+T*5+S+C+b+Z+C+E*3+s*8+Z+C+b+Z+U+s*3+U+n+E*5+S+I*5+S+L*5+D+T+s*8+U*3

Try it online!

Outputs:

EEEEE     IIIII     L         TTTTT     U   U
E           I       L           T       U   U
EEEE        I       L           T       U   U
E           I       L           T       U   U
EEEEE     IIIII     LLLLL       T        UUU

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

Java 8, 218 bytes (CHLTU)

v->{String s="     ",n="\n",c="C    ",h="H   H",l="L    ",t="  T  ",u="U   U";return" CCCC"+s+h+s+l+s+"TTTTT"+s+u+n+c+s+h+s+l+s+t+s+u+n+c+s+"HHHHH"+s+l+s+t+s+u+n+c+s+h+s+l+s+t+s+u+n+" CCCC"+s+h+s+"LLLLL"+s+t+s+" UUU";}

Explanation:

Try it online.

v->{                 // Method with empty unused parameter and String return-type
  String s="     ",  //  String containing five spaces
         n="\n",     //  String containing new-line
         c="C    ",  //  String for three repeated parts in C
         h="H   H",  //  String for four repeated parts in H
         l="L    ",  //  String for four repeated parts in L
         t="  T  ",  //  String for four repeated parts in T
         u="U   U";  //  String for four repeated parts in U
  return" CCCC"+s+h+s+l+s+"TTTTT"+s+u+n        //  Line 1
        +c+s+h+s+l+s+t+s+u+n                   //  Line 2
        +c+s+"HHHHH"+s+l+s+t+s+u+n             //  Line 3
        +c+s+h+s+l+s+t+s+u+n                   //  Line 4
        +" CCCC"+s+h+s+"LLLLL"+s+t+s+" UUU";}  //  Line 5

At first I was using letters that looked similar and used a replace function with if-checks. This ended up over 400 bytes however, so I dropped it completely instead of trying to golf it.

I then looked at letters with repeated parts. There are four letters with four repeated parts on their five lines: H, L, T and U.
And although I already had them in alphabetic order, it is also the best order for these five letters, because I can omit the trailing space in the bottom part of the U (" UUU "" UUU").

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

Powershell, 89 bytes

Inspired by the AdmBorkBork's nice trick.

$d="DDDD5  OOO5  CCCC5IIIII5L"
"$d
$("D   D5O   O5C55 I5  L
"*3)$d`LLLL"-replace5,'     '

Output:

DDDD       OOO       CCCC     IIIII     L
D   D     O   O     C           I       L
D   D     O   O     C           I       L
D   D     O   O     C           I       L
DDDD       OOO       CCCC     IIIII     LLLLL

Powershell (without tricks), 106 bytes

Any 5 letters, 25 chars with 5 lower bits as mask:

0..4|%{-join(0..4|%{0..4|%{(' ','GOLFA'[$i%5])[(+'NNA_NAQAAQYQAG_QQAAQNN_AQ'[+$i]-shr$_)%2]}
$i++
' '*5})}

Output:

 GGG       OOO      L         FFFFF      AAA 
G         O   O     L         F         A   A
G  GG     O   O     L         FFF       AAAAA
G   G     O   O     L         F         A   A
 GGG       OOO      LLLLL     F         A   A
\$\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.