74
\$\begingroup\$

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.

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

94 Answers 94

60
\$\begingroup\$

Brain-Flak, Flakcats, Brain-Flueue, Brain-Flak Classic, Miniflak, and Fλak 18 bytes

Proven optimal!

((([()][()][()])))

Try it online!

Explanation

Brain-Flak, Brain-Flueue, Miniflak, and Fλak

   ([()][()][()]) Push -3
  (              ) Copy
 (                ) Copy

This prints:

-3
-3
-3

(There is a trailing newline)

Brain-Flak Classic

Brain-Flak Classic is the original version of Brain-Flak and has some important differences from modern Brain-Flak. In BFC [...] prints its contents rather than negating it.

   [()] Print 1
       [()] Print 1
           [()] Print 1
  (            ) Push 3
 (              ) Push 3
(                ) Push 3

At the end of executing the contents of the stack (3 3 3) is printed.

This prints:

1
1
1
3
3
3

(There is a trailing newline)

Flakcats

Flakcats is quite different from the other 4 flaks and I am surprised that this works in Flakcats. The three operators here are nearly the same as the ones that Brain-Flak uses.

The main difference in this particular program between Flakcats is the (...) operator which in Flakcats is equivalent to ([{}]...) in Brain-Flak. This however does not make a difference to us because it picks up zeros and thus operates much in the same way that Brain-Flak does.

Here is that program compiled into Brian-Flak:

([{}]([{}]([{}][()][()][()])))

This prints:

-3
-3
-3

(There is a trailing newline)

Proof of Optimality in Brain-Flak and Miniflak

This is not a formal proof, but rather an informal proof that would have to be expanded to be made more rigorous

Because of the restrictions that Brain-Flak programs must be a balanced-string and the program length must be a multiple of 3 any valid submission must be a multiple of 6 in length. This means any solution smaller than 18 must be length 12.

Because of the outputs trailing newline the final height of the stack must be a multiple of three or we will break the restrictions on output.

Any valid submission of length 12 must have 2 types of braces (having less would break the restrictions on number of distinct characters and more would mean more than 12 characters). Since the program produces output it must have a push.

This leaves us to select our other set of braces. The options are:

<...>/<>

This fails because we need to generate "value" in order to create any number other than zero we must give up a () to create a one which makes it impossible to push more than two times.


[...]/[]

This fails for the same reason the last failed. The square braces are really bad at making value. The [] monad can create value but we need to push numbers first and we then don't have enough parens left over to push three times.


{...}/{}

This one is promising, we could create a loop and use one () to push multiple times, but alas it is not possible.

In order for the loop to end there must be a zero on the stack at some point and in order for us to have the correct output we must have something other than zero on the stack at the end of the program. Since we have neither [] nor <> the zero at the end of the loop must be a implicit zero from the bottom of the stack. This means the loop cannot add any new numbers to the stack making it useless.


Since none of the brace choices can create a program of length 12 none can exist.

Since Miniflak is a subset of Brain-Flak any shorter Miniflak program would also be a shorter Brain-Flak program and thus does not exist.

Proof of Optimality in Brain-Flueue

Brain-Flueue is a joke language based off of Brain-Flak. The two are so similar their interpreters are identical everywhere but two lines. The difference between the two is, as their names suggests, Brain-Flueue stores its data in queues while Brain-Flak stores its data in stacks.

To start we have the same restrictions on program size created by Brain-Flak, thus we are looking for a program of size 12. In addition we are going to need a (...) in order to create any output and another pair. the <> and [] pairs do not work in Brain-Flueue for the exact same reason they do not work in Brain-Flak.

Now we know that our program must consist of the characters ((())){{{}}}.

Via the same methods used in the previous proof we can demonstrate that there must be a loop in the final program.

Now here is where the proofs differ, because Brain-Flueue operates across queues rather than stacks the program can exit a loop with values on the queue.

In order to exit the loop we will need a zero in the queue (or an empty queue but if the queue is empty we get the same problem as Brain-Flak) this will mean that we will have to open our program with ({}) to create the zero. We will need a push inside of the loop to push the necessary number of items to the queue. We will also need to push a non zero number before the loop so that we can enter the loop at all; this will cost us at absolute minimum (()). We have now used more parens than we have.

Thus there is no Brain-Flueue program to do the task that is 12 bytes, and furthermore there our program is optimal.

Optimal solution in Flakcats and Brain-Flak Classic

The following solution is optimal in Flakcats and Brain-Flak Classic.

((([][][])))

Explanation

    [][][] -3
 (((      ))) push 3 times

Alternative 24 byte Brain-Flak solutions

(<((<((<(())>)())>)())>)

Try it online!

((<((<((<>)())>)())>)())

Try it online!

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

Try it online!

\$\endgroup\$
2
  • 2
    \$\begingroup\$ +1 for the proof as well. \$\endgroup\$
    – hyperneutrino
    Commented Jan 26, 2017 at 21:35
  • 3
    \$\begingroup\$ +1 for the polyglot as well, esp. not all outputs are the same. \$\endgroup\$ Commented Mar 17, 2018 at 2:04
31
\$\begingroup\$

Jelly, 9 bytes

**‘‘‘888*

A full program which prints 700227072, which is 888 cubed.

TryItOnline!

How?

**‘‘‘888* - Main link: no arguments
          - implicit L=R=0
*         - power       A = L ^ R = 1
  ‘       - increment   B = L + 1 = 1
 *        - power       C = A ^ B = 1
   ‘      - increment   D = C + 1 = 2
    ‘     - increment   E = D + 1 = 3
     888  - literal     F = 888
        * - power           F ^ E = 700227072
\$\endgroup\$
1
  • 7
    \$\begingroup\$ 888^3 is 700227072? That's very clever, perhaps other languages can use this trick. \$\endgroup\$ Commented Jan 26, 2017 at 16:08
24
\$\begingroup\$

Polyglot of purely literal answers, 9 bytes

333111222

This is a community wiki post for collecting answers that are just a literal that the language in question prints out automatically. Because it's a community wiki, feel free to edit it to add more languages where it works.

This program works in:

  • PHP
  • HTML (arguably not a language)
  • Jelly (and M)
  • 7 (more interesting, because the program's interpreted as both data and code; the first 3 prints the data, the rest of the program is useless stack manpulation)
  • CJam
  • Japt
  • Carrot
  • R (the R display also outputs [1] as metadata)
  • RProgN
  • Actually (though it actually prints 2\n2\n2\n1\n1\n1\n3\n3\n3\n)
  • ///
  • Noodel
  • TI-Basic
  • SimpleTemplate
  • ReRegex
  • Husk
  • Resource (although this outputs the string reversed)
  • cat

Ignoring the final newline, this is valid in quite a few more languages:

Most links go to Try It Online!

\$\endgroup\$
7
  • 3
    \$\begingroup\$ This prints 2\n2\n2\n1\n1\n1\n3\n3\n3\n in Actually, which is perfectly valid. Should that be added to the post? \$\endgroup\$ Commented Jan 25, 2017 at 20:10
  • 1
    \$\begingroup\$ @ETHproductions I actually think Actually should be added to the post since it uses the same code ;) \$\endgroup\$
    – user41805
    Commented Jan 25, 2017 at 20:12
  • 1
    \$\begingroup\$ As the person who made Actually, I agree that it belongs in this post. The newlines don't really make a difference. \$\endgroup\$
    – user45941
    Commented Jan 26, 2017 at 3:21
  • \$\begingroup\$ This also works on the language I've written: SimpleTemplate. It will compile it into an over-kill echo '333111222'; (in PHP) but it works. \$\endgroup\$ Commented Jan 26, 2017 at 18:13
  • 4
    \$\begingroup\$ @IsmaelMiguel: This is a community wiki answer; it was only 29% written by ETHproductions (and in fact, it was me who originally created the answer, as you can see from the revision history; ETHproductions has more text in the current version of the answer than anyone else, but definitely isn't responsible for the whole thing). Its entire purpose is to be edited by a large range of users as a collaborative effort. (This is distinct from normal answers, which aren't designed to be edited.) \$\endgroup\$
    – user62131
    Commented Jan 26, 2017 at 19:11
22
\$\begingroup\$

C#, 114 111 118 102 bytes

If we don't care about using proper words: (102 bytes)

class CCcddiilMMmmnrrSSsttvvWWyy{static void Main(){{System.Console.Write(("A TEA AT TEE"));;;}}}///".

If we care about proper words: (120 bytes)

class erebeWyvern{static void Main(){int embedWildbanana;{System.Console.Write(("A TEA AT TEE"));;}}}///CC Myst mvcSMS".

My original submission - case insensitive: (113 bytes)

class EreBeWyvern{static void Main(){int embedwildbanana; {System.Console.Write(("A TEA AT TEE"));;}}}/// vyt".

I know the comment isn't really in the spirit of the CG, but it's all I could come up with in a limited amount of time, I'll see if I can improve it through the day. Surely I must get at least some bonus points for the nod to being adventurous.

Edit: Thank you to roberto06 for catching the missing letters!

\$\endgroup\$
10
  • 1
    \$\begingroup\$ I'm a C++ guy, not C#, but can you not just wrap the Write call in {()} without affecting it? \$\endgroup\$
    – Sparr
    Commented Jan 25, 2017 at 20:01
  • 1
    \$\begingroup\$ You might be able to put the parentheses around the argument, rather than the call as a whole. \$\endgroup\$
    – user62131
    Commented Jan 25, 2017 at 20:11
  • 7
    \$\begingroup\$ Brownie points for the wild banana. \$\endgroup\$
    – darrylyeo
    Commented Jan 25, 2017 at 21:07
  • 6
    \$\begingroup\$ Nice! I like the variable names. +1 \$\endgroup\$ Commented Jan 26, 2017 at 1:53
  • 1
    \$\begingroup\$ You should remove V from your comment, and add vyt, since Vis only present there while v is present twice (typo, I guess), y is also present twice, and t is present 5 times. See here. Nevertheless, awesome job ! \$\endgroup\$
    – roberto06
    Commented Jan 26, 2017 at 8:56
21
\$\begingroup\$

JavaScript, 36 33 bytes

alert(((alert|alert||333111222)))

Alerts 333111222. This works because | converts both of its operands to 32-bit integers, and any value that doesn't look anything like an integer (e.g. the function alert) gets converted to 0. 0|0 is 0, so the || operator returns its right operand, or 333111222

A few more interesting versions:

(a="(trelalert)\\\"")+alert(a+=a+=a)

Outputs (trelalert)\"(trelalert)\"(trelalert)\".

A solution using .repeat would be the same length, thanks to the shared aert:

alert("(trpp.all)\\\"".repeat(3.33))

which outputs (trpp.all)\"(trpp.all)\"(trpp.all)\".

Taking advantage of the extra backslashes to get rid of l and p almost works:

a\x6cert("(trax.cc)\"".re\x70eat(6.00677))

This one outputs (trax.cc)"(trax.cc)"(trax.cc)"(trax.cc)"(trax.cc)"(trax.cc)".

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Nice abuse of decimals! \$\endgroup\$
    – darrylyeo
    Commented Jan 25, 2017 at 20:46
  • 2
    \$\begingroup\$ @darrylyeo Heh, thanks. I could've easily stuck those in the string, but that wouldn't be as fun ;-) \$\endgroup\$ Commented Jan 25, 2017 at 20:46
  • \$\begingroup\$ Thought I'd let you know you were topped by an ES6 answer. \$\endgroup\$
    – darrylyeo
    Commented Jan 28, 2017 at 3:30
15
\$\begingroup\$

CJam, 9 bytes

10,10,10,

Outputs 012345678901234567890123456789

Try it online!

Explanation

10,       The range from 0 to 9
   10,    The range from 0 to 9
      10, The range from 0 to 9
\$\endgroup\$
5
  • \$\begingroup\$ doesn't 3,3,3, work for 7 bytes? \$\endgroup\$
    – chim
    Commented Jan 26, 2017 at 9:46
  • \$\begingroup\$ Ah! yeah, the third requirement :) \$\endgroup\$
    – chim
    Commented Jan 26, 2017 at 9:48
  • \$\begingroup\$ Argh, a missed opportunity to use 99,99,99,, because why not? \$\endgroup\$ Commented Mar 18, 2018 at 7:58
  • \$\begingroup\$ @workoverflow Because that doesn't work with the third requirement. The program needs to contain three distinct characters. \$\endgroup\$
    – DLosc
    Commented Mar 20, 2018 at 8:41
  • \$\begingroup\$ @DLosc Touche, I forgot about that! \$\endgroup\$ Commented Mar 20, 2018 at 12:21
13
\$\begingroup\$

brainfuck, 12 bytes

++[+...][][]

Nobody said the output had to be short. This will output 3 copies of every ascii character except the first 2.

You can prove that this is as short as it will get. You need to output therefore you need 3 '.' there need to be different outputs therefore you need 3 [+-] now we're up to 6. 9 characters have to be printed, which means either adding 6 more '.' or adding a loop, which will add another 6 characters.

Try it online!

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

Perl 6, 15 bytes

.say;.say;.say;

Prints six distinct characters, three times each:

(Any)
(Any)
(Any)

Try it online!

How it works

  • A bare method call operates on the current topic, $_.
  • $_ starts out as the type object of type Any, which say prints as (Any).
\$\endgroup\$
1
10
\$\begingroup\$

Python 2, 36 30 bytes

Since a trailing newline isn't allowed, this is probably as short as it can get:

print"\\\""*3;print;print;3**3

Try it online

Outputs \" three times, followed by three newlines.


The below programs don't count the trailing newline, so they're not valid.

27 bytes:

print"""printprint"""*3*3*3

Prints 54 of each character in print.

Try it online


Same length, shorter output:

print"""printprint*3*3"""*3

Outputs printprint*3*3printprint*3*3printprint*3*3


24 bytes:

print~9;print~9;print~9;
\$\endgroup\$
6
  • \$\begingroup\$ You could do print"""printprint*3*3"""*3 for a much shorter output ;-) \$\endgroup\$ Commented Jan 25, 2017 at 20:05
  • \$\begingroup\$ Could you not do print 123;print 123;print 123; for the naive solution? \$\endgroup\$ Commented Jan 25, 2017 at 20:33
  • \$\begingroup\$ OP has clarified that the single trailing newline is not allowed (see comments). \$\endgroup\$
    – FlipTack
    Commented Jan 25, 2017 at 20:36
  • 1
    \$\begingroup\$ @ETHproductions Sure. It depends how naive we're being. \$\endgroup\$
    – mbomb007
    Commented Jan 25, 2017 at 20:43
  • 3
    \$\begingroup\$ Even more naive: print~9;print~9;print~9; \$\endgroup\$
    – Sp3000
    Commented Jan 25, 2017 at 22:35
9
\$\begingroup\$

PKod, 9 bytes

sonsonson

Outputs: 111222333


Explanation:

Background: PKod has only one variable that you mess with, with the code
This variable starts with default value of 0

s  -  Add next char to the variable, and jump over it. 
n  -  Print numeric value of variable

o has ascii char code "111" in decimal. Thus s adds 111 to the variable, then prints the number. First "son" makes it 111 and prints 111. Next makes it 222 and prints 222, lastly makes it 333 and prints 333

\$\endgroup\$
9
\$\begingroup\$

Ruby, 12 bytes

p$@;p$@;p$@;

outputs

nil
nil
nil

Try it online!

To fulfill the second "encouraged" criterion, I need 15 characters:

p 1;p 3;p 1133;

produces

1
3
1133

Try it online too!

\$\endgroup\$
9
\$\begingroup\$

C, 66 Bytes

main(i){{for(i=0;i<3;i++){printf("""poop+fart=<3<3at0m=m0n""");}}}

Output

poop+fart=<3<3at0m=m0npoop+fart=<3<3at0m=m0npoop+fart=<3<3at0m=m0n    

Old Version 72 Bytes

main(i){for(i=0;i<3;i++){printf("poop+fart=<3<3 at {\"0m=m0\"}" "\n");}}
\$\endgroup\$
1
  • 3
    \$\begingroup\$ Not only your code is much smaller than what I did, but it also contains real bits of poop and farts. Bravo. \$\endgroup\$
    – dim
    Commented Jan 26, 2017 at 19:57
9
\$\begingroup\$

JavaScript (ES6), 30 bytes

+alert((({alert}+{alert}+{})))

Outputs [object Object][object Object][object Object].

Works by creating three objects:

  • the first two are of the form { "alert" : alert } using ES6 notation {alert}

  • the third is a simple empty object

Then it uses + to concatenate them together, and all three have an identical expression as a string, [object Object].

The leading + is useless, only present to fill out the number of + characters, but is harmless to the output of the program.

\$\endgroup\$
3
  • \$\begingroup\$ Way to beat the other JS answer! \$\endgroup\$
    – darrylyeo
    Commented Jan 28, 2017 at 3:29
  • \$\begingroup\$ You should also add (ES6) to the title. \$\endgroup\$
    – darrylyeo
    Commented Jan 28, 2017 at 3:29
  • \$\begingroup\$ @darrylyeo Thanks! :) And I added ES6 \$\endgroup\$
    – apsillers
    Commented Jan 28, 2017 at 4:12
8
\$\begingroup\$

Hexagony, 9 bytes

x!!xx@@!@

Try it online!

Print out 120120120. x can be replaced by f-m (102-109)

Explanation

  x ! ! 
 x x @ @
! @ . . .

The xx@@ is only a filler to comply with the rules. The main flow is saving x into the memory (with ASCII value 120) and then print it as a number 3 times.

\$\endgroup\$
7
\$\begingroup\$

Microscript II, 9 bytes

{{{~~~}}}

Explanation: Creates a code block, but doesn't invoke it. When execution ends, the contents of the main register (IE this code block) are implicitly printed.

\$\endgroup\$
3
  • \$\begingroup\$ Have you posted something similar in the Quine challenge? \$\endgroup\$
    – wizzwizz4
    Commented Jan 25, 2017 at 19:08
  • \$\begingroup\$ @wizzwizz4 {} would technically be a quine, but I don't think it meets our definition of a "proper quine". The program "q"q (which I did submit to the quine challenge) does, however. \$\endgroup\$ Commented Jan 25, 2017 at 19:09
  • \$\begingroup\$ @wizzwizz4: That wouldn't be a proper quine, because each character represents itself. \$\endgroup\$
    – user62131
    Commented Jan 25, 2017 at 19:09
7
\$\begingroup\$

Bash + coreutils, 15 9 bytes

id;id;id;

Try it online!

Sample Output:

uid=1000 gid=1000 groups=1000 context=system_u:unconfined_r:sandbox_t:s0-s0:c19,c100,c173,c211
uid=1000 gid=1000 groups=1000 context=system_u:unconfined_r:sandbox_t:s0-s0:c19,c100,c173,c211
uid=1000 gid=1000 groups=1000 context=system_u:unconfined_r:sandbox_t:s0-s0:c19,c100,c173,c211

(If you try this out, it will print your uid, gid, etc., 3 times.)


If you want to avoid repeating the same string 3 times (and also have the same output for everybody, unlike my first answer), the best I've found for bash + Unix utilities is 15 bytes long:

dc<<<cczdzfzfdf

Try this second version online!

Output:

2
0
0
3
2
0
0
3
3
2
0
0

(No newlines in the program, 12 newlines in the output.)

Explanation of the dc program in this answer:

c Clears the stack.
Stack: (empty)

c Clears the stack.
Stack: (empty)

z Pushes the current size of the stack (0) onto the stack.
Stack: (top) 0

d Duplicates the item at the top of the stack.
Stack: (top) 0 0

z Pushes the current size of the stack (2) onto the stack.
Stack: (top) 2 0 0

f Prints the stack, top to bottom, with a newline after each item printed (this prints the first 3 lines of the output, 2 / 0 / 0 /)

z Pushes the current size of the stack (3) onto the stack.
Stack: (top) 3 2 0 0

f Prints the stack, top to bottom, with a newline after each item printed (this prints the next 4 lines of the output, 3 / 2 / 0 / 0 /)

d Duplicates the item at the top of the stack.
Stack: (top) 3 3 2 0 0

f Prints the stack, top to bottom, with a newline after each item printed (this prints the final 5 lines of the output, 3 / 3 / 2 / 0 / 0 /)
\$\endgroup\$
4
  • \$\begingroup\$ How does the second one work? \$\endgroup\$
    – 2xsaiko
    Commented Feb 1, 2017 at 14:56
  • \$\begingroup\$ @therealfarfetchd I've added an explanation to the answer. \$\endgroup\$ Commented Feb 1, 2017 at 17:39
  • \$\begingroup\$ Damn, dc is far more powerful than I thought. Nice job! \$\endgroup\$
    – 2xsaiko
    Commented Feb 3, 2017 at 15:02
  • \$\begingroup\$ @therealfarfetchd Thanks. I like dc. Btw, there were a couple of typos in the explanation which I just fixed. \$\endgroup\$ Commented Feb 4, 2017 at 0:08
7
\$\begingroup\$

C, 111 bytes

(Note how the byte count is also the three same numbers. Wow. You can't do more meta than that.)

#include<stdio.h>
#define b "<acdhlmoprsu>."
#define t "en"
main(){{{printf(("<acdhlmoprsu>." b b t t t));;;}}}

Prints:

<acdhlmoprsu>.<acdhlmoprsu>.<acdhlmoprsu>.enenen
\$\endgroup\$
6
\$\begingroup\$

PHP, 33 bytes

<?=($s="<?;<?=;'".'"').($s).($s);

Opted for something more interesting than the 9-byte program with no PHP tag.

Outputs <?;<?=;'"<?;<?=;'"<?;<?=;'"

Try it online!

\$\endgroup\$
6
\$\begingroup\$

99, 15 bytes

9 9  9999
9
9
9

That is nine nines, three spaces, and three line feeds, the output is -1110-1110-1110.

Try it online!

How?

9 9  9999 - V(9)=V(9)-V(9999)=1-1111=-1110
9         - print V(9)
9         - print V(9)
9         - print V(9)

The two spaces are treated as one, this third space could be a trailing space on any line too.

\$\endgroup\$
6
\$\begingroup\$

LOLCODE, 273 240 (360 286) bytes

HAI 1.2
I HAS A U
IM IN YR M UPPIN YR Q TIL BOTH SAEM Q 1
VISIBLE "Y SUB.EK"
IM OUTTA YR M
IM IN YR T UPPIN YR Q TIL BOTH SAEM Q 2
VISIBLE "Y SUB.EK"
IM OUTTA YR T
IM IN YR X UPPIN YR Q TIL BOTH SAEM Q 12
VISIBLE "IM"
IM OUTTA YR X
KTHXBYE

Note the trailing new line and try it online. The second line was more or less arbitrary and can possibly replaced by a shorter command, but I just learned LOLCODE for this puzzle. Since the version number is required in the first line, I used the numbers to add loops of length 1, 2 and 0 mod 3 to ensure the right number of characters will be printed. From this I simply counted each character (with this tool). If it appeared 0 mod 3 times, no action was required. If it appeared 1 mod 3 times, it was added to the 1- and 2-loop so it would appear three times in the output. If it appeared 2 mod 3 times, the character was added to the 12-loop. EDIT: By replacing the first VISIBLE with an assignment (still useless but required to have 12 instead of 11 new lines), I was able to cut off 33 bytes.

Output (60 byte):

Y SUB.EK
Y SUB.EK
Y SUB.EK
IM
IM
IM
IM
IM
IM
IM
IM
IM
IM
IM
IM

Note the trailing new line.

Nice thing about this solution in comparison to the other answers is that the Output can easily manipulated to output somewhat meaningful text. Example (286 bytes with trailing new line):

HAI 1.2
I HAS A U
IM IN YR MW UPPIN YR Q TIL BOTH SAEM Q 1
VISIBLE "YO SUB. EEEEK!"
IM OUTTA YR MW
IM IN YR STA UPPIN YR Q TIL BOTH SAEM Q 2
VISIBLE "YO SUB. EEEEK!"
IM OUTTA YR STA
IM IN YR XURG UPPIN YR Q TIL BOTH SAEM Q 12
VISIBLE "IMO U R SWAG! "
IM OUTTA YR XURG
KTHXBYE

Try it online. Output (222 bytes with trailing new line):

YO SUB. EEEEK!
YO SUB. EEEEK!
YO SUB. EEEEK!
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 
IMO U R SWAG! 

Sadly, I'm not as good with anagrams as I thought :')

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Welcome to the site! \$\endgroup\$
    – DJMcMayhem
    Commented Mar 17, 2018 at 0:51
  • \$\begingroup\$ @DJMcMayhem Thanks. Anything I need to do to get LOLCODE such a nice automatic linking as I copied from other posts? (the # [language] style) The link to the source code is contained in the answer. \$\endgroup\$
    – SK19
    Commented Mar 17, 2018 at 0:55
  • \$\begingroup\$ The easiest way is, when you've put your program in TIO, to use the link menu and select (or copy) the choice for "Code Golf Submission". That gives you a template for a new post. I copied the part you seemed to be missing from there. \$\endgroup\$ Commented Mar 17, 2018 at 1:12
6
\$\begingroup\$

SHELL

to joke :) ( 9 Bytes )

ls;ls;ls;

or more seriously ( 24 Bytes )

sed s/./sed.g./g <<< edg

Result :

sed.g.sed.g.sed.g.
\$\endgroup\$
5
\$\begingroup\$

PHP, 24 bytes

<?=111?><?=222?><?=333?>
\$\endgroup\$
4
  • 1
    \$\begingroup\$ What does this output? How does it work? \$\endgroup\$
    – DJMcMayhem
    Commented Jan 25, 2017 at 22:59
  • 1
    \$\begingroup\$ It uses the PHP shorttag <? together with the immediate echo statement <?= to output 123 3 times. \$\endgroup\$ Commented Mar 18, 2018 at 4:43
  • \$\begingroup\$ The shorter version you just edited in is invalid since the <= ?> characters don't appear a multiple of 3 times. \$\endgroup\$
    – DJMcMayhem
    Commented Mar 18, 2018 at 5:14
  • \$\begingroup\$ Ah, right, I knew there was a reason for the original version being as it was - I completely flaked on the requirement - I will change it back. \$\endgroup\$ Commented Mar 18, 2018 at 5:17
4
\$\begingroup\$

V, 9 bytes

12i12i12i

Try it online!

Outputs 12i 24 times:

12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i

Vim, 12 bytes

12i12i12i<ESC><ESC><ESC>

Outputs the same as the V answer

\$\endgroup\$
4
\$\begingroup\$

Batch, 36 21 bytes

@echo
@echo
@echo

Outputs

ECHO is on.
ECHO is on.
ECHO is on.

Edit: Saved 15 bytes thanks to @P.Ktinos.

\$\endgroup\$
2
4
\$\begingroup\$

Befunge 93, 9 bytes

...,,,@@@

TIO

Prints 0 0 0 (Trailing space, followed by 3 null bytes)

Because Befunge's stack is padded with 0s, we can print both the ASCII character with that value, and the integer itself. Because Befunge automatically prints a space after an integer, we are left with 3 distinct characters.

. prints 0 (trailing space), , prints a null byte, and @ ends the program

\$\endgroup\$
4
\$\begingroup\$

Japt, 9 bytes

000OoOoOo

Prints undefinedundefinedundefined. Test it online!

Explanation

This code gets transpiled into the following JavaScript:

000,O.o(O.o(O.o()))

O.o is a function that outputs something without a trailing newline. When given no argument, it prints undefined, which could be considered a bug, but comes in handy here. It also returns undefined, so all three calls prints undefined.

I'm sure there are plenty of other ways to do this...

\$\endgroup\$
1
  • 1
    \$\begingroup\$ O_o Interesting :) \$\endgroup\$ Commented Jan 26, 2017 at 16:34
4
\$\begingroup\$

05AB1E, 9 bytes (I guess you could say this was a piece of PI)

-0 bytes thanks to Emigna/ETHProductions, made the solution more correct.

žqžqžq???

Alternate versions:

ž[g-Q]ž[g-Q]ž[g-Q]???

[g-Q] - Can put any letter a-Q here, as long as they all match (see below).

Try it online!

Explained:

PI,PI,PI,SORT,JOIN,SORT,JOIN,SORT,JOIN.

Result:

...111111222333333333444555555555666777888999999999

The reason it is only 9 bytes is because you don't need the sorts, I just put them in to help illustrate.

Result w/o { in the code:

3.1415926535897933.1415926535897933.141592653589793


Alternative Renditions:

The following commands can be used in place of PI:

ž 23  > žg       push current year
        žh       push [0-9]
        ži       push [a-zA-Z]
        žj       push [a-zA-Z0-9_]
        žk       push [z-aZ-A]
        žl       push [z-aZ-A9-0_]
        žm       push [9-0]
        žn       push [A-Za-z]
        žo       push [Z-Az-a]
        žp       push [Z-A]
        žq       push pi
        žr       push e
        žu       push ()<>[]{}
        žy       push 128
        žz       push 256
        žA       push 512
        žB       push 1024
        žC       push 2048
        žD       push 4096
        žE       push 8192
        žF       push 16384
        žG       push 32768
        žH       push 65536
        žI       push 2147483648
        žJ       push 4294967296
        žK       push [a-zA-Z0-9]
        žL       push [z-aZ-A9-0]
        žM       push aeiou
        žN       push bcdfghjklmnpqrstvwxyz
        žO       push aeiouy
        žP       push bcdfghjklmnpqrstvwxz
        žQ       push printable ASCII character set (32-128)
\$\endgroup\$
10
  • 2
    \$\begingroup\$ Get out for the pun; for the trick though get one :) \$\endgroup\$ Commented Jan 26, 2017 at 16:29
  • \$\begingroup\$ Nice one! I don't think žv, žw, or žx are valid though as they each have only 2 distinct digits. \$\endgroup\$ Commented Jan 26, 2017 at 16:36
  • \$\begingroup\$ Hmm, what's the point of the backwards character classes? \$\endgroup\$ Commented Jan 26, 2017 at 16:38
  • \$\begingroup\$ @ETHproductions ahhh, forgot about at least 3, was just PI at first when I wrote it. What do you mean backwards character classes? \$\endgroup\$ Commented Jan 26, 2017 at 17:08
  • 1
    \$\begingroup\$ Note that this is only valid if you don't count the newline that's implicitly printed. That could easily be fixed by replacing JJJ with ??? though. \$\endgroup\$
    – Emigna
    Commented Jan 27, 2017 at 12:40
4
\$\begingroup\$

Cubix, 12 bytes

A bit of a boring answer really. Outputs three 10s followed by newlines

N@N@NOoOoOo@

Try it online! Maps to the cube

    N @
    N @
N O o O o O o @
. . . . . . . .
    . .
    . .

N Pushs 10 to the stack
Oo x3 Outputs 10 and newline
@ halts the program

The initial N@N@ is not hit.

\$\endgroup\$
3
  • \$\begingroup\$ I count 34 spaces :/ \$\endgroup\$
    – SK19
    Commented Mar 16, 2018 at 22:41
  • \$\begingroup\$ @SK19 The code is N@N@NOoOoOo@ and does not include any spaces. \$\endgroup\$
    – MickyT
    Commented Mar 17, 2018 at 2:17
  • \$\begingroup\$ Ah, okay, I thought the cube needed to fulfill the requirement, too \$\endgroup\$
    – SK19
    Commented Mar 17, 2018 at 10:58
4
\$\begingroup\$

Japt, 9 bytes

`í`²²²í`í

Try it online!

Outputs

''sseerreerreerr'sererer'sererer'sererer'sererer'sererer'sererer'sererer

which contains each char of 'sererer 9 times.

I found this by accident while experimenting with Japt, and wanted to share this which IMO is much more interesting than a number literal polyglot and a solution that has three dummy bytes and simply prints something three times, even though those are also 9 bytes.

How it works

`í`²²²í`í

`í`        Shoco-compressed string of "'sererer"
   ²       Repeat 2 times
    ²      Repeat 2 times
     ²     Repeat 2 times
      í    Interleave with ... into a string
       `í    Shoco-compressed string of "'sererer"

Japt uses shoco library for string compression, which excels at compressing sequences of lowercase letters. It's actually surprising that one byte can decompress into an 8-char string.

\$\endgroup\$
4
\$\begingroup\$

SMBF, 18 15 12 bytes

This program prints its source code backwards. The first loop [[..]] and last < could be removed if it weren't for the source-restriction.

[[..]]<[.<]<

Try it online

Output:

<]<.[<]]..[[

Proof of Optimality:

Since the output requires at least nine characters (3 unique, 3 each), the program either needs nine prints . plus 3x2 other instructions to meet the source-restriction (this means 15 bytes), or the code uses a loop.

If it uses a loop, the characters necessary are []., three of each. Of course, a movement instruction < or > is necessary to avoid an infinite loop, meaning that a valid solution will be at least 12 bytes.

\$\endgroup\$
1
  • \$\begingroup\$ I think you can move two < to the end to drop the w. \$\endgroup\$ Commented Jan 25, 2017 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.