# Three-Three-Three!

Write a program that produces an output such that:

1. At least three distinct characters appear.
2. The number of occurrences of each character is a multiple of 3.

For example, A TEA AT TEE is a valid output since each of the 4 distinct characters, A, E, T and (space), occurs 3 times.

Of course, a challenge about the number 3 needs to have a third requirement. So:

1. The program itself must also follow the first two requirements. (This means your program will be at least 9 bytes long.)

You must write a full program, not a function. Be sure to show your program's output in your answer.

Also, to keep things interesting, you are highly encouraged:

• not to use comments to meet requirement 3 if you can help it
• to produce output that isn't just a string repeated 3 times
• to make the output different from the program itself (for languages that can automatically output the contents of its own program, you can contribute to this community wiki).

This is . Shortest code in bytes wins.

• Do newlines count (as a distinct character) ? Jan 25 '17 at 19:05
• Are programs that consist entirely of literals allowed? (There are a lot of languages where 123123123 will work, as currently written.)
– user62131
Jan 25 '17 at 19:09
• @zeppelin Yes, newlines count as a distinct character. Jan 25 '17 at 19:58
• What I mean to ask is, can a program output e.g. abcabcabc with a trailing newline? Jan 25 '17 at 20:18
• The challenge title doesn't meet the criteria, lol Mar 19 '18 at 14:11

# R, 9 bytes

c ;c ;c ;


Try it online!

Outputs

function (...) .Primitive("c") function (...) .Primitive("c") function (...) .Primitive("c")

This is a boring solution, still working on a more creative one.

# Pepe, 24 bytes

rEeEEeeEEErreEErreEEreEE


Try it online!

Program contains 6 r's, 6 e's, and 12 E's.

Explanation:

rEeEEeeEEErreEErreEEreEE # full program

rEeEEeeEEE               # push '103' to the stack
rreEErreEE     # output as int (r flag: preserve)
reEE # output as int


Output:

103103103


# Brachylog, 9 bytes

000gggwww


Try it online!

Prints [[[0]]]00. Exploits (unnecessarily, it turns out) the fact that, in the absence of constraints on a variable, its value is taken to be zero, and the w predicate which prints the value of its input variable without a newline places no constraints on its output variable. (In fact, if this was allowed to have only two unique characters, gggwww would produce the same output, and gwgwgw or wgwggw would also work.)

      w      Print
000          zero
g         enclosed in a list
g        enclosed in a list
g       enclosed in a list,
w     and print something with no supplied value,
w    and print something with no supplied value.


Various permutations of this program work, and are more visually novel than the one presented here, but it's the first version I came up with and to my mind very much to the point. Some permutations include 0gw0gw0gw which violates the second encouragement, w0gw00ggw which has a nice escalating effect, ggwgww000 which shows that the zeros being there really doesn't matter (it may as well be ggwgww777), and nothing containing the substring g0 since no matter what is on the left of the g 0 cannot possibly be a list containing it as its only element so the program will either fail or infinitely spew garbage as it tries to backtrack around the problem depending on whether or not there was a w earlier.

Less trivial variations on the same theme include 3ggw3gw3w, XgggwXwwX, w≡g≡wg≡gw, and w?gw?ggw? (which is actually compliant even with input!) I expected not to find a 9-byte solution and was pleasantly surprised to find a whole family of them.

# INTERCAL, 84 bytes

PLEASE.4<-#4DOREADOUT.4DOREADOUT.4DOREADOUT.4DOGIVEUPPLEASELEAS..4<<--##DDOOUUGGIIVV


Try it online!

Ignores the second encouragement and essentially ignores the third (since unreachable syntax errors are pretty much comments), because I'm not feeling quite insane enough today to work around them in INTERCAL. Prints


IV

IV

IV



(6 spaces, 6 newlines, 3 Is, 3 Vs), transparently just three instances of the Roman numeral 4 which could actually just as well have been any other number since spaces get printed above them taking care of the third unique character. Had to be printed three times because number output brings two newlines along with it. Attempting to just print a third newline alone makes it a bit longer...

# INTERCAL, 99 bytes

DO,1<-#1DO,1SUB#1<-#176DOREADOUT,1DO.3<-#3PLEASEREADOUT.3PLEASEGIVEUPDOOODD##UUBB7766REEAAT.LGGIIVV


Try it online!

Prints



III



(3 spaces, 3 newlines, 3 Is). Uses both numeric output and C-INTERCAL-style array output. Exactly as long as a version using just array output:

# INTERCAL, 99 bytes

DO,9<-#9DO,9SUB#1<-#41DO,9SUB#4<-#77DO,9SUB#7<-#14PLEASEREADOUT,9PLEASEGIVEUPDO,<<--##SULRRTTGGIIVV


Try it online!

Prints

ëëëQQQ>>>


(no spaces or newlines for once). This is the approach which feels most clever to me, as it turns an obstructive feature of array output into a tool: when trying to output a value from an array, what it actually outputs is the previous value minus the value mod 256 with its bits read backwards. This makes it rather difficult to print any particular value, but means that if we want to print a string of repeating characters, we don't need to actually set the corresponding elements of the array, because arrays initialize their elements to zero, and the difference between two identical codepoints is also zero. So this only sets the first, fourth, and seventh elements of ,9, and hypothetically it could even get away with not setting the first one but I'm not sure that null bytes are valid characters.

# INTERCAL, 87 bytes

DO,9<-#9DO,9SUB#4<-#7DO,9SUB#7<-#9DOREADOUT,9PLEASEGIVEUPPLEASEDO,,#SSUUB447RRTTLGGIIVV


Try it online!

If they are, then this version here still loses to the first one by 3 bytes, and prints this unprintable mess: 00 00 00 9F 9F 9F 0F 0F 0F.

# stacked, 24 bytes

''''   'putput'3*3*3*put


Try it online! Outputs 54 each of p u and t.

# Ouroboros, 12 bytes

n11n222n1(((


Outputs 011222 three times. Try it here.

### How?

In Ouroboros, each line of code represents a snake swallowing its tail. Execution proceeds from the head (start) of the line to the tail (end), and then loops back to the head. The ( instruction swallows characters from the tail. If the instruction pointer is swallowed, execution halts.

The n command outputs a number. Popping the empty stack gives zero, so the first n prints 0. The next prints 11, and the third prints 222.

Now we come to 1(: push 1 and swallow that many characters. The final paren is swallowed. The next-to-last paren does nothing1, and execution loops back to the beginning.

The second time through, the next-to-last paren is swallowed and we loop again. The third time, the third-to-last paren is swallowed. This swallows the IP, and the program ends.

1 The stack is empty, so it swallows 0 characters.

• "...each line of code represents a snake swallowing its tail" (⊙.☉)7 Jan 27 '17 at 1:12
• @Luigi en.wikipedia.org/wiki/Ouroboros (but yeah, that is a bit trippy) Jan 27 '17 at 3:46

## Retina, 18 12 bytes

Byte count assumes ISO 8859-1 encoding.


aaa¶¶ccc

¶


prints


a
a
a

c
c
c



That's 12 linefeeds.

Try it online!

# dc, 9 bytes

zfzfdzddf


Try it online!

Output:

0
1
0
3
3
3
1
1
0


(The program has no newlines; the output has 9 newlines.)

The new answer above is better than my old answer of the same length, because the new answer meets OP's suggestion that the output ideally shouldn't be the same string repeated 3 times. Here's the old answer, which I'll keep here so that @mbomb007's comment continues to make sense!

_A_A_Annn


Output is

-10-10-10


(no newlines in either the program or the output)

• ♫ Barbara _A_A_Annn Jan 25 '17 at 21:03
• @mbomb007 LOL!! Jan 25 '17 at 21:47

# Chip, 30 bytes

**ZZZZZZZZZT
*gggaaabbbTT



Output:

@@@AAACCC


Try it online!

(score includes 3 total newlines, and 3 bytes for -w on the command line)

Chip is a new language I've been designing, and this is it's first real test drive! It's a 2D bit-based language that functions somewhat like an integrated circuit you might put together with a breadboard.

This solution outputs three @'s (binary 01000000), three A's (01000001), then three C's (01000011) by turning the bits successively on.

### Breakdown

Ungolfed (or, really, without the excess parts):

*ZZZZZZZZZ
g  a  b  T


* is a source element which produces a high signal; that is sent to
g , which represents the bit 0x40 of the output stream, and
Z , which propagates signal after one clock tick. After 3 ticks (for three Z elements),
a receives a high signal, and now the 0x1 bit is also on. Three ticks later,
b turns on the 0x2 bit, and three ticks again activates
T , which terminates execution.

All other added elements are active (e.g. not a comment), but they don't do anything, similar to assigning a variable to itself.

• Where are the 3 newlines? If you put your code in <pre><code>...</code></pre> in markdown, we'll be able to see them. Jan 25 '17 at 21:06
• @mbomb007 End of each line and one more at the end. Did that change anything? I don't see a difference... Jan 25 '17 at 21:22
• Oh, wow.... there's gray boxes. Apparently the contrast or gamma or something is really screwed up on one of my monitors. Jan 25 '17 at 21:31
• I had that problem with a monitor a few months back. It fixed itself after a few days. Idk what caused it, but changing settings wouldn't fix it. Also, that final newline is required in the markdown, because the block shows one less due to some SE formatting issue. Jan 25 '17 at 21:35

# C, 57 bytes

main(){printf("^^-_-^-__","");("{{pprrmmaainttff,,}}");;}


Output

^^-_-^-__


Alternative Version, 56 bytes

main(){printf("%1$d%1$d%1$d","({{pprrmmaainttff,,}})");}  • { and } appear only once in your code, so I'm afraid this is not a valid answer. Apr 19 '17 at 8:14 • You also have a non-multiple-of-three number of " Apr 19 '17 at 8:28 • @Laikoni added two more of { and }. Apr 19 '17 at 9:07 • @VisualMelon added ,"" to printf Apr 19 '17 at 9:08 • You can remove all three commas. Jun 4 '18 at 1:36 # JSFuck (JavaScript), 84 bytes !![]+!![]+[!![]+!![]]+(!![]+!![])+(+!![])+(+!![])+(+!![])+(+[])+(+[])+(+[])+(([[]]))  Try it online! first we take the 3 shortest chars to express in jsfuck: 0: +[] (3 chars) 1: +!![] (5 chars) 2: !![]+!![] (9 chars)  combining them to get "222111000" we get this (75 chars) (this requires putting the second char in an array but then after that we can just add the other characters with the + operator): !![]+!![]+[!![]+!![]]+(!![]+!![])+(+!![])+(+!![])+(+!![])+(+[])+(+[])+(+[])  this has these charcounts: [ & ]: 13 ( & ): 7 !: 18 +: 17  we can increase our +, (), and [] counts just enough by adding an arithmetic 0 to the end (+(([[]]))). # Plumber, 45 bytes ]][] ==[[=]=]] []][ [[=][ [[=][[[= =]][[=  Try it online! The ]] and == at the beginning of the first two lines do nothing except lower the number of spaces and increase the number of those characters, and there are two trailing newlines to bring the total up to 6. This outputs the numbers 111000222. Characters: • 15 [ • 12 ] • 9 = • 6 \n • 3   # Squire commit c82e0e5, 21 bytes dump(dump(dump(III)))  Squire hath provideth a strange builtin called dump, which releases some forbidden knowledge about what it was called with, then rewards the value itself. Outputeth: Number(3) Number(3) Number(3)  # Forth, 21 bytes  1 1 1 . cr . cr . cr  Program contains 3 of each of 1.cr, and 9 spaces. Output contains 3 ones, 3 spaces, and 3 newlines. Try it online Output: Each 1 has a space after it. 1 1 1  # Pip, 9 bytes PzPzPzuuu  Outputs the lowercase alphabet three times, each time followed by a newline. Try it online! ### Explanation The naive attempt P12P12P12  actually prints 12 four times. That's because Pip autoprints the result of the last expression in the program. P12 prints 12, but it is also an expression that evaluates to 12. So an extra 12 is printed. We can avoid this by making the last expression in the program evaluate to nil. When nil is printed, it produces no output--not even a newline. The variable u is preinitialized to nil. Repeating it three times is fine, just adds a couple no-ops. # Retina, 27 bytes  aaabbb S\ S\ S\ \\\  Try it online The output is 150 bytes, containing 12 a, 12 b, and 126 newlines. # Del|m|t, 15 bytes TIO 8 9 8 9 8 9 555  Prints 0 0 0  (with a trailing space) (there are null bytes after every space, including the trailing one Because the stack is padded with 0s, we can just print the ASCII value and character, because printing the value also prints a space. 555 ends the program. # Del|m|t, 21 bytes TIO ; ; ; 8 8 8 8 8 8 555  prints 32 -1 32 -1 32 -1  (with a trailing space) No command line argument =   as delimiter ; pushes -1 followed by the delimiter, and 8 prints the top of the stack. 555 ends the program Here's another interesting solution with 24 bytes total: TIO ; 0 / / 8 8 8 >>>;;00/  (2 trailing spaces to make it a multiple of 3) This one just uses the -1, but is longer due to the lack of repetition, so the "end" command had to be pretty long prints -1 -1 -1  (also a trailing space) The ; pushes the delimiter (as above), the 0 drops the top, so the stack only has a -1 on it. / /  duplicates it twice, and 3 8s print. >>>;;00/  ends the program ## Batch ~ 9 bytes bc bc bc  Two random chars, followed by a new line, makes 3 chars that are shown 3 times. Hex dump: 62 63 0A 62 63 0A 62 63 0A ## Output: C:\Users\4story\Desktop>bc 'bc' is not recognized as an internal or external command, operable program or batch file. C:\Users\4story\Desktop>bc 'bc' is not recognized as an internal or external command, operable program or batch file. C:\Users\4story\Desktop>bc 'bc' is not recognized as an internal or external command, operable program or batch file.  My environment username happens to be "4story". However, it doesnt matter what directory you are in, or what your username is - output will always fulfill the rules. • Output typically has to be to stdout, not stderr. You should ask the OP if that's okay. Jan 25 '17 at 22:53 • @mbomb007 Maybe not: meta.codegolf.stackexchange.com/a/2451/36398 Jan 26 '17 at 9:30 • @mbomb007 it's a default for allowed, but ill ask him. Jan 26 '17 at 14:36 • @P.Ktinos It has a lot of downvotes as well. For each 3 upvotes, there are at least 2 downvotes. The other answers are far less controversial. Jan 26 '17 at 14:39 # GNU Sed, 12 bytes Golfed abc abc abc  (note the trailing newline) How It Works a text Appending text after a line. This is a GNU extension. Appends the "bc" string + LF 3 times, resulting in 3 b, 3 c and 3 LF characters in the output. Test %echo|sed -n 'abc abc abc ' bc bc bc %echo|sed -n 'abc abc abc '|tr \\n N|fold -1|sort|uniq -c 3 N 3 b 3 c  Try It Online ! • The newline only appears twice, I think you can add an extra newline at the end to meet this requirement Jan 25 '17 at 20:05 • ^ What he said. Your source code's length must be divisible by 3. Jan 25 '17 at 20:11 • @KritixiLithos, mbomb007 - Thank you ! Should be fixed now ! Jan 25 '17 at 20:15 # Bash, 21 bytes A pure Bash solution that has no external dependencies.  e== ;e=cchhoo;echo$e$e$e;


# Testing script

For convenience, I also wrote a test script that counts the number of occurrences of a character in a string. You can use it to validate your own solutions.

o={};
prompt.split.forEach(
ch=>o[ch]=o[ch]?o[ch]+1:1
);console.log(o)

• Question states "... full program. Not an answer". Off of this I think this is invalid. Jan 26 '17 at 16:25
• @geisterfurz007 Fixed. Jan 26 '17 at 16:40
• Looking good I think :) Just noticed that I wrote an answer instead of a function... Jan 26 '17 at 16:57

# Labyrinth, 12 bytes

Program:

!!!(!(!(!@@@


Output:

000-1-1-1


The last two @ aren't technically a comment, but they're just as useless. However, it's kind of inevitable since @'s a necessary character to exit a Labyrinth.

Explanation:

Labyrinth's stack contains an infinite number of 0's at the bottom.

!: pops the top of the stack and prints its decimal representation

(: decrements the top of the stack by 1

@: terminates the program

Because this program is a single line, most of Labyrinth's rules for deciding what direction to go are irrelevant; it just moves down the line from left to right.

# VBA, 12 Bytes

Anonymous VBE immediates window function that takes no input and outputs to the VBE immediates window.

?75:?75:?75:


## Output

75
75
75


## Python 27 Characters

print"\\\"printprint**"*333


The output and code comply with the rules. All characters occur 3 times in the code, as you can probably see. Since I'm multiplying by multiply of 3 the output will always be divisible by 3.

# Carrot, 21 bytes

aaa^*2^bbb^*2^ccc^*2^


Outputs:

aaaaaaaaabbbaaaaaaaaabbbaaaaaaaaabbbcccaaaaaaaaabbbaaaaaaaaabbbaaaaaaaaabbbcccaaaaaaaaabbbaaaaaaaaabbbaaaaaaaaabbbccc


Which is a 117 byte long string containing 81 as, 27 bs and 9 cs.

This also works for 9 bytes but it isn't as fun:

aaabbbccc

• I see you have an interest in Carrot :D Maybe you can help me decide a potential feature change in chat (don't mind the wrong ping in the message btw :/). Jun 15 '17 at 16:55

# SQL Server, PostgreSQL, SQLite, 27 bytes

SELECT  111222333 SSELLCCTT


Oracle SQL, MySQL, 46 bytes

SELECT  111222333 SSELCCTTFFRROOMMDDUUAAL  FROM DUAL


Output

111222333

• The top answer needs an extra E: SELECT 111222333 SSELLCCT makes it 27 bytes (which makes sense, 26 isn't a multiple of 3). Jun 15 '17 at 15:05
• Other 27-character solutions exist, like PRINT 123PRINT 123PRINT 123 (for MS SQL), but I think I found one for 24: PRINT 12PRINT 12PRINT 12, since we can count the newline that PRINT produces. Jun 15 '17 at 15:10

# Ly, 15 bytes

'&::'o::'&::o&o


Try it online!

# Perl 5, 21 bytes

say"\\\"ssaayyxx33"x3


Try it online!

# Turing Machine, 180 bytes

name: z
init: init
accept: accept

init,_
a1,0,>
a1,_
a2,0,>
a2,_
b0,0,>
b0,_
b1,1,>
b1,_
b2,1,>
b2,_
c0,1,>
c0,_
c1,2,>
c1,_
c2,2,>
c2,_
accept,2,>

name,3
name,3,-
za0,3
za0,-,-


Note the trailing new line. You can paste the source code into here. The machine takes 3*3=9 steps by simply going right and outputting 000111222 (the infinite blank symbols _ to the left and right are not counted). The last two states are unused states to have the source code fulfill the requirements. The used alphabet is _0123-, which is also dividable by 3 :-)

# Stax, 9 bytes

..3.3**3*


Run and debug online!

The output may not be what one would expect. Hope this is more interesting. Still output the same string repeated thrice, though.

## Explanation

..3          Two character literal. ASCII: [46, 51]
.3*       Two character literal, "3*"
*      Interlace, [46, "3*", 51]
3*    Repeat 3 times
Implicit output