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

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 – Ad Hoc Garf Hunter 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

# C#, 22 16 bytes

()=>$"{1L<<50}";  -6 bytes thanks to Orjan Johansen, using long instead of int. Outputs 1125899906842624  Alternately, if you allow an arbitrary parameter to be passed into the lambda: ## C#, 21 15 bytes _=>$"{1L<<49}";


Outputs

562949953421312

• If you use long you can do it shorter with only one group: ()=>$"{1L<<50}";. Try it online! – Ørjan Johansen May 17 '17 at 23:49 • Good job on posting such a short C# answer. You can also shave of a byte by using +"" instead of string interpolation. – LiefdeWen May 18 '17 at 8:16 • Neither 1L<<50+"" or ""+1L<<50 works for me due to << having lower precedence than +, so would need to add parens making the length the same. – milk May 18 '17 at 19:37 • Why do you include a semicolon? It's not part of the function. – LegionMammal978 May 21 '17 at 15:08 # Cubix, 6 4 bytes @"Ou  Try it online Cubified  @ " O u . .  This pushes the string Ou. to the stack, Outputs the top character (.) as a character code (46), does a u-turn to the right, Outputs again, and exits with @. • very nice answer, @(Ou works as well – MickyT May 18 '17 at 19:01 ## Excel, 7 bytes =9^7&""  Produces a 7 digit number and then appends empty string Uses general idea from pajonk in their answer [although obviously not the language trick :)] • Welcome to PPCG! I edited your header so that it gets picked up by the leaderboard. :) – Martin Ender May 19 '17 at 13:52 • "Why not just make a 4 digit number?" The challenge states that the function must return a string. It can be checked by T function whether something is string in Excel - the first solution isn't, the second is. Anyway, upvote as promised. – pajonk May 20 '17 at 16:51 • @pajonk Great point. I have taken the smaller solution out as I agree it does not meet the conditions. Thanks! – OpiesDad May 20 '17 at 21:19 # bash, 48 bytes bash bash bash bash bash bash! bash! bash! bash!  Output: /bin/bash: /bin/bash: cannot execute binary file  ## NodeJS REPL, 4 bytes Did someone say REPLs are languages? *;;;  ..._ (the underscore is actually a space character). For anyone not familiar with the Node REPL, it thinks my program isn't complete, so it's prompting for the rest of the line. • You could also use !!!0, 1e2 or "" – powelles May 22 '17 at 19:48 # JavaScript (ES6), 9 bytes _=>""+1E8  Returns 1 * 10^8, or 100000000. If I can return a number instead of a string, _=>1E5 is 6 bytes. f= _=>""+1E8 console.log(f()) • Beat me by a couple of minutes. – Steve Bennett May 17 '17 at 11:32 • Some of the Python answers seem to be outputting numbers, so you should be fine doing the same. – numbermaniac May 17 '17 at 11:53 • @numbermaniac But they print them, which converts them to string. – Neil May 17 '17 at 11:57 • @numbermaniac OP (Martin Ender) told me it was wrong. – Stephen May 17 '17 at 12:29 • a=b=>b+"" 9 bytes Include the function name :) – Esc Điệp Oct 1 '19 at 6:54 ## QBasic 4.5, 1 byte ?  This prints nothing. Followed by a newline. • Thou winneth one internet. – Joshua May 20 '17 at 19:24 # Ruby, 5 4 3 bytes Crossed out 4 is still 4 ;( p$*


Prints [] (empty array) then a newline

Try it online!

• Nice. I was about to propose p p, but didn't think about the newline. – Eric Duminil May 20 '17 at 9:16

# C (modern Linux), 19 bytes

main(){raise(11);}


Output (with newline):

Segmentation fault


How it works:

SIGSEGV is defined as 11 in /usr/include/asm-generic/signal.h. Therefore, raise(11) raises SIGSEGV, and when SIGSEGV is raised on Linux, all execution stops and Segmentation fault is printed.

## 20 bytes

main(){raise(2*2);}


Output (with newline):

Illegal instruction


## 22 bytes

main(){raise(2*3-1);}


Output (with newline):

Trace/breakpoint trap


## 22 bytes

main(){raise(5*2+5);}


Output (with newline):

User defined signal 1


## 22 bytes

main(){raise(1?26:0);}


Output (with newline):

Virtual timer expired


## 24 bytes

main(){raise(12*(1+1));}


Output (with newline):

CPU time limit exceeded


## 25 bytes

main(){raise(5*5?5*5:0);}


Output (with newline):

File size limit exceeded


## 25 bytes

main(){printf(raise(8));}


Output (with newline):

Floating point exception

• isn't that first one 18 bytes? – Destructible Lemon May 23 '17 at 4:28
• @DestructibleLemon Nope. There's a newline at the end. – MD XF May 23 '17 at 4:29
• why isn't the second one 20 bytes then? – Destructible Lemon May 23 '17 at 4:53
• To be pedantic, all of these messages are written by the shell that launched your program, not by your program itself. – Anders Kaseorg May 25 '17 at 8:16
• @MDXF It really is the shell, not the kernel. You can prove it by running echo 'main(){raise(11);}' | gcc -xc -; echo ./a.out | strace bash, which shows bash making the write call. The exact format varies from shell to shell. Here is where the message is defined within the bash source code. You will not find it anywhere in the Linux kernel outside of documentation. – Anders Kaseorg May 25 '17 at 20:54

# ><>, 4 bytes

"on;


Try it online!

Outputs ;110

# Python 3, 53 bytes

s='s=%r;print("0"*~-len(s%%s))';print("0"*~-len(s%s))


Try it online!

This must be the most quine-like answer ever.

• Why not print(1e6)? – CalculatorFeline May 17 '17 at 19:05
• @CalculatorFeline that would be un-quine-like. – Leaky Nun May 18 '17 at 3:50
• Your answer should not be a quine. – Notts90 supports Monica May 18 '17 at 9:12
• @Notts90 this isn't a quine. – Leaky Nun May 18 '17 at 9:13

## Alice, 5 bytes

g/@O



Try it online!

Prints:

103
g


### Explanation

This was quite fun to figure out. :)

g   Pop two implicit zeros from the stack and retrieve the code point at that
location in the code. That's the 'g' itself, so we're pushing 103.
/   Reflect to SE. Switch to Ordinal. The IP bounces diagonally up and down
through the code.
O   Implicitly convert the 103 to "103" and print it with a trailing linefeed.
Bounce off the top right corner and move back.
/   Reflect to W/ Switch to Cardinal.
g   Push 103 again.
The IP wraps back to the last column
O   Interpret the 103 as a code point and print the corresponding character.
This prints 'g'.
@   Terminate the program.


# APL, 2 bytes

-1


Prints ¯1 (the - is the Minus monad, whereas ¯ is the High minus negative indicator).

# Perl 5, 9 bytes

print$"x9  Prints 9 spaces, no newline. ## Explanation $" contains a " " by default. x9 uses the repetition operator to "multiply" the string by 9.

• Welcome to PPCG! – Martin Ender May 18 '17 at 13:24

## Powershell, 38 bytes

Just for fun, an answer that returns different output each time it's called.

[System.Guid]::NewGuid().ToString("B")


Prints a GUID surrounded with braces ("B"), such as:

{24cc14a3-ada4-4fcd-8a08-ec419b00f22d}


# R, 3 2 bytes

-T


Outputs:

-1


Old 3 byte answers:

Many examples, such as:

1/0
F/F
3^6


Outputs respectively:

Inf
NaN
729


Try it online!

• hah, -T! clever! – Giuseppe Aug 14 '18 at 17:28

# Java, 82 bytes

interface M{static void main(String[]a){for(int i=0;i++<82;)System.out.print(1);}}


Output:

1111111111111111111111111111111111111111111111111111111111111111111111111111111111


Try it online!

• Why not a lambda? I admit that it is boring, but I think it could be included to showcase Java 8. – Yytsi May 17 '17 at 12:10
• @TuukkaX I made one! – Olivier Grégoire May 19 '17 at 7:30

# JavaScript (ES6), 17 11 bytes

f=_=>"g="+f


## Try it

f=_=>"g="+f
console.log("Function source: f="+f)
console.log("Function length: "+(""+f).length+" + 2 (for variable assignment) = "+((""+f).length+2))
console.log("Function output: "+f())
console.log("Output length: "+f().length)
console.log("Output type: "+typeof f())

## Python 2, 10 bytes

Try it online

print 9**9


Outputs 10 bytes:

387420489
*newline*


There are other 10-byte answers with decimals and power. I like this one for e in the output:

print.3**8


Output:

6.561e-05
*newline*


Same 10 bytes, but for division (there are 5 versions):

.1/64 = 0.0015625
.3/64 = 0.0046875
.5/64 = 0.0078125
.7/64 = 0.0109375
.9/64 = 0.0140625

print.1/64


outputs:

0.0015625
*newline*


# C#, 23 bytes

()=>new string('@',23);


Creates a new string consisting of 23 @ characters

# dc, 2 bytes

Kp


Try it online!

Pushes the current precision on the stack (which is 0) and prints it with a trailing newline.

• dc prints a trailing newline after any command. The command 'c' has no other output, so it works and is one byte shorter – Jared K Mar 30 '18 at 19:22

## Bash, 1 byte:

#


It sort of outputs a newline...although I don't know if the program gets credit for that or the Bash interpreter.

I'm a bit dubious that this counts, so:

### Bash, 21 bytes

x=12345;echo $x$x$x$x


This is really terrible, I know. Are you allowed to call any standard program with Bash?

• codegolf.meta.stackexchange.com/a/7833/56341 languages are denfined by their implementation rather than by their declaration. so your 1 byte solution is perfectly valid – Roman Gräf May 17 '17 at 11:53
• Ok. I'm still not sure. Calling almost anything from a bash shell will generate a new line, it's not even the interpreter that's looking at my program that does that (I think). It's just that after doing whatever my program does (which is nothing), the Bash shell (which is essentially a REPL) outputs a blank line. – Steve Bennett May 17 '17 at 11:59
• It doesn't output anything. What version of Bash are you using? – eush77 May 17 '17 at 12:44
• Heh, see my comment, right? – Steve Bennett May 17 '17 at 13:02
• x=12345;echo $x$x$x$x only outputs 20 characters for a 21 character input. Try x=1234567;echo $x$x$x also 21 characters, 21 characters output (123456712345671234567) - oh wait, do we count the implicit \n? does that count as a feature of the program or the shell displaying output? – Baldrickk May 17 '17 at 13:21 # Fourier, 1 byte o  Try it FourIDE! Note, TIO.run outputs a trailing newline Outputs the value of the accumulator, 0. ### More interesting programs: 2P15o  Try it on FourIDE! Outputs 215, 32768. 4^do  Try it on FourIDE! Outputs the current year (doesn't work if used before 1000 AD). 999**999o  Try it on FourIDE! Outputs 997002999. The ** is undefined behaviour in Fourier. The way I think it works is A**B = A*A*B. # GNU Make, 24 21 bytes $(sort $(value$(0)))


returns

$(0)))$(sort $(value  Complete makefile: X=$(sort $(value$(0)))
$(info$(call X))

• How do you invoke this? For me if I put this in a Makefile and run make, I get make: *** No targets. Stop. – Digital Trauma May 17 '17 at 15:56
• @DigitalTrauma It's a user-defined function. I added the boilerplate to the post. – eush77 May 17 '17 at 16:10
• Very impressive! +1 – MD XF May 19 '17 at 1:38

## Underload, 6 bytes

()aaaS


Try it online!

Prints ((())).

() pushes an empty string to the stack. a "stringifies" it by wrapping it in (...) so after aaa we get (((()))). S prints that string (without the outermost parentheses, so we get only three pairs).

# Pyth, 1 byte

k


It prints a new line character.

Explanation: k is just a variable initialized to '' (empty string), and by default Pyth prints the values of instructions which do nothing, followed by a new line character. In this case, it prints an empty string and then the new line character.

Test it online! (the online interpreter doesn't show the \n, you will have to install Pyth on your computer to actually see it)

# Taxi, 540 bytes.

62 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 l 2 r 1 l 1 l 2 l.Pickup a passenger going to The Underground.Go to The Underground:w 1 r 2 r 1 r 2 l.[r]Switch to plan "e" if no one is waiting.Pickup a passenger going to Cyclone.Go to Cyclone:n 3 l 2 l.Pickup a passenger going to The Babelfishery.Pickup a passenger going to The Underground.Go to The Babelfishery:s 1 l 2 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.Go to Fueler Up:n 1 r 1 l.Go to The Underground:n.Switch to plan "r".[e]


Try it online!

Ungolfed:

62 is waiting at Starchild Numerology.
Go to Starchild Numerology: west 1st left 2nd right 1st left 1st left 2nd left.
Pickup a passenger going to The Underground.
Go to The Underground: west 1st right 2nd right 1st right 2nd left.
[r]
Switch to plan "e" if no one is waiting.
Pickup a passenger going to Cyclone.
Go to Cyclone: north 3rd left 2nd left.
Pickup a passenger going to The Babelfishery.
Pickup a passenger going to The Underground.
Go to The Babelfishery: south 1st left 2nd right 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st left 1st right.
Go to Fueler Up: north 1st right 1st left.
Go to The Underground: north.
Switch to plan "r".
[e]


It prints the integers 61 through 1 in descending order and with a decimal and 6 trailing zeros:

61.00000060.00000059.00000058.00000057.00000056.00000055.00000054.00000053.00000052.00000051.00000050.00000049.00000048.00000047.00000046.00000045.00000044.00000043.00000042.00000041.00000040.00000039.00000038.00000037.00000036.00000035.00000034.00000033.00000032.00000031.00000030.00000029.00000028.00000027.00000026.00000025.00000024.00000023.00000022.00000021.00000020.00000019.00000018.00000017.00000016.00000015.00000014.00000013.00000012.00000011.00000010.0000009.0000008.0000007.0000006.0000005.0000004.0000003.0000002.0000001.000000


## PowerShell, 2 bytes

+1


The upvote program. This give the output of 1 and a trailing newline to get 2 bytes. I am unsure if the operation is adding 1 to nothing or if it is rendering the positive integer of 1. Either way the result is the same.

# Pyramid Scheme, 32 bytes

^ ^
-^-
^-^
-^-
^-^
-^-
^-^
- -


Try it online!

## Explanation

This may not look like pyramid scheme but it is. Each triangle looks like:

 ^
-


This performs one of three operations

• If it has 2 args it pairs them together

• If it has 1 arg it returns it

• If it has 0 args it returns 0

So at the bottom we have two zeros, those are linked on the next level. On the next level two different pyramids grab the pair and then those pairs are paired together. This continues all the way up the pyramid. When we get to the top we have:

 ((((0,0),(0,0)),((0,0),(0,0))),(((0,0),(0,0)),((0,0),(0,0))))


Pyramid scheme's implicit output converts this to 16 zeros separated by newlines. That's 32 bytes.

## Powershell, 3 bytes

1E2


Prints 100

• Looks like you (hopefully accidentally) added a leading space to your code. – Skidsdev May 17 '17 at 12:06
• PowerShell adds a trailing newline. Newlines count for this one. 1e1 would work though – Matt May 25 '17 at 17:47