Input: a string, consisting of only printable ASCII characters
Output: a truthy/falsey value whether its characters are in alphabetical order (based on their UTF-8 unicode values), from any starting point inside the string including wrap-around by going left-to-right

For example: xyzabc would give a truthy result, because we could travel a→b→c→x→y→z, but xzy would give a falsey result, because all possible starting points (x→y→z; y→z→x; z→x→y) are not in the correct order.

This sounds pretty simple, right? But there is one catch, as this is a challenge: your program/function has to be in the correct order as well.

†: Based on the order of the characters in your own codepage. i.e. a program written in Jelly need to be (with the wraparound of course) in the order of its own codepage, instead of UTF-8 order.

Challenge rules:

  • The input can be in any reasonable format. Can be a string, read from STDIN, a list of characters, etc. (No, you are not allowed to take a list of unicode values - which would basically be an integer list - unless your language does this conversion by default (i.e. Java (char only), Whitespace, etc.)
  • The input is guaranteed to be printable ASCII (range \$[32,126]\$ / [' ','~']).
  • If your program/function is written in a different codepage, it does not necessary have to hold a truthy value when used as input for itself. The source code does need to be in the correct order based on the used codepage of course.
  • The input is guaranteed to be non-empty. (An input of one or two characters will always result in a truthy output.)
  • The input (and your source) can contain multiple of the same characters.
  • This is , for which the longest answer counting only distinct bytes wins (i.e. if your source code is ABBCabbc1223 your score would be 9 for 123ABCabc).

General rules:

  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
  • Default Loopholes are forbidden.
  • If possible, please add a link with a test for your code (i.e. TIO).
  • Also, adding an explanation for your answer is highly recommended.

Test cases:


msuwy !#),-./0123:;<?@BCFGILMNOQTWX]^_bf


  • \$\begingroup\$ related \$\endgroup\$ Jan 20, 2020 at 12:25
  • 8
    \$\begingroup\$ IMHO I find it a bit too bad that a single rule disallows per se most programming languages and allows only cryptic-characters-languages-created-only-for-golfing, it could be more open by for example counting the longest ordered sequence in the code. (But that would mean not counting commented characters to prevent having the whole alphabet as a comment, even if that would damage a bit current aswer) \$\endgroup\$
    – Kaddath
    Jan 21, 2020 at 13:57
  • 1
    \$\begingroup\$ @Kaddath I can understand your standpoint and kinda agree, but I don't think banning comments would help, since we don't have a clear definition of what a comment is. The current 05AB1E for example doesn't use any comments (in fact, the language doesn't even have comments), although there are still loads of no-ops which cancel each other out so only the code functionality remains. And not allowing no-ops kinda defeats the [code-bowling] part tbh. \$\endgroup\$ Jan 22, 2020 at 7:42
  • \$\begingroup\$ I'm willing to change the challenge to allow more answers (if Grimmy agrees), but it should require a clear definition of what is and isn't allowed. Currently I'm thinking of only allowing the 256 default characters of the used code-page perhaps (extended ASCII for most languages), so 256 would be the maximum score, and you can't for example score 137,929 by using all existing characters in for example a Lenguage/Unary answer. And comments are then still allowed. But not sure if that's a good solution. \$\endgroup\$ Jan 22, 2020 at 7:46
  • 1
    \$\begingroup\$ (if Grimmy agrees) I do. (Note that 256 is already the maximum score, since score is the number of distinct bytes). \$\endgroup\$
    – Grimmy
    Jan 22, 2020 at 14:38

1 Answer 1


05AB1E, 10 ... 172 distinct bytes


Try it online! or validate all test cases (note: the "all test cases" version omits ] and ë, since those don't play well with the header and footer required to run the code repeatedly).

Uses the 05AB1E code page. Validate restricted-source and scoring.

The useful code is just:

Ć            # append the first character of the input to the input
 Ç           # convert to a list of codepoints
  ü-         # pairwise subtraction
    1@       # >= 1?
      D      # duplicate
       O     # sum
        Q    # equal?
         Z   # maximum

The rest amounts to NOOPs.

  • 1
    \$\begingroup\$ Nice answer. I wasn't expecting that the entire alphabet (except for q) could be used as a no-op like that. :) And I've verified that it's indeed correct for 05AB1E's codepage, but you may want to explicitly mention it uses the custom 05AB1E codepage for challenges like this. Btw, you can add a few more no-ops between the Q and Z, like R and S for example, as well as UX or VY. :) \$\endgroup\$ Jan 20, 2020 at 13:33
  • \$\begingroup\$ Actually q can be used as well, since it's within a non-executed i} anyway. And yeah, I'm not done bowling, there's still a ton of bytes to add. \$\endgroup\$
    – Grimmy
    Jan 20, 2020 at 13:39
  • 1
    \$\begingroup\$ @KevinCruijssen I'm done with the low-hanging fruits. Of the 96 missing bytes, 46 are the bytes between ü and -, which can't be separated except by whitespace. \$\endgroup\$
    – Grimmy
    Jan 20, 2020 at 16:21

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.