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

185 Answers 185

1
3 4 5 6
7
0
\$\begingroup\$

Commodore 64 - 74 tokenized and BASIC bytes

Assuming by score in bytes, you mean tokens and bytes used by the BASIC interpreter, this works:

0 def fn b(x) = 38911-(fre(x)-2^16*(fre(x)<x)): print fnb(.);"bytes

There is a bug in the FRE() function on the Commodore 64 as it assumes maximum size of BASIC is 32K, or 32768 bytes.

Commodore VIC-20 (unexpanded) - 29 tonkenized and BASIC bytes

0?(60*60-17)-fre(.)"bytes
\$\endgroup\$
0
\$\begingroup\$

Zsh, 16 bytes

<<<$[##␐]\ bytes

Attempt This Online!

should be a literal 0x10 byte, but that doesn't show up in SE markdown.


Zsh -BCDEFGHIJ, 13 bytes

<<<$#-\ bytes

Attempt This Online!

Cheating.

\$\endgroup\$
3
  • \$\begingroup\$ What is that flag lol \$\endgroup\$ Aug 24, 2022 at 15:14
  • 2
    \$\begingroup\$ @thejonymyster It doesn't matter what the contents of the flag is, but the code itself is counting the length of the flags (I think). \$\endgroup\$
    – naffetS
    Aug 24, 2022 at 16:14
  • \$\begingroup\$ @Steffan That's correct. Note that Zsh already has the options 569X enabled by default, so by adding BCDEFGHIJ the length of the options reaches 13. \$\endgroup\$
    – pxeger
    Aug 24, 2022 at 17:33
0
\$\begingroup\$

Headascii, 55 BYTES

++++[]]]][]^^]]+++++PPDP++]]P^]+++++++P-----P(D+++P<-P!

Try it here, code will have to be pasted in and executed as shown below:

erun("++++[]]]][]^^]]+++++PPDP++]]P^]+++++++P-----P(D+++P<-P!")

Outputs 55 BYTES

Code breakdown:

++++[]]]][]^^]]+++++PPDP++]]P^]+++++++P-----P(D+++P<-P! full program
++++[]]]][                                              save 16 to R2
          ]^^                                           save 32 to R1
             ]]+++++PP                                  append "55" to string register
                      DP                                append " " to string register
                        ++]]P                           append "B" to string register
                             ^                          save 66 to R1
                              ]+++++++P                 append "Y" to string register
                                       -----P           append "T" to string register
                                             (          store 84 in R3
                                              D+++P     append "E" to string register
                                                   <-P  append "S" to string register
                                                      ! print string register

This breakdown isn't great but the basic idea is that [^( store to registers and ]D< return values from registers, and treat the rest like brainfuck basically :P

\$\endgroup\$
1
  • \$\begingroup\$ Oh wait this is 54 bytes in Headass, i'll add it later \$\endgroup\$ Aug 24, 2022 at 20:00
0
\$\begingroup\$

Thunno, 14 bytes

7 2*J" bytes"+

Attempt This Online!

Explanation

7 2*             # Push 7 * 2 (14)
    J            # Convert to string
     " bytes"    # Push the string " bytes"
             +   # Concatenate
                 # Implicit output
\$\endgroup\$
0
\$\begingroup\$

RProgN 2, 12 bytes

34*" bytes"+

Try it online!

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

Your Answer

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

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