65
\$\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\$
  • 5
    \$\begingroup\$ Do newlines count (as a distinct character) ? \$\endgroup\$ – zeppelin Jan 25 '17 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 Jan 25 '17 at 19:09
  • 2
    \$\begingroup\$ @zeppelin Yes, newlines count as a distinct character. \$\endgroup\$ – darrylyeo Jan 25 '17 at 19:58
  • 2
    \$\begingroup\$ What I mean to ask is, can a program output e.g. abcabcabc with a trailing newline? \$\endgroup\$ – ETHproductions Jan 25 '17 at 20:18
  • 1
    \$\begingroup\$ @ETHproductions Ah, I see. No, that is not allowed. Three trailing newlines would be acceptable, however. \$\endgroup\$ – darrylyeo Jan 25 '17 at 20:19

79 Answers 79

3
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Where are the 3 newlines? If you put your code in <pre><code>...</code></pre> in markdown, we'll be able to see them. \$\endgroup\$ – mbomb007 Jan 25 '17 at 21:06
  • \$\begingroup\$ @mbomb007 End of each line and one more at the end. Did that change anything? I don't see a difference... \$\endgroup\$ – Phlarx Jan 25 '17 at 21:22
  • \$\begingroup\$ Oh, wow.... there's gray boxes. Apparently the contrast or gamma or something is really screwed up on one of my monitors. \$\endgroup\$ – Phlarx Jan 25 '17 at 21:31
  • \$\begingroup\$ 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. \$\endgroup\$ – mbomb007 Jan 25 '17 at 21:35
3
\$\begingroup\$

C, 57 bytes

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

Output

^^-_-^-__

Alternative Version, 56 bytes

main(){printf("%1$d%1$d%1$d","({{pprrmmaainttff,,}})");}
\$\endgroup\$
  • \$\begingroup\$ { and } appear only once in your code, so I'm afraid this is not a valid answer. \$\endgroup\$ – Laikoni Apr 19 '17 at 8:14
  • \$\begingroup\$ You also have a non-multiple-of-three number of " \$\endgroup\$ – VisualMelon Apr 19 '17 at 8:28
  • \$\begingroup\$ @Laikoni added two more of { and }. \$\endgroup\$ – Khaled.K Apr 19 '17 at 9:07
  • 1
    \$\begingroup\$ @VisualMelon added ,"" to printf \$\endgroup\$ – Khaled.K Apr 19 '17 at 9:08
  • \$\begingroup\$ You can remove all three commas. \$\endgroup\$ – Jakob Jun 4 '18 at 1:36
3
\$\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\$
  • \$\begingroup\$ I think you can move two < to the end to drop the w. \$\endgroup\$ – Martin Ender Jan 25 '17 at 20:24
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

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

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.

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

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!

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

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

Try the old answer online!

Output is

-10-10-10

(no newlines in either the program or the output)

\$\endgroup\$
  • 5
    \$\begingroup\$ ♫ Barbara _A_A_Annn \$\endgroup\$ – mbomb007 Jan 25 '17 at 21:03
  • \$\begingroup\$ @mbomb007 LOL!! \$\endgroup\$ – Mitchell Spector Jan 25 '17 at 21:47
2
\$\begingroup\$

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 !

\$\endgroup\$
  • 2
    \$\begingroup\$ The newline only appears twice, I think you can add an extra newline at the end to meet this requirement \$\endgroup\$ – Cows quack Jan 25 '17 at 20:05
  • 2
    \$\begingroup\$ ^ What he said. Your source code's length must be divisible by 3. \$\endgroup\$ – mbomb007 Jan 25 '17 at 20:11
  • \$\begingroup\$ @KritixiLithos, mbomb007 - Thank you ! Should be fixed now ! \$\endgroup\$ – zeppelin Jan 25 '17 at 20:15
2
\$\begingroup\$

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)

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

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 
\$\endgroup\$
2
\$\begingroup\$

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.

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

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
\$\endgroup\$
  • \$\begingroup\$ 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 :/). \$\endgroup\$ – Cows quack Jun 15 '17 at 16:55
2
\$\begingroup\$

SQL Server, PostgreSQL, SQLite, 27 bytes

SELECT  111222333 SSELLCCTT

Oracle SQL, MySQL, 46 bytes

SELECT  111222333 SSELCCTTFFRROOMMDDUUAAL  FROM DUAL

Output

111222333
\$\endgroup\$
  • 1
    \$\begingroup\$ The top answer needs an extra E: SELECT 111222333 SSELLCCT makes it 27 bytes (which makes sense, 26 isn't a multiple of 3). \$\endgroup\$ – BradC Jun 15 '17 at 15:05
  • \$\begingroup\$ 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. \$\endgroup\$ – BradC Jun 15 '17 at 15:10
2
\$\begingroup\$

Ly, 15 bytes

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

Try it online!

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

Perl 5, 21 bytes

say"\\\"ssaayyxx33"x3

Try it online!

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

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
\$\endgroup\$
2
\$\begingroup\$

Java 8, 153 150 144 138 135 120 117 111 bytes

class Sbccddggmossuvvyy{public static void main(String... a){{};;System.out.print(",,,".replace(",", ",ab"));}}

-27 bytes thanks to @ØrjanJohansen.

Prints ,ab,ab,ab.

Try it online.

Code used to verify the occurrences of the characters are multiplies of 3, which is a modified version of my answer for a different challenge.

Explanation of the basic golfed program (72 bytes):

Try it online.

interface M{                          // Class
  static void main(String[]a){        //  Mandatory main-method
    System.out.print(",ab,ab,ab");}}  //   Print ",ab,ab,ab"

Things I (and @ØrjanJohansen) did to create multiples of 3:

  • Changed interface to class (and added public before static).
  • Changed class-name to Sbccddggmossuvvyy
  • Changed String[]a to String... a
  • Added unused no-op {}-block
  • Added two no-op ;
  • Changed ",ab,ab,ab" to ",,,".replace(",", ",ab")
\$\endgroup\$
  • 1
    \$\begingroup\$ You have nnn in there... Otherwise, I thought duplicating System.out.print("") seemed verbose, so I played around with some String methods, and managed to save 3 more bytes. Try it online!. \$\endgroup\$ – Ørjan Johansen Mar 19 '18 at 17:39
  • 1
    \$\begingroup\$ Another option with the same length. \$\endgroup\$ – Ørjan Johansen Mar 19 '18 at 17:40
  • \$\begingroup\$ @ØrjanJohansen Thanks! And not sure how I missed that nnn... Also, managed to golf three more by changing String...e to String...f, so we can remove the two e (and one f) in the interface name. \$\endgroup\$ – Kevin Cruijssen Mar 19 '18 at 17:45
  • 1
    \$\begingroup\$ Oh, replace can replace all those methods. Try it online! \$\endgroup\$ – Ørjan Johansen Mar 19 '18 at 18:00
  • 1
    \$\begingroup\$ Come to think of it, why not use replace for its intended purpose? Try it online! \$\endgroup\$ – Ørjan Johansen Mar 19 '18 at 18:19
2
\$\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\$
2
\$\begingroup\$

Pascal (FPC), 51 bytes

begin write('ABCABCABC')end.bbggin  wwrrtt(())dd..'

Try it online!

Boring one, please see below.


Pascal (FPC), 78 75 72 bytes

var f:int32;begin for f:=22to 33do write(' (())..:;;==abbdggvvww')end.a'

Try it online!

Output:

 (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww (())..:;;==abbdggvvww

(One string 12 times)

Based on 75-byte solution. I managed to remove 3 's by placing 1 from the string after end.. After parsing end., FPC parses 1 more token, then ignores the rest. ' alone after end. causes an error due to not closing the sting literal with another ', so I used one a from the string as a dummy token.


75-byte solution:

Breakthrough solution

var f:int32;begin for f:=22to 33do write(' ''(())''..:;;==aabbdggvvww')end.

Try it online!

Output:

 '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww '(())'..:;;==aabbdggvvww

(One string 12 times)


78-byte solutions:

var f:word;begin for f:=2to 22do write(' ''(())''..:;;==aabbgginoorrtvvw')end.

Try it online!

Output:

 '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw '(())'..:;;==aabbgginoorrtvvw

(one string 21 times)

or

var f:byte;begin for f:=2to 22do write(' ''(())''..:;;==aabdeegginvvwwyy')end.

Try it online!

Output:

 '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy '(())'..:;;==aabdeegginvvwwyy

(one string 21 times)

or

var f:char;begin for f:='a'to'c'do write('  (())..:;;==bbcdgghhinrrtvvww')end.

Try it online!

Output:

  (())..:;;==bbcdgghhinrrtvvww  (())..:;;==bbcdgghhinrrtvvww  (())..:;;==bbcdgghhinrrtvvww

That v in var really starts to annoy me...

\$\endgroup\$
  • \$\begingroup\$ Once you start adding things after end., you can just put all the extra chars there, scrap the var and for, and write a single constant string. \$\endgroup\$ – Ørjan Johansen Aug 28 '18 at 16:09
2
\$\begingroup\$

Pyth, 9 bytes

GGG\L\L\L

Try it online!

Outputs:

abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
L
L
L

(Note the trailing newline)

Explanation:

GGG\L\L\L - full program.
GGG       - output the entire alphabet 3 times, and a trailing newline
   \L\L\L - output L 3 times, and a trailing newline
\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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 

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

Retina, 27 bytes


aaabbb
S\`
S\`
S\`
\`\`\`

Try it online

The output is 150 bytes, containing 12 a, 12 b, and 126 newlines.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

V, 9 bytes

¬ac¬ac¬ac

Try it online!

This outputs:

ababcabcc

This is pretty straightforward. Each ¬ is the "range operator", that takes two character arguments and inserts each character in that range. So ¬ac inserts abc. Repeating this three times causes some weird issues with the layout of the output (which is why they're not in order) but thankfully this doesn't matter for this particular answer.

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

SmileBASIC, 9 bytes

?12?21?21

Output:

12
21
21

Not the most exciting thing, but it fulfills all 3 recommendations.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ Output typically has to be to stdout, not stderr. You should ask the OP if that's okay. \$\endgroup\$ – mbomb007 Jan 25 '17 at 22:53
  • \$\begingroup\$ @mbomb007 Maybe not: meta.codegolf.stackexchange.com/a/2451/36398 \$\endgroup\$ – Arc676 Jan 26 '17 at 9:30
  • \$\begingroup\$ @mbomb007 it's a default for allowed, but ill ask him. \$\endgroup\$ – P. Ktinos Jan 26 '17 at 14:36
  • \$\begingroup\$ @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. \$\endgroup\$ – mbomb007 Jan 26 '17 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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