# 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) ? – zeppelin 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. – darrylyeo Jan 25 '17 at 19:58
• What I mean to ask is, can a program output e.g. abcabcabc with a trailing newline? – ETHproductions Jan 25 '17 at 20:18
• @ETHproductions Ah, I see. No, that is not allowed. Three trailing newlines would be acceptable, however. – darrylyeo Jan 25 '17 at 20:19

# MATL, 12 9 bytes

3 Bytes saved thanks to @Luis

JVvJVvJVv


Outputs:

0 +1i
0 +1i
0 +1i


Try it Online!

Explanation

J is the shortcut for the complex number 0 + 1i. We convert this to a string with V and repeat this motif 3 times and concatenate the entire stack vertically three times using v.

• @LuisMendo Unfortunately since MATL trims trialing newlines it only has 2 :( – Suever Jan 25 '17 at 21:01
• @LuisMendo Ah you're right! There's also the newline in the TIO version. Thanks – Suever Jan 25 '17 at 21:04

# VBA, 123 bytes

Sub Auto_Open()
god_fx = ("OK" + " X")
For rapid = 1 To 3
MsgBox god_fx, 3 + 1 = rapid, Mid("mk OK X", 3 + 1)
Next
End Sub


It's a sub, but when you paste it in an empty Excel workbook, it'll run when you open the workbook.

Displays a MsgBox with in it 3x the text "OK" and 3x an "X" (the close button looks like an 'X', right?!) It even does this 3 times in a row for good measure :)

There are only 5 line endings in here, but that's because the VBA IDE always appends an empty line, making it 6 again. And since VBA doesn't care about case, I didn't either :P

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

# tcl, 24

puts 12
puts 12
puts 12


In the code, there is an Enter at the bottom, which the site ate.

Output: the output consists of 12Enter12Enter12Enter

demo

• This answer is invalid. The occurrences of each character used in your program must be a multiple of 3. – darrylyeo Jan 28 '17 at 3:41
• @darrylyeo: fixed now. – sergiol Jan 30 '17 at 0:33
• ...And that includes the space and the letters in puts. – darrylyeo Jan 30 '17 at 1:58
• @darrylyeo: Now fixed. Indeed. – sergiol Feb 2 '17 at 0:20

# Python 3, 87 bytes

AET=' TEE'
exec("""print('A TE');exec('print("A AT");exec("print(AET)")')""")
AET=="";



Try it online!

I wasn't going for the shortest solution - I just really, really wanted to abuse exec.

It can probably be made shorter, though I don't remember the last time I've had this much fun golfing python. Great challenge!

# Octave, 21 bytes

'ans==ans '%%%ans=  '
ans = ans==ans


Creates a string: 'ans==ans ', that's automatically printed (since ; is omitted), with ans = in front of it.

## REXX, 21 bytes

say 10
say 10
say 10


Outputs three 10s and three newlines.

I can think of funnier output, but since this is code golf, this is what you get.

# Braingolf, 27 bytes [non-competing]

20111[!_!_!_+]2200++[][];;;


Try it online!

It's a cheap method, but only one I can find that works in braingolf.

## Explanation

20111[!_!_!_+]2200++[][];;;
20111                        Pushes 2, 0, 1, 1 and 1 to the stack
[.......]               While loop, runs 3 times..
!_!_!_                 ..Prints the last item on the stack 3 times without popping
+                ..Pops and sums the last 2 items, pushing the result
2200           Pushes 2, 2, 0 and 0 to the stack
++         Sums 0 and 0, then 0 and 2
[]       While loop, runs 4 times, does nothing
[]     While loop, runs 3 times, does nothing
;;;  Suppress implicit output (then do it 2 more times)


# Triangular, 21 bytes

3>\..3...(;...d/dp]%<


Try it online!

Formats into this triangle:

     3
> \
. . 3
. . . (
; . . . d
/ d p ] % <


Prints 210210210. (2, 1 and 0 each printed 3 times.)

The program with only conrol flow:

     .
> \
. . .
. . . .
. . . . .
/ . . . . <


The above is a nice loop we can fit the code into. To achieve the desired output we simply want to print 210 three times. So we push 3 to the stack (the number of times we want to print it) and then 3 after a directional (3 decrements to 2, then to 1, then to 0).

The first directional \ pushes 3 to the stack, then puts the code into this loop: (d%]. That loop first decrements the top of stack, then prints it, then jumps back if the vale is nonzero.

The next part looks like this: pd; which pops the ToS (to get rid of the 0), decrements the new ToS (which was the 3 we pushed at the start), exit if the ToS is <= 0, then uses directionals to get back into the initial loop.

• I like how the triangle code contains 30 spaces :) – SK19 Mar 16 '18 at 22:44
• Each character in the source should appear three times – Jo King Mar 16 '18 at 22:55

# Aceto, 18+1=19 bytes

Requires the use of the command-line switch -l

"aaabbbccc"\p\p\"p


Prints, unsurprisingly, aaabbbccc.

# Attache, 24 bytes

Print!73Print!73Print!73


Try it online!

The output is (with a trailing newline):

73
73
73


For bonus "encouragement" points:

### Attache, 30 bytes

"PPrriinntt""""||**33"*3|Print


Try it online!

This is just:

"PPrriinntt""""||**33"*3|Print
"                    "            a string ("" is an escaped double quote)
*3          repeated 3 times
|Print    then print that string


# 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 :-)

# PHP, 27 bytes

<?=$s=";\<?=\",\<?;",$s,$s;  prints ;\<?=",\<?; three times <?=$s="\<<?=\",\>>",$s,$s?>


prints \<<?=",\>> three times

<?=$s=";<?,<?=;","$s","$s";  prints ;<?,<?=; three times Run with -n or try them online. TiO includes checks and two variants of a 30 byte solution. # JsFuck, 1044 Bytes [!!(([[]]))][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+[+[]]]+(![]+[])[+!![]]+(![]+[])[!![]+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]])()(+(+!![]+[!![]+!![]]+(+[])+(+!![])+(!![]+!![])+(+[])+(+!![])+(!![]+!![])+(+[])))  Bad one ## Matlab, 12 bytes 1:3,1:3,1:3,  Try it Online! # ink, 30 bytes -(i)>:{(-3):{(3)}} {3>i:->i}  Outputs >:3 >:3 >:3  and a trailing newline. The output was actually mostly unintentional. Try it online! ### Explanation -(i) Labelled gather - we can read how many times we've visited this part by looking at the variable i. We can also divert to here. >: Print the characters > and : {(-3): If negative 3 is nonzero... {(3)}} ...print the value of the number 3 Having at least one linebreak makes ink print a newline. (we have three) {3>i: If we've passed (i) fewer than three times... ->i} ...jump to (i)  # Boring alternative, 9 bytes 11 21 22  Outputs 11 21 22  and a trailing newline. As long as there are four lines, exactly three of which contain one or more characters, you can move and replace the characters (almost) however you want. ### Explanation We just print non-space characters as we encounter them, and print a newline whenever we encounter some number of linebreaks (and/or the end of the program) Try it online! # No printing literal characters at all, 39 bytes -(i){3:{-3}}{0:{(0)}}{0}<><>{(i<3):->i}  Outputs -30-30-30 with no trailing newline. This is basically the opposite of how you're supposed to use ink. Try it online! ### Explanation -(i) Labelled gather - we can read how many times we've visited this part by looking at the variable i. We can also divert to here. {3: If 3 is nonzero (it is) {-3}} Print -3 {0: If 0 is nonzero (is isn't) {(0)}} ...print 0 (we won't) {0} Print 0 (we *will*) <><> This is glue. It suppresses newlines. {(i<3): If we've passed (i) fewer than 3 times... ->i} ...divert to (i)  # Zsh, 18 bytes <<<$_
<<<$_ <<<$_



Try it online!

Also valid: $- with default options, and sometimes $$. # Zsh36 33 30 27 bytes This solution produces an acyclic output: echo {e,h,o}{,{}} eho\\cc\  echo {e,h,o}{,{}} eho\\cc\ {e,h,o}{,{}} # expands to e h o e{} h{} o{} eho # eho \\c # '\c' stops printing  The output contains 3 e, 3 h, 3 o, 3 {, 3 {, and 6 <space>. Comments on 33 byte solution: -3 bytes by using ) as the end of the range (still divisible by 3) <<<${(F):-{F..)}{F..)}$-$-((::..}
${ :- } # empty string fallback {F..)} # The range {F..)} has 30 elements... {F..)}{F..)} # so {F..)}{{F..)} has 900 elements$-$-((::.. # Leftover junk, added to each of the 900 elements${(F)                        }  # Join by newlines
<<<                                # Print to stdout



If trailing newlines are allowed, then <<<aabbccabc is a 12 byte solution.

# APL (Dyalog Unicode), 9 bytes

,⎕A,⎕A,⎕A


This prints the alphabet, 3 times.

Try it online!

Also works for the digits 0-9:

,⎕D,⎕D,⎕D


Try it online!

# Runic Enchantments, 9 bytes

aaa333@@@


Try it online!

### Explanation

Pushes 10 three times, pushes 3 three times, then prints and terminates. The extra two @ serve no purpose beyond complying with challenge requirements. "3*@" would comply with output rules (and is the shortest program that can), but does not comply with source rules.

import string
import random
nw_ls = list("".join(random.choice(string.ascii_uppercase) for _ in range(40)))
print("".join(nw_ls))
s_ls = dict()
for i in range(len(nw_ls)):
count = 0
for j in range(1,len(nw_ls)-1):
if nw_ls[i] == nw_ls[j]:
count += 1
if count % 3 == 0 and count > 1:
s_ls[nw_ls[i]] = count
print("".join(s_ls))

• Welcome to PPCG! Unfortunately, your answer doesn't seem to follow the challenge specifications - neither the source, nor the output has the number of occurrences of each character equal to a multiple of 3. Also, keep in mind that this is code-golf, so you should aim for the shortest possible code, and to be considered "serious contender" you should at the very least get rid of multi-char variable names and unnecessary whitespace. – Kirill L. Mar 26 at 12:29