75
\$\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
  • 7
    \$\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

191 Answers 191

1 2
3
4 5
7
2
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 27 bytes

	OUTPUT =3 * 9 ' bytes'
END

Try it online!

prints with a trailing newline.

\$\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.

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

PowerShell, 14 bytes

"$(2*7) bytes"

Try it online!

Ho-hum. Uses an inline code block $(...) to put 14 into the string before leaving it on the pipeline. Output is implicit.

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

Ruby, 18 bytes

puts"#{6*3} bytes"

Try it online!

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

brainfuck, 95 bytes

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

Try it online!

97 bytes:

>-[++>+[+<]>]>+.--.>++++[->++++++++<]>.[->+++<]>++.[--->+<]>+++.-----.+++[->+++<]>.[--->+<]>----.
\$\endgroup\$
2
\$\begingroup\$

CJam, 10 10 bytes

Ao" bytes"

Try it online!

\$\endgroup\$
3
  • \$\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\$ Mar 30, 2018 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\$ Mar 30, 2018 at 0:34
  • \$\begingroup\$ @IlmariKaronen Ao" bytes" works. \$\endgroup\$ Mar 30, 2018 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
\$\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\$
4
  • \$\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
  • \$\begingroup\$ You can remove tre space before and after the string literal and replace 0x17 with 0x15 to get 21 bytes: Try it online! \$\endgroup\$
    – noodle man
    Oct 23, 2023 at 11:49
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\$

Husk, 8 bytes

+sD4¨₆Ẏ¿

Try it online!

Explanation

+sD4¨₆Ẏ¿
    ¨₆Ẏ¿  Compressed string of " bytes"
  D4        Multiply 4 by 2
 s          Convert to string
+         Concatenate the strings
\$\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\$

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\$

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\$

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

dc, 14 bytes

7d+n[ bytes]p

Double it

\$\endgroup\$
1 2
3
4 5
7

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.