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

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\$ – Cows quack 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\$

Python 3, 18 bytes

print(9*2,'bytes')

Try it online!

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

k (oK), 16 bytes

Try it online!

($:4*4)," bytes"

String result of 4*4 and concatenate

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

Deadfish~, 59 bytes

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

Try it online!

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

C, 31 bytes

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

Try It Online!

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

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