Write a program that produces an output such that:
- At least three distinct characters appear.
- 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:
- 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 code-golf. Shortest code in bytes wins.
97 Answers 97
Brain-Flak, Flakcats, Brain-Flueue, Brain-Flak Classic, Miniflak, and Fλak 18 bytes
Proven optimal!
((([()][()][()])))
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
(<((<((<(())>)())>)())>)
((<((<((<>)())>)())>)())
((((((()()()){}){}){})))
-
3\$\begingroup\$ +1 for the polyglot as well, esp. not all outputs are the same. \$\endgroup\$Shieru Asakoto– Shieru Asakoto2018年03月17日 02:04:01 +00:00Commented Mar 17, 2018 at 2:04
Jelly, 9 bytes
**‘‘‘888*
A full program which prints 700227072, which is 888 cubed.
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
-
7\$\begingroup\$
888^3is700227072? That's very clever, perhaps other languages can use this trick. \$\endgroup\$ETHproductions– ETHproductions2017年01月26日 16:08:28 +00:00Commented Jan 26, 2017 at 16:08
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
3prints 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:
- 05AB1E
- 2sable
- GolfScript
- PowerShell
- m4 (any version, the program is portable)
- Pyth
- MATL
- Pip
- Stax
- Ink
- Keg
- Vyxal
Most links go to Try It Online!
-
3\$\begingroup\$ This prints
2\n2\n2\n1\n1\n1\n3\n3\n3\nin Actually, which is perfectly valid. Should that be added to the post? \$\endgroup\$ETHproductions– ETHproductions2017年01月25日 20:10:09 +00:00Commented 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– user418052017年01月25日 20:12:55 +00:00Commented 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– user459412017年01月26日 03:21:05 +00:00Commented 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\$Ismael Miguel– Ismael Miguel2017年01月26日 18:13:27 +00:00Commented Jan 26, 2017 at 18:13 -
5\$\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– user621312017年01月26日 19:11:35 +00:00Commented Jan 26, 2017 at 19:11
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!
-
1\$\begingroup\$ I'm a C++ guy, not C#, but can you not just wrap the Write call in {()} without affecting it? \$\endgroup\$Sparr– Sparr2017年01月25日 20:01:05 +00:00Commented 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– user621312017年01月25日 20:11:12 +00:00Commented Jan 25, 2017 at 20:11
-
7\$\begingroup\$ Brownie points for the wild banana. \$\endgroup\$darrylyeo– darrylyeo2017年01月25日 21:07:05 +00:00Commented Jan 25, 2017 at 21:07
-
6\$\begingroup\$ Nice! I like the variable names. +1 \$\endgroup\$MercyBeaucou– MercyBeaucou2017年01月26日 01:53:42 +00:00Commented Jan 26, 2017 at 1:53
-
1\$\begingroup\$ You should remove
Vfrom your comment, and addvyt, sinceVis only present there whilevis present twice (typo, I guess),yis also present twice, andtis present 5 times. See here. Nevertheless, awesome job ! \$\endgroup\$roberto06– roberto062017年01月26日 08:56:34 +00:00Commented Jan 26, 2017 at 8:56
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)".
-
2\$\begingroup\$ Nice abuse of decimals! \$\endgroup\$darrylyeo– darrylyeo2017年01月25日 20:46:03 +00:00Commented 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\$ETHproductions– ETHproductions2017年01月25日 20:46:49 +00:00Commented Jan 25, 2017 at 20:46
-
\$\begingroup\$ Thought I'd let you know you were topped by an ES6 answer. \$\endgroup\$darrylyeo– darrylyeo2017年01月28日 03:30:41 +00:00Commented Jan 28, 2017 at 3:30
CJam, 9 bytes
10,10,10,
Outputs 012345678901234567890123456789
Explanation
10, The range from 0 to 9
10, The range from 0 to 9
10, The range from 0 to 9
-
\$\begingroup\$ doesn't 3,3,3, work for 7 bytes? \$\endgroup\$chim– chim2017年01月26日 09:46:56 +00:00Commented Jan 26, 2017 at 9:46
-
\$\begingroup\$ Ah! yeah, the third requirement :) \$\endgroup\$chim– chim2017年01月26日 09:48:15 +00:00Commented Jan 26, 2017 at 9:48
-
\$\begingroup\$ Argh, a missed opportunity to use
99,99,99,, because why not? \$\endgroup\$workoverflow– workoverflow2018年03月18日 07:58:06 +00:00Commented 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– DLosc2018年03月20日 08:41:17 +00:00Commented Mar 20, 2018 at 8:41
-
\$\begingroup\$ @DLosc Touche, I forgot about that! \$\endgroup\$workoverflow– workoverflow2018年03月20日 12:21:02 +00:00Commented Mar 20, 2018 at 12:21
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.
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
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.
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;
-
\$\begingroup\$ You could do
print"""printprint*3*3"""*3for a much shorter output ;-) \$\endgroup\$ETHproductions– ETHproductions2017年01月25日 20:05:59 +00:00Commented Jan 25, 2017 at 20:05 -
\$\begingroup\$ Could you not do
print 123;print 123;print 123;for the naive solution? \$\endgroup\$ETHproductions– ETHproductions2017年01月25日 20:33:19 +00:00Commented Jan 25, 2017 at 20:33 -
\$\begingroup\$ OP has clarified that the single trailing newline is not allowed (see comments). \$\endgroup\$FlipTack– FlipTack2017年01月25日 20:36:22 +00:00Commented Jan 25, 2017 at 20:36
-
1\$\begingroup\$ @ETHproductions Sure. It depends how naive we're being. \$\endgroup\$mbomb007– mbomb0072017年01月25日 20:43:33 +00:00Commented Jan 25, 2017 at 20:43
-
3\$\begingroup\$ Even more naive:
print~9;print~9;print~9;\$\endgroup\$Sp3000– Sp30002017年01月25日 22:35:28 +00:00Commented Jan 25, 2017 at 22:35
Perl 6, 15 bytes
.say;.say;.say;
Prints six distinct characters, three times each:
(Any) (Any) (Any)
How it works
- A bare method call operates on the current topic,
$_. $_starts out as the type object of typeAny, whichsayprints as(Any).
-
1\$\begingroup\$ Now I've got a Yeah Yeah Yeahs song stuck in my head. \$\endgroup\$Stuart P. Bentley– Stuart P. Bentley2017年01月26日 10:45:57 +00:00Commented Jan 26, 2017 at 10:45
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");}}
-
4\$\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– dim2017年01月26日 19:57:02 +00:00Commented Jan 26, 2017 at 19:57
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.
-
\$\begingroup\$ Way to beat the other JS answer! \$\endgroup\$darrylyeo– darrylyeo2017年01月28日 03:29:01 +00:00Commented Jan 28, 2017 at 3:29
-
\$\begingroup\$ You should also add
(ES6)to the title. \$\endgroup\$darrylyeo– darrylyeo2017年01月28日 03:29:31 +00:00Commented Jan 28, 2017 at 3:29 -
\$\begingroup\$ @darrylyeo Thanks! :) And I added ES6 \$\endgroup\$apsillers– apsillers2017年01月28日 04:12:36 +00:00Commented Jan 28, 2017 at 4:12
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
Ruby, 12 bytes
p$@;p$@;p$@;
outputs
nil
nil
nil
To fulfill the second "encouraged" criterion, I need 15 characters:
p 1;p 3;p 1133;
produces
1
3
1133
Hexagony, 9 bytes
x!!xx@@!@
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.
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.
-
\$\begingroup\$ Have you posted something similar in the Quine challenge? \$\endgroup\$wizzwizz4– wizzwizz42017年01月25日 19:08:39 +00:00Commented 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\$SuperJedi224– SuperJedi2242017年01月25日 19:09:17 +00:00Commented Jan 25, 2017 at 19:09 -
\$\begingroup\$ @wizzwizz4: That wouldn't be a proper quine, because each character represents itself. \$\endgroup\$user62131– user621312017年01月25日 19:09:58 +00:00Commented Jan 25, 2017 at 19:09
Bash + coreutils, (削除) 15 (削除ここまで) 9 bytes
id;id;id;
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 /)
-
\$\begingroup\$ How does the second one work? \$\endgroup\$2xsaiko– 2xsaiko2017年02月01日 14:56:10 +00:00Commented Feb 1, 2017 at 14:56
-
\$\begingroup\$ @therealfarfetchd I've added an explanation to the answer. \$\endgroup\$Mitchell Spector– Mitchell Spector2017年02月01日 17:39:38 +00:00Commented Feb 1, 2017 at 17:39
-
\$\begingroup\$ Damn, dc is far more powerful than I thought. Nice job! \$\endgroup\$2xsaiko– 2xsaiko2017年02月03日 15:02:10 +00:00Commented 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\$Mitchell Spector– Mitchell Spector2017年02月04日 00:08:59 +00:00Commented Feb 4, 2017 at 0:08
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
PHP, 33 bytes
<?=($s="<?;<?=;'".'"').($s).($s);
Opted for something more interesting than the 9-byte program with no PHP tag.
Outputs <?;<?=;'"<?;<?=;'"<?;<?=;'"
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.
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.
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 :')
-
1\$\begingroup\$ Welcome to the site! \$\endgroup\$DJMcMayhem– DJMcMayhem2018年03月17日 00:51:02 +00:00Commented 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– SK192018年03月17日 00:55:44 +00:00Commented 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\$Ørjan Johansen– Ørjan Johansen2018年03月17日 01:12:55 +00:00Commented Mar 17, 2018 at 1:12
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.
PHP, 24 bytes
<?=111?><?=222?><?=333?>
-
1\$\begingroup\$ What does this output? How does it work? \$\endgroup\$DJMcMayhem– DJMcMayhem2017年01月25日 22:59:49 +00:00Commented Jan 25, 2017 at 22:59
-
1\$\begingroup\$ It uses the PHP shorttag
<?together with the immediateechostatement<?=to output 123 3 times. \$\endgroup\$junkfoodjunkie– junkfoodjunkie2018年03月18日 04:43:27 +00:00Commented 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– DJMcMayhem2018年03月18日 05:14:32 +00:00Commented 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\$junkfoodjunkie– junkfoodjunkie2018年03月18日 05:17:59 +00:00Commented Mar 18, 2018 at 5:17
Japt, 9 bytes
`í`222í`í
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
`í`222í`í
`í` Shoco-compressed string of "'sererer"
2 Repeat 2 times
2 Repeat 2 times
2 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.
V, 9 bytes
12i12i12i
Outputs 12i 24 times:
12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i12i
Vim, 12 bytes
12i12i12i<ESC><ESC><ESC>
Outputs the same as the V answer
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.
-
2\$\begingroup\$ Wouldn't 3 alone echo's work? echo\necho\necho - replace \n with a new line - it looks valid to me image.prntscr.com/image/ef96173169eb41168815203387d4975b.png , makes it 14 bytes. \$\endgroup\$Offtkp– Offtkp2017年01月25日 20:56:23 +00:00Commented Jan 25, 2017 at 20:56
-
\$\begingroup\$ Outgolfed: codegolf.stackexchange.com/a/108180/63033 \$\endgroup\$Offtkp– Offtkp2017年01月25日 22:37:43 +00:00Commented Jan 25, 2017 at 22:37
Befunge 93, 9 bytes
...,,,@@@
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
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...
-
1\$\begingroup\$ O_o Interesting :) \$\endgroup\$geisterfurz007– geisterfurz0072017年01月26日 16:34:07 +00:00Commented Jan 26, 2017 at 16:34
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).
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)
-
2\$\begingroup\$ Get out for the pun; for the trick though get one :) \$\endgroup\$geisterfurz007– geisterfurz0072017年01月26日 16:29:01 +00:00Commented Jan 26, 2017 at 16:29
-
\$\begingroup\$ Nice one! I don't think
žv,žw, oržxare valid though as they each have only 2 distinct digits. \$\endgroup\$ETHproductions– ETHproductions2017年01月26日 16:36:27 +00:00Commented Jan 26, 2017 at 16:36 -
\$\begingroup\$ Hmm, what's the point of the backwards character classes? \$\endgroup\$ETHproductions– ETHproductions2017年01月26日 16:38:32 +00:00Commented 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\$Magic Octopus Urn– Magic Octopus Urn2017年01月26日 17:08:43 +00:00Commented 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
JJJwith???though. \$\endgroup\$Emigna– Emigna2017年01月27日 12:40:50 +00:00Commented Jan 27, 2017 at 12:40
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.
-
\$\begingroup\$ I count 34 spaces :/ \$\endgroup\$SK19– SK192018年03月16日 22:41:50 +00:00Commented Mar 16, 2018 at 22:41
-
\$\begingroup\$ @SK19 The code is
N@N@NOoOoOo@and does not include any spaces. \$\endgroup\$MickyT– MickyT2018年03月17日 02:17:59 +00:00Commented Mar 17, 2018 at 2:17 -
\$\begingroup\$ Ah, okay, I thought the cube needed to fulfill the requirement, too \$\endgroup\$SK19– SK192018年03月17日 10:58:37 +00:00Commented Mar 17, 2018 at 10:58
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.
[[..]]<[.<]<
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.
-
\$\begingroup\$ I think you can move two
<to the end to drop thew. \$\endgroup\$Martin Ender– Martin Ender2017年01月25日 20:24:30 +00:00Commented Jan 25, 2017 at 20:24
123123123will work, as currently written.) \$\endgroup\$abcabcabcwith a trailing newline? \$\endgroup\$