Output with the same length as the code

In this challenge, you should write a program or function which takes no input and prints or returns a string with the same number of bytes as the program itself. There are a few rules:

• You may only output bytes in the printable ASCII range (0x20 to 0x7E, inclusive), or newlines (0x0A or 0x0D).
• Your code must not be a quine, so the code and the output must differ in at least one byte.
• Your code must be at least one byte long.
• If your output contains trailing newlines, those are part of the byte count.
• If your code requires non-standard command-line flags, count them as usual (i.e. by adding the difference to a standard invocation of your language's implementation to the byte count), and the output's length must match your solution's score. E.g. if your program is ab and requires the non-standard flag -n (we'll assume it can't be combined with standard flags, so it's 3 bytes), you should output 5 bytes in total.
• The output doesn't always have to be the same, as long as you can show that every possible output satisfies the above requirements.
• Usual quine rules don't apply. You may read the source code or its size, but I doubt this will be shorter than hardcoding it in most languages.

You may write a program or a function and use any of the standard methods of providing output. Note that if you print the result, you may choose to print it either to the standard output or the standard error stream, but only one of them counts.

You may use any programming language, but note that these loopholes are forbidden by default.

This is , so the shortest valid answer – measured in bytes – wins.

Leaderboard

var QUESTION_ID=121056,OVERRIDE_USER=8478;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){var F=function(a){return a.lang.replace(/<\/?a.*?>/g,"").toLowerCase()},el=F(e),sl=F(s);return el>sl?1:el<sl?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• – Martin Ender May 17 '17 at 11:19
• "Your code must not be a quine" but... but... it's tagged quine – Okx May 17 '17 at 11:21
• @Okx Because it's a generalised quine, i.e. the required output depends on the source code. – Martin Ender May 17 '17 at 11:22
• @MartinEnder You should probably disallow output by exit code, which is a default. If you allow it nearly every one byte program in nearly every language is allowed. One user has already done this – Wheat Wizard May 17 '17 at 22:37
• @WheatWizard output by exit code is not a string, so it doesn't apply here. – Martin Ender May 18 '17 at 4:29

PHP, 21668 7 bytes

<?=1e6;


Try it online!

Thanks to Jörg I'm beating Okx again :D

• <?=1e6; 7 Bytes – Jörg Hülsermann May 17 '17 at 12:10

TAESGL, 1 byte

S


Interpreter

Outputs a single space character

Other solutions

"≠        2 bytes, "≠" converted to "!="
«Ā»       3 bytes, decompresses "Ā" which is equal to "the"
SŔ4)      4 bytes, " " repeated 4 times
5ē)ĴT     5 bytes, first 5 Fibonacci numbers joined
G→6,"A    6 bytes, draws a line to the right of "A" for 6 characters


Stack Cats, 1 + 3 = 4 bytes

+


Try it online!

Requires either the -o or -n flag for numeric output. Prints two zeros, with a linefeed each.

Explanation

Stack Cats has a tape of stacks which are all initialised to an infinite wells of zeros, but the starting stack has a -1 on top (which acts as a terminator when input is given). The + command swaps the first and third element on the current stack. So:

-1           0
0           0
0     +    -1
0   ---->   0
.           .
.           .
.           .


At the end of the program, the current stack is printed from top to bottom. Since the -1 is again treated as a terminator, it's not printed itself. Due to the -o flag, the values are printed as decimal integers with trailing linefeeds.

Octave, 7 bytes

[['']]'


Try it online!

TI-Basic (TI-84 Plus CE OS 5.2+), 4 bytes

toString(10^(3

tostring( is a two-byte token, 10^( is a one-byte token. This returns the string "1000" which is 4 bytes long.

• @Scrooble toString( is a two byte token, so the output does need to be 4 bytes, not 3, even though it has 3 tokens – pizzapants184 Sep 10 '17 at 4:43
• I know. I probably shouldn't post anything at 12:30 AM to avoid embarrassment. I was too slow to recall my comment before you saw it. – Khuldraeseth na'Barya Sep 10 '17 at 4:46

Fission, 4 bytes

R"N;


Try it online!

Prints N;R with a trailing linefeed.

The R creates a right-going atom. " toggles string mode which traverses an immediately prints N;R (wrapping at the end of the line). Then N prints a linefeed and ; destroys the atom, terminating the program.

AWK, 21 bytes

BEGIN{printf"%21s",0}


Try it online!

Simply prints:

                    0


The 0 could of course be any digit. No new line is printed, since that would add 2 bytes.

OCaml, 22 bytes

List.find ((=) "") []


Outputs

Exception: Not_found.


It search for "" (empty string) in the empty list []

• Welcome to PPCG! It seems this prints a trailing linefeed, so the output is actually 23 bytes. (I don't know OCaml but I imagine the easiest fix would be to pad the code with another space, or add a trailing linefeed to it as well.) – Martin Ender May 18 '17 at 16:07
• Hi, the output is 22 bytes when counting the newline ! However, for the code, I added the trailing newline to the count – juloo65 May 18 '17 at 16:12
• Ah okay, should have counted the bytes then. It might be good if you mentioned that both code and output include the linefeed. – Martin Ender May 18 '17 at 16:14

Ruby, 3 bytes

p""


Prints this, plus a newline

""


Here's another 3 byte one:

p:a


Prints this, plus a newline

:a


R, 7 bytes

stop( )

Prints Error: (with a trailing space)

16 bytes (only works in version 3.3.1)

version$nickname Prints Bug in Your Hair. Not nearly as good but I like it anyway. charcoal, 1 ⎚  Try it online! Explanation: ⎚ Clears the empty screen [implicitly print nothing plus a trailing newline]  • What is that character supposed to be? Is it an old CRT TV screen? – Beta Decay May 22 '17 at 8:47 • searching it comes up with the wikipedia article for clear, like in bash – Destructible Lemon May 22 '17 at 10:07 Mathematica, 2 bytes Code: .0  Output: 0.  This is the output of Wolfram kernel from command line, and the plaintext output from the front end. If you must argue about the extra number tick added when copying directly from the front end, then 0.0 will do. ><>, 11 bytes 01+:b=?;:n!  Prints numbers from 1-10 (12345678910) • Nope. Maybe because there's a bounty on it? One of only three featured questions. – AGourd May 24 '17 at 19:26 • Maybe. Still, not many people are constantly looking at the fifth page. Then again, maybe the OP and bounty-watchers... – MD XF May 24 '17 at 19:26 • Well, I don't really know what to tell you. I'm as surprised as you honestly. – AGourd May 24 '17 at 19:28 • I was pretty surprised when my 19-byte solution to this challenge got 100+ votes. And it only took 30 seconds to write... – MD XF May 24 '17 at 19:29 Whitespace, 36 bytes   Try it online! Generates the output "-15-14-13-12-11-10-9-8-7-6-5-4-3-2-1" (36 characters without quotes, no trailing newline) Explanation Pushes the number -15 onto the stack (encoded in binary as 01111, with a leading 0 for padding to match the output) then counts toward 0 outputting the current number each iteration. Starting from a negative number gives an extra byte of output per iteration and also allows me to use a jump while negative instruction to fall through the loop and exit implicitly. That single padding byte in the code is a downer though but solutions without it are longer. Python 3, 13 bytes print("a"*13)  Outputs "aaaaaaaaaaaaa" Cjam, 1 byte N  Explanation N e#Push '\n' and implicit print  J, 6 bytes echo!4  Try it online! Output: 24  Notice the three spaces on the second line. JavaScript (ES6), 17 bytes Edit: I overlooked the rules. This is now returning a string, but is much longer than initially intended. Returns "Infinity,Infinity". let f = _=>${[1/0,1/0]}

console.log(f())

C#, 574947 44 bytes

()=>{for(int i=0;i<44;i++)Console.Write(7);}


-8 bytes thanks to Martin

Not 100% on whether lambdas like this are accepted answers, but my previous submission in this format was accepted just fine, so I'm gunna go with it.

Same as the java answer, but better because it's not Java

Deadfish, 1 byte

o


Outputs the accumulator, which is 0 before any action takes place.

note: deadfish prints the accumulator as a number, not as a character code, so the output is "0" (0x48)

QBIC, 8 2 bytes

?z


Prints 10, to which z is auto-initialised.

Original brainfart answer

?A+@1234


Explanation:

?       PRINT
A+      A$(which is undefined, but hold on!), plus @1234 The string literal 1234, which we now call A$


Outputs 12341234, which is also 8 bytes. We save a byte by putting the string lit at EOF, because we now don't need to use the delimiter. The definition of the literal is moved to the top of the QBasic code by the interpreter, ensuring it existst at the moment of the first call to A$. SQLite, 32 bytes .width 31 .mode column SELECT"";  Try it online! Outputs 31 spaces and a newline. Brain-Flak, 12 bytes (((([()]))))  Try it online! This prints -1 -1 -1 -1  • This seems to be 11 bytes of output, not 12. – DJMcMayhem May 17 '17 at 16:34 • @DJMcMayhem You're right, fixed – Wheat Wizard May 17 '17 at 16:39 • It's to bad -v print Brain-Flak Ruby Interpreter v1.4.2 instead of just v1.4.2. – Riley May 17 '17 at 23:30 Klein, 7 5 + 3 bytes Uses the 110 topology 1. 2@  If we unfold the topology here we get 1.122@  This outputs 1 1 2 2 with a trailing newline. Thanks to Martin Ender for saving two bytes! Somme, 2 bytes :.  Try it online! Outputs 42. Explanation: :. : duplicate; no input, so popping from an empty stack pushes 42 . output as a number  • popping from an empty stack pushes 42 ಠ_ಠ – MD XF Sep 12 '17 at 3:43 Stacked, 9 bytes $put:+put


Try it online!

Outputs [put put]. \$put pushes a function literal to the stack, : duplicates it, + concats the two functions, and put outputs the representation of the top of the stack.

Haskell, 16 bytes

main=print[0..6]


Try it online! Output:

[0,1,2,3,4,5,6]



(Note the trailing newline.)

MSM, 8 bytes

'.;;.;.;


Output:

........


MSM operates on its own source and takes commands from the left and treats the right as a stack. Stack trace:

' . ; ; . ; . ;                  # ' pushes the next char on the stack
; ; . ; . ; .                # ; is dup
; . ; . ; . .              # dup again
. ; . ; . . .            # . is concat
; . ; . ..             # dup
. ; . .. ..          # concat
; . ....           # dup
. .... ....      # concat
........       # MSM stops if there's only one element in the stack


Python 2, 11 bytes

print 4**16


Beep boop.

• You can do 8**9 for 10 bytes. – PurkkaKoodari May 17 '17 at 12:14
• @Pietu1998 I was about to do 9**9, but @DeadPossum ninja'd me, so I'd rather keep this... – Yytsi May 17 '17 at 12:16

Python 3 REPL, 3 bytes

1e0


Prints 1.0.

If trailing newline counts,

5*2


Prints 10, then a trailing newline.

• Yes, the trailing linefeed counts. – Martin Ender May 18 '17 at 4:36