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

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

Clojure, 24 bytes

(println(+ 17 7)"bytes")

Try it online!

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

Lua, 21 bytes

print(3*7 ..' bytes')

The space before .. (string concatenation operator) is required or the parser sees 7.. as a malformed number.

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

K4, 18 15 bytes

Solution:

($6+9)," bytes"

Example:

q)k)($6+9)," bytes"
"15 bytes"

Explanation:

Evaluated right-to-left, don't think I can get lower than 15 this way:

($6+9)," bytes" / the solution
      ," bytes" / join " bytes" with...
(    )          / do together
  6+9           / 6+9 = 15
 $              / cast to string

Alternative:

Another 15 byte solution, has potential to be golfed if anyone can make "41" in 4 chars or "31" in 3 chars:

|"setyb ",$49+2
\$\endgroup\$
0
\$\begingroup\$

Aceto, 16 15 bytes

es7+
t"8p
ybp
"

We first push " bytes", then 78+ (15) and then print both.

edit: Fixed counting final newline character edit2: Saved 1 byte thanks to Jo King

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

Excel, 13 bytes

=4+9&" bytes"

Using CONCATENATE for 28 bytes:

=CONCATENATE(4*6+4," bytes")
\$\endgroup\$
0
\$\begingroup\$

Ruby, 16 bytes

p "#{9+7} bytes"

Try it online!

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

LOWER, 93 bytes

ₔ₉₃ₔₓ₃₂ₔₓ₉₈ₔₓ₁₂₁ₔₓ₁₁₆ₔₓ₁₀₁ₔₓ₁₁₅

Try it online!

This is all Unicode characters, so no 9s or 3s here.

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

JavaScript (Node.js), 22 bytes

alert(`${8+14} bytes`)
\$\endgroup\$
  • \$\begingroup\$ ok. will do that. \$\endgroup\$ – Muhammad Salman Apr 15 '18 at 13:06
  • \$\begingroup\$ @Cowsquack : There done. Thanks for the info \$\endgroup\$ – Muhammad Salman Apr 15 '18 at 13:32
  • \$\begingroup\$ OK? I see what the point is. It must outputting that on its own. Ok will update that. \$\endgroup\$ – Muhammad Salman Apr 15 '18 at 14:37
  • \$\begingroup\$ Nice, this works fine now :) \$\endgroup\$ – Kritixi Lithos Apr 15 '18 at 14:40
  • \$\begingroup\$ @Cowsquack: Thanks you for all the help. \$\endgroup\$ – Muhammad Salman Apr 15 '18 at 14:46
0
\$\begingroup\$

Make, 96 bytes

d=$1 $1 $1 $1 $1 $1 $1 $1
all:
	@echo $(words $(call d,x x x x x x x) $(call d,x x x x x)) bytes

Try it online!

\$\endgroup\$
  • \$\begingroup\$ See this and this standard loophole. I do not think that your answer is valid. \$\endgroup\$ – Jonathan Frech Sep 26 '18 at 20:16
  • \$\begingroup\$ @JonathanFrech fixed \$\endgroup\$ – Logern Sep 26 '18 at 21:39
0
\$\begingroup\$

Pepe, 74 bytes

rEeEeeEeEereEEreeeEeeeeereeEEeeeEereeEEEEeeEreeEEEeEeereeEEeeEeEreeEEEeeEE

Try it online!

It's a boring answer, rEeEeeEeEereEE pushes 74 into stack r and outputs the number, and the rest of the code prints bytes

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

Emojicode, 46 bytes

🏁🍇😀🍪🔡38 8🔤 bytes🔤🍪🍉

Try it online!

I wanted to add my own answer to this question, but seeing as y’all took all the GOOD languages, I had to pick one of the weird ones 😜

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

Python (REPL), 16 bytes

'%d bytes'%(8*2)

Output :

16 bytes
\$\endgroup\$
  • 7
    \$\begingroup\$ You could use f-strings like f'{7*2} bytes' \$\endgroup\$ – Jo King Sep 27 '18 at 14:34
  • \$\begingroup\$ Or, if you insist on using an older version of Python, you could use raw string r'%d bytes'%14 \$\endgroup\$ – mypetlion Sep 27 '18 at 16:04
0
\$\begingroup\$

LOLCODE, 66 bytes

Just because it's funny

HAI 1.2,VISIBLE SMOOSH PRODUKT OF 2 AN 33 AN " bytes" MKAY,KTHXBYE

Output

66 bytes

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

Go, 46 Bytes

package main;func main(){print(38+8," bytes")}
\$\endgroup\$
  • 3
    \$\begingroup\$ Yeah, but now you have no space between the number and the bytes \$\endgroup\$ – Jo King Sep 27 '18 at 14:40
0
\$\begingroup\$

C (gcc), 32 bytes

main(){printf("%d bytes",8*4);}

Nothing crazy here.

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

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.