58
\$\begingroup\$

Challenge:

The concept is simple enough: write a full program to output its own code golf score!

Output should only be the byte count of your program and a trailing bytes.

BUT WAIT..... there is one restriction:

  • Your source code can not include any of the digits from your byte count
  • So if your score is 186 bytes, your program can not contain the characters 1 , 6 , or 8

Example Output:

315 bytes
27 Bytes
49 BYTES

Additional Rules:

  • Unnecessary characters, spaces, and newlines are forbidden in the source code, however trailing spaces and newlines are perfectly acceptable in output
  • There should be a single space between the number and bytes in the output
  • Letters are case insensitive
  • No self inspection or reading the source code
  • standard loopholes are disallowed

  • this is , so

Shortest code in bytes wins!

\$\endgroup\$
  • 6
    \$\begingroup\$ Does this need the quine tag, or may the code self-inspect? \$\endgroup\$ – Adám Mar 29 '18 at 15:59
  • 3
    \$\begingroup\$ @Dat, given the formatting of the word bytes I suspect the intention is that the count should include the bytes it takes to print the text: bytes \$\endgroup\$ – Jeff Schaller Mar 29 '18 at 16:16
  • 2
    \$\begingroup\$ Are leading spaces in output acceptable? \$\endgroup\$ – rafa11111 Mar 29 '18 at 17:43
  • 4
    \$\begingroup\$ If my code is 1 byte long, should I output 1 bytes or 1 byte? (keep in mind there are already 41 answers, although I don't think any are affected) \$\endgroup\$ – Erik the Outgolfer Mar 29 '18 at 18:07
  • 1
    \$\begingroup\$ @JoKing well I didn’t address casing in the rules, but if somehow using capital letters makes your score lower, then by all means I’d love to see what you came up with. I say go for it! \$\endgroup\$ – X1M4L Mar 29 '18 at 22:50

156 Answers 156

3
\$\begingroup\$

JavaScript, 16 15 bytes

x=>0xf+' bytes'
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ _=>5*3+' bytes' \$\endgroup\$ – Neil Mar 29 '18 at 19:36
  • \$\begingroup\$ @Neil Both the code and the byte-count contains a 5 in that case.. \$\endgroup\$ – Kevin Cruijssen Mar 29 '18 at 20:04
  • \$\begingroup\$ @KevinCruijssen Bah, I can't believe I overlooked that. \$\endgroup\$ – Neil Mar 29 '18 at 21:17
  • \$\begingroup\$ Submissions are required to be full programs "write a full program to output its own code golf score!" \$\endgroup\$ – user41805 Apr 15 '18 at 12:55
3
\$\begingroup\$

7Zip - 90 14 bytes

Hex dump:

00 75 0d 08 c0 00 0d 08 03 00 00 03 04 1d  

To use:

save into a source file, named anything.

run the compiler from the command line: 7z e [source name]

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

C, 33 32 bytes

main(){printf("%d bytes",040);}

There is a trailing newline, which is not "unnecessary" since the C standard demands it. Try it online here.

Thanks to NieDzejkob for golfing 1 byte.

Alternative with the same bytecount, thanks to ErikF:

main(){printf("%d bytes",' ');}

Try it online here.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ , 040 for 32 bytes \$\endgroup\$ – NieDzejkob Mar 29 '18 at 15:58
  • \$\begingroup\$ , 040 is against the (updated) rules but I added a trailing newline instead of the space. Thank you! \$\endgroup\$ – O.O.Balance Mar 29 '18 at 16:25
  • 2
    \$\begingroup\$ You could also use ,' ' to avoid any numerals at all! \$\endgroup\$ – ErikF Mar 30 '18 at 5:51
  • \$\begingroup\$ @ErikF now that is clever. thanks :) \$\endgroup\$ – O.O.Balance Mar 30 '18 at 11:15
  • \$\begingroup\$ 31 bytes \$\endgroup\$ – Steadybox Mar 30 '18 at 11:53
3
\$\begingroup\$

Excel VBA, 10 bytes

An anonymous VBE immediate window function that takes no input and outputs to the vbe immediate window.

?2*5"bytes

Output

10 bytes
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ My Excel shows additional leading space. Is it allowed? \$\endgroup\$ – pajonk Mar 30 '18 at 9:04
  • \$\begingroup\$ @pajonk That is the default nature VBA's Print and ? statement when handling number types, and is generally accepted to be valid for PPCG. That said, it may the space may be forcefully removed by converting to a string, and then operating upon that string, such as ?6+7&&" bytes for 13 bytes. \$\endgroup\$ – Taylor Scott Mar 30 '18 at 17:28
3
\$\begingroup\$

Jstx, 4 bytes

♦─]P

Try it online!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

C++ (GCC), 51 bytes

Thanks to @ceilingcat!

#import<iostream>
main(){std::cout<<063<<" bytes";}

Try it online!

C++ (GCC), 56 bytes

#import<iostream>
main(){std::cout<<(int)'8'<<" bytes";}

Try it online!

More portable version (60 bytes):

#import<iostream>
int main(){std::cout<<(int)'<'<<" bytes";}

#import is not standard C++, but should work at least with GCC, Clang, and MSVC.

Try it online!

Standard compliant version (61 bytes):

#include<iostream>
int main(){std::cout<<(int)'='<<" bytes";}

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Suggest 063 for (int)'8', 067 for (int)'<' and 070 for (int)'=' \$\endgroup\$ – ceilingcat Apr 1 '18 at 0:09
3
\$\begingroup\$

Mathematica frontend, 18 bytes (maybe 10?)

Row@{2*9," bytes"}

Thanks to @ovs

A naughty way ... as I don't know whether this counts (10)

2" bytes"5

Well it depends on how you define space.

enter image description here

Wolfram Language (Mathematica), solution w/o frontend (30)

Print[ToString[5*6]<>" bytes"]

Try it online!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Hexagony, 26 22 Bytes

B{3'/bs.<t>;ey;:!$@P0/

-4 Bytes @Jo King

Try it online!


More Readable:

   B { 3 '
  / b s . <
 t > ; e y ;
: ! $ @ P 0 /
 . . . . . .
  . . . . .
   . . . .

Reuses every semicolon twice similar to this answer.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It even uses one of the semi-colons 4 times! \$\endgroup\$ – Jo King Sep 28 '18 at 11:20
3
\$\begingroup\$

Bash, 20 18 17 bytes

echo $[8+9] bytes

Try it online!

-2 bytes thanks to @manatwork.
-1 byte thanks to @boboquack.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ echo $[20-2] bytes for 18 bytes? \$\endgroup\$ – manatwork Mar 29 '18 at 17:20
  • \$\begingroup\$ @manatwork woah, I didn't know bash could do math like that \$\endgroup\$ – NieDzejkob Mar 30 '18 at 8:32
  • \$\begingroup\$ “The old format $[expression] is deprecated and will be removed in upcoming versions of bash.” — man bash. But in meantime we enjoy using it here in PPCG. \$\endgroup\$ – manatwork Mar 30 '18 at 8:37
  • 2
    \$\begingroup\$ echo $[5#33] bytes also works for a score of 18. \$\endgroup\$ – Digital Trauma Mar 30 '18 at 17:40
  • 1
    \$\begingroup\$ Doesn’t 8+9 work for 17? \$\endgroup\$ – boboquack Jul 30 '19 at 6:01
3
\$\begingroup\$

Poetic, 277 bytes

for the A.I. system i did, i tried to put in humans
i know i am one of those
i am trying human testing for cyber-enabled virtual brains
a for-profit company rakes in massive loads of cash educating interns,
& then force-feeding things to all the interns until we earn a diploma

Outputs 277 bytes.

Try it online!

Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.

This was a fun program to write, although I'm not entirely sure I've fulfilled the "no unnecessary characters" requirement. If my answer needs to be amended, let me know!

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ "& then force-feeding things to all the interns until we earn a diploma". Absolutely wonderful! \$\endgroup\$ – Lyxal Nov 3 '19 at 10:47
3
\$\begingroup\$

Pyramid Scheme, 477 440 BytEs

     ^   ^       ^   ^       ^   ^
    ^-  / \     ^-  / \     ^-  / \
   / \ /out\   / \ /out\   / \ /out\
  /out\-----^ /out\-----^ /out\-----^
 ^-----^   / \-----^   / \-----^   / \
 -^   / \ /chr\   / \ /chr\   / \ /chr\
  -^ /chr\-----^ /chr\-----^ /chr\-----^
  /*\-----^   / \-----^   / \-----^   / \
 ^---^   / \ /66 \   / \ /116\   / \ /115\
/8\ / \ /32 \-----  /121\-----  /69 \-----
---/55 \-----       -----       -----
   -----

Try it online!

Outputs 440 BytEs by multiplying 8 by 55.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Wouldn't that violate the rule against unnecessary whitespace? Or maybe I don't understand? \$\endgroup\$ – Steve Bennett Jun 24 at 1:54
  • \$\begingroup\$ @SteveBennett You're right. I've modified it so that the program doesn't have redundant characters (though it can be golfed pretty easily \$\endgroup\$ – Jo King Jun 25 at 12:30
  • 1
    \$\begingroup\$ 431 bytes, Psll code: (out (_ 431) " ") (out _ "b") (out _ "y") (out _ "t") (out _ "e") (out _ "s") \$\endgroup\$ – MarcinKonowalczyk Aug 28 at 23:39
  • \$\begingroup\$ @MarcinKonowalczyk There's a source restriction on this challenge so that you can't use numbers from the score (in your case 4,3 or 1) \$\endgroup\$ – Jo King Aug 29 at 2:58
  • \$\begingroup\$ though i managed to modify the format to work \$\endgroup\$ – Jo King Aug 29 at 3:32
2
\$\begingroup\$

Pyth, 10 bytes

+T" bytes"

Try it here

If you don't mind separating with a newline instead of a space, you can get it down to 8 bytes with

y4"bytes
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

J, 19 bytes

echo' bytes',~":_bj

Try it online!

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

C# (.NET Core), 65 bytes

class P{static void Main(){System.Console.Write(0x41+" bytes");}}

Try it online!

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ I'm afraid your code contains a 5.. Easily fixed by using 72-7, though. \$\endgroup\$ – Kevin Cruijssen Mar 29 '18 at 16:53
  • 2
    \$\begingroup\$ Fixed! With a little bit of hex to make it look clever! =D \$\endgroup\$ – Anderson Pimentel Mar 29 '18 at 17:12
  • \$\begingroup\$ A bit silly and crooked: class Q{static void Main(){new System.Exception("sixty four");}} => 64 and the word bytes is in the exception when you drill down through it! \$\endgroup\$ – PmanAce Mar 29 '18 at 17:30
2
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 27 bytes

	OUTPUT =3 * 9 ' bytes'
END

Try it online!

prints with a trailing newline.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Excel (Immediate Window), 12 bytes

?3*4&"bytes"

This solution assumes that leading space is allowed.
Below the one without leading space in output (14 bytes):

?2*7&&" bytes"

It's the result of suspicious behaviour of the concatenate operator &. When only one, it surrounds the number with spaces; however two consecutive ones strip the spaces. Weird.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Ruby, 18 bytes

puts"#{6*3} bytes"

Try it online!

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

brainfuck, 95 bytes

+[--------->+<]>.----.--[--->++<]>--.[->+++<]>++.[--->+<]>+++.-----.+++[->+++<]>.[--->+<]>----.

Try it online!

97 bytes:

>-[++>+[+<]>]>+.--.>++++[->++++++++<]>.[->+++<]>++.[--->+<]>+++.-----.+++[->+++<]>.[--->+<]>----.
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

CJam, 10 10 bytes

Ao" bytes"

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ +1 for the no-op space used just to pad the byte count. Too bad CJam doesn't have a predefined variable with the initial value 9. \$\endgroup\$ – Ilmari Karonen Mar 30 '18 at 0:10
  • \$\begingroup\$ ...although I just realized that the challenge forbids "[u]nnecessary spaces and newlines". But you could still do e.g. " bytes"A\ or A" bytes"+ to comply with the rules as specified. \$\endgroup\$ – Ilmari Karonen Mar 30 '18 at 0:34
  • \$\begingroup\$ @IlmariKaronen Ao" bytes" works. \$\endgroup\$ – Esolanging Fruit Mar 30 '18 at 3:10
2
\$\begingroup\$

Gol><>, 11 bytes

bn"setyb "H

Try it online!

How it works

bn"setyb "H
b            push number 11
 n           pop and print as integer
  "setyb "   push " bytes" in reverse order
          H  print the stack content as chars, then halt
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Japt, 8 bytes

#+` ßs

char-code 8 concatenated with " bytes" compressed.

Try it online!

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Identical to what I had, again. would also work. \$\endgroup\$ – Shaggy Apr 2 '18 at 15:56
2
\$\begingroup\$

Google Sheets, 12 bytes

An anonymous worksheet function that takes no input and outputs to the calling cell

=3*4&" bytes
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

MSSQL, 26 24 bytes

print str(8*3) +' bytes'
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

F#, 24 23 bytes

I hope this counts. Never code golfed before

printfn "%i bytes" 0x17

Just switched 24 to octal 23 to hex

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Welcome to the site! It looks like you have some extraneous whitespace. Could that be removed? Also, I don't know a whole lot about F#, but are you sure this is a full program? The original rules stated write a full program to output it's own score \$\endgroup\$ – James Mar 30 '18 at 19:52
  • \$\begingroup\$ @DJMcMayhem whoops, dropped that extra space. Also I do believe this is a full program. It compiles and runs just fine in Visual Studio without anything else, though I may misunderstand what that means. \$\endgroup\$ – an earwig Mar 30 '18 at 19:56
  • \$\begingroup\$ Whoops, my bad. I assumed that F# was like C# where you need class declarations in a full program. Looks valid to me! \$\endgroup\$ – James Mar 30 '18 at 20:04
2
\$\begingroup\$

Windows Command Line, 20 bytes

set/a4*5&echo  bytes

Run Windows Command Prompt (cmd.exe), type the command and hit Enter.

img

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

SQL, 18 bytes

SELECT 2*9,'bytes'
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Swift 4, 19 18 bytes

Saved 1 byte thanks to Jo King.

print(9*2,"bytes")

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Why not 9*2?- \$\endgroup\$ – Jo King Apr 5 '18 at 15:58
  • \$\begingroup\$ @JoKing What an oversight... Thanks! \$\endgroup\$ – xoudini Apr 5 '18 at 16:00
2
\$\begingroup\$

m4, 15 bytes

As in the m4 POSIX macro processor.

eval(8+7) bytes
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Vim, 12 10 bytes

i9<C-o><C-a> bytes
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

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

toString(9+5)+" BYTES

toString( is a two-byte token, all other characters used are one-byte tokens.

toString( can be replaced with eval( for the same output and score.

Explanation:

  • toString(9+5) Returns the string "14"

  • +" BYTES Adds the string " BYTES", to get "14 BYTES"

  • TI-Basic implicitly returns/prints the last item evaluated, so 13 BYTES is output.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ What calculator has a toString( function? \$\endgroup\$ – kamoroso94 Apr 9 '18 at 10:05
  • 1
    \$\begingroup\$ @kamoroso94 The TI-84 Plus CE. Source \$\endgroup\$ – pizzapants184 Apr 9 '18 at 15:06

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.