Longest pristine(ish) codepoint run

2

2

Your challenge is to create the longest run of characters with incrementing Unicode codepoints in a pristine program as you can. To keep things simple, I'll abridge the definition for this challenge to be "any program which produces no errors but will error if any one character is removed".

Let's define a codepoint run as any contiguous substring of N characters, where 1 <= N <= program length, where the Unicode/UTF-8 codepoints increment by 1 for each character.

For example: abc, <=>, {|, and ƐƑƒƓƔ are all codepoint runs.

Your program (must be a standalone program) doesn't have to be purely a codepoint run. Instead, its score will be the length in characters of the longest codepoint run in its source code. A program dabc's score would be 3.

Note that your program does not need to actually output anything, as long as it does not error.

  • Compiler warnings do not count as errors
  • Your program does not need to (but still can) error if more than 1 contiguous character is removed
  • Your program may take input only if the contents of the input do not affect whether or not the program errors
  • Any code which is not part of the longest codepoint run is ignored in the scoring
  • Highest score, as in code golf, is per-language

Redwolf Programs

Posted 2019-11-09T21:07:33.690

Reputation: 2 561

Yeah, I realized it was trickier than I first thought and deleted my comment. I suspect for most languages, the goal will be to achieve putting in the longest possible Unicode sequence into a string or comment in a pristine way, with a pristine check that it's the right length or that the code itself has the right length. – xnor – 2019-11-09T21:26:06.073

@xnor It's impossible AFAIK to put a comment in a pristine program, and strings would be hard still – Redwolf Programs – 2019-11-09T21:27:50.153

What does the program have to do? Nothing/not error? A specific task? – caird coinheringaahing – 2019-11-09T23:17:05.830

@cairdcoinheringaahing Anything, as long as it follows the specification – Redwolf Programs – 2019-11-09T23:20:09.843

1To the 4 people who have voted to close, what's the reason? I have nothing to go on here... – Redwolf Programs – 2019-11-12T17:09:29.037

I consider any challenge in which it is possible to get an arbitrarily good score in many different languages to be per se too broad. – pppery – 2019-12-03T01:00:26.483

1@pppery I made a mistake in the specification, but I wouldn't consider it "too broad." The challenge is defined clearly, it's just not that good. You're a little trigger happy with closing posts for unusual reasons I've noticed... – Redwolf Programs – 2019-12-03T02:46:51.560

Answers

5

Python 3, run of 1,114,111

#coding:utf
assert len(open(__file__).read(1061))==1061
"""	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼʽʾʿˀˁ˂˃˄˅ˆˇˈˉˊˋˌˍˎˏːˑ˒˓˔˕˖˗˘˙˚˛˜˝˞˟ˠˡˢˣˤ˥˦˧˨˩˪˫ˬ˭ˮ˯˰˱˲˳˴˵˶˷˸˹˺˻˼˽˾˿̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼͇͈͉͍͎̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́͆͊͋͌̕̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮͯ͘͜͟͢͝͞͠͡ͰͱͲͳʹ͵Ͷͷ͸͹ͺͻͼͽ;Ϳ΀΁΂΃΄΅Ά·ΈΉΊ΋Ό΍ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ΢ΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϏϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧ"""

Try it online!

The triple-quoted contains the entire Unicode range except for the null byte \0 which terminates a program. (Thanks to Chas Brown for suggesting triple-quoting, which allowed 13 more characters.) The TIO link uses a shortened version; assume that the number 1061 is replaced with the code length.

The program opens itself and checks that it has the appropriate length, which guards against any deletion. No one-character deletion can disable this logic in the code. Lowering either the number of characters read or the number checked for equality will make the assertion fail.

I'm not totally sure if all Unicode characters except '\0' are valid in Python code, and I haven't been able to test it. Maybe this is system dependent. Please let me know if this fails at some point.

We can also do this without reading the file:

s="""	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼʽʾʿˀˁ˂˃˄˅ˆˇˈˉˊˋˌˍˎˏːˑ˒˓˔˕˖˗˘˙˚˛˜˝˞˟ˠˡˢˣˤ˥˦˧˨˩˪˫ˬ˭ˮ˯˰˱˲˳˴˵˶˷˸˹˺˻˼˽˾˿̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼͇͈͉͍͎̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́͆͊͋͌̕̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮͯ͘͜͟͢͝͞͠͡ͰͱͲͳʹ͵Ͷͷ͸͹ͺͻͼͽ;Ϳ΀΁΂΃΄΅Ά·ΈΉΊ΋Ό΍ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ΢ΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϏϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧ"""
assert len(s)==999

Try it online!

There isn't a way to delete a character from the assertion line while keeping it syntactically valid and preserving the length number.

xnor

Posted 2019-11-09T21:07:33.690

Reputation: 115 687

Instead of a comment, can you use a triple-quoted string? Then you could include code point 14... – Chas Brown – 2019-11-09T22:09:10.487

Not sure if reading your own source code should be allowed, but I guess it's too late – Redwolf Programs – 2019-11-09T22:11:50.977

@ChasBrown I had tried that, but it complains about an invalid escape sequence with the backslash, and using a raw string doesn't fix it. Edit: Never mind, I messed up escaping in the test, I think your idea works. – xnor – 2019-11-09T22:11:56.143

3... and this is why the creator should have required real pristine code. – pppery – 2019-11-09T22:15:32.337

1@RedwolfPrograms I'm pretty sure one could do the same without source code reading just as s=[the string];assert len(s)==[its length]. – xnor – 2019-11-09T22:21:39.600

I think you don't want the #coding:utf in python3 which defaults to utf-8 encoding (on my Mac, and also at TIO anyway). – Chas Brown – 2019-11-09T22:42:13.373

@ChasBrown You're right, looks like it only gives the "Non-UTF-8 code" error for the source-reading version. – xnor – 2019-11-09T22:46:18.243

1

C# (Visual C# Interactive Compiler), Score: 1114076

var s=@"Insert all characters from character 36 then on";if(s.Length!=1114076)throw new Exception();

Try it online!

Embodiment of Ignorance

Posted 2019-11-09T21:07:33.690

Reputation: 7 014