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.)
6Does this need the [tag:quine] tag, or may the code self-inspect? – Adám – 2018-03-29T15:59:46.263
Pardon me for asking, but what is a
trailing byte
(I'm sorta new ). – Dat – 2018-03-29T16:14:08.6173@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 – 2018-03-29T16:16:30.0502Are leading spaces in output acceptable? – rafa11111 – 2018-03-29T17:43:55.807
3If my code is 1 byte long, should I output
1 bytes
or1 byte
? (keep in mind there are already 41 answers, although I don't think any are affected) – Erik the Outgolfer – 2018-03-29T18:07:33.183@X1M4L Also, I don't recommend code to be able to self-inspect, this would easily make a generalized quine challenge if not for that. – Erik the Outgolfer – 2018-03-29T18:11:41.940
Can
bytes
be uppercase? – Jo King – 2018-03-29T22:44:49.9001@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 – 2018-03-29T22:50:34.283
@X1M4L i can imagine that in some programming languages (mostly very ancient ones) there are no lowercase characters in a character set. In this case however, it's just to make Brainfuck code more compact which seems fair. – Konrad Borowski – 2018-03-30T12:44:41.720
Can the output be surrounded by quotes? – Reinstate Monica -- notmaynard – 2018-03-30T13:54:28.360
@iamnotmaynard im sorry but output is limited to numerical byte count, the word
bytes
, and white-space characters – X1M4L – 2018-03-30T15:51:26.540As rafa11111 asked earlier: Are leading spaces acceptable? – Stewie Griffin – 2018-04-01T15:31:15.830
@StewieGriffin - I you read the question only trailing whitespaces seems to be allowed. – Cyclonecode – 2018-04-04T08:48:42.373
Can
bytes
be in any case pattern, e.g.bYtEs
? – Hello Goodbye – 2019-12-27T14:56:19.283@HelloGoodbye sure – X1M4L – 2019-12-31T07:32:25.547