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 »
Challenges

Source with the whole alphabet in order of appearance

+4
−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 sub-sequence 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, you may 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.
Why should this post be closed?

1 comment thread

Warnings (2 comments)

5 answers

+1
−0

TI-BASIC, 23 bytes

Like lyxal's answer, this program exits immediately, so nothing after the Stop is executed.

The program

Stop
GarbageCollectDetectAsymOffDispGraphiconj(BLACKClrfHomenormalpdf(SeqaClrAllListsFullvwAxesgetKeyZStandard

For those who are wondering, the reason this program is less than 26 bytes is that in TI-BASIC, while the user is shown long words for builtins like DispGraph, what's actually being stored in the program memory is a smaller number of bytes. So, while BLACK is five characters long, behind the scenes it's a number that's two bytes in memory.

As a result, builtin functions and variables and such are treated as single characters when editing. So pressing the del key once would delete the entire word BLACK.

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

1 comment thread

Alphabet in less than 26 bytes (2 comments)
+2
−0

Japt, 26 bytes

aBcDeFgHiJkLmNoPqRsTuVwXyZ

Try it

Trivial Solution, 26 bytes

ABCDEFGHIJKLMNOPQRSTUVWXYZ

Try it

Explanations

In the first solution each lowercase letter is a method that gets applied to its preceding uppercase letter, which is a predefined variable (except a which gets implicitly applied to the first input variable), and takes everything that follows as an argument. As the k method does not expect any arguments, everything that follows the k is essentially ignored.

aBcDeFgHiJkLmNoPqRsTuVwXyZ
a                              :Absolute difference between the first input (default 0) and
 B                             : 11
  c                            : Rounded up to the nearest multiple of
   D                           :  13
    e                          :  Multiplied by 10 raised to the power of
     F                         :   15
      g                        :   Sign of difference with
       H                       :    32
        i                      :    Evalauate the following every H milliseconds and return an intervalID
         J                     :     -1
          k                    :     Prime factors
           L                   :      100
            m                  :      Minimum with
             N                 :       Array of all inputs (empty)
              o                :       Modify last element
               P               :        Empty string
                q              :        Split on
                 R             :         Newline
                  s            :         Sliced from (0-based index)
                   T           :          0
                    u          :          Modulo
                     V         :           Second input variable (default 0)
                      w        :           Maximum with
                       X       :            Fourth input variable (default 0)
                        y      :            GCD with
                         Z     :             Sixth input variable (default 0)
                               :Implicit output of result (-1)

The second solution is just all of Japt's built-in variable names, each of which has a default value, with the value of the last one being output. To explain the 13 that aren't included above:

A  :10
C  :12
E  :14
G  :16
I  :64
K  :Date object
M  :Math object
O  :What I call the "Other" object, which includes miscellaneous methods such as string compression, explicit output and console.log
Q  :Quotation mark
S  :Space
U  :First input variable (default 0)
W  :Third input variable (default 0)
Y  :Fifth input variable (default 0)
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+4
−0

Python, 88 bytes

import abc,code,fcntl,graphlib,json,pickle,cmd,errno,heapq,re,struct,csv,pwd,xml,sys,bz2

Attempt This Online!

Requires a Unix-like operating system for fcntl and pwd, and at least version 3.9 for graphlib.

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

0 comment threads

+3
−0

Bash + a ton of non-standard packages that were already installed on my machine, non-competing 83 bytes

tabs #bash: set tabs on a terminal
cd #bash: change directory
efibootmgr #linux: modify the EFI boot manager
ghh #git: alias of git help
dijkstra #graphviz: reads a stream of graphs and for each computes the distance of every node from sourcenode.
lmdown #flexLM : shut down the FlexLM licence manager daemon
open #linux : open program on a new virtual terminal
qrencode #qrencode: encode stdin as QR code
gstu #git: alias of git stash push --include-untracked
vmware-user #vmware: daemon that allows drag-and-drop and clipboard sync to the VM guest running this
gssproxy #libvirt: daemon to manage access to GSSAPI credentials.
zcat #gzip : cat but for gzipped input

So obviously this is very silly, hence non-competing, especially when you consider the stuff that's available on this machine (nobody except me has flexLM installed). To make it somewhat fair, I have not installed a single package to answer this, I simply looked at my available commands.

Technically, almost all of these will complain about missing arguments. this does not prevent bash from correctly executing each program and letting it print whatever it wants to stdout/stderr :)

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

0 comment threads

+6
−0

Vyxal, 27 bytes

QabcdefghijKlmnopqrstUvwxyz

Try it Online!

Works by exiting straight away. The joys of a language where every letter is a built-in function.

Explained

QabcdefghijKlmnopqrstUvwxyz
Q                            # Terminate the program
 a                           # Are any of the items in the (non-existent) input truthy?
  b                          # Convert that to binary
   c                         # Is that in the input?
    d                        # Double the result of that
     e                       # input ** that
      f                      # Flatten into a list of digits
       g                     # Get the smallest digit
        h                    # Push digit[0]
         i                   # and get the inputh digit of that
          j                  # Join the input on the result. This will give a string.
           K                 # All non-empty substrings of the stringthat occur more than once in the string
            l                # Get the pairwise overlaps of that list
             m               # And mirror it
              n              # Push the string "abcdefghijklmnopqrstuvwxyz"
               o             # And remove that from the mirrored list
                p            # Prepend that to the input
                 q           # Surround in backticks, escaping backslashes and existing backticks
                  r          # Does the input contain a regex match of that?
                   s         # Sort that
                    t        # Push that[-1]
                     U       # Uniquify the result
                      vw     # Wrap each item
                        x    # Call this program all over again
                         yz  # Incidentally, this is never executed, but then again, neither is the entire program after the first Q. :p        
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »