72
\$\begingroup\$

Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'.

Your task is to write a set of (up to 5) programs in any language (which has a text-based syntax*) to output all 26 letters of the alphabet in order. However for each vowel aeiou, at least one of the programs must not include any occurrence of the vowel.

So there must be

  • a program that does not use 'a' or 'A' anywhere in the syntax of the program.
  • a program that does not use 'e' or 'E' anywhere in the syntax of the program.
  • a program that does not use 'i'  or 'I' anywhere in the syntax of the program.
  • a program that does not use 'o' or 'O' anywhere in the syntax of the program.
  • a program that does not use 'u' or 'U' anywhere in the syntax of the program.

All of them must output abcdefghijklmnopqrstuvwxyz.

The winner shall be the solution where the length of all programs is the shortest.

* since the constraint wouldn't be much of a challenge in Piet or Whitespace

\$\endgroup\$
21
  • 4
    \$\begingroup\$ @w0lf: No, it says "up to 5 programs" and "length of all programs", which I read as "there can be only one program and its length counts in this case". \$\endgroup\$
    – schnaader
    Apr 24, 2012 at 11:09
  • 9
    \$\begingroup\$ @PeterTaylor: You don't think having to avoid using vowels in your syntax is a unique challenge? As a JS programmer, it's especially interesting :) \$\endgroup\$
    – mellamokb
    Apr 24, 2012 at 13:51
  • 2
    \$\begingroup\$ Are newlines acceptable in the output (i.e. one per character)? I can shorten some of my code if that is the case... \$\endgroup\$
    – Gaffi
    Apr 24, 2012 at 21:17
  • 2
    \$\begingroup\$ Is uppercase output allowed? \$\endgroup\$ Sep 16, 2016 at 11:09
  • 2
    \$\begingroup\$ I'm the OP. Uppercase not allowed. \$\endgroup\$
    – shamp00
    Sep 17, 2016 at 5:21

120 Answers 120

2
\$\begingroup\$

Sage CLI, 42

No e,i,o,u:

map(chr,[97..122])

No a,i,o:

'%c'*26%tuple([97..122])

Fun fact: str, chr, and cmp are the only Python builtins that don't contain vowels!

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

Brainfuck, 31 bytes

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

How it works

-              wrap to 255
[----->++>+<<] loop 51 times  r1=102 r2=51
>----->+       r1=97 r2=52
[--<.+>]       loop 26 times and print letters a-z
\$\endgroup\$
1
  • \$\begingroup\$ I was wondering when a Brainfuck solution would rear its head... +1 \$\endgroup\$ Jun 2, 2015 at 6:02
2
\$\begingroup\$

Perl 5.10+, 23 chars

(This is an improvement on previous such entry but I don't have the reputaion to comment there):

no a, e, o, u:

print "\x61"..z

no e, i, o, u:

say a..z
\$\endgroup\$
2
\$\begingroup\$

Marbelous, 94 Bytes(I think)

.. @1 61 ..
.. .. // ..
.. Dn \\ ..
++ =0 \/ ..
@1 !! .. ..

:Dn
}0 .. 85 }0 }0
\\ {0 // {> {<

One program, no vowels, I think this qualifies as text-based, but I could be wrong. Marbelous interpreter

\$\endgroup\$
1
  • \$\begingroup\$ I think this is 94 bytes (unless there was whitespace originally that wasn't put into your answer). \$\endgroup\$
    – laurencevs
    Sep 30, 2014 at 17:18
2
\$\begingroup\$

Piet, 104 (8x13) codels

Not eligible for this challenge, but I did it nonetheless.

enter image description here

I guess I could golf it a bit more, but this should be a good start.

output:

D:\codegolf\npiet-1.3a-win32>npiet "alphabet codegolf.png"
abcdefghijklmnopqrstuvwxyz
\$\endgroup\$
2
  • \$\begingroup\$ Not eligible to win as the question says “any language (which has a text-based syntax*)”, but nice one anyway. \$\endgroup\$
    – manatwork
    Aug 18, 2015 at 13:09
  • \$\begingroup\$ I know. I did it just for the fun of it and wasn’t going for winning the challenge. :) \$\endgroup\$
    – M L
    Aug 18, 2015 at 13:17
2
\$\begingroup\$

Burlesque, 12 characters

'`'zr@[-\[sh

(see here in action.)

With a:

'a'zr@\[sh

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

JS (ES2018), 54 bytes

\141l\145rt`\141bcd\145fgh\151jklmn\157pqrst\165vwxyz`

Alerts "abcdefghijklmnopqrstuvwxyz".

So, you can update the JS score to 54 bytes.

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

Pyth - 1 Byte

G

Implicitly print alphabet

\$\endgroup\$
1
  • \$\begingroup\$ Implicitly Print Alphabet. IPA. \$\endgroup\$
    – user85052
    Dec 14, 2019 at 13:44
2
\$\begingroup\$

Keg, 8 bytes (SBCS)

b;(|:1+

TIO

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

Keg, 7 bytes (SBCS)

\`zɧ^_^

This generates the range from backtick to z and removes the backtick character.

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

Keg, 4 bytes

b;zɧ

Generates a range from a to z and prints it.

Try it online!

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

W, 8 bytes

97;122.C

Pretty simple:

97;122.  % Generate a range from 97 ('a') to 122 ('z')
       C % Convert this to its character form
\$\endgroup\$
2
\$\begingroup\$

W d, 5 4 bytes

(ÇL·

Explanation

After decompression:

'a    % Character a
  'z. % Up to character z
\$\endgroup\$
2
\$\begingroup\$

Vyxal, 3 bytes

kB∷

Try it Online!

Explanation:

kB   # Built-in constant "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  ∷  # Second half of the string
     # Implicit output

Alternate 3 byte solution

kzṘ

Try it Online!

Explanation:

kz   # Built-in constant "zyxwvutsrqponmlkjihgfedcba"
  Ṙ  # Reverse the string
     # Implicit output
\$\endgroup\$
2
\$\begingroup\$

05AB1E, 4 bytes

žpRl

Try it online!

Doesn't use any vowel. If it were to use vowels, It'd be just this instead.

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

C 108

Technically cheating, but

x[]={1684234849,1751606885,1818978921,1886350957,1953722993,2021095029,31353};y(){z("%s",x);}

Compile with -Dy=main -Dz=printf (I counted those towards the char count). Of course if you're allowing -D, go full hog and say -Dp=main(c){for(;c<27;)putchar(96+c++);} 39 characters there. (Or one, depending on how you count).

\$\endgroup\$
2
  • \$\begingroup\$ With the same method, you could shorten a lot with "abcd%cfg.... \$\endgroup\$
    – ugoren
    Jun 3, 2012 at 19:55
  • \$\begingroup\$ Yes, but the the array was more intimidating. That's half comprehensible. \$\endgroup\$
    – walpen
    Jun 3, 2012 at 21:32
1
\$\begingroup\$

Lua, 56

_G["pr\105nt"]"\97bcd\101fgh\105jklmn\111pqrst\117vwxyz"

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

Erlang escript 75

It's pretty hard to do any golfing in Erlang but anyway:

$ cat alphabet 

'm\x61\x69n'(_)->
'\x69\x6f':'f\x6frm\x61t'('l\x69sts':'s\x65q'(97,122)).

Note empty line at beginning of escript and also line break in main function. They are both mandatory. Run it using

$ escript alphabet
\$\endgroup\$
1
\$\begingroup\$

MATLAB, 17 characters

x='`':'z';x(2:27)

NOTE: Would be a winner with 7 characters if the first letter wasn't a vowel :-)

'a':'z'
\$\endgroup\$
1
\$\begingroup\$

Powershell, 29 + 39 = 68 chars

If newlines are acceptable in the output (as has been asked in the question's comments), this can be further reduced to 51 chars.

Uses no 'eiou' (29 chars):

$s="";$s+=97..122|%{[char]$_}

Uses no 'au' (39 chars):

-join(97..122|%{new-object string($_)})

Both work off of the same concept of translating integers into their ASCII values, the first by an explicit cast to char and the second by using the string constructor to perform the cast implicitly.

\$\endgroup\$
4
  • \$\begingroup\$ The "no eiou" solution doesn't output anything, and the variable has a bunch of spaces in it which weren't in the question spec. (Though, having not yet gotten an answer for newlines, I'm not sure we can assume any whitespace is out.) You'd need to add ;$s (3 characters) to make it output. \$\endgroup\$
    – Iszi
    Dec 12, 2013 at 21:52
  • 1
    \$\begingroup\$ That said, you could stick with the same principle and even shorten it by 3. 97..122|%{$s+=[char]$_};$s This also eliminates the spaces. \$\endgroup\$
    – Iszi
    Dec 12, 2013 at 21:55
  • \$\begingroup\$ Another variant of the 39-character script. Same length. 97..122|%{$s+=new-object string($_)};$s \$\endgroup\$
    – Iszi
    Dec 12, 2013 at 22:01
  • \$\begingroup\$ another modification to the first one which eliminate spaces $ofs='';"$(97..122|%{[char]$_})" however it adds an 'o' and is now 32 characters. \$\endgroup\$
    – Tim Lewis
    Mar 4, 2014 at 15:27
1
\$\begingroup\$

Python shell, 48 + enter

str('\x61bcd\x65fgh\x69jklmn\x6fpqrst\x75vwxyz')

Output:

'abcdefghijklmnppqrstuvwxyz'

If this is valid, I think my answer is too?

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

Forth, 46

.\" \x61bcd\x65fgh\x69jklmn\x6fpqrst\x75vwxyz"
\$\endgroup\$
1
\$\begingroup\$

C (77)

Here's my crack at it. Dunno if I broke some kind of anti-compiler-flag rule, but here goes:

int main(){int i=97;while(++i<'{')if(i^'e'&&i^'i'&&i^'o'&&i^'u')putchar(i);

To compile and run:

$ gcc az.c -include "stdio.h" -o az
$ ./az
bcdfghjklmnpqrstvwxyz

In case anyone's interested, here's a quick explanation of some of the 'micro-optimizations':

97 is the decimal equivalent of 0x61, or 'a'. Used because it saves one char over 'a'.

'{' is the char immediately after 'z', it saves me an = (i<='z' vs i<'{').

A^B returns 0 when A and B are equal, and anything but when they aren't, which is as good as != for my purposes. It saves me four chars.

Loop starts out immediately ++'ing i to skip 'a' from the get-go, and save me an extra two chars. It saves me 9 chars altogether (exclude i^'a'&& and the i and ; I would've had to put had I incremented i within the block)

And finally, I used a compiler flag to include stdio.h instead of putting it in the file, saving me 18 chars. I don't know if this is "cheating" or anything, so feel free to point it out if it is.

P.S. This is my first code golf, so if I'm missing a rule, spoken or not, don't hesitate to correct me.

\$\endgroup\$
3
  • \$\begingroup\$ This program uses the letters a and i (in main) and e, o, and u in if(i^'e'&&i^'i'&&i^'o'&&i^'u'). I suspect you've misunderstood the question. \$\endgroup\$
    – Gareth
    Jan 30, 2014 at 9:19
  • \$\begingroup\$ @Gareth I probably did. I interpreted the goal as to "make a program that prints every letter in the alphabet (sans a,e,i,o,u) in the shortest amount of code you can manage." \$\endgroup\$ Jan 30, 2014 at 17:58
  • \$\begingroup\$ @Gareth Oh. Yes, I completely misunderstood the question. I thought the output was supposed to exclude vowels, but the source was fine including them. It was the other way around. \$\endgroup\$ Jan 30, 2014 at 18:09
1
\$\begingroup\$

Bash, 31 chars

I think this is the shortest bash version so far:

z=({Z..z});tr -d \ <<<${z[@]:7}

This one outputs exactly abcdefghijklmnopqrstuvwxyz with no whitespace between any letters.

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

Clojure: 81 over 2 statements

No i, o, or u: 35 chars

(apply str(map char(range 97 123)))

No a or e: 46 chars

(str \u0061"bcd"\u0065"fghijklmnopqrstuvwxyz")

REPL (RPL?) session:

cd-glf-s-hrd> (apply str(map char(range 97 123)))
"abcdefghijklmnopqrstuvwxyz"
cd-glf-s-hrd> (str \u0061"bcd"\u0065"fghijklmnopqrstuvwxyz")
"abcdefghijklmnopqrstuvwxyz"
\$\endgroup\$
1
\$\begingroup\$

Cjam 6

'{,97>
  • creates the character "{"
  • lists all characters less than "{" (this ends if you try to print it because character 0 stops things from outputting)
  • removes any with a value less than or equal to 97
\$\endgroup\$
2
  • 1
    \$\begingroup\$ CJam was created after this challenge was posted. \$\endgroup\$
    – lirtosiast
    Aug 18, 2015 at 15:31
  • 1
    \$\begingroup\$ @ThomasKwa I realised that after having answered it. This disqualifies it from winning, but I think it is interesting enough it shouldn't be removed. \$\endgroup\$
    – kaine
    Aug 18, 2015 at 15:33
1
\$\begingroup\$

T-SQL, 120 (65+55)

This answer assumes results of both PRINT and SELECT are allowed as output.

65 characters without e, o, u:

PRINT'abcd'+CHAR(101)+'fghijklmn'+RTRIM(0x6F707172737475)+'vwxyz'

55 characters without a, i:

SELECT LEFT(0x616263646566676869,9)+'jklmnopqrstuvwxyz'
\$\endgroup\$
1
\$\begingroup\$

Haskell (interpreted), 17

[['`'..]!!1..'z']

Back-quote comes before 'a', so a is the second element of the sequence starting with back-quote. This is then just the sequence from a to z.

This is technically a naked Haskell expression. (If you save it to ".ghci", though, running ghci will print the alphabet.)

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

><>, 35 bytes

!v99*:f1++$ff++31p!
 >: 1+:bb*1+)?;

><> outputs with the command 'o', hopefully it also provides introspection capability so we'll just edit the code at runtime to add the 'o'. This is done with the command 'p' at the end of the first line.

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

F# (96) characters, using fsharpi

// Without u (48 chars)
sprintf "abcdefghijklmnopqrst%cvwxyz" (char 117)

// Without a, e, i, o (48 chars)
"\u0061bcd\u0065fgh\u0069jklmn\u006fpqrstuvwxyz"

This was tough since all the functions to manipulate sequences contain vowels. Also the functions for outputting to stdout are printf and printfn, therefore this only produces a string instead of writing it out.

These lines will need to be ran through the F# interpreter and ended with ;; to execute.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.