23
\$\begingroup\$

Write a program to print or return one of these strings verbatim:

abcdefghijkmnopqrstuvwxyz

ABCDEFGHIJKMNOPQRSTUVWXYZ

Notice that there is no L.

\$\endgroup\$
5
  • 18
    \$\begingroup\$ Probably worth saying "Note that there's Noel in there!" to avoid any confusion. \$\endgroup\$ Nov 23, 2023 at 21:31
  • 1
    \$\begingroup\$ Does it have to be printed or can it be returned from a function? \$\endgroup\$
    – Yousername
    Nov 23, 2023 at 21:51
  • 2
    \$\begingroup\$ @Yousername returning it is fine. \$\endgroup\$
    – Someone
    Nov 23, 2023 at 21:51
  • 4
    \$\begingroup\$ Could be useful, or not: 65-75, 77-90 on oeis \$\endgroup\$
    – Stef
    Nov 24, 2023 at 14:08
  • 4
    \$\begingroup\$ Or, in song form by Alex Horne and the Horne Section. \$\endgroup\$
    – TRiG
    Nov 24, 2023 at 17:55

45 Answers 45

12
\$\begingroup\$

brainfuck, 49 bytes

+++++++++++++[->+>+++++>+<<<]>--[->.+<]>>+[-<+.>]

Try it online!

Starting with a cell containing 13 we set up 3 cells containing 13,65,13. The 65 is the ASCII code of the letter to be printed and the other cells are down-counters (which are adjusted to 11 and 14 before use.) A nice feature is that the loop for printing the first 11 letters increments the ASCII code after printing and the loop printing the last 14 letters increments the ASCII code before printing, thereby skipping L naturally.

\$\endgroup\$
10
\$\begingroup\$

Octave / MATLAB, 21 18 bytes

Anonymous function that takes no inputs and outputs the string with uppercase letters.

@()['A':'K' 77:90]

Try it online!

How it works

The code concatenates the two ranges of letters: before and after the 'L'. The second range is defined numerically to save two bytes. This can be done because concatenating chars and numbers implicitly converts each number to the char with the corresponding codepoint.

\$\endgroup\$
9
\$\begingroup\$

Charcoal, 3 bytes

⁻βl

Try it online! Link is to verbose version of code. Explanation: β is a Charcoal variable predefined to the lowercase alphabet.

⁻αL

Try it online! Link is to verbose version of code. Explanation: α is a Charcoal variable predefined to the uppercase alphabet.

\$\endgroup\$
8
\$\begingroup\$

R, 22 bytes

!Map(cat,letters[-12])

Try it online!

Exits with an error; credit to ovs.

R, 23 bytes

x=Map(cat,letters[-12])

Try it online!

Also credit to ovs.

R, 24 bytes

cat(letters[-12],sep="")

Try it online!

\$\endgroup\$
2
  • 4
    \$\begingroup\$ x=Map(cat,letters[-12]) saves one I think. Could also think about exiting with error with !Map... \$\endgroup\$
    – ovs
    Nov 23, 2023 at 23:21
  • \$\begingroup\$ @ovs thanks, both great improvements! \$\endgroup\$
    – Giuseppe
    Nov 25, 2023 at 20:14
7
\$\begingroup\$

Bash, 23 bytes, original answer

printf %s {a..k} {m..z}

Try it online!

Bash, 21 bytes, thanks to Nahuel Fouilleul

echo {a..z}|tr -d \ l

Try it online!

\$\endgroup\$
2
  • 3
    \$\begingroup\$ -2bytes Try it online! \$\endgroup\$ Nov 24, 2023 at 9:10
  • \$\begingroup\$ @NahuelFouilleul Nice one, added as separate entry. \$\endgroup\$
    – Jonah
    Nov 24, 2023 at 17:46
6
\$\begingroup\$

Various Languages, 25 bytes

abcdefghijkmnopqrstuvwxyz

or

ABCDEFGHIJKMNOPQRSTUVWXYZ

In many languages, the shortest solution is also the least interesting.

Works in: ///, ARBLE, PHP, ReRegex, ...

\$\endgroup\$
6
\$\begingroup\$

Vyxal 3,, 4 bytes

n'l-

Try it Online!

First Vyxal answer, so I’m sure there may be a more concise way, but I like that it almost reads ‘no el’!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ What’s nice with this one is that it almost reads as "noel"! \$\endgroup\$ Nov 24, 2023 at 7:08
6
\$\begingroup\$

PowerShell Core, 25 bytes

-join$('a'..'k';'m'..'z')

Try it online!

I think solving that with 25 bytes has a certain je ne sais quoi.
Only works in PowerShell Core, Windows PowerShell can't enumerate characters.

PowerShell, all flavors, 27 bytes

'abcdefghijkmnopqrstuvwxyz'

Try it online!

The boring/trivial solution with 27, which would end up as National Fruitcake Day. Somewhat related to CodeGolf, as golfed code and fruitcake have a similar density.

PowerShell, all flavors, 31 bytes

-join([char[]]$(65..75;77..90))

Try it online!

So here's New Year's Eve.
Which is what we also get from the trivial solution in Batch:

Windows Batch, 31 bytes

@echo abcdefghijkmnopqrstuvwxyz
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can even go down to 21 bytes :) And 26 for the all flavours version: Try it online! \$\endgroup\$
    – Julian
    Nov 24, 2023 at 0:22
6
\$\begingroup\$

Retina, 14 bytes


26*#
Y`#`l
l

Try it online! Outputs in lowercase but if the program is uppercased then it will output in uppercase instead. Explanation:


26*#

Insert 26 #s. (I can't use the default _ because that's a special transliteration character.)

Y`#`l

Translate each # in turn into the next character of the alphabet. (It's possible to skip the l here but it's longer overall.)

l

Remove the l.

The best I could do in Retina 0.8.2 without resorting to 26-byte hard-coding was 27 bytes, but with some inspiration from @FryAmTheEggman I got it down to 16 15 bytes:

T`l`_l
}`$
z
l

Try it online! Outputs in lowercase but if the program is uppercased then it will output in uppercase instead. Explanation:

T`l`_l

Move all of the letters so far one step backwards in the alphabet, but delete any a.

$
z

Append a z to the current string.

}`

Repeat the above until the transformation becomes idempotent. This happens when the string is the entire alphabet; the a is deleted, the b-z get transliterated into a-y, and another z is appended.

l

Remove the l.

\$\endgroup\$
4
  • \$\begingroup\$ I was fiddling in Retina 1 but didn't think of manually inserting the correct number of things. Luckily, my idea didn't use any new features. \$\endgroup\$ Nov 24, 2023 at 3:27
  • \$\begingroup\$ @FryAmTheEggman That's a great idea... but I still golfed some more bytes off! \$\endgroup\$
    – Neil
    Nov 24, 2023 at 8:48
  • \$\begingroup\$ ... and also a lot of bytes off of two of my other Retina 0.8.2 answers... \$\endgroup\$
    – Neil
    Nov 24, 2023 at 10:07
  • \$\begingroup\$ Nice! Using the transliterate to also remove the byte and close the loop makes it a very clean looking solution. \$\endgroup\$ Nov 24, 2023 at 16:03
6
\$\begingroup\$

x86-64 machine code, 17 15 bytes

B0 E6 04 5B AA 2C 4B 3C 01 14 F1 75 F5 AA C3

Try it online!

Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes in RDI a memory address at which to place the result, as a null-terminated byte string.

In assembly:

f:  mov al, -26     # Set AL to -26.
r:  add al, 'Z'+1   # Add this value to AL to produce a letter.
    stosb           # Write AL to the output string, advancing the pointer.
    sub al, 'K'     # Subtract 'K' from AL.
    cmp al, 1       # Set flags from calculating AL - 1. CF is 1 iff AL is 0.
    adc al, 'K'-'Z' # Add (this value + CF) to AL. The net change is +1 or +2.
    jnz r           # If the result is nonzero, repeat the loop.
    stosb           # Write AL (0) to the output string, advancing the pointer.
    ret             # Return.
\$\endgroup\$
6
\$\begingroup\$

CP-1610 machine code, 14 DECLEs1 = 17.5 bytes

1. CP-1610 instructions are encoded with 10-bit values (0x000 to 0x3FF), known as DECLEs. Although the Intellivision is also able to work on 16-bit data, programs were really stored in 10-bit ROM back then.

A routine that writes the Christmas alphabet at R4.

The method used here would be more relevant if there were several letters to skip. With just one letter, using SLLC / ADCR only saves a few CPU cycles compared to CMPI / BEQ.

                            ROMW  10          ; use 10-bit ROM
                            ORG   $4800       ; map our code at $4800
                      
4800  02BC 0200             MVII  #$200,  R4  ; R4 = BACKTAB pointer
4802  0004 0148 000D        CALL  alpha       ; invoke our routine
                      
4805  02BD 0030             MVII  #$30,   R5  ; R5 = pointer into STIC registers
4807  01C0                  CLRR  R0
4808  0268                  MVO@  R0,     R5  ; no horizontal delay
4809  0268                  MVO@  R0,     R5  ; no vertical delay
480A  0268                  MVO@  R0,     R5  ; no border extension
480B  0002                  EIS               ; enable interrupts
                      
480C  0017                  DECR  R7          ; loop forever
                      
                            ;; our routine
                      alpha PROC
                      
480D  02B8 010F             MVII  #$010F, R0  ; R0 = letter code, initialized to 'A'
480F  02B9 0010             MVII  #$0010, R1  ; R1 = mask used to skip 'L'
                      
4811  0059            @loop SLLC  R1          ; left-shift the mask into the carry
4812  002F                  ADCR  R7          ; add the carry to the program counter
                                              ; (i.e. skip MVO@ if the carry is set)
4813  0260                  MVO@  R0,     R4  ; write the letter
4814  02F8 0008             ADDI  #8,     R0  ; update R0 to the next letter
4816  0378 01D7             CMPI  #$01D7, R0  ; compare with 'Z'
4818  0226 0008             BLE   @loop       ; loop if less than or equal
                      
481A  00AF                  MOVR  R5,     R7  ; return
                      
                            ENDP

Output

screenshot

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Congratulations on your 200th k-c post and therefore gold k-c tag badge! (I'm guessing that this one was your 200th, given your badge award date...) \$\endgroup\$
    – Neil
    Dec 22, 2023 at 16:59
  • \$\begingroup\$ @Neil It probably was this one indeed. Thank you! And congrats on your 402nd k-c post. ;-) \$\endgroup\$
    – Arnauld
    Dec 22, 2023 at 17:05
  • \$\begingroup\$ Shame I don't qualify for a second gold k-c tag badge ;-) \$\endgroup\$
    – Neil
    Dec 22, 2023 at 19:17
6
\$\begingroup\$

Python, 39 bytes

print(25*"%c"%(*{*range(65,91)}-{76},))

Attempt This Online!

Only 5 bytes longer than hardcoding the entire thing ...

How?

Unlike dictionaries, sets are in general not guaranteed to preserve insertion order, so why does this work?

C-Python implementation detail: (small) integers are their own hash values.

\$\endgroup\$
5
\$\begingroup\$

RProgN 2, 4 bytes

a`l-

Try it online!

Or for upper-case

A`L-

Try it online!

Just removes literal L from the alphabet builtin.

\$\endgroup\$
5
\$\begingroup\$

V (vim), 14 bytes

:h<_
jjYZZPtmx

Try it online!

Yet another post uses the trick found by Lynn.

\$\endgroup\$
5
\$\begingroup\$

Python 3, 71 bytes

import string as s
print(s.ascii_lowercase[:11]+s.ascii_lowercase[12:])

Try it online!

\$\endgroup\$
7
  • 2
    \$\begingroup\$ 60: from string import ascii_lowercase as s;print(s[:11]+s[12:]); 58: from string import*;s=ascii_lowercase;print(s[:11]+s[12:]) \$\endgroup\$
    – tsh
    Nov 24, 2023 at 6:55
  • 2
    \$\begingroup\$ The boring loop is 54 bytes, the most boring solution only 34 bytes \$\endgroup\$
    – Philippos
    Nov 24, 2023 at 10:39
  • 1
    \$\begingroup\$ 56: from string import*;a=printable;print(a[10:21]+a[22:36]) \$\endgroup\$
    – Stef
    Nov 24, 2023 at 13:17
  • \$\begingroup\$ Trying to be smart, but sadly 75 bytes: from math import*;print(''.join(chr(n+isqrt(3*n//2))for n in range(56,81))) \$\endgroup\$
    – Stef
    Nov 24, 2023 at 14:06
  • \$\begingroup\$ @Stef followed your way, and in fact got to 65;see my answer \$\endgroup\$ Nov 28, 2023 at 14:20
5
\$\begingroup\$

Perl 5, 13 bytes

say A..K,M..Z

Try it online!

\$\endgroup\$
5
\$\begingroup\$

Python 3, 51 50 bytes

print(''.join(chr(i+65)for i in range(26)if i-11))

Try it online!

Simple iteration combining range and chr.

-1 byte thank to @UndoneStudios's amazing hint of using str.join


Python 3, 54 bytes

a=*range(65,91),
print(*map(chr,a[:11]+a[12:]),sep='')

Try it online!

Using tuple destructuring.

\$\endgroup\$
2
  • \$\begingroup\$ -1 byte? print(''.join(chr(i+65)for i in range(26)if i-11)) \$\endgroup\$ Nov 28, 2023 at 14:14
  • \$\begingroup\$ @UndoneStudios How could I have not thought of that? Thank you so much! \$\endgroup\$
    – enzo
    Nov 28, 2023 at 14:20
4
\$\begingroup\$

Ruby, 19 bytes

([*?a..?z]-[?l])*''

Attempt This Online!

Since the task allows simply returning the string instead of printing, I believe it should be acceptable as this snippet. If not, it's +4 for $><< in front.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ I think it would be acceptable to make this a function that returns a list of characters, so this works for 18 bytes: ->{[*?a..?z]-[?l]} \$\endgroup\$
    – noodle man
    Nov 24, 2023 at 2:39
4
\$\begingroup\$

XPath 2: 42 41 27 bytes

First attempt: 42 bytes

codepoints-to-string(remove(97 to 122,12))

Explanation:

  • 97 to 122 returns the sequence 97, 98, 99, ... 122
  • remove( ..., 12) removes the 12th item
  • codepoints-to-string() converts the numbers to a string

The result of the evaluation is the christmas string. Try it online.


Second attempt 41 bytes, thanks to @Philippos

codepoints-to-string(remove(65 to 90,12))

(upper case letters)


Third attempt (27 bytes), the "trivial" (but so far the shortest) solution (@jonathan-allan)

"abcdefghijkmnopqrstuvwxyz"

is a equally valid XPath expression.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Very nice, thank you for your contribution! You could even save one byte printing the uppercase christmas alphabet: codepoints-to-string(remove(65 to 90,12)) \$\endgroup\$
    – Philippos
    Nov 24, 2023 at 18:19
  • \$\begingroup\$ Thank you for both parts of your comment! \$\endgroup\$
    – topskip
    Nov 24, 2023 at 19:46
  • \$\begingroup\$ "abcdefghijkmnopqrstuvwxyz" saves bytes if that is truly a full-program or function (I do not know XPath, but it works in the linked interpreter(?)). \$\endgroup\$ Nov 24, 2023 at 19:54
  • 1
    \$\begingroup\$ This is a perfectly valid XPath expression, so this is the shortest. \$\endgroup\$
    – topskip
    Nov 24, 2023 at 20:02
4
\$\begingroup\$

Haskell, 23 bytes

filter(/='L')['A'..'Z']

Explanation

['A'..'Z'] represents the entire uppercase alphabet, (/='L') is a shorthand for the lambda \x -> x /= 'L'. When both are passed to filter, this keeps all letters from the alphabet that are not L.

Alternatively, this can also be done with an extra byte using list comprehensions:

[x|x<-['A'..'Z'],x/='L']
\$\endgroup\$
2
  • \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$ Nov 25, 2023 at 17:29
  • \$\begingroup\$ Nice answer! I'm a bit sad that ['A'..'K']++['M'..'Z'] is shorter by a byte :) \$\endgroup\$
    – Lynn
    Nov 27, 2023 at 16:20
4
\$\begingroup\$

Python 3, 50 49 bytes

print(''.join(chr(x+x//76)for x in range(65,90)))

You could save two bytes by using Python 2, but nobody uses that anymore:

Python 2, 47 bytes

print ''.join(chr(x+x/76)for x in range(65,90))
\$\endgroup\$
3
  • 1
    \$\begingroup\$ You don't need the space before for. \$\endgroup\$
    – Neil
    Nov 25, 2023 at 19:34
  • \$\begingroup\$ @Neil thanks for the hint! \$\endgroup\$ Nov 25, 2023 at 21:20
  • 1
    \$\begingroup\$ You can save another byte from the Python 2 version: the space after print isn't needed. \$\endgroup\$
    – DLosc
    Nov 27, 2023 at 16:24
4
\$\begingroup\$

morsecco: 112 bytes

Yes, that's 4.5 times the size of the pure input, but don't forget that we have only three symbols, resulting in a factor ~5, compared to the full character set.

The whole christmas alphabet in morse code already takes 102 characters; with the overhead of conversion and printing it would be 124 bytes, so this loop solution is shorter (not counting the christmas tree formatting, which starts beautifully with Entering 65, but doesn't really work out well, because whitespaces are sometimes meaningful in Morsecco):

   .
-.....-
 -- -
  - -
 -.- -
  . -   
  .--     
. .-..-.--
   .-    
--.. --.-
 . .----   
.- --.. --.
 . -.--.-- 
.- --. --.-   
. -..--.- --.
  • The first line initializes the stack with 65 (A)
  • Line 2 sets a jump Mark to start a loop, Konvert the number to Text and Write it to stdout.
  • Now comes the golfing trick: line 3 Adds –75 (K) and skips after --.- is zero (so the last line handles the L skipping by Entering 77)
  • The 4th line subtracts another 15 to test for the Z and skips after the --. that closes the loop for the other characters
  • The 5th line Adds 91 (–75 + –15 + 91 = 1, so the value is incremented) and Goes to the mark that was set. This saves three bytes compared to saving a copy of the value, dropping the modified version and adding 1 to the copy.

Cheating version: 47 bytes

Yes, morsecco ignores all characters except for dot, dash and space, but to cheat, you can Read the source code from the empty address, Cut it after the Z and Output. Yes, such tricks are probably legal when golfing, but boring:

ABCDEFGHIJKMNOPQRSTUVWXYZ.   .-. -.-. --..- ---
\$\endgroup\$
3
\$\begingroup\$

Uiua, 11 bytes

▽≠@l.+@a⇡26

Try it!

▽≠@l.+@a⇡26
        ⇡26  # range from 0 to 25
     +@a     # add letter a
    .        # duplicate
 ≠@l         # where is it not equal to l?
▽            # keep
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Same length alternative: +@a+>10.⇡25 \$\endgroup\$
    – Bubbler
    Nov 24, 2023 at 1:10
3
\$\begingroup\$

APL (dzaima/APL), 6 bytes

⎕A~'L'

Try it online!

\$\endgroup\$
3
\$\begingroup\$

sclin, 9 bytes

$abc"l"--

Try it on scline!

Very straightforward.

\$\endgroup\$
3
\$\begingroup\$

Google Sheets, 45 bytes

=sort(replace(join(,char(row(65:90))),12,1,))

...or 47 bytes:

=join(,filter(char(row(65:90)),row(65:90)<>76))

These formulas are longer than their output.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Wouldn't it be shorter just to write it literally as abcdefghijkmnopqrstuvwxyz..? \$\endgroup\$
    – ATaco
    Nov 23, 2023 at 21:46
  • 2
    \$\begingroup\$ Yes. Kinda defeats the purpose though. Spreadsheet formula languages are not optimal in many code-golf questions. The patterns therein may however be of use in other contexts. \$\endgroup\$ Nov 23, 2023 at 21:49
3
\$\begingroup\$

Scala, 48 30 bytes

Saved 18 bytes thanks to @corvus_192


Golfed version. Try it online!

'A'to'Z'patch(11,"",1)mkString
\$\endgroup\$
2
  • \$\begingroup\$ println("abcdefghijkmnopqrstuvwxyz") saves 12 bytes though. \$\endgroup\$ Nov 24, 2023 at 19:50
  • \$\begingroup\$ 30 bytes: 'A'to'Z'patch(11,"",1)mkString (requires -language:postfixOps) \$\endgroup\$
    – corvus_192
    Nov 27, 2023 at 11:23
2
\$\begingroup\$

Acc!!, 41 bytes

Count i while 25-i {
Write (65+i)*77/76
}

Try it online!

Explanation

Loop i from 0 to 24. Add 65 to convert to uppercase codepoints A through Y; then scale by a linear factor to skip over code point 76 (L). (Division in Acc!! is integer division, but the floating-point version would be \$ 65.86, 66.87, \cdots, 74.97, 75.99, 77.00, 78.01, \cdots, 90.17 \$)

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

jq, 27 characters

[range(65;91)]-[76]|implode

Sample run:

bash-5.2$ jq -nr '[range(65;91)]-[76]|implode'
ABCDEFGHIJKMNOPQRSTUVWXYZ

Try it online!

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

Japt, 4 bytes

;BkÊ

Test it here

\$\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.