24
\$\begingroup\$

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

abcdefghijkmnopqrstuvwxyz

ABCDEFGHIJKMNOPQRSTUVWXYZ

Notice that there is no L.

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

49 Answers 49

1
2
2
\$\begingroup\$

Kotlin, 40 35 bytes

{(('a'..'z')-'l').joinToString("")}

Try it online!

Kotlin, 40 35 31 bytes

{(('a'..'z')-'l').map(::print)}

Try it online!

Lambdas () -> String and () -> Unit, respectively, that uses minus applied to a CharRange.

-5 bytes thank to @corvus_192's wonderful reminder that minus can be replaced by -

-4 bytes on () -> Unit by replacing the forEach with a map.

\$\endgroup\$
2
  • \$\begingroup\$ why not {(('a'..'z')-'l').joinToString("")} \$\endgroup\$
    – corvus_192
    Commented Nov 27, 2023 at 11:09
  • \$\begingroup\$ @corvus_192 I've completely forgot that minus can be overloaded as -. Thank you so much! \$\endgroup\$
    – enzo
    Commented Nov 27, 2023 at 11:38
2
\$\begingroup\$

C (GCC), 48 46 42 bytes w/ help from @Neil and @ceilingcat

main(x){for(;x++<27;)x-13&&putchar(x+63);}

Attempt this online

\$\endgroup\$
4
  • \$\begingroup\$ x-27&&(x-12&&putchar(x+64))+main(x+1); seems to work. \$\endgroup\$
    – Neil
    Commented Nov 25, 2023 at 5:56
  • \$\begingroup\$ Or perhaps x-26&&putchar(x+64+(x>11))+main(x+1);? \$\endgroup\$
    – Neil
    Commented Nov 25, 2023 at 5:57
  • \$\begingroup\$ Yep, that makes better sense :P. Added. \$\endgroup\$
    – Qaziquza
    Commented Nov 25, 2023 at 11:02
  • \$\begingroup\$ c;f(){for(c=64;++c<91;)c-76&&putchar(c);} is 41 bytes, but f(){puts("abcdefghijkmnopqrstuvwxyz");} is 39 \$\endgroup\$
    – veqtrus
    Commented Dec 26, 2023 at 15:29
2
\$\begingroup\$

GolfScript, 10 bytes

91,65>'L'-

Try it online!

GolfScript, 11 bytes

'alm{'{,^}/

Try it online!

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

Knight (v2), 27 bytes

;=a 64W>91=a+1a|?76aO+Aa'\'

Try it online!

Well, at least it's shorter than this (28 bytes):

O"ABCDEFGHIJKMNOPQRSTUVWXYZ"
\$\endgroup\$
2
\$\begingroup\$

Python, 65 bytes:

Uses the formula given by Stef in the comments, so I guess this could probably stay up for not being boring...

lambda:''.join(chr(int(i+((1.5*i)**.5)//1))for i in range(56,81))
\$\endgroup\$
2
\$\begingroup\$

YASEPL, 26 bytes

algorithmic way of doing it

=a$97`1}3,108,2›`2+}2,123

YASEPL, 28 bytes

lazy way of doing it

>"abcdefghijkmnopqrstuvwxyz"
\$\endgroup\$
2
\$\begingroup\$

Deadfish~, 27 bytes

iisiiiis{ic}ici{ic}icicicic

Try it online!

My first Deadfish~ answer, I don't know if it could be improved.

How does it work?

ii                             accumulator: 2
  s                            accumulator: 4
   iiii                        accumulator: 8
       s                       accumulator: 64
        {ic}                   accumatator: [65, 75] ('A' -> 'J')
            ic                 accumulator: 76 ('K')
              i                accumulator: 77
               {ic}            accumulator: [78, 88] ('M' -> 'V')
                   icicicic    accumulator: [89, 92] ('X' -> 'Z')
\$\endgroup\$
2
\$\begingroup\$

Pip, 6 5 bytes

-1 byte thanks to @DLosc

zRM'l

Yea I think that's about as short as it can get, unless someone has some genius strategy.

Turns out I'm not genius enough :P

Try It Online!

\$\endgroup\$
2
  • \$\begingroup\$ Not a genius strategy, but... 5 bytes ;P \$\endgroup\$
    – DLosc
    Commented Feb 25 at 6:27
  • \$\begingroup\$ @DLosc I didn't realize that was a thing. Genius :P \$\endgroup\$
    – Aiden Chow
    Commented Feb 27 at 6:55
2
\$\begingroup\$

05AB1E, 5 4 bytes

-1 thanks to noodle man

A'lм

Try it online!

A'lм
A       The lowercase alphabet
 'lм    Minus the 'l'
\$\endgroup\$
1
  • \$\begingroup\$ "l" can be 'l \$\endgroup\$ Commented Feb 27 at 23:34
2
\$\begingroup\$

Nibbles, 17 nibbles (8.5 bytes)

-.,26ch+64$"L"

Attempt This Online!

Explanation

  ,26          # for i in range [1-26]
       +64$    #  add 64 to i
     ch        #  convert i to char
-.         "L" # concat all and remove "L"
               # (implicitly print entire string)

Alternately, -.,26ch+96$"l" works for lowercase and has the same score.

\$\endgroup\$
1
\$\begingroup\$

Commodore BASIC - 28 characters

Enter this in direct mode, the ? denotes a PRINT command:

?"ABCDEFGHIJKMNOPQRSTUVWXYZ

Note that in Commodore BASIC, you do not necessarily require a closing quotation mark when printing a string literal.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Isn't this 27 characters (or bytes)? \$\endgroup\$
    – Aiden Chow
    Commented Nov 28, 2023 at 7:32
  • \$\begingroup\$ One PETSCII character on Commodore 8-bit machines is equal to 1 byte, but Commodore BASIC, like many early Microsoft BASIC variants is tokenised. \$\endgroup\$ Commented Nov 29, 2023 at 8:56
  • \$\begingroup\$ A more precise answer is that it is difficult to make a byte count for my entry here as it is a special kind of program that runs in direct mode, i.e., it is run immediately after you enter this and press the RETURN key. It is not stored in BASIC memory, unlike BASIC programs which are written with line numbers, and may be executed with the RUN command. \$\endgroup\$ Commented Nov 30, 2023 at 9:16
1
\$\begingroup\$

Pyth, 9 bytes

+<G11>G12

Try it online!

Explanation

G - Pyth's pre-initialised variable to the lowercase letters in the alphabet.

< - used to slice the string till 11.

> - used to slice the string from 12, thereby leaving the letter l.

Pyth, 4 bytes | Thanks to @FryAmTheEggman

-G"l

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Nice! You can save quite a bit by using -, which is overloaded in Pyth to work on strings in a manner similar to how it works on sets. \$\endgroup\$ Commented Nov 27, 2023 at 17:04
1
\$\begingroup\$

Python 3, 47 46 bytes

for i in range(65,90):print(end=chr(i+(i>75)))

Try it online!

Yet another boring loop in Python 3 :)

\$\endgroup\$
1
\$\begingroup\$

MathGolf, 4 bytes

▄'l-

Try it online.

Explanation:

▄     # Push the lowercase alphabet
 'l- '# Remove the "l"
      # (after which the entire stack is output implicitly as result)
\$\endgroup\$
1
\$\begingroup\$

JavaScript, 67 bytes

_=>Array.from({length:25},(_,x)=>(x+10+(x>10)).toString(36)).join``

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Lua, 139 bytes

p,c,l=io.write,string.char,{}for i=65,90 do if i~=76 then l[#l+1]=i end end for j=1,#l do p(c(l[j]))end p"\n"for k=1,#l do p(c(l[k]+32))end

Try it online!

Explanation

Lua allows us to reference functions, similar to pointers in C and C++. This means we can rename the io.write and string.char functions to p and c. On the same line, we also create an empty table.

p, c, l = io.write, string.char, {}

Next we need to populate our l table with the ASCII codes of A through Z, making sure to skip ASCII code 76 that represents an L.

To insert an element into a Lua table, we could use table.insert, but that would be quite long. So we get the length of l using #l, add 1 to the length, and place the ASCII code into the new index.

for i=65,90 do
    if i ~= 76 then
        l[#l + 1] = i
    end
end

Once that's done, we then start looping over the table to print the characters. For this explanation, I'll expand p and c to show the function names.

The first loop will print the upper-case letters. Then we add a new line. Then we start another loop to print out the lower-case letters, that is +32 to our l ASCII table.

for j=1,#l do
    io.write(string.char(l[j]))
end
io.write"\n"
for k=1,#l do
    io.write(string.char(l[k] + 32))
end
\$\endgroup\$
3
  • \$\begingroup\$ note that you're only supposed to print one of the strings. you can include the other program in your post though \$\endgroup\$
    – ASCII-only
    Commented Feb 28 at 13:04
  • \$\begingroup\$ also unfortunately it seems like the naive approach might be the shortest: 32 \$\endgroup\$
    – ASCII-only
    Commented Feb 28 at 13:04
  • \$\begingroup\$ whereas the shortest non-naive approach seems to be 55 \$\endgroup\$
    – ASCII-only
    Commented Feb 28 at 13:09
0
\$\begingroup\$

Nibbles, 9 nibbles (4.5 bytes)

-|@\$u"L"

Attempt This Online!

Explanation

Inspired by Mike Bufardeci's Nibbles answer, but since most of it is different I thought I'd post it separately.

-|@\$u"L"
  @        List of all printable ASCII characters
 |         Filter, keeping the ones that
   \$u     are uppercase letters
-     "L"  Remove L
\$\endgroup\$
0
\$\begingroup\$

brainfuck, 186 162 bytes

-24 bytes from managing data a little bit better

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

Try it online!

this is my first time with brainfuck x3 very sloppy and probably really inefficient because this is the first time I've coded something like this with brainfuck

\$\endgroup\$
0
\$\begingroup\$

Arturo, 24 bytes

print join--@`a`..`z``l`

Try it!

\$\endgroup\$
1
2

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.