58
\$\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
  • 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\$ – 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

156 Answers 156

0
\$\begingroup\$

uBASIC, 14 bytes

An anonymous answer.

0?2*7;" bytes"

Try it online!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

MY-BASIC, 18 bytes

An anonymous MY-BASIC answer that outputs to STDOUT.

Print 9+9," bytes"

Try it online!

| improve this answer | |
\$\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!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Red, 19 bytes

prin[22 - 3 'bytes]

Try it online!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

jshell, 12 bytes

9+3+" bytes"

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

| improve this answer | |
\$\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!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

AWK, 19 14 bytes

$0=2*7" bytes"

Try it online!

| improve this answer | |
\$\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
| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Vim, 13 Bytes

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

FALSE, 11 bytes

'\u000B." bytes"

\u000B should be replaced by the corresponding character.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Haxe, 20 bytes

trace(4*5+' bytes');

Try it online!

| improve this answer | |
\$\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!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Go, 66 64 bytes

package main;import"fmt";func main(){fmt.Printf("%d bytes",'@')}
| improve this answer | |
\$\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'.

| improve this answer | |
\$\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 " "
| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

V, 13 bytes

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

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

Try it online!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

JavaScript, 20 bytes

alert(5*4+" bytes");
| improve this answer | |
\$\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.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Batch, 31 bytes

@set /a r=29+2 
@echo %r% bytes
| improve this answer | |
\$\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!

| improve this answer | |
\$\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.

| improve this answer | |
\$\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
| improve this answer | |
\$\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

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Excel, 13 bytes

=4+9&" bytes"

Using CONCATENATE for 28 bytes:

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

Ruby, 16 bytes

p "#{9+7} bytes"

Try it online!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

LOWER, 93 bytes

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

Try it online!

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

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

JavaScript (Node.js), 22 bytes

alert(`${8+14} bytes`)
| improve this answer | |
\$\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\$ – user41805 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!

| improve this answer | |
\$\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

| improve this answer | |
\$\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 😜

| improve this answer | |
\$\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.