# Output your Score!

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


• 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!

• Does this need the quine tag, or may the code self-inspect? – Adám Mar 29 '18 at 15:59
• @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 – Jeff Schaller Mar 29 '18 at 16:16
• Are leading spaces in output acceptable? – rafa11111 Mar 29 '18 at 17:43
• 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) – Erik the Outgolfer Mar 29 '18 at 18:07
• @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! – X1M4L Mar 29 '18 at 22:50

# JavaScript, 19 bytes

Octal was invented to serve two purposes:

• setting file permissions in Linux
• answering this challenge

alert(023+' bytes')

Try it online!

• Does this count as a full program? – ericw31415 Mar 29 '18 at 21:06
• @ericw31415 This is a browser program, as defined in this meta answer. – Arnauld Mar 29 '18 at 21:13
• +1 because finally clarifying me why octal is not completely useless! – sergiol Apr 15 '18 at 11:31

# Perl 5, 16 bytes

There are many other ways to get 16 but this one is mine

say afpbytes^PPP


Try it online!

• How does this work? – caird coinheringaahing Mar 30 '18 at 13:00
• @cairdcoinheringaahing In perl you can leave out the quotes on strings if they looks like a literal and don't conflict with a keyword (and is very much deprecated but we don't care in golf), Binary operators & | ^ and ~ can also be applied to strings and work on them like on a list of ASCII values (if and only if both sides are strings). For | and ^ it works as if the shorte string is extended with \0. After that is a simple exercise to find combinations of letters that xor to the desired output, – Ton Hospel Mar 30 '18 at 14:12

# 7, 23 characters, 9 bytes

54340045141332401057403


Try it online!

This is a fairly hard challenge in a language that consists entirely of digits, but I managed it…

This is just 9 bytes in 7's encoding. (Strictly speaking, it's 8⅜ bytes (23 × ⅜ − ¼ because the final two trailing 1 bits can be omitted), but for the first time, PPCG's requirement to round up to a whole number of bytes is actually an advantage because it means that the extra trailing 1 bits are necessary and thus not banned by the question.) A reversible hex dump:

00000000: b1c0 2530 b6a0 22f8 1f                   ..%0.."..


The main challenge of writing this program in 7 was golfing it to under 10 bytes (as writing 7 without using 0 or 1 is pretty hard.) This uses the same structure as the standard "Hello world" program:

54340045141332401057403
5434004514133240105      commands 0-5 append literals to data space
7     start a new section of data space
403  another literal appended to data space
{implicit: eval the last section as commands}
4    swap 1st and 2nd sections with an empty section between
6   reconstruct the commands that would create the 1st section
3  output (+ some other effects we don't care about)


In other words, we start by creating two sections of the data space; we have two literals, each of which pushes a sequence of commands there. The second section (they're pushed stack-style so first push = last pop) is a fairly arbitrary sequence of commands but is pushed using the command sequence 5434004514133240105 (thus producing the data sequence 5434664574733246765; when discussing 7 in text, I normally use normal font for a command that pushes a literal, and bold for the corresponding resulting literal). The first section is pushed using the command sequence 403, producing 463. Then the first section is copied back to the program (an implicit behaviour of 7).

The 463 is now composed of (bold) commands that do something immediately, rather than (non-bold) commands that just push literals. 4 rearranges the sections to get our "string literal" into the first section. Then 0 does the operation that 7 is most known for: taking a section of data space, and reconstructing the command sequence that's most likely to have created it. In the case where the original command sequence was all 0-5, this is 100% accurate (unsurprisingly, as those commands purely push data and thus leave obvious evidence of what they did), and so we get our original sequence 5434004514133240105 back. Finally, 3 prints it.

So the remaining thing to look at here is the encoding of the string. This has its own domain-specific language:

5434004514133240105
5                    change encoding: 6 bits per character
43                  select character set: digits and common symbols
40                '9'
04              space
51            select character set: uppercase letters
4133240105  'B' 'Y' 'T' 'E' 'S'


(There's no "select character set: lowercase letters" in the "digits and common symbols" character set – you have to go via a different character set first – so I needed to use uppercase to golf this short enough to fit underneath the effective 10-byte limit.)

# Canvas, 8 bytes

８ bytes＋


Try it here!

A more interesting 20 byte solution:

bytecount.innerText＃


Try it here!

• OK, that is pretty clever. – Adám Mar 29 '18 at 15:58

# brainfuck, 53 BYTES

+[[<+>->->++>----<<<]>-]>-.--.<<<+.<.<.-----.>+++.<-.


Try it online!

Another submission with capitalised bytes. Found with the help of the excellent BF-crunch helper by primo.

# PHP, 14 bytes

<?=7*2?> bytes

• How about putting the bytes part outside the ?>? Try it online! – Jo King Mar 30 '18 at 0:02
• @JoKing great 3 less bytes :) – Cyclonecode Mar 30 '18 at 1:37
• Just fyi, it's probably best that you split up your answer into multiple answers if you cover more than one language. – Conor O'Brien Mar 30 '18 at 16:56
• @ConorO'Brien - Oki will do – Cyclonecode Mar 30 '18 at 17:10

# PHP older than 7.2, 13 bytes

Assumes default settings (E_NOTICE warnings disabled) and PHP version older than 7.2.

Needs to be decoded with xxd -r

00000000: 3c3f 3d7e cecc df9d 868b 9a8c 3b         <?=~........;


Or if you prefer Base64

PD89fs7M352Gi5qMOw==


Try it online!

# R, 16 bytes

cat(4*4,"bytes")


Try it online!

• Isn't it 17 because of your missing space? – PmanAce Mar 30 '18 at 3:05
• @PmanAce "Output should only be the byte count of your program and a trailing bytes". The program is 16 bytes. – Giuseppe Mar 30 '18 at 3:13
• cat by default adds a space between its inputs. – Giuseppe Mar 30 '18 at 3:13
• object.size outputs in the correct format (with bytes included by default). Annoyingly, the shortest I could find is 17: object.size(0)-39. TIO – Robin Ryder Aug 2 at 16:12
• Apparently, in Hadley's version, a 1-length vector is of length 48, so there must exist a version of R in which this 16-byte code works: object.size(0)/3. – Robin Ryder Aug 3 at 8:13

# Stax, 5 bytes

╗↑╞ô╝


Run and debug it

Unpacked, it looks like this. Packed source mode makes this kind of trivial and uninteresting.

5p     print 5 with no line break
5l@   print the compressed string " bytes"


If you don't want to use packed source mode, 6^p5l@ works for 7 bytes.

• I've downvoted this answer, because I think that using packed mode, while a clever way of saving bytes, feels like cheating (which it isn't) at worst, and uncreative at best. Rather than go on a downvote spree of all Stax restricted-source answers, I'll leave this downvote to cover all such similar answers. – caird coinheringaahing Apr 11 '18 at 19:34
• I certainly agree that it's uncreative. But I think the fault lies with the concept of restricted-source, not the language. This is actually the most direct way of producing "5 bytes" using Stax. – recursive Apr 11 '18 at 19:36
• I do agree that there is a problem with the challenge (hence why I've downvoted it), but I still dislike this answer. Please don't delete it though (just preemptive caution), there's nothing wrong with it. – caird coinheringaahing Apr 11 '18 at 19:39

# Python 3, 2524 18 bytes

print(6*3,'bytes')


Try it online!

• But "4" is in "24". Maybe "33-9"? – recursive Mar 29 '18 at 15:44
• @recursive 3*8 should be fine, though – Kevin Cruijssen Mar 29 '18 at 15:45
• @recursive whoops, fixed it :P – NieDzejkob Mar 29 '18 at 15:47

# 05AB1E, 6 bytes

₂¤“ÿ¡Ï


Try it online!

₂      # [26]        | Pushes 26 (many other alternatives).
¤     # [2, 6]      | Split out tail.
“ÿ¡Ï # ['6 bytes'] | ÿ = "Interpolate top of stack.", ¡Ï = "bytes" (compressed)


Alternatives for ₂¤ include: 5>, ₁¤, 3·

# Bash, 21 bytes

"Read your own source code" is clearly not the winner here, but no one else submitted one, so what the heck.

echo wc -c<$0 bytes  Try it online! # Retina, 15 bytes  bytes *>w..+  This program counts the number of substrings with at least two characters in the string " bytes", and then prints this count and the string itself. Try it online! # PHP + HTML, 16 bytes &#49;&#54; bytes  Yes, this is getting pretty close to loophole abuse, but I felt this needed to be posted. And the use of PHP means that this answer technically is written in a Turing-complete programming language. Of course, any other similar HTML templating language would work just as well. Live demo (without PHP): &#49;&#54; bytes • Beat me to it! And the ; can usually be omitted! – wedstrom Apr 2 '18 at 21:53 • Ahh but then it would be 14/15 bytes – wedstrom Apr 2 '18 at 21:57 # dc, 14 11 bytes [ bytes]Bnn  Try it online! -3 bytes by @Cows quack • [ bytes]Bnn shaves some bytes – Cows quack Mar 29 '18 at 15:52 • @Cowsquack thanks! – NieDzejkob Mar 29 '18 at 15:55 • @cowsquack duckies go MOO, I'd assume :P? – Magic Octopus Urn Mar 30 '18 at 22:05 • @MagicOctopusUrn Ducks, what are ducks? :P – Cows quack Mar 31 '18 at 9:03 # MATL, 13 bytes '57$f}xiw'4-c


Try it online!

This pushes the string '57$f}xiw' and subtracts 4, to get 13 bytes. This is converted to characters using c. • 6EV' bytes'h is 12 (I was just about to post it) – Giuseppe Mar 29 '18 at 16:11 • although it's the same boring approach :P – Giuseppe Mar 29 '18 at 16:11 # Octave, 22 bytes disp([50 50 ' bytes'])  Try it online! # Octave, 23 bytes printf('%i bytes',9+14)  Try it online! And this: disp(['','67$f}xiw'-4])


Try it online!

• The first answers seems fine, but... how does the second one works? o.O – rafa11111 Mar 29 '18 at 18:14
• @rafa11111 Subtracting 4 from (the ASCII codes of) '67$f}xiw' gives the ASCII codes of '23 bytes'. Then, concatenating with the empty string '' converts ASCII codes to chars – Luis Mendo Mar 29 '18 at 19:07 • @Luis Mendo Pretty clever! Thanks for clarifying! – rafa11111 Mar 29 '18 at 19:13 # Petit Computer BASIC, 11 bytes ?9+2,"bytes  Using a comma in a print statement will move the cursor over to the next multiple of the current tab size. In SmileBASIC, that is 4 by default, so this would output 11 bytes (2 spaces) but PTC BASIC used 3 instead, so the output has the correct spacing. # APL (Dyalog Unicode), 12 bytes Full program which implicitly prints to STDOUT. 'bytes',⍨3×4  Try it online! ,⍨ is appends the string to the result of the multiplication. APL's default display of mixed-type data puts a space between a number and subsequent text. • I may be wrong, but don't you have a 2 in your byte count and program? 3*4 should be fine though – fyrepenguin Mar 29 '18 at 20:04 • @fyrepenguin Heh, right you are, of course. How silly of me. – Adám Mar 29 '18 at 20:39 # Brain-Flak, 100 BYTES ((((((<>))))))(((()[[]]((((()()((((([][]){}){}())[()]))[[][]])()){})()[][]))[()()[]])[]){({}<>)<>}<>  Try it online! Outputs the bytes part in all caps. Someone familiar with Brain-Flak might be really confused with all the ((<>)) at the beginning, but rest assured, they're only there to abuse the stack height nilad ([]) and none of the 0s they produce are printed. # Haskell, 26 bytes main=putStr$"\50\54 bytes"


Try it online!

### 29 bytes

main=putStr$pred<$>"3:!czuft"


Try it online!

• Unnecessary whitespace is now forbidden, but you can use a \$ instead. – Ørjan Johansen Mar 30 '18 at 0:57
• @ØrjanJohansen Thanks for pointing out. – Laikoni Mar 30 '18 at 10:42

# Whitespace, 112 bytes

Just because nobody's done it yet:





Try it online!

Prints " BYTES" in caps, since uppercase letters have shorter binary ASCII codes. The commands in the program, in my own made up visible notation, are:

Push 112
PrintNum
Push 0
Push 0x53
Push 0x45
Push 0x54
Push 0x59
Push 0x42
Push 0x20
Label _
PrintChr
Dup
JumpZ S
Jump _
Label S
End


# Java 5 or 6, 44 bytes (full program)

enum A{A;{System.out.print(0x2C+" bytes");}}


No TIO-link, because Java 5/6 is old.. In Java 5/6 it was possible to have an enum with code instead of the mandatory main-method, making it shorter for full program challenges.

Also errors with java.lang.NoSuchMethodError: main\nException in thread "main" in STDERR after printing to STDOUT, which is fine according to the meta (but if the challenge would have disallowed additional errors to STDERR, System.exit(0); can be added (and the octal numbers has to be updated) to prevent the error.

Suggested by @OlivierGrégoire (and his relevant Java tip).

# Java 8+, 74 bytes (full program)

interface M{static void main(String[]a){System.out.print(0112+" bytes");}}


Try it online.

# Java 8+, 16 15 bytes (lambda function)

v->0xF+" bytes"


-1 byte thanks to @OliverGégoire.

Try it online.

• Technically not a full program :) – O.O.Balance Mar 29 '18 at 15:54
• @O.O.Balance Oops.. somehow read past that, thanks for the correction. There goes my score.. XD – Kevin Cruijssen Mar 29 '18 at 16:48
• 37*2 contains a 7, so it is not valid. Your alternative solution is fine though. – O.O.Balance Mar 29 '18 at 23:01
• v->0xE+"bytes" or v->0xF+" bytes". Can't test but should work anyways. Nothing says the score and "bytes" must be separated. – Olivier Grégoire Mar 30 '18 at 10:56
• @OlivierGrégoire I know, I know. ;) When I posted the full program I was doubting to answer it as enum thinking about your tip-answer. Do you know any online compiler that still supports it? I prefer to have a link with test code for my answers.. – Kevin Cruijssen Mar 30 '18 at 14:36

# FerNANDo, 79 bytes

3 3
1
2 2
0 1 3 3 1 2 2 3
0 1 3 3 2 1 0 2
0 1 3 0 0 1 0 1
0 3 3 1 0 0 3 1
1 1
1


Try it online!

# Applescript, 15 bytes

Yes, I’m going there.

9+6&”bytes”

• But... Your source code can not include any of the digits from your byte count – nicael Mar 29 '18 at 19:10
• @nicael Dang, you’re right. One second then... – DonielF Mar 29 '18 at 19:12
• Correct me if I'm wrong, but isn't ” a multibyte character (3 bytes in Unicode if I remember correctly), so this is more than 11 bytes? – caird coinheringaahing Apr 3 '18 at 0:35
• @cairdcoinheringaahing ...Shoot. You’re right - “ is 2 bytes, upping this to 15. – DonielF Apr 3 '18 at 1:05
• does this not still print 11? – Destructible Lemon Apr 3 '18 at 3:11

## ><>, 13 bytes

#o<" bytes"nd


Try it online!

## Batch, 32 bytes

@@echo %COMSPEC:~-10,-010% bytes


COMSPEC is usually %WINDIR%\system32\cmd.exe so I extract the substring from 10 to 8 characters from the end. Old 16-byte self-referencing version:

@echo %~z0 bytes


Fortunately the byte count wasn't a multiple of 10.

• @manatwork OK, I hadn't seen that, here's a new version. – Neil Mar 29 '18 at 21:16

# JavaScript, 16 15 bytes

x=>0xf+' bytes'

• _=>5*3+' bytes' – Neil Mar 29 '18 at 19:36
• @Neil Both the code and the byte-count contains a 5 in that case.. – Kevin Cruijssen Mar 29 '18 at 20:04
• @KevinCruijssen Bah, I can't believe I overlooked that. – Neil Mar 29 '18 at 21:17
• Submissions are required to be full programs "write a full program to output its own code golf score!" – Cows quack Apr 15 '18 at 12:55

## 7Zip - 90 14 bytes

Hex dump:

00 75 0d 08 c0 00 0d 08 03 00 00 03 04 1d


To use:

save into a source file, named anything.

run the compiler from the command line: 7z e [source name]`