117
\$\begingroup\$

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>

asked May 17, 2017 at 11:17
\$\endgroup\$
20
  • 2
    \$\begingroup\$ Related. Related. \$\endgroup\$ Commented May 17, 2017 at 11:19
  • 1
    \$\begingroup\$ @Mr.Xcoder Yes, if you declare them as such. \$\endgroup\$ Commented May 17, 2017 at 16:25
  • 1
    \$\begingroup\$ @DJMcMayhem I figured that in many esolangs it's trivial to print a null byte with one byte of code or similar things, and thought it would lead to more interesting answers if the results were actually readable. \$\endgroup\$ Commented May 17, 2017 at 16:45
  • 4
    \$\begingroup\$ @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 \$\endgroup\$ Commented May 17, 2017 at 22:37
  • 2
    \$\begingroup\$ @WheatWizard output by exit code is not a string, so it doesn't apply here. \$\endgroup\$ Commented May 18, 2017 at 4:29

291 Answers 291

1
...
6 7
8
9 10
1
\$\begingroup\$

Scratch, 64 bytes

define
set[a v]to[
repeat[4
set[a v]to(join(a)([e ^ v]of[2
say(a

Uses scratchblocks syntax.

answered Apr 1, 2021 at 9:41
\$\endgroup\$
1
\$\begingroup\$

Swift, 36 bytes

print(String(repeating:" ",count:36))
answered Jun 4, 2021 at 21:59
\$\endgroup\$
1
\$\begingroup\$

Knight, 2 bytes

O0

Try it online!

Prints 0, followed by a newline.

answered Jun 4, 2021 at 22:40
\$\endgroup\$
1
\$\begingroup\$

Pip, 1 byte

x

Outputs the empty string plus a trailing newline. Try it online!

answered Jun 23, 2021 at 15:08
\$\endgroup\$
1
\$\begingroup\$

JavaScript, 5 bytes

f=
x=>!1
console.log(f());

answered Oct 18, 2021 at 22:23
\$\endgroup\$
1
  • \$\begingroup\$ Cool, thank you, updated I think this follows the rules now \$\endgroup\$ Commented Oct 19, 2021 at 14:36
1
\$\begingroup\$

Javascript REPL, 9 bytes

`${8**9}`

outputs the string

134217728

console.log(`${8**9}`)

Well, i like it

Javascript REPL, 8 Bytes

same approach 1 byte less

`${8e7}`

outputs the string

80000000

console.log(`${8e7}`)

answered Oct 24, 2021 at 21:06
\$\endgroup\$
0
1
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 19 bytes

 output =99 ^ 9
end

Outputs:

913517247483640899

Try it online!

answered Oct 25, 2021 at 11:11
\$\endgroup\$
1
\$\begingroup\$

INTERCAL, 12 bytes

DOREADOUT#81

Outputs:

 
LXXXI

Try it online!

answered Oct 25, 2021 at 11:17
\$\endgroup\$
1
\$\begingroup\$

4, 39 bytes

3.6003960133602328000000002500100000194

Try it online!

How it works:

3. Start of the program.
 6 00 39 Sets cell 00 to 39.
 6 01 33 Sets cell 01 to 33.
 6 02 32 Sets cell 02 to 32.
 8 00 While cell 00 is not zero:
 0 00 00 02 Sets cell 00 as the addition of cells 00 and 02.
 5 00 Gets the value of cell 00 and prints it as UNICODE character.
 1 00 00 01 Sets cell 00 as the subtraction of cells 00 and 01.
 9 End loop.
4 End of the program.

I avoided printing ASCII characters below 0x20, as the rules demanded. Otherwise, if one does not care for the nonprintable ASCII chars, it could be as simple as follows:

4, 27 bytes

3.60056 60101 800 500 1000001 9 4

Try it online!

Spaces kept for readability. Prints 0x56 to 0x00.

answered Nov 13, 2021 at 19:33
\$\endgroup\$
1
\$\begingroup\$

Backhand, 1 byte

h

Try it online!

Immediately halts, printing the top of the stack (if empty, 0) as a number.

Backhand, 4 bytes

v11H

Try it online!

Somewhat more interesting one which actually uses Backhand's execution nature. Prints four copies of ASCII 1; the 1s can be changed to any of 0-9a-f to print ASCII 0-15 characters.

v11H initial step = 3
v → reduce step size to 2
 1 → push 1
 1 ← bounce off and push 1
v reduce step size to 1
 11 → push 1 twice
 H halt, printing the entire stack as a string
answered Nov 18, 2021 at 5:33
\$\endgroup\$
1
  • 1
    \$\begingroup\$ There's also "H. for 3 bytes \$\endgroup\$ Commented Nov 18, 2021 at 5:37
1
\$\begingroup\$

in floop, 2 bytes

;;

Try it online!

I seriously doubt it's possible to do anything more complex than this, as in floop's only output method is by halting.

rydwolf
19.3k2 gold badges90 silver badges180 bronze badges
answered Jan 30, 2022 at 19:37
\$\endgroup\$
1
\$\begingroup\$

Vyxal, 1 byte

×ばつ

Try it Online!

Apparently we don't have a Vyxal answer yet. Outputs *.

answered Jul 5, 2022 at 21:58
\$\endgroup\$
1
\$\begingroup\$

Thunno, 1 byte

+

Attempt This Online!

Prints \0ドル\$. Also works in Thunno 2: Attempt This Online!

Thunno, \$ 2 \log_{256}(96) \approx \$ 1.65 bytes

Z1

Attempt This Online!

Constant for \10ドル\$

Others include:

aA, aB, aC, aD, aE, aF, aG, aH, aI, aJ, aK, aL, aM, aN, aO, aP, aQ, aR

which are constants for \10ドル\$, \15ドル\$, \20ドル\$, ..., \95ドル\$.

answered Mar 15, 2023 at 13:00
\$\endgroup\$
1
\$\begingroup\$

Ly, 1 byte

y

Try it online!

Pushes the size of the stack onto the stack, then exits. Entries on the stack are printed as numbers by default. Outputs 0.

answered May 30, 2023 at 3:13
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Kinda feels like cheating, but it’s a perfectly valid answer! \$\endgroup\$ Commented Jun 1, 2023 at 18:32
1
\$\begingroup\$

Desmoslang Assembly, (削除) 14 (削除ここまで) (削除) 7 (削除ここまで) 8 Bytes

[1...8OT

Old (14 Bytes):

EP+1M-14)14OJT
answered May 29, 2023 at 16:09
\$\endgroup\$
1
\$\begingroup\$

Rockstar, 8 bytes

Outputs 0.015625

say 1/64

Try it (code will need to be pasted in)

answered May 30, 2023 at 15:58
\$\endgroup\$
1
\$\begingroup\$

Python 3 (PyPy), 13 bytes

print('h'*13)

Try it online!

answered Jun 1, 2023 at 18:12
\$\endgroup\$
1
  • \$\begingroup\$ This works in regular python as well. \$\endgroup\$ Commented Jun 1, 2023 at 18:42
1
\$\begingroup\$

(,) (削除) 81 (削除ここまで) (削除) 65 (削除ここまで) 48 Chars or \48ドル\log_{256}(3)\approx\$ 9.51 Bytes

Thanks to @Leo for -17? chars!

(,,(),,(),,((),()()()()()()()(),,,(),,()()()()))

(Assuming by same number of bytes you mean same number of chars)
Tio

answered May 31, 2023 at 5:58
\$\endgroup\$
1
  • \$\begingroup\$ You can make it shorter by not using the N flag, since then each output will print 2 bytes (the number and a newline): inparencomma.pythonanywhere.com/… \$\endgroup\$ Commented Jul 6, 2023 at 3:26
1
\$\begingroup\$

Vyxal, 4 bytes

kSĖ 

There’s a trailing space.

Click the sus image below to Try It Online!TM

Explanation

kSĖ­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‏​⁢⁠⁢‌⁤​‎‏​⁢⁠⁡‌­ 
kS # ‎⁡Push the character 'ඞ'.
 Ė # ‎⁢Execute the top of the stack as Vyxal code.
 # Just a space
‎⁣
# ‎⁤When 'ඞ' is run as Vyxal code, it prints the string 'sus' with a newline.
💎 Created with the help of Luminespire at https://vyxal.github.io/Luminespire
answered Jul 5, 2023 at 17:52
\$\endgroup\$
0
1
\$\begingroup\$

///, 12 bytes

/a/bb/aaaaaa

Try it online!

Outputs bbbbbbbbbbbb. Explanation:

/a/bb/ Replace each a with bb
 aaaaaa 6 a's -> 12 b's (Implicit output)

Alternate program, also 12 bytes with same output:

/a/bbbbbb/aa

Try it online!

answered Jul 14, 2023 at 17:53
\$\endgroup\$
1
\$\begingroup\$

Vyxal, 5 bytes

`∞`∞₴

Output

\w+w\

Yes, I know. Very crazy.

Try it Online!

answered Jul 15, 2023 at 8:21
\$\endgroup\$
1
\$\begingroup\$

Befalse (quirkster), 8 bytes

:::: 9.;

Try it!

Prints eight tab characters. 9. is the "loop body", and the leading :s increase the loop count as in the Fibonacci sequence (similar to Hello world trick). A space before 9 is necessary to ensure the last : executes the loop body twice in full.

answered May 23, 2024 at 5:53
\$\endgroup\$
1
\$\begingroup\$

Bespoke, 16 bytes

Bespoke program.

Prints Stack underflow. to STDERR.

Alternate version, 47 bytes

"Hey, so can I do some modified way?" stated I.

Prints 31^31, which is 47 digits long.

answered Jan 27 at 5:42
\$\endgroup\$
0
\$\begingroup\$

Ohm, 5 bytes

αvssL

Explanation

αvssL
αv push 'aeiou'
 ss convert to string two times (NOP)
 L print without newline
answered May 17, 2017 at 11:45
\$\endgroup\$
0
\$\begingroup\$

Pip, 4 bytes

L2P1

Try it online!

This prints 1\n1\n, at 4 bytes including the newlines.

answered May 17, 2017 at 12:22
\$\endgroup\$
0
\$\begingroup\$

Minimal-2D, 72 bytes

/D+++++++++L
 R/D /LR/>>D /LR
 R->++>+++<</UU R->..</UU

Try it online!

Outputs 72 6s. This is BF in a 2D layout.

answered May 17, 2017 at 14:28
\$\endgroup\$
0
\$\begingroup\$

yup, 12 bytes

0e:::::{0##}

Try it online!

Pushes 6 1s, and, while there are 1 on the top of the stack, output a 0 followed by a 1.

answered May 17, 2017 at 14:32
\$\endgroup\$
0
\$\begingroup\$

Jellyfish, 2 bytes

p0

Try it online!

Prints 0 and a trailing linefeed.

answered May 17, 2017 at 14:40
\$\endgroup\$
0
\$\begingroup\$

Rexx 15 Bytes

say left("",15)

Try it here

answered May 17, 2017 at 16:48
\$\endgroup\$
0
\$\begingroup\$

Lua, 10 bytes

print(1e6)

Outputs:

1000000.0

Try it online!

answered May 17, 2017 at 21:17
\$\endgroup\$
0
1
...
6 7
8
9 10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.