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?
Mar 29, 2018 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 Mar 29, 2018 at 16:16
• Are leading spaces in output acceptable? Mar 29, 2018 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) Mar 29, 2018 at 18:07
• Can bytes be in any case pattern, e.g. bYtEs? Dec 27, 2019 at 14:56

# JavaScript, 19 bytes

Octal was invented to serve two purposes:

• setting file permissions in Linux

alert(023+' bytes')

Try it online!

• Does this count as a full program? Mar 29, 2018 at 21:06
• @ericw31415 This is a browser program, as defined in this meta answer. Mar 29, 2018 at 21:13
• +1 because finally clarifying me why octal is not completely useless! Apr 15, 2018 at 11:31
• +1 for answering this challenge Jun 25, 2020 at 1: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? Mar 30, 2018 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, Mar 30, 2018 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.
Mar 29, 2018 at 15:58
• Notice that one of the restrictions is "Your source code can not include any of the digits from your byte count" so the first solution is not valid in this case =) Nov 4, 2019 at 6:23
• @Cyclonecode That "8" there isn't a regular ASCII 8 though - it's a full-width 8 character in this unicode version of the code, though really it's the byte 0xD5, which is completely unrelated to any 8s Nov 4, 2019 at 6:59

# 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, 2018 at 0:02
• @JoKing great 3 less bytes :) Mar 30, 2018 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. Mar 30, 2018 at 16:56

# 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. Apr 11, 2018 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. Apr 11, 2018 at 19:36

# Python 3, 2524 18 bytes

print(6*3,'bytes')


Try it online!

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

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

# Keg, 6 bytes

bytes


Uses an unprintable character at the beginning to push 6 to the stack. Then when it gets printed at the end, a space is automatically added after the 6 due to it being an integer.

Try it Online!

# R, 16 bytes

cat(4*4,"bytes")


Try it online!

• Isn't it 17 because of your missing space? Mar 30, 2018 at 3:05
• @PmanAce "Output should only be the byte count of your program and a trailing bytes". The program is 16 bytes. Mar 30, 2018 at 3:13
• cat by default adds a space between its inputs. Mar 30, 2018 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 Aug 2, 2019 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. Aug 3, 2019 at 8:13

# Pyramid Scheme, 477 440 BytEs

     ^   ^       ^   ^       ^   ^
^-  / \     ^-  / \     ^-  / \
/ \ /out\   / \ /out\   / \ /out\
/out\-----^ /out\-----^ /out\-----^
^-----^   / \-----^   / \-----^   / \
-^   / \ /chr\   / \ /chr\   / \ /chr\
-^ /chr\-----^ /chr\-----^ /chr\-----^
/*\-----^   / \-----^   / \-----^   / \
^---^   / \ /66 \   / \ /116\   / \ /115\
/8\ / \ /32 \-----  /121\-----  /69 \-----
---/55 \-----       -----       -----
-----


Try it online!

Outputs 440 BytEs by multiplying 8 by 55.

• Wouldn't that violate the rule against unnecessary whitespace? Or maybe I don't understand? Jun 24, 2020 at 1:54
• @SteveBennett You're right. I've modified it so that the program doesn't have redundant characters (though it can be golfed pretty easily
– Jo King
Jun 25, 2020 at 12:30
• 431 bytes, Psll code: (out (_ 431) " ") (out _ "b") (out _ "y") (out _ "t") (out _ "e") (out _ "s") Aug 28, 2020 at 23:39
• @MarcinKonowalczyk There's a source restriction on this challenge so that you can't use numbers from the score (in your case 4,3 or 1)
– Jo King
Aug 29, 2020 at 2:58
• though i managed to modify the format to work
– Jo King
Aug 29, 2020 at 3:32

# dc, 14 11 bytes

[ bytes]Bnn


Try it online!

-3 bytes by @Cows quack

• [ bytes]Bnn shaves some bytes Mar 29, 2018 at 15:52
• @Cowsquack thanks! Mar 29, 2018 at 15:55
• @cowsquack duckies go MOO, I'd assume :P? Mar 30, 2018 at 22:05
• @MagicOctopusUrn Ducks, what are ducks? :P Mar 31, 2018 at 9:03

# 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·

• Too bad this doesn't work. Mar 29, 2018 at 16:19

# 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! # 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! Apr 2, 2018 at 21:53 • Ahh but then it would be 14/15 bytes Apr 2, 2018 at 21:57 # 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  • Ah, didn't notice there was already a Whitespace answer.. Here is a shorter one (104 bytes).. Will delete mine again. Here is the same with added highlighting and explanation. Mar 30, 2018 at 15:02 • Oh, hmm. I guess the text is short enough that implementing the loop actually hurts more than just repeating the PrintChar. (And I know, I can always drop the final NNN, but I really like not having errors.) Mar 30, 2018 at 18:21 # Brain-Flak, 100 BYTES 80 bYTES ((((((()()()))[]{})))((({}){})(((({}){}))<([]([](([][][])([{}]()({{}}))))[])>)))  Try it online! Outputs the bytes part in reverse title case. Does away with the (<>) abuse to pad the stack height and instead reuses those elements to add up to 83 for the final push, as well as contributing to pushing the 80  part. Initially, this pushes 3 8 8 32 32 to the main stack while pushing 8 16 32 to the "third" stack (this is used to produce 80  (8+16+32,16+32,32)). Then inside that we push the bytes part inside a < >. Here we use the stack height (5) to get the differences between the elements (9 5 15 -14) before finally summing the stack to produce 83 (S). # Octave, 22 bytes disp([50 50 ' 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! # 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. Mar 30, 2018 at 0:57 • @ØrjanJohansen Thanks for pointing out. Mar 30, 2018 at 10:42 # 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 Mar 29, 2018 at 19:10 • @nicael Dang, you’re right. One second then... Mar 29, 2018 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? Apr 3, 2018 at 0:35 • @cairdcoinheringaahing ...Shoot. You’re right - “ is 2 bytes, upping this to 15. Apr 3, 2018 at 1:05 • does this not still print 11? Apr 3, 2018 at 3:11 # Poetic, 277 bytes for the A.I. system i did, i tried to put in humans i know i am one of those i am trying human testing for cyber-enabled virtual brains a for-profit company rakes in massive loads of cash educating interns, & then force-feeding things to all the interns until we earn a diploma  Outputs 277 bytes. Try it online! Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols. This was a fun program to write, although I'm not entirely sure I've fulfilled the "no unnecessary characters" requirement. If my answer needs to be amended, let me know! • "& then force-feeding things to all the interns until we earn a diploma". Absolutely wonderful! Nov 3, 2019 at 10:47 # 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) Mar 29, 2018 at 16:11 • although it's the same boring approach :P Mar 29, 2018 at 16:11 # 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 Mar 29, 2018 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 Mar 29, 2018 at 19:07
• @Luis Mendo Pretty clever! Thanks for clarifying! Mar 29, 2018 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 Mar 29, 2018 at 20:04
• @fyrepenguin Heh, right you are, of course. How silly of me.
Mar 29, 2018 at 20:39

# C, 33 32 bytes

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


There is a trailing newline, which is not "unnecessary" since the C standard demands it. Try it online here.

Thanks to NieDzejkob for golfing 1 byte.

Alternative with the same bytecount, thanks to ErikF:

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


Try it online here.

• , 040 for 32 bytes Mar 29, 2018 at 15:58
• , 040 is against the (updated) rules but I added a trailing newline instead of the space. Thank you! Mar 29, 2018 at 16:25
• You could also use ,' ' to avoid any numerals at all! Mar 30, 2018 at 5:51
• @ErikF now that is clever. thanks :) Mar 30, 2018 at 11:15
• 31 bytes Mar 30, 2018 at 11:53

# 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 :) Mar 29, 2018 at 15:54
• @O.O.Balance Oops.. somehow read past that, thanks for the correction. There goes my score.. XD Mar 29, 2018 at 16:48
• 37*2 contains a 7, so it is not valid. Your alternative solution is fine though. Mar 29, 2018 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. Mar 30, 2018 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.. Mar 30, 2018 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!