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

145 Answers 145

1
\$\begingroup\$

Befunge-98 (FBBI), 12 bytes

"c.4k,@setyb

Try it online!

Thank you Jo King and Mistah Figgins for -3 bytes.

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

Attache, 19 bytes

Print&$bytes!STN!$t

Try it online!

Explanation

Print&$bytes!STN!$t
Print       !          print
     &$bytes           (with "bytes" as a right argument)
             STN!      convert string to number...
                 $t    "t" (corresponds to 19)

In sane syntax, this is: Print[STN["t"], "bytes"], which joins the arguments by spaces.

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

vim, 12 bytes

a9 bytes<ESC>03<C-A>

<ESC> is 0x1b. <C-A> is 0x01

Try it online!

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

Cubix, 23 bytes

@"!w"SETYB"uUo<S;O'$.;

Try it online!

Cubified:

    @ "
    ! w
" S E T Y B " u
U o < S ; O  '
    $ .
    ; .

Watch it run

Failrly simple pushes SETYB onto the stack, pushes character 23 (ETB) and outputs as an integer. Push 32 (space) onto the stack then start outputting chars and popping until stack is empty.

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

MBASIC, 17 bytes

6 PRINT 8+9"bytes

MBASIC requires line numbers; "6" doesn't appear in the output either. Turns out that the trailing quote is optional.

Output:

RUN
 17 bytes
Ok
\$\endgroup\$
  • 1
    \$\begingroup\$ Byte count is calculated from the source code, not the RAM it takes up. So this should be 18 bytes. But +1 for using an uncommon language; we need more variety around here. \$\endgroup\$ – Ray Sep 27 '18 at 18:23
  • 1
    \$\begingroup\$ Even with a tokenizing interpreter? \$\endgroup\$ – wooshinyobject Sep 27 '18 at 19:08
  • \$\begingroup\$ Yes. If the size of the target language/object code/internal representation mattered, the score would change every time improvements were made to the implementation's optimizer. And there would be a lot of situations where making the source code larger would make the target code smaller, and vice versa, since optimizers work better when they have a lot of explicit information about what assumptions are safe to make. \$\endgroup\$ – Ray Sep 28 '18 at 1:58
1
\$\begingroup\$

Pascal (FPC), 29 bytes

begin write($1D,' bytes')end.

Try it online!

$1D is a hexadecimal constant. I'm glad Pascal has something shorter than other languages!

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

Python 3, 18 bytes

print(9*2,'bytes')

Try it online!

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

k (oK), 16 bytes

Try it online!

($:4*4)," bytes"

String result of 4*4 and concatenate

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

Chevron, 12 bytes

^n<<3*4
>^n

This is a fairly new language of my own creation - prototype interpreter, documentation, and example programs can be found at https://github.com/superloach/chevron.

Explanation:

  • ^n<<3*4 - calculate 3*4, store as n
  • >^n - output n
  • nothing else - implicit exit
\$\endgroup\$
1
\$\begingroup\$

Deadfish~, 59 bytes

iisioiiiioii{ii}icii{iii}iic{ii}iiicdddddc{d}dddddc{i}iiiic

Try it online!

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

C++, 52 bytes

[]{std::string a="41 bytes";a[0]++;a[1]++;return a;}

Try it online!

facepalm is it even competable? it just barely wins against BF! but still, no 5s and 2s in the code.

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

Pyramid Scheme, 477 bytes

      ^      ^      ^      ^      ^      ^
     / \    / \    / \    / \    / \    / \
    /out\  /out\  /out\  /out\  /out\  /out\
   ^-----^ -----^ -----^ -----^ -----^ -----^
  /*\   / \    / \    / \    / \    / \    / \
 ^---^ /chr\  /chr\  /chr\  /chr\  /chr\  /chr\
/9\ / \-----^ -----^ -----^ -----^ -----^ -----^
---/53 \   / \    / \    / \    / \    / \    / \
   -----  /32 \  /98 \  /121\  /116\  /101\  /115\
          -----  -----  -----  -----  -----  -----    

Try it online!

Outputs 477 bytes by multiplying 9 by 53. This only has 4 extra whitespace to pad out the number to one that can be represented properly.

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

C, 31 bytes

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

Try It Online!

The unprintable character is the unit separator which value is 31.

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

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

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.