71
\$\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\$
15
  • 6
    \$\begingroup\$ Does this need the quine tag, or may the code self-inspect? \$\endgroup\$
    – Adám
    Mar 29, 2018 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\$ Mar 29, 2018 at 16:16
  • 2
    \$\begingroup\$ Are leading spaces in output acceptable? \$\endgroup\$
    – rafa11111
    Mar 29, 2018 at 17:43
  • 5
    \$\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\$ Mar 29, 2018 at 18:07
  • 2
    \$\begingroup\$ Can bytes be in any case pattern, e.g. bYtEs? \$\endgroup\$ Dec 27, 2019 at 14:56

178 Answers 178

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

Japt, 8 bytes

#+` ßs

char-code 8 concatenated with " bytes" compressed.

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Identical to what I had, again. would also work. \$\endgroup\$
    – Shaggy
    Apr 2, 2018 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
\$\endgroup\$
2
\$\begingroup\$

MSSQL, 26 24 bytes

print str(8*3) +' bytes'
\$\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!

\$\endgroup\$
3
  • \$\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\$
    – DJMcMayhem
    Mar 30, 2018 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, 2018 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\$
    – DJMcMayhem
    Mar 30, 2018 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

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

SQL, 18 bytes

SELECT 2*9,'bytes'
\$\endgroup\$
2
\$\begingroup\$

ArnoldC, 216 Bytes

Try it online!

IT'S SHOWTIME
    HEY CHRISTMAS TREE i
    YOU SET US UP 4
    GET TO THE CHOPPER i
        HERE IS MY INVITATION i
        YOU'RE FIRED 54
    ENOUGH TALK
    TALK TO THE HAND i
    TALK TO THE HAND "BYTES"
YOU HAVE BEEN TERMINATED

Output

216
BYTES

Well, i took too long with my php answer, i had to try this.

As far as i read, i can't write without a line break or concatenate an integer with a string :(

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

Swift 4, 19 18 bytes

Saved 1 byte thanks to Jo King.

print(9*2,"bytes")

Try it online!

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

Vim, 12 10 bytes

i9<C-o><C-a> bytes
\$\endgroup\$
2
\$\begingroup\$

Backhand, 11 bytes

"" sbbeOytH

Try it online!

Non-linear pointer progression makes for weird looking programs. Outputs 11 bytes.

The orde: of commands is such:

"  s  e  t      Start string literal to push letters
                Bounce and go left
     b  y       Finish pushing " bytes"
                Bounce and go right
 "  b  O  H   Push 11 to print and then halt and output the stack
\$\endgroup\$
2
\$\begingroup\$

C#, 68 65 64 bytes

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

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Welcome to PPCG! Your program contains the digits 5 and 6 which you are printing, that's not allowed. \$\endgroup\$ Sep 28, 2018 at 9:17
  • \$\begingroup\$ Fixed the program and thanks for the review @ØrjanJohansen \$\endgroup\$
    – SiD
    Sep 28, 2018 at 9:50
2
\$\begingroup\$

Python 3, 18 bytes

print(9*2,'bytes')

Try it online!

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

33, 14 bytes

Technically non-competing, as I made the language after this challenge was posted.

2c7xo" bytes"p

Pretty simple. Multiplies 2 and 7.

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

Runic Enchantments, 10 bytes

` ā`XESa@

Try it online!

Huh, I thumbed this one up and never answered it.

ā encodes the value 257 (still shorter than any other method) which gets multiplied by 10 and converted to a word via a dictionary. 2570 happens to be bytes. a encodes 10 (b-f encode 11 through 15) and gets around the "no digits" restriction. And conveniently enough, the rest of the program is 9 bytes.

Doesn't end up being shorter than " bytes"a@ (also 10 bytes), but oh well.

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

W d, 7 bytes

♣êæ█☺₧K

Explanation

Unpacked:

7 bytes"
\$\endgroup\$
2
\$\begingroup\$

RProgN 2, 10 bytes

°' Bytes'.

Explination

°           # Push 10 to the stack
 ' Bytes'   # Push the literal string " Bytes" to the stack
         .  # Concatenate. Implicit print.

Try it online!

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

Golfscript, 12 bytes

6 6+" bytes"

Try it online!

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

Javascript, 15 bytes

j=>0xf+' bytes'

Seems like the obvious answer.

Alternative:

j=>9+6+' bytes'

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

GolfScript, 10 bytes

n)" bytes"

Try it online!

n is a variable that represents \n, ) separates the last char from n and parses it to an integer. The ascii value of \n is 10.

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

Templates Considered Harmful, 30 bytes

St<51,48,' ','B',89,84,69,'S'>

Try it online!

This should be the best possible score. Every character here can be represented by a 2 byte ascii (ex. 66) value, or a 3 byte char literal (ex. 'B'). 28 is the theoretical minimum representing every character as ascii, but it is blocked by space being value 32. 29 is also blocked by Y and E. 30 works.

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

RAMDISP, 133 26 bytes

There's room for improvement.

[P[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]][*[[[[]]]]][+[[[]]]][S[; bytes]]]]

i honestly don't even remember how i did this, i attached a debugger, and found it it calculates 3 * 37 + 2.

[P[5[*5][+1][S[; bytes]]]]

26 = 5*5+1

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

PICO-8, 25 bytes

print(ord("」").." bytes")

ord() gets the index of a character, and is character 25 in P8SCII.

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

><>, 13 bytes

dn'setyb '>o<

Try it online!

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

Vyxal , 5 bytes

4›`¨∞

Try it Online!

Explanation :

4     # push 4
 ›    # increment
  `¨∞ # push "Bytes"
      # flag `ṡ` => join with space
      # implicit output
\$\endgroup\$
2
\$\begingroup\$

Haskell, 34 bytes

main=putStr$show(0x1D+5)++" bytes"

Try it online!

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

SOGL V0.12, 8 bytes

┌`m39Σ³‘

Try it Here!

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

Pari/GP, 18 bytes

print(2*9" bytes")

Try it online!

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

MATL, 12 bytes

6EV' bytes'h

Try it online!

Pushes 6, doubles with E, converts that to a string with V, and horzcats it with the string ' bytes' to get the proper spacing. Implicit output takes care of the rest.

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

SmileBASIC, 12 bytes

?3*4;" bytes

(Probably works in a bunch of other BASIC dialects, too)

Alternatives:

?&HC;" bytes
?9+3;" bytes
\$\endgroup\$

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.