Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Comments on Source with the whole alphabet in order of appearance [FINALIZED]

Post

Source with the whole alphabet in order of appearance [FINALIZED]

+3
−0

The challenge is to write as short a source as possible, where the English alphabet (in alphabetical order from top to bottom) "abcdefghijklmnopqrstuvwxyz" is a subsequence of the source code.

The first mentioning of the next expected letter is the only one that counts. If a letter appears earlier on than expected, then it does not count.

That is: if the letter a is the next expected letter, then in the source b;abs;c; the a counts and everything before it is ignored. The next expected letter in the alphabet is b, which is found immediately as the next letter in abs. That a b existed earlier on in the source has no relevance. Similarly, the s at the end of abs fills no purpose as the next expected letter is now c. And so on, until the whole alphabet has been found in the source.

  • Identifiers, variable/function names, string literals, integer/floating point constants (like 0xABCDEF) or anything else that can be named by the programmer do not count towards iterating through the alphabet.
  • Only keywords, function names or identifiers provided by the language's standard/default libraries count.
  • A solution may use non-standard libraries in which case it becomes a separate "language x + library y" solution.
  • Comments are not allowed anywhere in the source.
  • The program need not do anything meaningful but must compile cleanly (no language syntax or constraint violations etc) and execute without any crashes or exceptions thrown.
  • Function-only answers are accepted and encouraged.
  • Any library includes at the top of the program are free and do not count towards the total (if using tio.run, put such in the header section).
  • The challenge is case-insensitive, accepting both upper and lower case letters.
  • This is code golf, the shortest source that fulfil the requirements wins.

Non-golfed example of a correct solution in standard C:

C (gcc), 217 bytes

void func (void)
{
  fabs;cos;
  #define x long
  acosh;
  printf("hello world");
  jmp_buf j;
  isblank;
  long _Atomic l;
  alignof(int);
  puts;
  qsort;qsort;
  NULL;
  (void)pow;
  fmax;
  INFINITY;
  sizeof j;
}

Try it online!


To go through this source, func is an identifier and does not contribute to the solution (but to the total amount of characters for code golf like usual). Neither does x, "hello world" etc. We find the alphabet as follows (bold text):

void func (void) { fabs;cos; #define x long acosh; printf("hello world"); jmp_buf j; isblank; long _Atomic l; alignof(int); puts; qsort;qsort; NULL; (void)pow; fmax; INFINITY; sizeof j; }

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

4 comment threads

I think you also want to exclude comments, otherwise the simplestsolution is to have a single comment... (2 comments)
How many languages is this possible in? (4 comments)
Wording (3 comments)
Letters in numeric etc. constants? (3 comments)
How many languages is this possible in?
trichoplax‭ wrote 3 months ago

I don't know if there are languages for which not every letter is included in a language keyword, function name, constant, or identifier. If there are, then it sounds like these languages would be unable to compete. I have 2 thoughts on this:

  1. Not every challenge has to be open to every language. I like the idea of including as many languages as possible, but it's not necessary to include all.
  2. I wonder if more languages could be included by having a score that is affected by the number of letters of the alphabet you succeed in including. This could allow a language to compete that has no way of including "z". However, this also loses the simplicity of code golf scoring.

I don't have a preference on what approach to take. This is just some thoughts to perhaps lead to more discussion.

As you have proved that the challenge is possible for at least 1 language already, I think it's already a complete challenge.

Lundin‭ wrote 3 months ago

trichoplax‭ I honestly have no idea but probably all of the mainstream ones. Perhaps less so esoteric languages? The challenge accepts answers which is "language x + library y" even if "y" isn't officially part of the language/standard but some common extension. Like for example one could post an answer which is "C language + windows.h library" and then that answer only competes against other similar answers.

trichoplax‭ wrote 3 months ago

Good point about combining with a library. That seems to make this inclusive of more languages.

celtschk‭ wrote about 1 month ago

Many esoteric languages are obviously excluded. The most obvious example is Peat, which doesn't even characters in the first place, or Whitespace, where all programs consist of, well, whitespace. But also languages with single-letter commands are usually excluded because they typically don't cover the full alphabet.