25
\$\begingroup\$

Write a program that outputs the exact string:

jan ale o, toki!

("Hello, world" but in toki pona to prevent builtins.)

with an optional trailing newline.

Additionally when all copies of any one byte present in your program are removed the program must fail to produce a correct output no matter what byte is selected.

To fail it just has to produce a wrong result, it doesn't matter whether it errors or not. Wrong doesn't necessarily mean different, just wrong. So using a different output format or dropping the optional trailing newline are not failure.

You are not allowed to read your own source code.

Scoring

Answers will be scored on two properties, the first is the number of distinct bytes, used (max being 256) in the program, with higher score being better.

Since it shouldn't be too hard to achieve the maximum for your choice of language in the first category the second category is good old . Answers are scored then in total number of bytes with lower being better.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Here's a program to tell how many unique bytes you have, and here's a program to highlight the duplicates. \$\endgroup\$ Aug 23, 2021 at 16:07
  • 4
    \$\begingroup\$ Assuming most answers achieve maximal bytes, this seems rather related. \$\endgroup\$ Aug 23, 2021 at 16:09
  • 5
    \$\begingroup\$ "Hello, world" but in toki pona to prevent builtins Are you sure Mathematica doesn't have a builtin for this...? \$\endgroup\$
    – Luis Mendo
    Aug 23, 2021 at 16:10
  • 3
    \$\begingroup\$ The moment when you find out your language only accepts valid UTF-8 sequences... \$\endgroup\$
    – Bubbler
    Aug 23, 2021 at 23:54
  • 2
    \$\begingroup\$ Here's a program that count distinct bytes in utf-8, and tells you the missing ones \$\endgroup\$
    – MarcMush
    Aug 24, 2021 at 12:50

9 Answers 9

7
\$\begingroup\$

Jelly, 256 bytes, score 256

Crushed my other answer :)

⁾j¡»“b¢£¥¦©¬®µ½¿ÆÇÐÑa×ØŒÞßæçðıȷñ÷øœnþ"#$&'()*-.078 :;<=>?@ABCEFGHḥIJKLMNPQRSTUVWlXYZ[\]^_`cdfghempqruvwxyz{|}~Ɲ¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼oƁƇƊƑƓƘⱮƤƬƲȤɓƈɗ,ƒɠɦƙɱɲƥʠɼʂƭʋȥẠṣḄḌẸḤỊḲḶṂṆṚṢṬỤṾtẈỴẒȦḂĊĖḞĠİĿṀṄȮḳṘṠṪẆẊẎŻạḅḍẹịḷṃkṇọṛṭ§ẉỵẓȧḃċḋėḟiġḣŀṁṅȯṗṙṡṫẇẋẏż!”s9123456DḊṖ+/¤Ḣ€O’‘%⁽«ÄỌ

Try it online!

Or try to remove any byte - this will remove the byte at the nth position and evaluate the result as a niladic link.

Some notable byte positions...

  • removing any of \$217\$ to \$231\$ (ġḣŀṁṅȯṗṙṡṫẇẋẏż!) will print jan ale o, toki without the final !
  • removing \$1\$ () will, when run as a full-program, hang waiting for input, and, if an input is given, it will then error comparing an integer to a string (on TIO it will give an EOF error with no pre-prepared input).
  • removing \$241\$ (D) will take about 12 seconds but will print j
  • removing \$256\$ () will print a list of integers, the ordinal values of jan ale o, toki!.

The base program

A large portion of the code is:

“b¢£¥¦©¬®µ½¿ÆÇÐÑa×ØŒÞßæçðıȷñ÷øœnþ"#$&'()*-.078 :;<=>?@ABCEFGHḥIJKLMNPQRSTUVWlXYZ[\]^_`cdfghempqruvwxyz{|}~Ɲ¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼oƁƇƊƑƓƘⱮƤƬƲȤɓƈɗ,ƒɠɦƙɱɲƥʠɼʂƭʋȥẠṣḄḌẸḤỊḲḶṂṆṚṢṬỤṾtẈỴẒȦḂĊĖḞĠİĿṀṄȮḳṘṠṪẆẊẎŻạḅḍẹịḷṃkṇọṛṭ§ẉỵẓȧḃċḋėḟiġḣŀṁṅȯṗṙṡṫẇẋẏż!”

Which is a string with runs of \$15\$ bytes:

“b..a..n.. ..ḥ..l..e..Ɲ..o..,..ṣ..t..ḳ..k..i..!”

Here each of the \$15\$ occurrences of .. represents \$14\$ filler bytes that are simply placed arbitrarily (it isn't guaranteed that any placement of the remaining \$210\$ bytes would do but most will).

Replacing that for brevity with “data” the code is:

⁾j¡»“data”s9123456DḊṖ+/¤Ḣ€O’‘%⁽«ÄỌ - Link: no arguments
⁾j¡                                - list of characters = "j¡"
    “data”                         - list of characters = the data described above
   »                               - maximum (vectorises)
                                     -> replaces the first character with 'j'
                                        call this newData
                       ¤           - nilad followed by link(s) as a nilad:
           9123456                 -   9,123,456
                  D                -   to decimal digits -> [9,1,2,3,4,5,6]
                   Ḋ               -   dequeue -> [1,2,3,4,5,6]
                    Ṗ              -   pop -> [1,2,3,4,5]
                      /            -   reduce with:
                     +             -     addition -> 1+2+3+4+5=15
          s                        - split (newData) into slices of length (15)
                        Ḣ€         - head of each -> "jan ḥleƝo,ṣtḳki!"
                          O        - ordinals
                           ’       - decrement -> ordials - 1
                            ‘      - increment -> ordinals
                                     -> [106,97,110,32,7717,108,101,413,111,44,7779,116,7731,107,105,33]
                              ⁽«Ä  - 127
                             %     - (ordinals) modulo (127)
                                     -> [106,97,110,32,97,108,101,32,111,44,32,116,111,107,105,33]
                                 Ọ - cast to characters
                                     -> "jan ale o, toki!"
\$\endgroup\$
5
\$\begingroup\$

Julia 1.0, score 126 242, (269 259 bytes)

lowercase("
�	
#\$&'./;<=?%6890+-gh@BCDFGHJKM𿻽񨝞򈷴󧵺࿋ᣤ⢌㯙䡚嶃氼甬蟦鍂ꕇ돲츛톩’ñĉūƹǪȀɠʑˎ̿ͥξυЖѓҁӭԜծ֘׳خٓھۧܞݩސߵPQRSUVWXYZ^_`bdfmquvxyz{}~jAN aLE O, TokI!"[213:4*57])|>print

Try it online!

(the first 2 characters of the long string are \r\0)

Check the score (+1 because TIO turns \r into \n)

-10 bytes with Jakque's idea

hexdump

00000000  6c 6f 77 65 72 63 61 73  65 28 22 0d 00 01 02 03  |lowercase(".....|
00000010  04 05 06 07 08 09 0a 0b  0c 0e 0f 10 11 12 13 14  |................|
00000020  15 16 17 18 19 1a 1b 1c  1d 1e 1f 23 5c 24 26 27  |...........#\$&'|
00000030  2e 2f 3b 3c 3d 3f 25 36  38 39 30 2b 2d 67 68 40  |./;<=?%6890+-gh@|
00000040  42 43 44 46 47 48 4a 4b  4d f0 bf bb bd f1 a8 9d  |BCDFGHJKM.......|
00000050  9e f2 88 b7 b4 f3 a7 b5  ba e0 bf 8b e1 a3 a4 e2  |................|
00000060  a2 8c e3 af 99 e4 a1 9a  e5 b6 83 e6 b0 bc e7 94  |................|
00000070  ac e8 9f a6 e9 8d 82 ea  95 87 eb 8f b2 ec b8 9b  |................|
00000080  ed 86 a9 ee 84 8a ef 90  97 c2 92 c3 b1 c4 89 c5  |................|
00000090  ab c6 b9 c7 aa c8 80 c9  a0 ca 91 cb 8e cc bf cd  |................|
000000a0  a5 ce be cf 85 d0 96 d1  93 d2 81 d3 ad d4 9c d5  |................|
000000b0  ae d6 98 d7 b3 d8 ae d9  93 da be db a7 dc 9e dd  |................|
000000c0  a9 de 90 df b5 50 51 52  53 55 56 57 58 59 5a 5e  |.....PQRSUVWXYZ^|
000000d0  5f 60 62 64 66 6d 71 75  76 78 79 7a 7b 7d 7e 7f  |_`bdfmquvxyz{}~.|
000000e0  6a 41 4e 20 61 4c 45 20  4f 2c 20 54 6f 6b 49 21  |jAN aLE O, TokI!|
000000f0  22 5b 32 31 33 3a 34 2a  35 37 5d 29 7c 3e 70 72  |"[213:4*57])|>pr|
00000100  69 6e 74                                          |int|

Explanation

lowercase("long string...jAN aLE O, TokI!"[213:4*57])|>print
  • if a byte is missing in the long string, 4*57 will be greater than the length of the string and will error, alternatively, it will produce an incorrect unicode sequence and error as well
  • a byte missing in the numbers (213 and 4*57) will give an other substring or error
  • a byte missing elsewhere will be a syntax error or an undefined function
  • lowercase allows to mix the case in the Hello world and thus reduce the length of the string
  • 213:4*57 was found by brute-force

I believe this is all I can get with valid UTF-8 sequences

this is getting close to optimal, with only 17 repeated bytes

\$\endgroup\$
4
\$\begingroup\$

Husk, 256 256 bytes

Edit: removed '\' character from the filler string, which was otherwise interpreted as an escape signal and not counted towards its length (and so would be deletable).

↓₁-237+6L"¤½↕↑↔←→∟¡¿‼…‰‡√≤≥±∂∫∞≈≠≡⌐÷× #$%&`'()*./014589:;=>?@ABCDEFGHIJKMNOPQRSTUVWXYZ[]^_bcdefghiklmnopqrstuvwxyz{|}~·₂₃₄₅₆₇₈₉⌈⌉⌊⌋ΓΔΘΛΞΠΣΦΨΩαβγδεζηθλμξπρςστφχψω⁰¹²³⁴⁵⁶⁷⁸⁹¢£€¥ƒ´▲▼►◄§ḂĊḊĖĠḢİĿṀṄȮṖṘṠṪẆẊẎŻȧḃċḋėḟġḣıȷŀṁṅȯṗṙṡṫẇẋẏżÄËÏÖÜŸØäëïöüÿø◊□¶«»
¨\ja¬Ȧ¦₀,†Ḟ<!

Try it online!

First attempt using a long compressed string was quickly debunked, so here's one without compression of the filler string...

↓₁              # drop X characters from the compressed string on next line
                # which is ¨\ja¬Ȧ¦₀,†Ḟ<!¨ encoding "\jan ale o, toki!"

                # Calculate X as:
         L"     # Length of this non-compressed filler string 
                # (containing all the other Husk codepoints),
       +6       # plus 5,
   -237         # minus 257:
                # X should equal 1 (to remove the leading '`' character;
                # deletion of any character from the filler string yields X=0,
                # so the '\' is printed.
\$\endgroup\$
0
2
\$\begingroup\$

Zsh, score 256 (269 total bytes)

grep -Eax .{240}<<X|cut -f1
jan ale o, toki!    "#$%&'()*+/356789:;=>?@ABCDFGHIJKLMNOPQRSTUVWYZ[]^_\`bdhmqsvwyxz~...............................................................................................................................................................

Attempt This Online!

Those .s are all unprintables, so here's a hexdump:

00000000: 6772 6570 202d 4561 7820 2e7b 3234 307d  grep -Eax .{240}
00000010: 3c3c 587c 6375 7420 2d66 310a 6a61 6e20  <<X|cut -f1.jan 
00000020: 616c 6520 6f2c 2074 6f6b 6921 0922 2324  ale o, toki!."#$
00000030: 2526 2728 292a 2b2f 3335 3637 3839 3a3b  %&'()*+/356789:;
00000040: 3d3e 3f40 4142 4344 4647 4849 4a4b 4c4d  =>?@ABCDFGHIJKLM
00000050: 4e4f 5051 5253 5455 5657 595a 5b5d 5e5f  NOPQRSTUVWYZ[]^_
00000060: 5c60 6264 686d 7173 7677 7978 7a7e 0001  \`bdhmqsvwyxz~..
00000070: 0203 0405 0607 080b 0c0d 0e0f 1011 1213  ................
00000080: 1415 1617 1819 1a1b 1c1d 1e1f 7f80 8182  ................
00000090: 8384 8586 8788 898a 8b8c 8d8e 8f90 9192  ................
000000a0: 9394 9596 9798 999a 9b9c 9d9e 9fa0 a1a2  ................
000000b0: a3a4 a5a6 a7a8 a9aa abac adae afb0 b1b2  ................
000000c0: b3b4 b5b6 b7b8 b9ba bbbc bdbe bfc0 c1c2  ................
000000d0: c3c4 c5c6 c7c8 c9ca cbcc cdce cfd0 d1d2  ................
000000e0: d3d4 d5d6 d7d8 d9da dbdc ddde dfe0 e1e2  ................
000000f0: e3e4 e5e6 e7e8 e9ea ebec edee eff0 f1f2  ................
00000100: f3f4 f5f6 f7f8 f9fa fbfc fdfe ff         .............

Needs to be run with LC_ALL=C, because otherwise grep/cut/Zsh get confused by broken Unicode.

Explanation

<<X takes the rest of the file and passes it to grep, which searches for a line containing 241 characters. -E is necessary to activate the {} quantifier, -a forces processing of the input even though it is "binary" not "text", and -x ensures the whole line has to match, not just a substring.

If it matches (i.e. no characters on the second line have been removed), this is passed to cut, which outputs only the 1st field (tab-separated).

If any character on the first line (including the newline) is removed, the search command will break or the pattern won't be matched.

\ escapes the `, because even in a heredoc (<<X), some expansions (importantly ``) are still processed, and otherwise it would be unmatched.

x is duplicated in the second line even though it's already used in the first line, because if it's removed from the grep command then the pattern still matches, but we need it to disallow any of the digits 240 from being removed (otherwise there is always a 20-character substring of that line, or whatever)

\$\endgroup\$
2
\$\begingroup\$

Charcoal, 141 bytes, score 97

⍘⍘!ltoojjjtnn!!iiea,teoikneleaa ¦ !,aeijklnot¦ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Try it online! Explanation: The string !ltoojjjtnn!!iiea,teoikneleaa is interpreted in the custom base !,aeijklnot and then converted to the custom base of printable ASCII. Removing any of the characters in the custom base will obviously prevent them from being output, but also removing any of the other printable ASCII will scramble the result, while removing the either of the two non-ASCII characters will break the Charcoal program as a whole.

\$\endgroup\$
1
\$\begingroup\$

><>, 297 bytes, score 256

'!ikot ,o ela naj'!;v
"#$%&()*+-./01234567o;
89:<=>?@ABCDEFGHIJKL ;
MNOPQRSTUVWXYZ[\]^_` ;
bcdfghmpqrsuwxyz{|}~ ;
.................... ;
.................... ;
.................... ;
.................... ;
.................... ;
.................... ;
.................... ;
.................... ;

Try it online!

(replace the dots with all the unprintable ascii)

The main idea is fairly simple, removing any byte will block the "print corridor" with the termination character ;

Some notable exceptions:

  • Removing the letters in the original phrase will crash the instruction pointer into J, K or L
  • Removing a single quote will crash the instruction pointer at k
  • Removing ; will crash the instruction pointer at L
  • Removing newlines or v will cause no output to be written.
\$\endgroup\$
2
  • \$\begingroup\$ Does this actually work with the unprintables? They will form multibyte characters this way, depending on the internals of the interpreter this might break the alignment even in the default mode. \$\endgroup\$
    – Wheat Wizard
    Aug 24, 2021 at 21:47
  • \$\begingroup\$ It seems ><> reads the file as UTF encoded so this will not work. I believe it make work in *><> though. \$\endgroup\$
    – Wheat Wizard
    Aug 24, 2021 at 21:51
1
\$\begingroup\$

Python 3, 243 unique bytes, 265 261 bytes

B=0
input("
	#$%&'*+-/25789;<>?@CDFGHMPQRSUVWXYZ^_`bcdghjkmqsvyz{|}~ŸÜĜŜƜǜȜɜʜ˜̜͜ΜϜРѡҢӣԤե֦קب٩ڪ۫ܬݭޮ߯ఀ᱁Ⲃ㳃䴄嵅涆緇踈鹉꺊뻋켌퍽ᅬ𐑒񓔕򖗘󙚛_JaN ALE \x4f, TOKI!".lower()[136:])

Try it online!

Score ! (the score shows 242 because tio interprets \n and \r the same way)

Note :

as MarcMush pointed, TIO link doesn't like unicodes \U10xxxx. To make my link works, I changed 󙚛 by _ in the code.

Explanation:

the code is equivalent to :

B=0
input("""<bunch of useless stuff>JaN ALE \x4f, TOKI!""".lower()[<index>:])
  • store the wanted string upper case and lower it allows to reduce the number of bytes as they would have been stored in the code anyways. I also used \x4f instead of O to save 1 byte
  • if ant byte is removed from the first line, the program will crash due to a syntax error or a Name error.
  • if any byte is removed from the string, or the slice, the portion written would not be the correct one.
  • if any other byte is removed, the code will crash
\$\endgroup\$
2
  • \$\begingroup\$ I don't know why but the links given by TIO seams broken. Will try to fix that later \$\endgroup\$
    – Jakque
    Aug 24, 2021 at 18:24
  • 1
    \$\begingroup\$ I had the same problem, I think i was due to some \U10xxxx character, I think TIO doesn't like the byte 244 \$\endgroup\$
    – MarcMush
    Aug 24, 2021 at 22:20
0
\$\begingroup\$

Jelly, 256

“¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi“jklmnopqrstuvwxyz{|}~¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḤỊḲḶṂṆỌṚṢṬỤṾẈỴẒȦḂĊḊĖḞĠḢİĿṀṄȮ“ṖṘṠṪẆẊẎŻạḅḍẹḥịḳḷṃṇọṛṣṭ§Äẉỵẓȧḃċḋėḟġḣŀṁṅȯṗṙṡṫẇẋẏż¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+,-./0123456789:;<=>“?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^“_`abcdefghijklmnopqrstuvwxyz{|}~¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḤỊḲḶṂṆỌṚṢṬỤṾẈỴẒȦḂ“ĊḊĖḞĠḢİĿṀṄȮṖṘṠṪẆẊẎŻạḅḍẹḥịḳḷṃṇọṛṣṭ§Äẉỵẓȧḃċḋėḟġḣŀṁṅȯṗṙṡṫẇẋẏż¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+,-./01“23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝ“ƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḤỊḲḶṂṆỌṚ“ṢṬỤṾẈỴẒȦḂĊḊĖḞĠḢİĿṀṄȮṖṘṠṪẆẊẎŻạḅḍẹḥịḳḷṃṇọṛṣṭ§Äẉỵẓȧḃċḋėḟġḣŀṁṅȯṗṙṡṫẇẋẏż¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+“,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW“XYZ[\]^_`abcdefghijklmnopqrstuvw“xyz{|}~¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḤỊḲḶṂṆỌṚṢṬỤṾẈỴẒȦḂĊḊĖḞĠḢİĿṀṄȮṖṘṠṪẆẊẎŻạḅḍẹḥịḳḷṃṇọṛṣṭ§Äẉỵẓȧḃċḋėḟ“ġḣŀṁṅȯṗṙṡṫẇẋẏż¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`“abcdefghijklmnopqrstuvwxyz{|}~¶°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḤỊḲḶṂṆỌṚṢṬỤṾẈỴẒȦḂĊḊĖḞĠḢİĿṀṄȮṖ“ṘṠṪẆẊẎŻạḅḍẹḥịḳḷṃṇọṛṣṭ§Äẉỵẓȧḃċḋėḟġḣŀṁṅȯṗṙṡṫẇẋẏż¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+,-./0123456789:“;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[”Ẉ‘’Ọ«“ŀW»

A full program using all 256 bytes in Jelly's code-page.

I am very confident that this can be beaten since it is a naive attempt using a run-length encoding of the ordinals, which stands at 1368 bytes!

For 251 of the bytes the program will run successfully as a monadic Link - see them all here.

For the other five see these full programs:
removing fails,
removing fails,
removing fails,
removing fails, and
removing « produces text, but must be run as a full-program

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

x86 .COM , 256/256 byte,

00000000: bff2 01b8 9190 2905 6681 4506 9594 9392  ......).f.E.....
00000010: b409 575a 83ea 03fe 8d2a ffcd 22c3 ????  ..WZ.....*.."...
000000e0: ???? ???? ???? ???? ???? ???? ???? ??6a  ...............j
000000f0: 616e b1f1 6c65 206f 978b e0dc 6b69 2124  an..le o....ki!$

asm:

    org 100h
    mov di, 0x1F2
    mov ax, 0x9091
    sub [di], ax
    add [di+6], dword 0x92939495
    mov ah, 9
    push di
    pop dx
    sub dx, 3
    dec byte [di-0x1F2+k+1]
k:  int 0x22
    ret
    db 0x1EF-$ dup ?
    db 'j'
    dw 'an'
    dw ' a'+0x9091-0x10000
    dd 'le o'
    dd ', to'-0x92939495
    dd 'ki!$'

Fill the db 0x1EF-$ dup ? with all left bytes

Maybe it's possible to make one with MZ head

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.