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

163 Answers 163

2
\$\begingroup\$

Vim, 12 10 bytes

i9<C-o><C-a> bytes
\$\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.

\$\endgroup\$
2
  • \$\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\$ Apr 9 '18 at 15:06
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\$

MathGolf, 9 bytes

G½ "bytes

Try it online!

Explanation

Quite simple really

G            Push 18
 ½           Halve the result, giving 9
             Push a space character
   "bytes    Push "bytes"
\$\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 '18 at 9:17
  • \$\begingroup\$ Fixed the program and thanks for the review @ØrjanJohansen \$\endgroup\$
    – SiD
    Sep 28 '18 at 9:50
2
\$\begingroup\$

Python 2, 17 bytes

print 9+8,'bytes'

Output: 17 bytes

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

C# (Mono C# Shell), 27 bytes

Console.Write(3*9+" bytes")

Try it online!

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

Perl 5 + -Mfeature+say, 14 bytes

Relies on a generated program, so TIO link is to Bash which generates the program from xxd output. Uses -Mfeature+say instead of -M5.10.0 although I don't think it matters that much...

say~"ÎËß"

Try it online!

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

Brain-Flak, 90 bYTES

((((((<>))))[])[]([]((((([][][]))))([{}]()([]({}{}){}{}<>)))))(([][])[()]((([]{}))({}{})))

Try it online!

It took a while but I got us down to double digits.

I stole a technique of pushing a bunch of zeros in order to abuse [] from JoKing's answer. However I have modified it a bit.

Instead of pushing zeros I just push whatever is convenient (which does happen to include zeros). This is ok since JoKing gets rid of them with a loop that doesn't pick up zeros (which is reversing the stack), I use <> to switch to the other stack.

Other than that shared trick out answers are quite divergent.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 88 bYTES is a little easier to generate by modifying the end slightly \$\endgroup\$
    – Jo King
    Jul 18 '20 at 1:45
  • 1
    \$\begingroup\$ Back at you ;). I'm pretty sure 77 or 76 bYTES is possible though, but I've only got that down to 80 bytes \$\endgroup\$
    – Jo King
    Jul 18 '20 at 7:06
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\$
1
\$\begingroup\$

jamal, 14 characters

{@* 2 7} bytes

Sample run:

bash-4.4$ perl jamal.pl ownsize.jam 
14 bytes
\$\endgroup\$
1
\$\begingroup\$

Fortran (GFortran), 24 bytes

PRINT*,11+13,'BYTES'
END

Try it online!

Outputs "24 BYTES" with some leading spaces, because, you know, it's Fortran... you can't tell him to do something and expect that he will do exactly as you said, specially if it involves strings :)

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

TeX, 16 bytes

^^q^^v bytes\bye
\$\endgroup\$
1
\$\begingroup\$

Ruby, 15 bytes

p"#{0xf} bytes"

Try it online!

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

Foo, 13 bytes

&9+4$i" bytes

Try it online!

Explanation

&9+4$i" bytes
&9              push 9
  +4            add 4 (13)
    $i          output as integer
      " bytes   print out " bytes"

14 bytes

@20&$h" bytes"

Same general idea, but (ab)uses hexadecimal printing.

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

Pyth, 11 bytes

+hT" bytes"

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Why do you have h? Doesn't that just add the eleventh byte that it's there to account for, and it can thus be removed safely? \$\endgroup\$
    – Steven H.
    Apr 10 '18 at 22:21
1
\$\begingroup\$

Python 2, 18 17 bytes

print 8+9,'bytes'

-1 byte thanks to @Wondercricket.

Try it online.

\$\endgroup\$
2
  • \$\begingroup\$ That trailing space is not in the output, I think it's still precisely what the rule is intended to forbid. However, you can use parentheses around 2*9 instead. \$\endgroup\$ Mar 30 '18 at 0:48
  • \$\begingroup\$ @ØrjanJohansen I changed it to 8+9 instead to save a byte. :) \$\endgroup\$ Mar 30 '18 at 6:58
1
\$\begingroup\$

Rust, 34 bytes

fn main(){print!("{} bytes",17*2)}

Try it online!

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

C# (Visual C# Interactive Compiler), 20 bytes

Write(11+9+" bytes")

Try it online!

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

Excel, 13 bytes

=6+7&" bytes"

Output: 13 bytes

Nothing fancy. It's different from the other Excel answers as those are both based in VBA. This formula version is longer.

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

T-SQL, 32 bytes

print char(51)+char(50)+' bytes'

Best I could come up with.

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

Javascript,26 bytes

console.log(78/3+" bytes")

Try it online!

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