title: 5 Favorite Letters

text:
# Question
Title: 5 Favorite Letters
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.

# Answer
# Jelly,  ~~41~~  40 bytes

N.B. I have a 39 byte answer too.

### LICTE

```
141D+“ȷɓSɠ’“ðƁ ƥ“JrŀṘ’jḃ11“LICTE”K¤żⱮŒṙY

```

**TryItOnline!**

### Idea

Use a run length decode with letters that have as similar middle as possible with only one run length of each "pixel value" per row per letter.

Put a flat start like "L" to avoid different run length decode values for the rows.

Place the one different letter (could not find 5) of the three middle rows at the end so the smallest difference may be added arithmetically.

Output wanted; the run lengths; and these converted from base 11:

```
                                                  L,  , I,  , C,  , T,  , E   value
                                                  -------------------------
L         IIIII      CCCC     TTTTT     EEEEE     1, 9, 5, 6, 4, 5, 5, 5, 5   399633415
L           I       C           T       E         1,11, 1, 7, 1,11, 1, 7, 1   431646160+1
L           I       C           T       EEEE      1,11, 1, 7, 1,11, 1, 7, 4   431646160+4
L           I       C           T       E         1,11, 1, 7, 1,11, 1, 7, 1   431646160+1
LLLLL     IIIII      CCCC       T       EEEEE     5, 5, 5, 6, 4, 7, 1, 7, 5   1179122455

```

The three values `399633415`, `431646160`, and `1179122455` in base `250` as Jelly code page indices are then `ðƁ ƥ`, `ȷɓSɠ`, and `JrŀṘ` which can be used to encapsulate the run-length information.

### The code

```
141D+“ȷɓSɠ’“ðƁ ƥ“JrŀṘ’jḃ11“LICTE”K¤żⱮŒṙY - Main link
141D                                     - 141 as a decimal list: [1, 4, 1]
     “ȷɓSɠ’                              - 431646160
    +                                    - add: [431646161, 431646164, 431646161]
           “ðƁ ƥ“JrŀṘ’                   - list [399633415,1179122455]
                      j                  - join: [399633415, 431646161, 431646164, 431646161, 1179122455]
                       ḃ11               - convert to bijective base 11: [[1, 9, 5, 6, 4, 5, 5, 5, 5], [1, 11, 1, 7, 1, 11, 1, 7, 1], [1, 11, 1, 7, 1, 11, 1, 7, 4], [1, 11, 1, 7, 1, 11, 1, 7, 1], [5, 5, 5, 6, 4, 7, 1, 7, 5]]
                                  ¤      - nilad followed by link(s) as a nilad:
                          “LICTE”        -   list of characters "LICTE"
                                 K       -   join with spaces   "L I C T E"
                                    Ɱ    - map across (the lists of numbers) applying:
                                   ż     -   zip             e.g. [['L',1],[' ',9],['I',5],[' ',6],['C',4],[' ',5],['T',5],[' ',5],['E',5]]
                                     Œṙ  - run-length decode e.g. "L         IIIII      CCCC     TTTTT     EEEEE"
                                       Y - join with line feeds

```
> 13 votes

# Answer
## Charcoal, ~~51~~ 49 bytes (ECXKI)

```
Ｇ←⁵↓³→⁴EＭ⁷→Ｇ↑²↗²→⁴CＭ⁶→ＧＨ↘↗³XＭ⁶→ＧＨ↓→↗³KＭ⁸→ＰTIII‖Ｏ↓

```

Outputs

```
EEEEE      CCCC     X   X     K   K     IIIII
E         C          X X      K  K        I
EEEE      C           X       KKK         I
E         C          X X      K  K        I
EEEEE      CCCC     X   X     K   K     IIIII

```

Try it online!

Using characters that are vertically symmetrical, draws the top halves and then reflects. Most of these make use of Polygon () and PolygonHollow (`ＧＨ`) to draw a series of connected line segments with a particular character. `I` can more easily be done with MultiPrint (), using `T` as the direction.

Note: PolygonHollow just draws the segments specified, without completing the polygon or filling it. Polygon will complete and fill (not what we want) **if** the polygon can be completed with a simple line in one of the eight cardinal or intercardinal directions. Otherwise, it behaves like PolygonHollow, for a savings of one byte.

The order of characters was chosen to require only horizontal moves from the endpoint of one to the start of the next. Here's how the cursor proceeds:
> 33 votes

# Answer
## PowerShell v2+, ~~138~~ ~~128~~ ~~114~~ ~~112~~ ~~106~~ 105 bytes (LICTD)

```
"L1    IIIII1 CCCC1TTTTT1DDDD
$("L11 I1  C11 T1  D   D
"*3)LLLLL1IIIII1 CCCC1  T1  DDDD"-replace1,'     '

```

The idea is to maximize the spaces between the letters so we can get repeated compressions.

Borrows the middle-row deduplication trick from Florent's answer. Saved 6 bytes thanks to Ben Owen by using string multiplication for the middle three rows, and an additional byte thanks to Matt.

Output is like the following at 227 bytes, for a 53.7% reduction --

```
PS C:\Tools\Scripts\golfing> .\5-favorite-letters.ps1
L         IIIII      CCCC     TTTTT     DDDD
L           I       C           T       D   D
L           I       C           T       D   D
L           I       C           T       D   D
LLLLL     IIIII      CCCC       T       DDDD

```
> 19 votes

# Answer
# JavaScript, ~~110~~ 109 bytes (CLOUD)

```
` CCCC5L9 OOO6U3U5DDDD
${x=`C9L9O3O5U3U5D3D
`,x+x+x} CCCC5LLLLL6OOO7UUU6DDDD`.replace(/\d/g,c=>" ".repeat(c))

```

```
console.log(
` CCCC5L9 OOO6U3U5DDDD
${x=`C9L9O3O5U3U5D3D
`,x+x+x} CCCC5LLLLL6OOO7UUU6DDDD`.replace(/\d/g,c=>" ".repeat(c))
)
```

Output is 227 bytes:

```
 CCCC     L          OOO      U   U     DDDD
C         L         O   O     U   U     D   D
C         L         O   O     U   U     D   D
C         L         O   O     U   U     D   D
 CCCC     LLLLL      OOO       UUU      DDDD

```
> 13 votes

# Answer
# PHP, ~~107~~ ~~104~~ ~~102~~ ~~94~~ 86 bytes

Ok I'm confident I have the smallest possible source with this method now. I wrote a script to generate and then gzip every possible combination of five letters. There are two solutions that match for the shortest compressed -- LODIC and LDOIC. I'm going with the former because it's more fun to say.

Source:

```
<?=gzinflate(base64_decode('81GAA39/fwjDBQggLE8QgDCdgYDLB6EYioGqoRisHkrTSCUIEOtWAA'));

```

Output:

```
% php foo.php
L          OOO      DDDD      IIIII      CCCC
L         O   O     D   D       I       C
L         O   O     D   D       I       C
L         O   O     D   D       I       C
LLLLL      OOO      DDDD      IIIII      CCCC

```
> 13 votes

# Answer
# ES6 (Javascript), ~~194~~, 181 bytes (IGOLF/ANY)

This one is long, and is not really optimized (not yet at least), but can be modified to print any particular message, by only changing the bitmap data.

*EDIT:* Replaced inner *reduce* with *map*, use bit shift for padding

**Golfed**

```
[0x1f73a1f,0x484610,0x49c61e,0x48c610,0x1f73bf0].map(r=>[0,1,2,3,4].map(p=>('0000'+(r>>(20-p*5)<<5).toString(2)).substr(-10).replace(/(1|0)/g,b=>' IGOLF'[(p+1)*b])).join``).join`\n`

```

**Demo**

```
[0x1f73a1f,0x484610,0x49c61e,0x48c610,0x1f73bf0].map(r=>[0,1,2,3,4].map(p=>('0000'+(r>>(20-p*5)<<5).toString(2)).substr(-10).replace(/(1|0)/g,b=>' IGOLF'[(p+1)*b])).join``).join`\n`

IIIII      GGG       OOO      L         FFFFF
  I       G         O   O     L         F
  I       G  GG     O   O     L         FFFF
  I       G   G     O   O     L         F
IIIII      GGG       OOO      LLLLL     F

```

**Theory**

Take a letter:

```
IIIII
  I
  I
  I
IIIII

```

convert it to binary matrix (bitmap)

```
11111
00100
00100
00100
11111

```

do the same for other 4 letters, scan a line, by taking "top" 5 bits off each

11111 01110 01110 10000 11111

convert to a hexadecimal string (should be using base36 or even printable ASCII here)

0x1f73a1f

apply the same algorithm to other 4 lines, to get the bitmap.

Render in the reverse order.
> 12 votes

# Answer
# 05AB1E, 44 bytes

This was a fun one.
I feel like I need to come back and try and golf it some more when I have time.

Uses CP-1252 encoding.
Inspired by *carusocomputing's* answer.

**ECOIH**

```
‘ÓÑOIHH‘SðýJ3×S•Td<UÕ‘áÓ?Â¢tWvkÔÚ•S)øü×J3äû»

```

Try it online!

**Explanation**

`‘ÓÑOIHH‘` pushes the string `"ECOOIHH"`.

`SðýJ3×S` joins the string by spaces, repeats it thrice and converts it to a list.
The resulting list is `['E', ' ', 'C', ' ', 'O', ' ', 'O', ' ', 'I', ' ', 'H', ' ', 'H', 'E', ' ', 'C', ' ', 'O', ' ', 'O', ' ', 'I', ' ', 'H', ' ', 'H', 'E', ' ', 'C', ' ', 'O', ' ', 'O', ' ', 'I', ' ', 'H', ' ', 'H']`.

`•Td<UÕ‘áÓ?Â¢tWvkÔÚ•` pushes the number `564631055513119191317171314619131717500`.

`S)ø` zips the list and the number together.

`ü×J` does pairwise string repetition and joins them together.
The result is the string `EEEEE CCCC OOO IIIII H HE C O O I H HEEEE C O O I HHHHH`.

`3äû»`splits that into 3 pieces, adds the first and second piece in reverse order and joins by newlines.
> 10 votes

# Answer
# JavaScript (ES6), 96 bytes (DIOCL)

```
`${x="DDDD6IIIII6OOO7CCCC5L"}
${y=`D3D7I7O3O5C9L
`,y+y+y+x}LLLL`.replace(/\d/g,d=>" ".repeat(d))

```

The idea here is to not only make the middle three lines identical, but also make the first line nearly identical to the last. Since there are only 4 letters that perfectly fit this description `CDIO`, `L` is the next best option, as it only requires 4 added characters at the end of the string.

As with Florent's answer, this is a snippet that returns the result. Add 3 bytes if it needs to be a function.

### Test snippet

```
console.log(`${x="DDDD6IIIII6OOO7CCCC5L"}
${y=`D3D7I7O3O5C9L
`,y+y+y+x}LLLL`.replace(/\d/g,d=>" ".repeat(d)))
```
> 9 votes

# Answer
## Bash+coreutils with figlet, 55440 solutions, 112 106 bytes each

```
 set H E L P D;for l;do figlet -f banner $l|sed "s/.//3;s/.//5;s/#/$l/g;2d;5d">$l;done;paste $@|expand -t10

```

**Output:**

```
H   H     EEEEE     L         PPPP      DDDD
H   H     E         L         P   P     D   D
HHHHH     EEEE      L         PPPP      D   D
H   H     E         L         P         D   D
H   H     EEEEE     LLLLL     P         DDDD

```

Hey, we already have a program for ASCII art! The *banner* font almost does the job, except it outputs 7x7 letters. Hmm, let's just remove the 3rd and 5th columns, and the 2nd and 5th lines, and see what it gives...

It turns out that many letters will be output the required way, namely, B D E F H J L P T U Z.

It suffices to replace the arguments of the first *set* command with any combination of those letters to still obtain a correct result! Hence, this gives us 11\*10\*9\*8\*7=55440 solutions, each of those being 106 bytes long.
> 9 votes

# Answer
# 05AB1E, ~~102~~ ~~90~~ ~~89~~ 69 bytes (EOIXC)

```
•Cv¶ÉH&9;´ß{ø‰¿šq3d$µ_©Û¶«K>Ò±sÒ9ÍÊC4ÊÚúNÏŒº9¨gÚSÞ•34B2ð:2ôvy`×}J3äû»

```

Try it online!

## Output (230 bytes):

```
EEEEE      OOOO     IIIII     X   X      CCCC
E         O    O      I        X X      C
EEEE      O    O      I         X       C
E         O    O      I        X X      C
EEEEE      OOOO     IIIII     X   X      CCCC

```

> 69 / 230 = 70% Compression

## Explanation:

The theory was to pick vertically symmetrical letters, then encode the first 3 lines an palindromize them. Basically, I encoded as {#} of {Letter} in 2 byte pairs. I'm sure there's a better way to do this.

```
•Cv¶ÉH&9;´ß{ø‰¿šq3d$µ_©Û¶«K>Ò±sÒ9ÍÊC4ÊÚîòvÅrè‘¾)jM•34B
                    <decodes to>
"E5 6O4 5I5 5X1 3X1 6C4E1 9O1 4O1 6I1 8X1 1X1 6C1 4E4 6O1 4O1 6I1 9X1 7C1 4"

2ô            # Split into encoded pairs.
  vy   }      # Loop through each letter and number pair.
    `×        # Add the letter X number of times.
       J      # Join together.
        3ä    # Split into 3 parts length.
          û   # Palindromize.
           »  # Print separated by newlines.

```

-20 bytes thanks to Emigna, I'll be in the chat to ask some questions soon ;).
> 7 votes

# Answer
# MATL, 49 bytes

```
5:lyI&(g84*t0*ytP+g73*yy!qy5XyPl5LY(90*yy!P12-&hc

```

Try it online!

This produces the letters `TIHZN`:

```
TTTTT     IIIII     H   H     ZZZZZ     N   N
  T         I       H   H        Z      NN  N
  T         I       HHHHH       Z       N N N
  T         I       H   H      Z        N  NN
  T       IIIII     H   H     ZZZZZ     N   N

```

### Explanation

`T` is relatively easy to build from scratch. `I` can be obtained essentially as `T` plus its vertical reflection. `H` is `I` transposed. `N` is `Z` transposed and vertically reflected.

```
5:        % Push [1 2 3 4 5]
lyI&(     % Write [1 ;2; 3; 4 ;5] in the third column, filling with zeros.
          % This gives the shape of the 'T'
g84*      % Change nonzeros into 84 (ASCII for 'T'). Zeros will be displayed
          % as spaces
t0*       % Duplicate and multiply by zeros. This gives the separator
y         % Duplicate from below: pushes the 'T' again
tP+       % Duplicate, flip vertically, add. Gives the shape of the 'I'
g73*      % Change nonzeros into 73 (ASCII for 'I')
yy        % Duplicate separator and 'I' array
!         % Transpose. Gives the shape of the 'H'
q         % Subtract 1. Transformss 73 into 72 (ASCII for 'H'), and 0 into -1,
          % which will later be changed back into 0 when converting to char
y         % Duplicate separator
5XyP      % Size-5 identity matrix flipped vertically: gives slash of the 'Z'
l5LY(     % Fill first and last rows with ones. Gives the shape of the 'Z'
90*       % Multiply by 90 (ASCII for 'Z')
yy        % Duplicate separator and 'Z' array
!P        % Transpose and flip vertically. Gives shape of the 'N'
12-       % Subtract 12 to yield ASCII code for 'N'. 0 is converted to -12
&h        % Concatenate the nine arrays horizontally
c         % Convert to char. Implicitly display

```
> 6 votes

# Answer
# Vim, ~~116 bytes~~ 99 bytes

### ELITC

Golfed it under 100 with the help of @DrMcMoylex.

```
9i59Yo191919171
E L I T CPqqjx:%s/\d/\=repeat('"',submatch(0))
q8@q3bi  Y7w.PP4rE{wl4r 22wl.2x

```

This contains unprintable characters, so I've added them in below (Vim style), so you can see them.

```
9i5^[9^AYo191919171
E L I T C^[Pqqjx:%s/\d/\=repeat('^R"',submatch(0))
q8@q3bi  ^[Y7w.PP4rE{wl4r 22wl.2x

```

TryItOnline!

It basically uses the same run-length decode that the jelly answer does. I used letters where I could (hopefully) repeat the top on the bottom, and the middles would all 3 be the same. Once the tops, bottoms, and middles are created I edit the characters to make them correct:

1. Add two spaces to the I (more on that below)
2. Add two spaces to the T
3. Add the bar of the E
4. Remove the top of the L
5. Remove the bottom of the T (and delete the 2 spaces)

I have to add two spaces to the I, because I didn't allow two digit numbers (so I wouldn't need a separator. This leads to a 9 space run where I need 11.
> 6 votes

# Answer
# JavaScript ES6, 168 bytes, CHAMP

We can stop looking guys, we have a `CHAMP` over here

```
f=_=>
` C3cHaHdA2dMaMcP3
CgHaHcAaAcMM MMcPaP
CgH4cA4cM M McP3
CgHaHcAaAcMaMcP
 C3cHaHcAaAcMaMcP`.replace(/[a-z\d]/g,(a,i,c)=>+a?c[i-1].repeat(a):' '.repeat(parseInt(a,36)-7))

a.innerHTML = f()
```

```
<pre id=a>
```
> 5 votes

# Answer
# Brainf\*** ~~512~~ 411 Bytes

**Better redo:**

This one does a better job at optimizing the tape, sacrificing setup characters for printing characters. The tape in this one looks like `'C' 'E' ' ' 'F' 'I' 'L' '\n'`, improving efficiency. I chose these because they lack internal spaces, making it so that they don't have to go back and forth between character and space more than necessary

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

```

If you want to read what it's doing:

```
Set the tape with 67,69,32,70,73,76,10
++++++++[>+++++++++>+++++++++>++++>+++++++++>+++++++++>+++++++++>+<<<<<<<-]>----->--->>-->+>++++>++<<<<
.<<....>>.....<.....>.....>.....<.....>>.....<<.....>>>.>.<<<<<< First Line
.>>.........<.>.........>.<...........>>.<<.......>>>.>.<<<<<< Second Line
.>>.........<....>......>....<........>>.<<.......>>>.>.<<<<<< Third Line
.>>.........<.>.........>.<...........>>.<<.......>>>.>.<<<< Fourth Line
.<<....>>.....<.....>.....>.<.........>>.....<<.....>>>..... Fifth Line

```

Output:

```
 CCCC     EEEEE     FFFFF     IIIII     L
C         E         F           I       L
C         EEEE      FFFF        I       L
C         E         F           I       L
 CCCC     EEEEE     F         IIIII     LLLLL

```

**Former Submission:**

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

```

I chose to go with ABCDE because it make setting up the tape for output much easier, but the time and characters I wasted in going from the letter to ' ' for all the negative space inside the A, B, and D and the placement of the endline at the end of the tape kinda killed me, I think.

I ended up with a tape that had the values `0 0 'A' 'B' 'C' 'D' 'E' ' ' \n` and then output from there

```
++++++++[>++++<-]>[>++>++>++>++>++>+<<<<<<-]>+>++>+++>++++>+++++>>++++++++++     This all sets up the tape as 0 0 A B C D E ' ' '\n'
<.<<<<<...>>>>>......<<<<....>>>>.......<<<....>>>.....<<....>>......<.....>>.<<<<<< First Line
.>>>>>...<<<<<.>>>>>.....<<<<.>>>>...<<<<.>>>>.....<<<.>>>.........<<.>>...<<.>>.....<.>>.<<<<<< Second Line
.....>>>>>.....<<<<....>>>>......<<<.>>>.........<<.>>...<<.>>.....<....>>.<<<<<< Third Line
.>>>>>...<<<<<.>>>>>.....<<<<.>>>>...<<<<.>>>>.....<<<.>>>.........<<.>>...<<.>>.....<.>>.<<<<<< Fourth Line
.>>>>>...<<<<<.>>>>>.....<<<<....>>>>.......<<<....>>>.....<<....>>......<..... Last Line

```

Output:

```
 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

```
> 5 votes

# Answer
# , ~~62~~, 53 bytes

```
iC±  I· D³ Dµ O³ O¸ Z3ñYp$XñS ´Cµ µIµ ´D· ³O¶ µZYHP

```

Try it online!

This outputs `C I D O Z`:

```
 CCCC     IIIII     DDDD       OOO      ZZZZZ
C           I       D   D     O   O        Z
C           I       D   D     O   O       Z
C           I       D   D     O   O      Z
 CCCC     IIIII     DDDD       OOO      ZZZZZ

```
> 4 votes

# Answer
# Stax, 33 bytes "BCDEO"

```
┌☼&.àτ▲█╟;c♦▌ΩÅ╡≤♫¿(┌▲▲≡3*╤J s*è«

```

Run and debug it

I picked letters that

* have vertical symmetry
* whose middle three columns are identical

These properties mean that each letter can be represented by a 3x3 grid. Here are the 9 regions, represented by digits.

```
12223
45556
78889
45556
12223

```

Consider the letter "B". It can be represented by 3 octal digits: `656`. Each digit contains three bits, which control which regions are enabled for that letter. This technique also works for "CDEO".

Unpacked, ungolfed, and commented, the program looks like this.

```
"!^*14>G2eo"!   crammed integer literal             [63672, 54545, 64565]
|p              palindromize                        [63672, 54545, 64565, 54545, 63672]
m               for each, run this and output...
  E             extract decimal digits to array     [6, 3, 6, 7, 2]
  `)"+0`        compressed string literal           "BCDEO"
  \             zip arrays                          [[6, 66], [3, 67], [6, 68], [7, 69], [2, 79]]
  {             map array using block
    E           explode array                       6, 66
    Z\          tuck a zero under, and make pair    6, [0, 66]
    :B          custom base convert                 [66, 66, 0]
    3)          pad to length 3                     [66, 66, 0]
    3O\         tuck a one under a 3 and pair       [66, 66, 0], [1, 3]
    :B          repeat elements corresponding times [66, 66, 66, 66, 0]
    A(          pad right to length 10              [66, 66, 66, 66, 0, 0, 0, 0, 0, 0]
  m

```

Run this one
> 4 votes

# Answer
# Ruby, ~~110~~ ~~107~~ 102 bytes (DOCIL)

```
puts a=?D*4+(t=' '*7)+?O*3+t+?C*4+(s=' '*5)+?I*5+s+?L,['D   D'+s+'O   O'+s+?C+' '*11+?I+t+?L]*3,a+?L*4

```

Prints

```
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

```

EDIT: Saved some chars by avoiding `join` and moving things around
> 3 votes

# Answer
# Perl 5 `-p`, 82 bytes (DOCIL)

Using the same letters and strategy everyone else is using (reusing the lines where possible), combined with an RLE decoder.

```
}{$_=($;="4D7 3O7 4C5 5I5 L")."
D3 D5 O3 O5 C11 I7 L"x3 ."
$;4L";s/\d+(.)/$1x$&/ge

```

Try it online!

---

# Perl 5 `-p`, 95 bytes (ABCDE)

Contains unprintables, so the link includes them in `\x##` notation. Verification for 95 bytes.

```
}{$_=unpack B125,"w...0.?.G..#....";s;.;($&?(A..E)["@-"/5%5]:$").("@+"%25?$"x5x!("@+"%5):$/);ge

```

Try it online!

## Explanation

The main data is stored as a binary matrix in the 16 byte string passed to `unpack`, which is called to convert to binary. Then `s///` is called to replace each character with either `$"` (space) or if `$&` is falsy (`0`) or `(A..E)["@-"/5%5]` otherwise, where `"@-"` is the start index of the current character (`@-` is a list so `$-[0]` would return the first element, but interpolating into a string is 1 byte shorter) and we divide it by `5` and then take that result modulo `5` resulting in `0-4` (as the decimal part is ignored in list indices) based on the position, this correctly gets the letters in the right place for each of the larger letters. This is then appended to with, if `"@+"%25` (like `"@-"` above, but `@+` contains the end index of the current match) is truthy, `$"x5x!("@+"%5)` (space repeated \[`x`\] five times, repeated once when `"@+"%5` is false) which adds the required spaces after each letter, or `$/` (newline) otherwise.
> 3 votes

# Answer
# C#, 290 279 267 265 Bytes

*Edit: Saved 12 bytes thanks to @milk! And 2 more thanks to @TheLethalCoder*

Golfed:

```
void F(){string g="     ",h="H   H",A="A   A",B=h+"|"+A;Func<string,string>j=a=>a.Replace("|",g)+"\n";Console.Write(j(" SSSS|"+h+"| AAA |RRRR |PPPP")+j("S    |"+B+"|R   R|P   P")+j(" SSS |HHHHH|AAAAA|RRRR |PPPP")+j("    S|"+B+"|R  R |P")+j("SSSS |"+B+"|R   R|P"));}

```

Ungolfed:

```
public void F()
{
  string g = "     ", h = "H   H", A = "A   A", B = h + "|" + A;
  Func<string, string> j = a => a.Replace("|", g) + "\n";
  Console.Write(j(" SSSS|" + h + "| AAA |RRRR |PPPP") +
  j("S    |" + B + "|R   R|P   P") +
  j(" SSS |HHHHH|AAAAA|RRRR |PPPP") +
  j("    S|" + B + "|R  R |P") +
  j("SSSS |" + B + "|R   R|P"));
}

```

Outputs:

```
 SSSS     H   H      AAA      RRRR      PPPP
S         H   H     A   A     R   R     P   P
 SSS      HHHHH     AAAAA     RRRR      PPPP
    S     H   H     A   A     R  R      P
SSSS      H   H     A   A     R   R     P

```
> 3 votes

# Answer
# Befunge, 120 bytes (CKYTF)

**Source**

```
#&49+14489+56*1449135*44711425*:12p9138*7+:89+:56*55*v_@
-1g05$$_\#!:2#-%#16#\0#/g#20#,g#+*8#4<80\9*2p06%5p05:<^:,g2!%5:

```

**Output**

```
  CCCC     K   K     Y   Y     TTTTT     FFFFF
 C         K  K       Y Y        T       F
 C         KKK         Y         T       FFFF
 C         K  K        Y         T       F
  CCCC     K   K       Y         T       F

```

Try it online!

In case it matters, I should point out that my output has a leading space on each line. The rules didn't explicitly prohibit that, so I'm hoping that's OK. If not, please just consider this a non-competing entry.

**Explanation**

The letters of the word are encoded as a simple sequence of 25 integers, each integer being a binary representation of 5 pixels. Since Befunge requires you to perform a calculation to instantiate any integer greater than 9, the letters were chosen so as to minimize the number of calculations required, and ordered so potential repeating values could be duplicated rather than recalculated.

We also need to store the ASCII value of each letter, offset by 32, in an array which is indexed by the modulo 5 of a decrementing index (so it goes 0 4 3 2 1 ...). The reason for offsetting by 32 is so the value can be multiplied by a pixel bit (1 or 0) and then added to 32 to produce either a space or the character required.

This array of letter values is stored in the first 5 bytes of the code, so it's easy to access. This also then influenced the choice of letters, since those values needed to be meaningful when interpreted as a code sequence. This is the sequence `#&49+`. The `#` jumps over the `&` and the `49+` just pushes 13 onto the stack which is subsequently ignored.
> 3 votes

# Answer
# Befunge-98, ~~109~~ 98 bytes (FUNGE / ANY)

```
:5%!2>j#4_;\$&\#;\:0`!#@_:::'@/'@*-\'@/2%*' +,:'@/:2/-'@*-\1+:5%!2>j#4_;' 3k:4k,#;:55*%!2>j#4_;a,;

```

Try it online!

## Input (115 characters):

```
2022 1141 1134 935 2021 102 1141 1262 103 101 998 1141 1390 1639 997 102 1141 1646 1127 101 102 949 1134 935 2021 0

```

Input is the integer version of a binary number with the format `aaaaabbbbbb` where `aaaaa` is a reversed map of the character to print (for example, the second row in the N is `NN N`, so the mask is `10011`), and `bbbbbb` is the ascii character to print, minus 32.

I also created a befunge-98 program to create my inputs:

```
4k~44p34p24p14p04p          v
+1.+-**244g4%5\**88_@#`0:&::<

```

Try it online!

## Output (255 characters):

```
FFFFF     U   U     N   N      GGG      EEEEE
F         U   U     NN  N     G         E
FFFF      U   U     N N N     G  GG     EEEE
F         U   U     N  NN     G   G     E
F          UUU      N   N      GGG      EEEEE

```

> (255 - (115 + 98)) / 255 = 16% compression

## Explanation:

```
:5%!2>j#4_;\$&\#;\:0`!#@_     Get input if it is available, else end program
:::'@/'@*-\'@/2%*' +,         Output the current input character (or a space,
                              if the mask dictates so)
:'@/:2/-'@*-                  Throw away current mask bit
\1+                           Swap loop iterator to top of stack, increment it
:5%!2>j#4_;' *3k:4k,#;        If iterator % 5 == 0, print five spaces
:55*%!2>j#4_;a,;              If iterator % 25 == 0, print newline character

```

This is probably pretty golfable; I've spent barely any time thinking about potential reductions.

Theoretically this can print any sequence of 5x5 ascii art.

Thanks to James Holderness for helping me get out of triple digits!
> 3 votes

# Answer
# Python 2, 124 bytes

```
d,i,o,c,l,s,n='DIOCL \n'
T=d*4+s*6+i*5+s*6+o*3+s*7+c*4+s*5+l
M=d+s*3+d+s*7+i+s*7+o+s*3+o+s*5+c+s*9+l+n
print T+n,M,M,M,T+l*3

```

Similar to my other answer, but with better letter choices. Outputs this:

```
DDDD      IIIII      OOO       CCCC     L
D   D       I       O   O     C         L
D   D       I       O   O     C         L
D   D       I       O   O     C         L
DDDD      IIIII      OOO       CCCC     LLLL

```
> 3 votes

# Answer
## Python 3, ~~234~~ ~~228~~ ~~227~~ 166 bytes (CLOUD):

```
import base64,gzip;b=b'ABzY86gn$d0{>HR1_A{T@KJyRe}8`nBNU1i6kLFS%Nec$q1YdaQ51tPO;sx(oDBkK&Q=Hwg(wC)8vxUXJX_-c000';print(gzip.decompress(base64.b85decode(b)).decode())

```

Prints:

```
 CCCC     L          OOO      U   U     DDDD
C         L         O   O     U   U     D   D
C         L         O   O     U   U     D   D
C         L         O   O     U   U     D   D
 CCCC     LLLLL      OOO       UUU      DDDD

```
> 2 votes

# Answer
# Python 3, 178 bytes

```
e,f,i,t,h,s='EFITH '
p=print
S=s*5
D=i+s*9+t+s*7
A=e*5+S
F=S+i*5+S
B=e+s*9+f+s*11+D+h+s*3+h
C=h+s*3+h
p(A+f*5+F+t*5+S+C)
p(B)
p(e*4+s*6+f*4+s*8+D+h*5)
p(B)
p(A+f+s*4+F,s+t+s*7+C)

```

Won't win, but does not use any compression. It makes this:

```
EEEEE     FFFFF     IIIII     TTTTT     H   H
E         F           I         T       H   H
EEEE      FFFF        I         T       HHHHH
E         F           I         T       H   H
EEEEE     F         IIIII       T       H   H

```

Any help is welcome, I probably missed something. I didn't use Python 2 because you can't do the `p=print`, and that saves 17 bytes. Try it on repl.it.
> 2 votes

# Answer
# Ruby, 101 bytes (TIFLE)

```
"o@h@u".bytes{|i|k=3+i%2;puts "%-10s"*5%"TIFLE".chars.map{|j|i/=2;(i/16>i%2*3?'  ':'')+j+j*k*(i%2)}}

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

```

I picked letters that required a single block of letters (1,4 or 5 letters long) on each line. F,L and E are left justified, but T and I require leading spaces where a single letter (vertical part) is printed. The code for adding these spaces looks like it could be improved.

**ungolfed**

```
"o@h@u".bytes{|i|               #for each byte (64 always set, 32...2 bits set for horiz bar, 1 bit=length of bar)
   k=3+i%2                      #decode least sig. bit for no of chars printed if a 1 is found
   puts "%-10s"*5%              #puts "%-10s%-10s%-10s%-10s%-10s" format string (expects array of subsitutes)
     "TIFLE".chars.map{|j|      #for each letter
        i/=2                    #halve i
        (i/16>i%2*3?'  ':'')+   #if i large enough and i%2 zero, add leading space (or T and I)
        j+j*k*(i%2)             #print the letter once, then additional letters if bar required.
     }
}

```
> 2 votes

# Answer
# C 176 bytes

If implicit ints are allowed then it's possible to cut off another 8 bytes.

```
#define C ,//11 bytes
#define R(r)r r r r r//21 bytes
T(int l){int c=324;printf(R(R("%c")R(" "))"\n" R(R(C(++c,l>>=1)&1?c/5:32)));}//77 bytes
f(){T(67010460);T(34702434);T(66160574);T(34702434);T(67010466);}//65 bytes

```

Output: E D C B A

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

```

How it works: The macro R just repeats a piece of code 5 times. Given how often fives appear in this problem, very useful. Now: here's what T(int) does. T takes an integer, and uses it as a bit field to determine where to print letters and where to print white space. For example, if given `T(0b11111111100111111110011100)`, it will output: `EEEEE DDDD CCCC BBBB AAA` . It progressively counts down as to what letter it prints. First it prints E, then D, then C, then B, then A. Calling f() will print the entire thing.
> 2 votes

# Answer
## Batch, 135 bytes (DOCILe)

```
@set b=
@set s=@echo DDDD%b%  OOO%b%  CCC%b% IIIII%b%L
@set t=@echo D   D%b%O   O%b%C%b%%b% I%b%  L
%s%
%t%
%t%
%t%
%s%LLLL

```

Note: the first line ends in 5 spaces.
> 2 votes

# Answer
# BASH, ~~95~~, 111 bytes (EBASH)

**Golfed**

```
base64 -d<<<4ADlADhdACLpBDSMnNdRTj0Ob2qBPVT3HkdMRZzZ3kL+yIb6mhkz06EM+KOspSDy2EBoUKKL6pfwNo0akV0zAA==|xz -dqFraw

```

**Explanation**

Base64 over raw LZMA byte stream

**Demo**

```
>base64 -d<<<4ADlADhdACLpBDSMnNdRTj0Ob2qBPVT3HkdMRZzZ3kL+yIb6mhkz06EM+KOspSDy2EBoUKKL6pfwNo0akV0zAA==|xz -dqFraw

EEEEE     BBBB       AAA       SSSS     H   H
E         B   B     A   A     S         H   H
EEEE      BBBB      AAAAA      SSS      HHHHH
E         B   B     A   A         S     H   H
EEEEE     BBBB      A   A     SSSS      H   H

```

**Disclaimer**

Yes, I'm well aware that this is not really portable, that's why I've paid a byte to suppress the *xz* warnings with *-q* in the first case \>:)
> 2 votes

# Answer
# Python 2, ~~208~~ ~~194~~ 193 bytes

This is my first ever code golf ;) Fun to do

```
for i in range(0,25,5):
 for c,p in {'M':18732593,'O':15255086,'N':18667121,'T':32641156,'Y':18157700}.items():
  print format(p,'025b')[i:i+5].replace('0',' ',).replace('1',c)+'   ',
 print

```

Output:

```
Y   Y    M   M    TTTTT     OOO     N   N
 Y Y     MM MM      T      O   O    NN  N
  Y      M M M      T      O   O    N N N
  Y      M   M      T      O   O    N  NN
  Y      M   M      T       OOO     N   N

```

Using a dictionary destroys the sort order of the letters, but that was not a requirement
> 2 votes

# Answer
## perl 94 bytes.

The first 4 letters (`D`, `O`, `I`, `C`) are specifically chosen to have the upper and lower lines similar, and the middle ones similar. As there is not any other similar letter, I chose the "L" to be able to apply the same algorithm and add the missing 4L.

```
for(($a="D5 6O3 6I5 6C4 5L")."
","D 3D 5O 3O 7I 7C 9L
"x3,$a."4L
"){s/(.)(\d)/$1x$2/eg;print}

```

I saved some extra bytes by replacing the `\n` in the code with a real new line.

Result:

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

```
> 2 votes

# Answer
# brainfuck, ~~380 371~~ 351 bytes

Edit: -9 bytes by switching to multiples of 17 and combining printing the first line with correcting the offsets Edit: -20 by just using one cell to store the letters, you moron past me

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

```

Try it online!

The best thing about this code is that it vaguely represents the actual letter themselves when the appropriate whitespace is added.

# How It Works

```
Sets up the tape in the format:
1 2 4 8 16 32 64 128 0 0'

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

....<. ..... .>+.... <..... >++..... <..... .>++...<. ..... >-..... ----<<------.>>
.<...>.<.....>+.<.... ..... >++.<.... ..... >++.<.... ..... >-.     ----<<.>>
..... <..... >+.<.... ..... >++....<. ..... >++.<..>..<.....>-....  ----<<.>>
.<...>.<.....>+.<.... ..... >++.<.... ..... >++.<...>.<..... >-.     ----<<.>>
....<. ..... .>+....< ..... >++.....< ..... .>++...<. ..... >-.

```
> 2 votes

# Answer
# Jelly,  ~~40~~  39 bytes (FSLIC)

\- Yep, the United States' **F**ederal **S**avings & **L**oan **I**nsurance **C**orporation!

```
“=;⁻ʋ®Ʋ\⁸d°5ġ$SƲ!ėɠẈvr’ḃ13s9“Ƭß»K¤żⱮŒṙ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.

```
“...’ḃ13s9“Ƭß»K¤żⱮŒṙY - Link: no arguments
“...’                 - (base 250) number     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]]
               ¤      - nilad followed by link(s) as a nilad:
          “Ƭß»        -   list of characters  "FSLIC"
              K       -   join with spaces    "F S L I C"
                 Ɱ    - map across (the lists of numbers) applying:
                ż     -   zip                 [[['F',5],[' ',6],['S',4],[' ',5],['L',1],[' ',9],['I',5],[' ',6],['C',4]],...]
                  Œṙ  - run-length decode     ["FFFFF      SSSS     L         IIIII      CCCC",...]
                    Y - join with newline characters

```

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

# Answer
# 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
> 1 votes

# Answer
## 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

```
> 1 votes

# Answer
# 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

```
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# 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 `.5`s 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];

```
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# 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"))

```
> 1 votes

# Answer
# 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).
> 1 votes

# Answer
# 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!
> 1 votes

# Answer
# 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.)*
> 1 votes

# Answer
# 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.
> 1 votes

# Answer
# 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
```
> 0 votes

# Answer
# 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"`).
> 0 votes

# Answer
# 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

```
> 0 votes

# Answer
# FEU, 83 bytes, DOCIL

```
a/4\n5554LLLL
m/5/D1D2O1O2C0020I03\n/4/DDDD02OOO02CCCC2IIIII3/3/2L/2/10/1/0 /0/  /g

```

Try it online!

## Explanation

0, 1, and 2 are for spacing. They're 2, 3, and 5 spaces respectively.

3 starts the letter L.

4 is line 1, and line 5 is just line 1 with 4 extra L's.

5 is line 2, 3, and 4.
> 0 votes

# Answer
# APL (Dyalog Classic), 87 bytes

Decodes 45 vertical lines of 5 types from 15 characters. Converts them to binary matrix and then multiplies it by a coefficient matrix. The final matrix contains indices of letters in a string.

```
' DILOC'[1+(⊃,/{9\⍪5⍴⍵}¨⍳5)×(⍉5 5⍴(25⍴2)⊤47679)[;1+∊(5 5 5⊤⊢)¯6+⎕AV⍳'ÏSSS9i⌶⌶⌶⌶RSÐSS']]

```

Output:

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

```

Try it online!
> 0 votes

# Answer
# MAWP, 700 bytes

It would've been *real* dandy if this question was about 4 characters.

```
499WA;48W!!;;;499WA;48W!!!!!;;;;;;188WM!!;;;48W!!!!!!;;;;;;;299WA!!;;;48W!!!!!;;;;;;699WM;48W!!;;;699WM;48W!!!!;;;;;199WA!!!;;;;25W;499WA!;;48W;499WA!;;48W!!!!;;;;;188WM;48W!!;;;188WM;48W!!!!;;;;;299WA;48W!!;;;299WA;48W!!!!;;;;;699WM;48W!!;;;699WM;48W!!!!;;;;;199WA;48W!!;;;199WA;25W;499WA;48W;499WA;48W;499WA;48W!!!!;;;;;188WM!!!!;;;;;48W!!!!;;;;;299WA;48W!!;;;299WA;48W!!!!;;;;;699WM;48W!!;;;699WM;48W!!!!;;;;;199WA!!!;;;;25W;499WA;48W!!;;;499WA;48W!!!!;;;;;188WM;48W!!;;;188WM;48W!!!!;;;;;299WA;48W!!;;;299WA;48W!!!!;;;;;699WM;48W;699WM;48W;699WM;48W!!!!;;;;;199WA;25W;499WA;48W!!;;;499WA;48W!!!!;;;;;188WM;48W!!;;;188WM;48W!!!!!;;;;;;299WA!!;;;48W!!!!!!;;;;;;;699WM;48W;699WM;48W!!!!!;;;;;;199WA;

```

Made with the help of Kevin Cruijssen's MAWP string generator and a *lot* patience and exclamation marks.

## Output:

```
M   M      AAA       OOO      W   W     PPPP
MM MM     A   A     O   O     W   W     P   P
M M M     AAAAA     O   O     W   W     PPPP
M   M     A   A     O   O     W W W     P
M   M     A   A      OOO       W W      P

```

Try it!
> 0 votes

---
Tags: code-golf, ascii-art, kolmogorov-complexity
---


# Question
Title: Shortest program that continuously allocates memory
Write a program which runs forever and allocates more and more memory on the heap the longer it runs, at least until you reach the limit of the operating system on the amount of memory that can be allocated.

Many kernels won't actually reserve memory you allocate until you use it for something, so if your program is in C or some other low level language you'll have to make sure you write something to each page. If you're using an interpreted language, you're probably not going to have to worry about this.

Shortest code wins.

# Answer
# Funge-98 (`cfunge`), 1 byte

```
9

```

I would have posted this earlier, but decided to test it, and it took a while to get my computer back to a usable state. `cfunge` stores the Funge stack on the operating system's heap (which is easily verifiable by running the program with a small memory limit, something that I should have done earlier!), so an infinitely growing stack (as with this program, which just pushes `9` repeatedly; Funge programs wrap from the end of a line back to the start by default) will allocate memory forever. This program likely also works in some Befunge-93 implementations.

More interesting:

```
"NULL #(4

```

This was my first idea, and is an infinite allocation that doesn't rely on the Funge stack (although it blows up the Funge stack too). To start with, the `"` command pushes a copy of the rest of the program to the stack (it's a string, and the program wraps round, so the close quote also serves as the open quote). Then the `N` reflects (it has no meaning by default), causing the program to run backwards. The `"` runs again, and pushes the program to the stack – the other way round this time, with the `N` at the top of the stack – then the program wraps around, loading a library with a 4-letter name (`4(`; the `NULL` library is part of `cfunge`'s standard library). `NULL` defines all uppercase letters to do reflect, so the `L` reflects, the `#` skips the library load on the way back, the `4` pushes junk we don't care about to the stack and the whole program repeats from the start. Given that loading a library multiple times has an effect, and requires the library's command list to be stored once for each copy of the library (this is implied by Funge-98's semantics), it leaks memory via non-stack storage (which is an alternative method of defining "heap", relative to the language rather than the OS).
> 47 votes

# Answer
## Brainfuck, 5 bytes

```
+[>+]

```

This requires an interpreter that has no limit on the length of the tape.
> 32 votes

# Answer
# Bash + coreutils, 5

or

# Ruby, 5

```
`yes`

```

`yes` produces endless output. Putting `yes` in backticks tells the shell to capture all output and then execute that output as a command. Bash will continue allocating memory for this unending string until the heap runs out. Of course the resulting output would end up being an invalid command, but we should run out of memory before that happens.

Thanks to @GB for pointing out this is a polyglot in ruby too.
> 22 votes

# Answer
# Python, 16 bytes

Keeps nesting `a` until an error is reached:

```
a=0
while 1:a=a,

```

The first few iterations (as tuples) look like this:

```
0
(0,)
((0,),)
(((0,),),)

```

and so on and so forth.
> 21 votes

# Answer
## \>\<\> (Fish), 1 byte

```
0

```

Try it here!

`0` can actually be substituted for any hexadecimal number 1-f.

**Explanation**

`0` in \>\<\> simply makes a 1x1 codebox for the fish to swim in. It constantly adds a `0` onto the stack, swims right, which loops backaround to `0`, adding it to the stack again. This will go on forever.
> 18 votes

# Answer
## Perl, 12 bytes

```
{$"x=9;redo}

```

In perl, the `x` operator, with a string on the left and a number on the right, produces a repeated string. So `"abc" x 3` evaluates to `"abcabcabc"`.

The `x=` operator mutates the left argument, replacing contents of the variable on its left with the result of repeating it's contents as many times as its right hand side indicates.

Perl has a number of a number of strangely named built in variables, one of which is `$"`, whose *initial* value is a single space.

The `redo` operator jumps to the beginning of the enclosing `{}`.

The first time the `x=` operator is done, it changes the value of `$"` from `" "`" to `" "`, which is 9 spaces.

The second time the `x=` operator is done, it changes the value of `$"` to `" "`, which is 81 spaces.

The third time, `$"` becomes a 729 byte long string of spaces.

I think you can see where this is going :).
> 12 votes

# Answer
## Java 101 bytes

```
class A{public void finalize(){new A();new A();}public static void main(String[]a){for(new A();;);}}

```

Catching main Program in a endless Loop after creating and throwing away a object. Garbage collection does the job of leaking by creating 2 objects for each deleted ones
> 11 votes

# Answer
# sed, 5 bytes

**Golfed**

```
H;G;D

```

**Usage (any input will do)**

```
sed 'H;G;D' <<<""

```

**Explained**

```
#Append a newline to the contents of the hold space,
#and then append the contents of the pattern space to that of the hold space.
H

#Append a newline to the contents of the pattern space,
#and then append the contents of the hold space to that of the pattern space.
G

#Delete text in the pattern space up to the first newline,
#and restart cycle with the resultant pattern space.
D

```

**Screenshot**

Try It Online !
> 11 votes

# Answer
# Haskell, ~~23~~ 19 bytes

```
main=print$sum[0..]

```

Print the sum of an infinite list
> 10 votes

# Answer
# C++ (using g++ compiler), ~~27~~ ~~23~~ 15 bytes

*Thanks to Neop for helping me to remove 4 bytes*

This solution does not really leak any memory because it allocates everything on the stack and thus causes a stack overflow. It is simply infinitely recursive. Each recursion causes some memory to be allocated until the stack overflows.

```
main(){main();}

```

## Alternative solution

This solution actually leaks memory.

```
main(){for(;;new int);}

```

## Valgrind output

This is the Valgrind output after terminating the program several seconds into the run time. You can see that it is certainly leaking memory.

```
==2582== LEAK SUMMARY:
==2582==    definitely lost: 15,104,008 bytes in 3,776,002 blocks
==2582==    indirectly lost: 0 bytes in 0 blocks
==2582==      possibly lost: 16 bytes in 4 blocks
==2582==    still reachable: 4 bytes in 1 blocks
==2582==         suppressed: 0 bytes in 0 blocks

```
> 9 votes

# Answer
## ///, 7 bytes

```
/a/aa/a

```

Constantly replace `a` with `aa`, ad nauseum.
> 9 votes

# Answer
# JAVA, ~~81~~ ~~79~~ 78 bytes

# JAVA (HotSpot) ~~71~~ 70 bytes

Shorter than other Java answers at the time I posted (81, later 79 bytes):

```
class A{public static void main(String[]a){String x="1";for(;;)x+=x.intern();}}

```

As suggested by @Olivier Grégoire, a further byte can be saved:

```
class A{public static void main(String[]a){for(String x="1";;)x+=x.intern();}}

```

Placing `x+=x.intern()` as the for loop increment would not help anything, because a semicolon is still required to end the for statement.

As suggested by @ETHproductions, just using `x+=x` works too:

```
class A{public static void main(String[]a){String x="1";for(;;)x+=x;}}

```

Which can also benefit from @Olivier Grégoire's tip:

```
class A{public static void main(String[]a){for(String x="1";;)x+=x;}}

```

My only misgivings about that is that it is not guaranteed to allocate data *on the heap*, as an efficient JVM can easily realize that `x` never escapes the local function. Using `intern()` avoids this concern because interned strings ultimately end up stored in a static field. However, HotSpot does generate an `OutOfMemoryError` for that code, so I guess it's alright.

Update: @Olivier Gregoire also pointed out that the `x+=x` code can run into `StringIndexOutOfBoundsException` rather than `OOM` when a lot of memory is available. This is because Java uses the 32-bit `int` type to index arrays (and Strings are just arrays of `char`). This doesn't affect the `x+=x.intern()` solution as the memory required for the latter is quadratic in the length of the string, and should thus scale up to on the order of 2^62 allocated bytes.
> 9 votes

# Answer
# Perl 6, 13 bytes

```
@= eager 0..*

```

## Explanation:

`@ =` store the result into an unnamed array

`eager` make the following list eager

`0 .. *` infinite range starting at zero
> 8 votes

# Answer
# Python 3, 16 bytes

```
i=9
while 1:i*=i

```

This comes from the fact that there is no limit to integer size in Python 3; instead, integers can take up as much memory as the system can handle (if something about my understanding of this is wrong, do correct me).
> 8 votes

# Answer
## Rust, 46 bytes

```
fn main(){loop{std::mem::forget(Box::new(1))}}

```

Notice something interesting about this Rust program, leaking heap allocations until out of memory?

That's right, no unsafe block. Rust guarantees memory safety in safe code (no reading of uninitialized data, read after free, double free etc.), but memory leaks are considered perfectly safe. There's even an explicit function to make the compiler forget about RAII cleanup of out of scope variables, which I use here.
> 6 votes

# Answer
# TI-83 Hex Assembly, 7 bytes

```
PROGRAM:M
:AsmPrgm
:EF6A4E
:C3959D
:C9

```

Creates appvars indefinitely until an `ERR:MEMORY` is thrown by the OS. Run with `Asm(prgmM)`. I count each pair of hex digits as one byte.
> 6 votes

# Answer
# Python, 8 bytes

```
2**9**99

```

The OP has allowed the technicality of a program that doesn't technically run "forever", but allocates more memory than any computer could possibly handle. This isn't quite a googolplex (that would be `10**10**100`, 11 bytes), but naively, log base 2 of the number is

```
>>> 9**99.
2.9512665430652752e+94

```

i.e., 10^94 bits to represent it. WolframAlpha puts that as 10^76 larger than the deep web (keep in mind that there are about 10^80 atoms in the universe).

Why 2 instead of 9 you ask? It doesn't make much of a difference (using 9 would only increase the number of bits by a factor of `log2(9) = 3.2`, which doesn't even change the exponent). But on the other hand, the program runs much faster with 2, since the calculation is simpler. This means it fills up memory immediately, as opposed to the 9 version, which takes a little longer due to the calculations required. Not necessary, but nice if you want to "test" this (which I did do).
> 6 votes

# Answer
# Jelly, ~~3~~ 2 bytes

-1 byte thanks to Dennis (`W` wraps)

A link (i.e. function or method), which also works as a full program, that recursively wraps its input into a list.

The input starts as zero so the first pass creates the list `[0]`
The second pass then makes this `[[0]]`
The third pass then makes this `[[[0]]]`
and so on...

---

Previous 3 byter, which leaks much faster:

```
;Ẇß

```

recursively concatenates all non-empty contiguous sublists of its input to its input.
`[0]` -\> `[0,[0]]` -\> `[0,[0],[0],[[0]],[0,[0]]]` and so on...
> 5 votes

# Answer
# C (linux), 23 bytes

```
main(){while(sbrk(9));}

```

`sbrk()` increments the top of the data segment by the given number of bytes, thus effectively increasing the amount of memory allocated to the program - at least as reported in the `VIRT` field of `top` output. This only works on Linux - the macOS implementation is apparently an emulation that only allows allocation of up to 4MB.

---

So a slightly more general answer:

# C, 25 bytes

```
main(){while(malloc(9));}

```

I watched it on the macOS Activity Monitor. It went all the way up to about 48GB, then eventually the process received a SIGKILL signal. FWIW my macbook pro has 16GB. Most of the memory used was reported as compressed.

Note that the question effectively requires each allocation to be written to, which doesn't happen explicitly here. However it is important to note that for every `malloc(9)` call, it is not just the 9 user requested bytes that are allocated. For each block allocated there will be a malloc header that is also allocated from somewhere on the heap, which is necessarily written to by the `malloc()` internals.
> 5 votes

# Answer
# Java 7, 106 bytes

```
class A{public void finalize(){for(;;)Thread.yield();}public static void main(String[]a){for(;;)new A();}}

```

### Less Golfed

```
class A{
    @Override
    public void finalize(){
        for(;;) {
            Thread.yield();
        }
    }
    public static void main(String[]a){
        for(;;){
            new A();
        }
    }
}

```

The `finalize` method is called on an object by the garbage collector when garbage collection determines that there are no more references to the object. I have simply redefined this method to loop forever so the garbage collector never actually frees the memory. In the `main` loop I create new objects which will never be cleaned up so eventually this will use up all the available memory.

# Java 7 (fun alternative), 216 bytes

```
import sun.misc.*;class A{public static void main(String[]a)throws Exception{java.lang.reflect.Field f=Unsafe.class.getDeclaredField("theUnsafe");f.setAccessible(1>0);for(;;)((Unsafe)f.get(null)).allocateMemory(9);}}

```

### Less Golfed

```
import sun.misc.*;
class A{
    public static void main(String[]a)throws Exception{
        java.lang.reflect.Field f=Unsafe.class.getDeclaredField("theUnsafe");
        f.setAccessible(true);
        Unsafe u = (Unsafe)f.get(null);
        for(;;) {
            u.allocateMemory(9);
        }
    }
}

```

This is a fun one more than anything else. This answer makes use of the `Unsafe` Sun library which is an undocumented internal API. You may need to change your compiler settings to allow restricted APIs. `Unsafe.allocateMemory` allocates a specified amount of bytes (without any boundary checking) which is not on the heap and **not** under java's garbage collector management so this memory will stick around until you call `Unsafe.freeMemory` or until the jvm runs out of memory.
> 5 votes

# Answer
# Haskell, 24 bytes

```
f x=f$x*x
main=pure$!f 9

```

The main problem in Haskell is to beat the laziness. `main` needs to have some `IO` type, so simply calling `main=f 9` would not work. Using `main=pure(f 9)` lifts the type of `f 9` to an `IO` type. However using constructs like `main=pure 9` does not do anything, the `9` is returned or displayed nowhere but simply discarded, so there is no need to evaluate the argument of `pure`, hence `main=pure(f 9)` does not cause any memory to be allocated as `f` is not called. To enforce evaluation, the `$!` operator exists. It simply applies a function to an argument but evaluates the argument first. So using `main=pure$!f 9` evaluates `f` and hence continuously allocates more memory.
> 5 votes

# Answer
## Haskell (using ghc 8.0.1), 11 bytes

```
m@main=m>>m

```

Non-tail recursion. `main` calls itself and then itself again.
> 5 votes

# Answer
## dc, 7 bytes

```
[ddx]dx

```

`[ddx]` pushes a string containing "ddx" to the stack. `dx` duplicates it then executes it as code (leaving one copy on the stack). When executed, it makes two duplicates then executes one, leaving one more copy on the stack each time.
> 5 votes

# Answer
# Perl, 4 bytes

```
do$0

```

Executes itself, in the current interpreter. When finished, execution returns to the calling script, which requires a call stack.
> 5 votes

# Answer
# Racket, 13 bytes

```
(let l()(l)1)

```

I'm not entirely certain if my answer falls under this question. Please let me know if I should remove this answer.
> 4 votes

# Answer
# JavaScript ~~22~~ ~~21~~ ~~17~~ ~~16~~ 15 Bytes

```
for(a=0;;)a=[a]

```

Saved 4 bytes by wrapping the list in another list as in @Jonathan Allan's Jelly answer.

Saved 1 byte thanks to @ETHProductions

### Alternative solution 15 Bytes (only works with proper tail calls)

```
f=a=>f([a]);f()

```
> 4 votes

# Answer
# 05AB1E, 2 bytes

```
[A

```

Try it online! Will just keep pushing `abcdefghijklmnopqrstuvwyxz` onto the stack for eternity.

**All possible 2-byte solutions:**

```
[  # Infinite loop.
 A # Push alphabet.
 0 # Push 0.
 1 # Push 1.
 2 # Push 2.
 3 # Push 3.
 4 # Push 4.
 5 # Push 5.
 6 # Push 6.
 7 # Push 7.
 8 # Push 8.
 9 # Push 9.
 T # Push 10.
 X # Push 1.
 Y # Push 2.
 ® # Push -1.
 ¶ # Push \n.
 º # Push len(stack) > 0, so 0 once then 1 for eternity.
 ð # Push a space.
 õ # Push an empty string.
 ¾ # Push 0.
 ¯ # Push [].
 M # Push -inf.
 ) # Wrap current stack in an array.

```
> 4 votes

# Answer
# Ruby, 11 bytes

```
loop{$*<<9}

```

Keeps pushing `9` onto `$*`, which is an array initially holding the command line arguments to the Ruby process.
> 4 votes

# Answer
## Python, 35 bytes

```
def f(a=[]):a.append(a)
while 1:f()

```

`a` is never released and just gets bigger until you hit a `MemoryError`

You can view the execution on Python Tutor.
> 3 votes

# Answer
# Python REPL, 13 bytes

```
9
while 1:_*9

```

The first line, `9`, sets the built-in `_` (last-integer) variable to 9. The infinite loop then keeps setting this to itself multiplied by 9.

Python integers have no upper limit, so this will keep growing until `MemoryError`.

This only works in the shell, where the `_` variable is available. This is allowed by meta.
> 3 votes

# Answer
# PHP, ~~14~~ 13 bytes

Saved a byte thanks to Alex Howansky

```
while($a.=1);

```

Indefinitely builds a string of 111111111111...
> 3 votes

# Answer
## TI-BASIC, 8

```
:Lbl A
:While 1
:Goto A

```

(all 1-byte tokens, and two newlines)

This continuously leaks memory because structured control flow such as `While` anticipated being closed by an `End` and pushes something on the stack (not the OS stack, a separate stack in heap memory) to keep track of that. But here we're using `Goto` to leave the loop (so no `End` is executed to remove the thing from the stack), the `While` is seen again, the thing gets pushed again, etc. So it just keeps pushing them until you get `ERR:MEMORY`
> 3 votes

# Answer
## Mathematica, 16 bytes

```
For[i=0,0<1,i++]

```

Endlessly adds `1` to an arbitrary precision integer, causing its representation in memory to slowly grow.

Might also be the slowest submission since memory allocated only grows logarithmically with time. In fact, I've only let it run to several hundred billion, which barely alters allocated memory. So how do I know it grows without bound? Try the variant

```
For[i = 1, 0 < 1, i += i]

```

so that the memory usage is now linear in time... (If you want to watch `i`,

```
Monitor[For[i = 1, 0 < 1, i += i], i]

```

and notice, for instance, that the front end is allocating memory to hold the displayed values faster than the kernel is, because the binary representation is much less fluffy that the decimal representation and resulting graphical object. I suppose one could stress test one's 2D video acceleration by switching to the console interface and running the `Monitor[]` there... Heh.)
> 3 votes

# Answer
# BASH, 2 bytes

```
$0

```

Parameter $0 is the filename of the script, so it will call itself forever.
> 2 votes

# Answer
# Microscript II, 3 bytes

```
1[s

```

Rough translation:

```
x=1
while x
  push x

```
> 2 votes

# Answer
# Ceylon, 55 54 35 bytes

```
shared void r(){variable Object x=0;while(0<1){x=[x];}}

```

This is a simple while loop, which creates a one-element tuple containing the previous value, i.e. an ever-growing linked list.

I get an OutOfMemoryError (with the default JVM settings on my computer) after:

```
real    5m42.727s
user    21m31.200s
sys     0m3.472s

```

5m42s (using 21 minutes of processor time, says `time`).

Even shorter is the "functional" approach (which in effect does exactly the same):

```
shared void r(){loop<Object>(0)((x)=>[x]).each(noop);}

```

Unfortunately I need the type parameter here, otherwise Ceylon assumes `Integer` (which is the type of `0`) and complains that `[0]` is not an Integer.

The second version is much slower (I've let it run overnight):

```
real    197m26.677s
user    770m9.300s
sys     1m23.744s

```

A different approach is just filling a really big sequence of integers:

```
shared void r(){max((1:9^9)*.not);}

```

`1:9^9` is a `Measure<Integer>` (an Iterable containing 9^9 elements, starting with 1), by itself not having lots of memory (just the two numbers). But the `*.not` attribute spread creates a big ArraySequence with the value of `i.not` for each element of the Iterable. We need to do something with the result (otherwise the compiler complains that this is not a statement), therefore the `max(...)`. The `max` function is never called here, because this gives an OutOfMemoryError (with "GC overhead limit exceeded") after 6 minutes while trying to build and fill the array:

```
real    6m23.948s
user    23m46.956s
sys     0m5.200s

```
> 2 votes

# Answer
# SMBF, 5 bytes

Although the brainfuck solution also works in SMBF, I decided to create a solution that only works in SMBF.

```
<[>+]

```

Since the source is placed on the tape to the left of the pointer, `<` will move the pointer to point at `]`, and then we loop, traveling forever on the tape.
> 2 votes

# Answer
# WinDbg, 9 bytes

```
as/c a z1

```

This works by creating a string of infinite length. `as /c` Sets an alias (here called `a`) to the result of the following command(s): `z 1` is an infinite do while loop that also prints a line when the while condition is true: `redo [###] {redone_code}`. So `a` will be set to a string like:

```
redo [1] z1
redo [2] z1
redo [3] z1
.
.
.
redo [23489723984] z1
.
.
.

```
> 2 votes

# Answer
## SAS, ~~75~~ 19

SAS doesn't really lend itself to golfing but I thought I'd have a go, and at least it beats ~~Java~~ ~~some of the Java answers~~ quite a lot of stuff, actually.

**Original submission:**

```
data;dcl hash h();h.definekey('i');h.definedone();a:i+1;h.add();goto a;run;

```

This creates a hash object and keeps adding new values to it until SAS runs out of memory. None of the hash operations fail prior to that point, so no need to capture any pesky return codes for them. SAS does have `do` loops, but `goto` saves a few characters.

**New submission:**

```
%macro a;%a%mend;%a

```

Much simpler - a trivial recursive macro. If left running for long enough, it eventually fails with an out of memory error. Both submissions assume that SAS was invoked with `option memsize = 0`, otherwise it will instead fail when it hits that limit if it is lower than the available system memory.
> 2 votes

# Answer
# Actually, 3 bytes

```
1W1

```

Try it online!

This is an infinite loop that pushes a `1` to the stack each time it runs. Actually is implemented in Python, and its stack is a deque, so, despite the name, all memory is dynamically allocated on the heap.
> 2 votes

# Answer
# Labyrinth, 1 byte

```
_

```

This keeps pushing a 0 to the stack.
> 2 votes

# Answer
# Brain-Flak, 10 bytes

```
(()){(())}

```

Try it online!
> 2 votes

# Answer
# , 2 bytes

```
òé

```

You can try it online, even though it won't output anything.

This simply fills up the interal "buffer" with the `ÿ` character (`0xFF`) until the end of time.
> 2 votes

# Answer
## C#, 109 bytes

```
public class P{static void Main({for(;;)System.Xml.Serialization.XmlSerializer.FromTypes(new[]{typeof(P)});}}

```

Cross posted from here because it answers this question nicely as well.

We found the idea behind this leak in production code and researching it leads to this article. The main problem is in this long quote from the article (read it for more info):

> Searching my code for `PurchaseOrde`r, I find this line of code in `page_load` of one of my pages `XmlSerializer serializer = new XmlSerializer(typeof(PurchaseOrder), new XmlRootAttribute(“”));`
>
> This would seem like a pretty innocent piece of code. We create an `XMLSerializer` for `PurchaseOrder`. But what happens under the covers?
>
> If we take a look at the `XmlSerializer` constructor with Reflector we find that it calls `this.tempAssembly = XmlSerializer.GenerateTempAssembly(this.mapping, type, defaultNamespace, location, evidence);` which generates a temp (dynamic) assembly. So every time this code runs (i.e. every time the page is hit) it will generate a new assembly.
>
> The reason it generates an assembly is that it needs to generate functions for serializing and deserializing and these need to reside somewhere.
>
> Ok, fine… it creates an assembly, so what? When we’re done with it, it should just disappear right?
>
> Well… an assembly is not an object on the GC Heap, the GC is really unaware of assemblies, so it won’t get garbage collected. The only way to get rid of assemblies in 1.0 and 1.1 is to unload the app domain in which it resides.
>
> And therein lies the problem Dr Watson.

Running from the compiler in Visual Studio 2015 and using the Diagnostic Tools Window shows the following results after about 38 seconds. Note the Process memory is steadily climbing and the Garbage Collector (GC) keeps running but can't collect anything.
> 2 votes

# Answer
# Pushy, 3 bytes

```
1$a

```

Just keeps pushing to the stack...

```
1     % Push 1
$     % While last item != 0 (forever):
a     %   Push char-codes of the lowercase alphabet

```

This is just one example: several 3 byte solutions exist, such as `1$1`, `1$&`, `9$9`, etc - anything that will "infinitely" push to the stack.
> 1 votes

# Answer
## tinylisp repl, 12 bytes

```
(d f(q(L(f L

```

Defines a function `f` that will keep allocating memory when called. If submissions must be full programs, here's a 15-byte solution:

```
((v(d f(q(L(f L

```

### Explanation

The repl supplies missing parens at the end of the line, so the code is really `(d f(q(L(f L))))`.

`(d f(q(...)))` defines `f` to be the unevaluated list `(...)`. In tinylisp, functions are simply two-element lists. The first element is the parameter list and the second is the function body. Here, the first element is `L`, which (because it's not wrapped in parentheses) makes this a variadic function in which the entire argument list is assigned to `L`. The function body `(f L)` simply calls `f` again with `L` as its argument.

This is tail recursion, so the call stack doesn't come into play. But notice what happens to `L` on successive calls:

```
(f)        Called with no arguments; L gets empty list ()
(f ())     Called with one argument, empty list; L gets (())
(f (()))   Called with one argument, (()); L gets ((()))

```

And so on, wrapping the argument in another layer of list each time.
> 1 votes

# Answer
# Fission, 3 bytes

```
RX+

```

Continuously creates atoms and increments its mass.

Try it online!

```
R                 creates an atom moving right
 X                clones atom, one keeps moving to the right, the other gets reflected left
  +               increment the atom's mass

```

Because of wrapping, this program will continuously create atoms with non-negative mass

Another alternative:

```
RX'

```

`R` and `X` works like you expect it to, and `'` sets the atom's mass to the ASCII value of the next character it hits, ie `'R'` (because of wrapping). Thus, this continuously creates atoms with the ASCII value of `'R'`.
> 1 votes

# Answer
# Java, 127+19=146

Golfed:

```
import java.util.*;class A{public static void main(String[]q){List l=new LinkedList();for(;;){String s="";for(int i=0;i>-1;++i)s+=' ';l.add(s);}}}

```

Ungolfed:

```
import java.util.*;

public class A {
  public static void main(String[] args) {
    List<String> l = new LinkedList<>();
    for (;;) {
      String s = new String();
      for (int i = 0; i > -1; ++i) {
        s += ' ';
      }
      l.add(s);
    }
  }
}

```

This program does *not* rely on the garbage collector or `finalize()` method like the other Java answers do. Java only interns and merges strings that are constructed from literals, unless specifically interned. That means this program will end up creating strings of size 2<sup>31</sup> essentially forever, assuming LinkedList works as expected.
> 1 votes

# Answer
## PowerShell, 14 bytes

```
for(){$i+="z"}

```

Infinite loop creates a variable(string) and appends new characters to the end. Unbearably slow, took over an hour to consume two megabytes. Verified it would consume all the RAM available using something a bit faster: `for(){$i+=("z"*9MB)}`
> 1 votes

# Answer
# Dyalog APL, 4 bytes

```
⊂⍣≡⍬

```

enclose

until

identical to the previous iteration (i.e. never, as each iteration has one more level of enclosure)

empty (numeric) list

The program starts as follows:

`[]`, enclose that, yielding

`[[]]`. Is that identical to `[]`? No, so we enclose that, yielding

`[[[]]]`. Is that identical to `[[]]`? No, so we enclose that...

Since each enclosure needs a new pointer, memory usage will slowly increase until WORKSPACE FULL.
> 1 votes

# Answer
# SmileBASIC, 18 bytes

```
@L
A$=A$+@A
GOTO@L

```

Keeps creating strings consisting of `@A@A@A...`. It would be much faster to use PUSH to modify the original string, but that would use more characters.
> 1 votes

# Answer
# √ å ı ¥ ® Ï Ø ¿ , 3 bytes

```
(1)

```

## Explanation

```
(   › Start an infinite loop
 1  › Push 1 to the stack
  ) › End an infinite loop

```
> 1 votes

# Answer
# C, 10 bytes

```
f(x){f();}

```

The x is needed for memory to be used in addition to stack space. This will endlessly make calls to itself each time taking ~32bits to store x.
> 1 votes

# Answer
# OIL, 12 bytes

Here in annotated form (remove anything but numbers to run):

```
1 # copy
-1 # from line -1 (containing, by default, a 0)
6 # to line 6 (the first line after the last line) %
8 # increment
2 # line 2 (marked with %)
6 # goto (since the next line will now be 0, go to line 0)

```

Even though seemingly nothing changes (lines are 0 by default and are being set to 0), internally, there's a difference between an unallocated line and a line with an explicit 0 in it.
> 1 votes

# Answer
# Aceto, 2 bytes

```
e>

```

Pushes *e* (2.71..) on the stack, and moves the IP back to the first cell.

There are of course many 2-byte solutions in Aceto, (any single character literal (`1234567890ePR'`), followed by a command that makes the thing infinite (I can think of `<>O`, but there might be more), but I chose `e>` because it looks a bit like a heart (`<3` sadly doesn't work).
> 1 votes

# Answer
# Rust, ~~35~~ 31 bytes

-4 bytes thanks to madlaina (`into_raw` -\> `leak`)

```
||loop{Box::leak(Box::new(0));}

```

Try it online

### Full program, 40 bytes

```
fn main(){loop{Box::leak(Box::new(0));}}

```

Try it online

Unlike the other Rust solution, this uses `Box::leak` to leak the boxed value, turning it into a `&'static mut i32`.
> 1 votes

# Answer
# asm2bf \- 15 bytes

```
@l
psh 1
jmp %l

```

Will push `1` until the interpreter/system runs out of memory.
> 1 votes

# Answer
# Kotlin, 27 bytes

```
var o=Any()
while(1>0)o={o}

```

Stacking functions returning functions.

54 bytes if no .kts: `fun main(a:Array<String>){var o=Any();while(1>0)o={o}}`
> 0 votes

# Answer
# F#, 22 bytes

`let rec f x=f(1::x);()`

Call it in F# interactive passing an empty list: `f []`

The function recursively calls itself, adding elements to the list. The tuple at the end is there so that the type inference can determine that the function return type is unit.
> 0 votes

# Answer
# BotEngine, 2x3=6

```
ve<
>e^

```

Rough translation:

```
forever:
  enqueue 'e'
  enqueue 'e'

```
> 0 votes

# Answer
# Java 104 bytes

```
import java.util.*;class A{public static void main(String[]a){List b=new ArrayList();for(;;)b.add(1);}}

```

This will allocate a List and let it grow constantly until it runs out of space.
> 0 votes

# Answer
# JavaScript - ~~14~~ 18 bytes

```
while(x=[self.x]);

```

Based on the activity on @Lmis' answer, some fun with evaluating expressions in intermediate scopes. Didn't manage to avoid reference errors :'(!
> 0 votes

# Answer
# Commodore 64

If `?STRING TOO LONG ERROR` counts, then this will work on the Commodore 64 and VIC-20:

```
0 a$=a$+" ":goto

```

or if you need `?OUT OF MEMORY ERROR` then:

```
0 dim a(255,255)

```

However, the last solution does not use a loop as the error is reported as soon as `run` is entered.
> 0 votes

# Answer
# C#, 28 bytes

```
()=>{var _="a";for(;;)_+=_;}

```

What is there to say? It adds the contents of `_` to `_` forever. Throws `OutOfMemoryException` almost instantly.
> 0 votes

# Answer
# Sinclair ZX80/ZX81 BASIC, ~14 bytes ~7 bytes (ZX81/ZX80 8K ROM), ~10 bytes ~5 bytes (ZX80 4K ROM)

```
 1 GOSUB 1

```

As there is never a return from the GOSUB (presented as `GO SUB` on the ZX80 with 4K ROM), the stack is filled which will eventually cause the interpreter to error. To clear the stack, simply enter `NEW` which should initiate a soft reset.
> 0 votes

# Answer
# c#, 55 bytes

```
class c{static void Main(){string c="";for(;;)c+='c';}}

```

Alternative 54 bytes

```
class c{static void Main(){string c="c";for(;;)c+=c;}}

```
> 0 votes

# Answer
# VB.NET, 162 bytes

```
Module m
    Sub Main()
        Dim s = ""
        While (1)
            s = s + "1" : Threading.Thread.Sleep(2147483647)
        End While
    End Sub
End Module

```

It won't really run forever but close enough. It should take about 584942417 years to allocate 8gb.
> 0 votes

# Answer
# Whitespace, 8 bytes

```

```

Try it online!

## Explanation

(s - space, t - tab, n - newline)

```
nssn ; Declares a label consisting of the empty sequence
nstn ; Call the procedure given by the empty label (declared above)

```

This is a slight abuse of the rules. The call procedure command jumps to the specified label and marks the current location for a later return. The mechanisms for doing this are implementation dependent but a basic implementation used by many interpreters is to push the current location to a call stack and pop values when a ret command is encountered. This will therefore end up filling up the call stack of the interpreter.

---

# Whitespace, 12 bytes - Fills the stack

```

```

Try it online!

## Explanation

```
nssn ; Declare label ''
sssn ; Push 0
nsnn ; Jump to label ''

```

Continuously pushes the value 0 to the stack, causing the stack to grow until the interpreter crashes.

---

# Whitespace, 29 bytes - Fills the heap

```

```

Try it online!

## Explanation

```
ssstn ; push 1
nssn  ; label ''
sns   ; duplicate n
tsss  ; add (effectively multiplies by 2)
sns   ; duplicate n (to use as a heap address)
sns   ; duplicate n (to use as a value)
tts   ; store n at the address n
nsnn  ; jump ''

```

Fills heap addresses given by 2^n with the value of 2^n, starting at n=1. Consumes memory faster on interpreters that implement the heap as an array but will also work for interpreters that use a non-contiguous data structure backing the heap (such as a dictionary/map).
> 0 votes

# Answer
# Implicit, 2 bytes

```
(a

```

Try it online! (Uses up all allowed TIO memory in about 1 second)

```
(   create jump point
 a  push 97
    implicit infinite loop

```
> 0 votes

# Answer
# Flurry, 14 bytes

```
(<>{}{({})}){}

```

Adapted from this answer. One of the `{}` terms is replaced with `{({})}`, a function which pushes its argument to the stack. Thus the infinite loop grows the stack on every iteration.
> 0 votes

# Answer
# Keg, 2 bytes

```
{a

```

Try it online!

Simply push infinite `a`s
> 0 votes

---
Tags: code-golf
---