53
\$\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
  • 3
    \$\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

143 Answers 143

1
\$\begingroup\$

Python 2, 17 bytes

print 9+8,'bytes'

Output: 17 bytes

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

Malbolge, 94 bytes

('&$:^"!65Y{z10/Sutsq)Monl*#Gih}|Bcc>P`<;:rqIY542q}0R.yO+ibK'H^]\"m}kA@?x,vQcs876$3ONMFjJIHA)?

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ Unfortunately, this doesn't obey the restriction that the source code can't contain the digits of the scores, since there's a 4 in the code. \$\endgroup\$ – Jo King Aug 2 at 7:58
  • \$\begingroup\$ @JoKing This code is in encoded form, therefore the real executed source code doesn't contain this 4. \$\endgroup\$ – Krzysztof Szewczyk Aug 2 at 8:00
  • 1
    \$\begingroup\$ I don't understand. This appears to be the source code, regardless of what is actually being executed as the program runs and modifies itself. That still counts \$\endgroup\$ – Jo King Aug 2 at 9:44
  • \$\begingroup\$ Can you either delete this or fix it so it is a valid answer? \$\endgroup\$ – Jo King Aug 6 at 12:24
1
\$\begingroup\$

Keg, 6 bytes

bytes

Uses an unprintable character at the beginning to push 6 to the stack. Then when it gets printed at the end, a space is automatically added after the 6 due to it being an integer.

Try it Online!

\$\endgroup\$
0
\$\begingroup\$

Attache, 18 bytes

Print[!4-6,$bytes]

Try it online!

This is simply printing !4-6 (which is factorial(4) - 6) followed by bytes.

\$\endgroup\$
0
\$\begingroup\$

Groovy, 22 bytes

{print"${0x16} bytes"}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

jamal, 14 characters

{@* 2 7} bytes

Sample run:

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

Pyt, 35 bytes

2⁵1⁺ᴇ⁻⁻1ᴇ⁺²2ᴇ4²+9⁺²⁺1ᴇ⁺²6-áƇǰ8Ḟ1+⇹ǰ

Try it online!

Explanation:

2⁵         Push 32
1⁺ᴇ⁻⁻      Push 98
1ᴇ⁺²       Push 121
2ᴇ4²+      Push 116
9⁺²⁺       Push 101
1ᴇ⁺²6-     Push 115
á          Convert stack to array, and push the array onto the stack
Ƈ          Cast to characters ([" ","b","y","t","e","s"])
ǰ          Join the elements of the array (" bytes")
8Ḟ1+       Push 35
⇹          Swap the top two elements on the stack
ǰ          Concatenate the stack as a string ("35 bytes")
           Implicit print
\$\endgroup\$
0
\$\begingroup\$

Swift, 22 bytes

print("\(18+4) bytes")

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Pip, 10 bytes

t." bytes"

Try it online!

Conveniently, there's a preset variable for the number 10.

\$\endgroup\$
0
\$\begingroup\$

Yabasic, 15 bytes

An anonymous answer that takes no input and outputs to STDOUT.

?7+8;
?" bytes"

Try it online!

\$\endgroup\$
0
\$\begingroup\$

uBASIC, 14 bytes

An anonymous answer.

0?2*7;" bytes"

Try it online!

\$\endgroup\$
0
\$\begingroup\$

MY-BASIC, 18 bytes

An anonymous MY-BASIC answer that outputs to STDOUT.

Print 9+9," bytes"

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Visual Basic .NET (Mono), 66 bytes

A declared Subroutine that takes no input and outputs to the console.

Module M
Sub Main
Console.Write(3*22 &" bytes")
End Sub
End Module

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Red, 19 bytes

prin[22 - 3 'bytes]

Try it online!

\$\endgroup\$
0
\$\begingroup\$

jshell, 12 bytes

9+3+" bytes"

I don't think it's on TIO.run despite having an article on Wikipedia.

\$\endgroup\$
  • \$\begingroup\$ For whatever reason, JShell requires TCP sockets to start up. For security reasons, those aren't available in TIO's sandbox. \$\endgroup\$ – Dennis Mar 30 '18 at 17:16
0
\$\begingroup\$

Neim, 10 bytes

μ( bytes)B

μ represents 10.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

AWK, 19 14 bytes

$0=2*7" bytes"

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ I don't get the point in using the x variable. Why not $0=2*7" bytes" for 14 bytes? \$\endgroup\$ – manatwork Mar 29 '18 at 18:11
  • 1
    \$\begingroup\$ Well obviously it's because I didn't think of it. :p \$\endgroup\$ – Robert Benson Mar 30 '18 at 12:37
0
\$\begingroup\$

Bash, 17 Bytes

echo $[8+9] bytes

output:

17 bytes
\$\endgroup\$
0
\$\begingroup\$

Vim, 13 Bytes

i<Ctrl-r>=7+6<Enter> bytes
\$\endgroup\$
0
\$\begingroup\$

FALSE, 11 bytes

'\u000B." bytes"

\u000B should be replaced by the corresponding character.

\$\endgroup\$
0
\$\begingroup\$

Haxe, 20 bytes

trace(4*5+' bytes');

Try it online!

\$\endgroup\$
0
\$\begingroup\$

C# (.NET Core), 16 bytes

n=>8*2+" bytes";

Try it online!


39 bytes

n=>System.Console.Write(~-40+" bytes");

Not sure whether returning the output from a function is valid, if not, here's a 39 byte solution.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Go, 66 64 bytes

package main;import"fmt";func main(){fmt.Printf("%d bytes",'@')}
\$\endgroup\$
0
\$\begingroup\$

Hoon, 23 bytes

(runt 1^0vcpi " bytes")

(runt [p q] "tape") prepends a byte sequence q to a string p number of times. p^q is sugar for [p q], and 0vXXX is base32 (@uv) encoding for the byte string '23'.

\$\endgroup\$
0
\$\begingroup\$

Pyke, 9 bytes

75 02 94 0A 09 58 EF 64 4A

Try it here!

u 02 94 0A 09      - integer list, length 2 ([2570, 9])
             X     - splat(^)
              .o   - lookup 2570 in dictionary (bytes)
                dJ - join by " "
\$\endgroup\$
0
\$\begingroup\$

V, 13 bytes

a20 bytes<esc>^7<C-x>

<esc> is \x1B and <C-x> is \x18.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

JavaScript, 20 bytes

alert(5*4+" bytes");
\$\endgroup\$
  • 1
    \$\begingroup\$ Unnecessary characters, spaces, and newlines are forbidden in the source code \$\endgroup\$ – l4m2 Mar 31 '18 at 12:50
  • 1
    \$\begingroup\$ @l4m2 Fixed now. \$\endgroup\$ – Esolanging Fruit Mar 31 '18 at 19:33
0
\$\begingroup\$

Ly, 14 bytes

72*u" bytes"&o

Try it online!

I tried a solution based on Ly's quine, but it quickly turned out to cost more bytes than it saved.

\$\endgroup\$
0
\$\begingroup\$

Batch, 31 bytes

@set /a r=29+2 
@echo %r% bytes
\$\endgroup\$
  • 6
    \$\begingroup\$ The source code is not allowed to include any of the digits of the byte count. 20*2 contains a zero. \$\endgroup\$ – Yair Rand Mar 29 '18 at 22:26
  • \$\begingroup\$ For only two lines, no @echo off to optimize \$\endgroup\$ – l4m2 Mar 31 '18 at 12:52
  • \$\begingroup\$ Thanks l4m2, I have shortened the answer and corrected my mistake. \$\endgroup\$ – Romen Apr 2 '18 at 13:22
  • 1
    \$\begingroup\$ Save two bytes: @set/ar=33-4. \$\endgroup\$ – Neil Apr 8 '18 at 10:41

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.