Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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' anywhere in the syntax of the program.
  • a program that does not use 'e' anywhere in the syntax of the program.
  • a program that does not use 'i' anywhere in the syntax of the program.
  • a program that does not use 'o' anywhere in the syntax of the program.
  • a program that does not use '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

Current rankings (06 Mar 2014):

share|improve this question
if one manages to make a single program that does not contain any vowel, do we need multiply the length of the program by 5? – w0lf Apr 24 '12 at 10:55
@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". – schnaader Apr 24 '12 at 11:09
@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 :) – mellamokb Apr 24 '12 at 13:51
Are newlines acceptable in the output (i.e. one per character)? I can shorten some of my code if that is the case... – Gaffi Apr 24 '12 at 21:17
What if the shebang contain vowels? #/usr/bin/perl -w at least 3 vowels? – F. Hauri Dec 12 '13 at 13:31

83 Answers 83

up vote 45 down vote accepted

Golfscript - 8 chars

share|improve this answer
damn, really can't beat golfscript in terms of conciseness... – Patrick Oscity Apr 25 '12 at 11:12
That being said, the readability stinks like crazy. – Andrew Gray Apr 9 '13 at 17:25
It's not that bad ;) generate a list of 123 numbers, remove those who aren't greater than 97, coerce it (array of numbers) to a string. – McKay Jan 29 '14 at 16:38

Brainfuck, 38 chars


There are, of course, no vowels (or any other letters) in brainfuck syntax.

share|improve this answer
Valid point there! ;) – WallyWest Dec 16 '13 at 0:17

PHP, 31 Bytes

No a,e,i,o,u:


The binary string after the tilde has the following hex representation:


Since there's a language scoreboard, I may as well submit this one as well:

Ruby (v1.8) 18 bytes

share|improve this answer
I'm not sure I understand how this works. Could I get an explanation? – Mr. Llama Apr 25 '12 at 18:22
When applied to a string, the ~ operator inverts all of the bits. Here I've inverted Because there are no symbols characters (or whitespace) in the binary string, quotes are not necessary either. – primo Apr 25 '12 at 18:31
You may want to specify an encoding for what you have there. – Joey Apr 26 '12 at 5:36
iso-8859-1. Three 'unprintable' characters were removed when it was posted, which is why I included the hex. – primo Apr 26 '12 at 6:33
Nice and probably the shortest possible PHP version. A command to generate the file: php -r 'echo("<?=~\x9e\x9d\x9c\x9b\x9a\x99\x98\x97\x96\x95\x94\x93\x92\x91\x90\x8f\x8e\‌​x8d\x8c\x8b\x8a\x89\x88\x87\x86\x85;");' > script.php. The command to run it: php -d error_reporting=0 script.php; echo. – axiac Aug 18 '15 at 12:39

Ruby (24 22)

Edit: parentheses can be omitted, 2 chars less:


24 chars in Ruby:


How it works

$> is an alias for $stdout or STDOUT. You can write to it using the << operator. The term '%c'*26 repeats the string '%c' 26 times. The % operator is defined on String as an alias to sprintf, so str % val is equivalent to writing sprintf(str,val). The format character %c is used to transform a char value to a char. These values come from [*97..122] which creates an array containing the values from 97 to 122. Et voilá!

share|improve this answer
Very nice. I was looking for a way to use << but had forgotten about $>. – Mark Reed Apr 25 '12 at 10:49
I didn't even know about $> before, but i guessed there had to be some dollar-variable alias for $stdout that no one can remember :) – Patrick Oscity Apr 25 '12 at 11:04
21 characters: $><<[*"`".."z"][1,26] (note: this only works in Ruby 1.8) – Ventero May 5 '12 at 0:11
@Ventero not only in Ruby 1.8, in Ruby 1.9.2 works as well. But using p [*"".."z"][1,26]` is even shorter. – Łukasz Niemier Sep 14 '12 at 9:57
@Hauleth: No, running it in 1.9 doesn't generate the correct output, as in 1.9 Array#to_s is the same as Array#inspect, whereas in 1.8 it's Array#join - so in 1.9 the output is ["a", "b", "c", "d", "e", ...] instead of abcdef.... For the same reason, p can't be used (it calls inspect on its arguments, instead of to_s). – Ventero Sep 14 '12 at 10:08

JavaScript (100)

No 'aeou':


No 'i':

share|improve this answer
+1 Nice improvement on my answer :) I had thought about using the \x## codes but weren't sure if they were valid in JavaScript. – mellamokb Apr 24 '12 at 16:28
why the alerts at all? on a js terminal, objects are echo'd automagically. ('\x61bcd\x65fghijklmn\x6fpqrst\x75vwxyz') @ 42 characters. – antony.trupe Apr 24 '12 at 17:26
@antony.trupe, for code golf, IO is typically done via the language's built in IO mechanisms (or common plugins). For JS this is typically alert, confirm, prompt, console.log, and document.write. Simply declaring a string literal doesn't produce it as output when executed. Otherwise, you'd be correct, and I would have used that. – zzzzBov Apr 24 '12 at 17:52
it produces output(by the definition I use anyways) in the google chrome console, but I concede the issue; it's an arbitrary restriction to begin with. – antony.trupe Apr 24 '12 at 18:32
@antony.trupe, in a language like PHP you'd be able to get away with using a literal, because that's how it performs IO. – zzzzBov Apr 24 '12 at 18:35






share|improve this answer
and a silly way to do it with no letters at all (12 chars): (@$`)$97+!26 – Aaron Davies Jan 20 '14 at 9:56
The K5 way is nearly your second solution but $ takes symbols instead of strings to control the type converted into: `c$97+!26 – JohnE Jun 2 '15 at 3:17

J, 26 23 17 16 characters

After an hour or so rummaging around in J's underwear drawer I've finally found a way to eliminate the a. and u: verbs.




with thanks to randomra for the #\ trick.

share|improve this answer
Nice solution! Managed to shorten with 1 char using #\ instead of +/\ . – randomra Apr 9 '13 at 0:47
@randomra Cool thanks. – Gareth Apr 9 '13 at 10:59
Get out of my underwear drawer – Joe Dec 3 '14 at 10:33

Bash (38)

No vowels at all.

/*/*/*ntf "/*/?ch? {\x61..z}"|/*/b?sh
share|improve this answer
This program fails on my system, because /*/b?sh does not exist. I have /usr/local/bin/bash, not /bin/bash. – kernigh May 4 '12 at 17:36
Nice use of shell globbing! – Mechanical snail May 19 '12 at 21:48

R, 17 + 19 = 36 characters

no ae (17):


no iou (19):

share|improve this answer

Golfscript, 10 characters

share|improve this answer
Why so verbose? – Peter Taylor Apr 24 '12 at 13:43

C, 90 88 84 characters

Compile using gcc -nostartfiles

b;_exit(){for(;b<26;)printf("%c",b+++97);}    // 42 chars, works for a, u
b;_start(){putchar(b+++97)>121?:_start();}    // 42 chars, works for e, i, o
share|improve this answer
_start and _exit are a nice way to get around main. But if a non-standard compilation line is OK, why not -DX=main? – ugoren Apr 24 '12 at 12:53
Somehow, -DX=main feels worse than -nostartfiles does (for me). It is a way to move a part of the source code to the compilation line and it is the same as writing #define X main in the source code which would be clearly invalid. Whereas -nostartfiles isn't a way to rename main, but removes the restriction that there must be a main function (called in _start). On the other hand, using -nostartfiles does feel a bit like cheating, especially as it contains 4 of the 5 "bad" letters :) – schnaader Apr 24 '12 at 13:21
It's a slippery slope... The distance from -nostartfiles to -DX=main is small, and then why not save some chars with -DX=main() and so forth. But I can't find a solution that doesn't involve anything fishy. – ugoren Apr 24 '12 at 16:22
There's no way you can define the main function to be "mn" for instance? – Neil Apr 26 '12 at 10:22
@Neil, only by doing something like -Dmn=main. A C function must have a main function unless a non-standard option like -nostartfiles is used. – Matthew Flaschen Apr 29 '12 at 3:17

BASH: 40 characters

  • No aeiou used.
  • No wildcard used.
`tr c-y '\141-w'<<<'rtkpvh %s c'` {b..z}
share|improve this answer

Ruby, 20 chars

  • 97.chr is an elaborate way of saying 'a'
  • .. specifies a Range
  • ?z is a shorter way of saying "z"
  • the [*range] causes the range to splat al it's values in an array
  • *'' is the same as join(''); it glues all array values together.
  • $><< Perlicism: print to stdout.
share|improve this answer
This code doesn't seem to work. ?z is not shorthand for 'z', but rather for 122. This, however, does work for 18 bytes: $><<[*97.chr..'z'] – primo Sep 13 '12 at 7:17
It does work in Ruby 1.9. – steenslag Sep 13 '12 at 14:42
I downloaded 1.9.3... and you're right. Why would they change something like that? I can see why anarchy golf is still running 1.8.7. Anyway, the 18 byte solution works for v1.8.7- – primo Sep 13 '12 at 15:30

Powershell, 75 62 characters

Edit: Used -f (String.Format) and array indexing to significantly reduce the code length.


How it works

gm is an alias for get-members, so 1|gm returns members of the value 1, which is of the System.Int32 type:

PS C:\> 1|gm
   TypeName: System.Int32
Name        MemberType Definition
----        ---------- ----------
CompareTo   Method     int CompareTo(System.Object value), int CompareTo(int value)
Equals      Method     bool Equals(System.Object obj), bool Equals(int obj)
GetHashCode Method     int GetHashCode()

"$(1|gm)" returns a string representation of the above list, which happens to contain all the vowels we need to complete the alphabet: "int CompareTo(System.Object value)..."

share|improve this answer
This isn't stable if MS adds members to System.Int32, though :-) – Joey Apr 26 '12 at 5:12
I think that would have to be ($x=''+$(gv))[8]+"bcd$($x[4])fgh$($x[25])jklmn$($x[26])pqrst$($x[19])vwxyz" which is also 75 characters :) – Danko Durbić Apr 26 '12 at 7:02
Argh, right. I fished the wrong item from my history. Sorry. – Joey Apr 26 '12 at 7:53
Actually, if you replace ''+$(gv) with "$(gv)" you get ($x="$(gv)")[8]+"bcd$($x[4])fgh$($x[25])jklmn$($x[26])pqrst$($x[19])vwxyz" which is 74 characters. Nice! – Danko Durbić Apr 26 '12 at 8:54
I used -f (String.Format) and array indexing to significantly reduce the code length. – Tim Lewis Mar 4 '14 at 20:03

Pyth, 1 Character


Pyth predefines certain variables. G is predefined as the lowercase alphabet. Pyth also implicitly prints each line with a reasonable return value.

share|improve this answer

MATLAB, 12+20=32 characters

No eiou (12):


No aeou (20)

share|improve this answer

dc: 18 17 characters


And there died a brave character.

share|improve this answer
I doubt so. I'm wrapping head around it and I don't see any way to shorten it. I have ended with exactly same solution except I used x for register which makes mine solution more obfuscated. – Hynek -Pichi- Vychodil Apr 21 '13 at 21:01
97[dP1+dBD>m]dsmx, 17 characters. Apparently you can always enter hexadecimal characters in DC, but as the input base is ten the value is B*10+D=11*10+13=123='{', and not 0xBD. – Fors Apr 21 '13 at 22:53
Oh, nice glich ;-) – Hynek -Pichi- Vychodil Apr 21 '13 at 23:25

Perl 5, 22 characters

(1) only contains a and e, 10 chars (requires 5.10+, run from the command line):


(2) only contains 'i', 12 chars:

print v97..z

If not allowed to run from the command line, then you need to use use 5.01;say a..z for the first one, at a cost of 7 characters and one more vowel, but it still has no 'i', so it results in a valid entry at 29 total characters.

share|improve this answer
The '-E' option is ok I think, but usually the 2 characters '-E' are added into the total character length. – Gareth Apr 24 '12 at 15:56
@gareth - the -E takes the place of -e for running a one-liner. If you're running a program from a file, then you're stuck with the use, although you could replace it with the command line option -M5.01 and shave off two more characters. – Mark Reed Apr 24 '12 at 16:17
I was thinking of the rule with the -p option where 2 characters are added to the count. Looking at this meta question though, you should be able to use the -M5.010 for free if that option helps shorten your code. – Gareth Apr 24 '12 at 16:29
you could replace your print statement with die to shave off 2 chars – ardnew Apr 30 '12 at 20:49
chr 97..z may be replaced with v97..z for 3 bytes. – primo Jul 24 '13 at 7:01

Python, 124 122 119 175 characters

Note: prints to output unlike earlier python answer.

Uses 'e', but no a,i,o,u - 63 61 59 65 (fix mistaken i move to lowercase) 115 chars (get rid of spaces).

exec('fr%cm sys %cmp%crt*\nf%cr x %cn r%cnge(97,123):std%c%ct.wr%cte(chr(x)),'%(111,105,111,111,105,97,111,117,105))

(Originally, it used print with a comma that inserted a space; also printed upper case letters. Now saw stringent requirements for 'abcdefghijklmnopqrstuvwxyz' as output; so adding import statement).

Doesn't use 'e' (uses a,i,o,u; could trivially get rid of a,u for small extension) - 61 60 chars

import string
print string.__dict__['low%crcas%c'%(101,101)]
share|improve this answer
Your first solution does use the letter i, so it should be: exec('f%cr x %cn r%cnge(65,91):pr%cnt chr(x),'%(111,105,97,105)) and we're back to 64 characters. – BioGeek Apr 26 '12 at 11:02
exec('fr%cm sys i mp%crt*\nf%cr... – Gareth Apr 26 '12 at 14:20
BioGeek & @Gareth - my manual vowel detection skills suck. Thanks for point it out; but I had an extra e written as a '%c' so in the end it evens out. – dr jimbob Apr 26 '12 at 15:58

Haskell, 12


Or is this cheating? :)

share|improve this answer
I admittedly don't know much about Haskell, but it gives me this error: Parse error: naked expression at top level – primo Dec 20 '12 at 9:39
You run it in the interpreter – RobAu Dec 20 '12 at 10:21

APL (Dyalog) (11 13)

You might need an APL font. This is supposed to be Unicode but there's no preview...

Only U (and perhaps if counting Greek vowels):

⎕UCS 96+⍳26

(That's: [quad]UCS 96+[iota]26)

Only A:

share|improve this answer
U is a vowel... – Tobia Jul 24 '13 at 23:26
@Tobia: and it took over a year for someone to see that (including me). I guess iota is actually also a vowel now that I'm thinking about it. Fixed it. – marinus Jul 25 '13 at 20:35
The APL functional symbol iota (U+2373) is not considered a letter in Unicode, and therefore can't be a vowel. Note, that it is distinct from the Greek small letter iota (U+03B9). – ngn Jun 13 '14 at 9:31

JavaScript (154)

(1) Only contains i (99 chars):


(2) Only contains aeou (55 chars):



share|improve this answer

In Perl,

it's also possible without any vowels

but much harder than in Ruby etc. This uses a total of 101 chars but doesn't require cmd line (perl -e) invocation.


=> Result: abcdefghijklmnopqrstuvwxyz

In contrast to the 'similar looking' PHP Solution, this is a real program. The program decoded reads:

perl -e "print STDERR a..z"

After encoding to octal values, another perl interpreter is called during run by the `` (backticks). The backticks would consume the output, therefore it's printed to STDERR.

The encoding is done by sprintf:

my $s = q{perl -e "print STDERR a..z"};
my $cmd = eval(
       '"' . join('', map sprintf("\\%o",ord $_), split //, $s) . '"'

and the eval'd encoding is the program posted (within backticks):




share|improve this answer
You could shorten this to 44 characters by only encoding the vowels :) – marinus Apr 30 '12 at 22:35

Python 159 117

As mentioned in the other python post the hardest part is dealing with the fact that the only way to output is to use print or sys.stdout.write, both of which contain i. Have to do it with 2 programs (which are freestanding and don't use the python interactive shell to create the output):

This one only uses i for 55 chars:


This one avoids using i for 104 chars:


EDIT: Massive breakthrough!!! I was thinking that use of eval (or even exec) was a bit of a cheat and not truly in the spirit of the competition. Anyway, trawling through the builtins I found a way to get hold of the print function without using i. So here is the avoid-i (and o) program for 68 chars:


But because that also avoids o, this can be paired with one that only avoids a, e, u for 49 chars:

share|improve this answer
You can toss away compatibility, and gain a character - vars(vars().values()[0]).values()[47] – ugoren May 6 '12 at 20:43

Ruby 196 164 44 47

share|improve this answer
Is this a valid answer, since p outputs quotation marks around the alphabet? – Mark Reed Apr 24 '12 at 14:51
i agree p x is equivalent to calling puts str.inspect, which results in surrounding quotation marks. – Patrick Oscity Apr 25 '12 at 11:13
@padde you are both right; changed. – w0lf Apr 25 '12 at 11:52
@padde I used your $><<, so +1 for that and congratulations; your version is much better – w0lf Apr 25 '12 at 11:54

Ruby, 22


No letters whatsoever :)

share|improve this answer

VBA: 76 brute force, 116 without 'cheating' (98 if newlines are acceptable in the output)

Standard Functions

Thanks to VBA's verbosity, I don't believe this can be done without 'E' or 'U' in a standard code module...

  • "E nd"
  • "F u nction"
  • "S u b"

Immediate Functions

Running with mellamokb's assumption, here's without the function declaration (leaving out SUB and FUNCTION) (116 chars, 98 if newlines are acceptable in output):

The below uses neither 'e' nor 'a' (43 chars, formatted to run in the immediate window):

b=65:Do:z=z+Chr(b):b=b+1:Loop Until b=91:?z

The below uses neither 'i' nor 'a' nor 'u' (33 chars, formatted to run in the immediate window):

For b=65 To 90:z=z+Chr(b):Next:?z

The below uses neither 'a' nor 'o' nor 'u' (40 chars, formatted to run in the immediate window):

b=65:While b<91:z=z+Chr(b):b=b+1:Wend:?z

If newline characters are allowed in the output, then the above examples can be shorter:

(37 chars)

b=65:Do:?Chr(b):b=b+1:Loop Until b=91

(27 chars)

For b=65 To 90:?Chr(b):Next

(34 chars)

b=65:While b<91:?Chr(b):b=b+1:Wend

Brute Force

Running with w0lf's Ruby answer

(76 chars, formatted to run in the immediate window):

share|improve this answer
I think it would be fair to leave Sub..End Sub out, since most other programs don't include function definition. – mellamokb Apr 24 '12 at 13:52
@mellamokb Well, that makes me feel better. I'll whip up some examples to add to this. – Gaffi Apr 24 '12 at 13:53
Just think of it as "code you run in the immediate window" :) – mellamokb Apr 24 '12 at 13:54
Well, if in doubt just call it VBScript which can be included in a file without needing a Sub :) – Joey Apr 26 '12 at 9:13
Fixed a bunch of needless spaces, changed print to ? since that works in the immediate window. – Gaffi Dec 19 '12 at 20:42

Python, 83

No a, i, o or u; 47:

x=97;s='';exec"s+=chr(x);x+=1;"*26+"pr\x69nt s"

No e; 36:

share|improve this answer

Rebmu: 15 characters


Reading Rebmu always requires a bit of unmushing to start with:

c: tc '` l 26 [pn ++ c]

Then it helps to expand the abbreviations:

c: to-char-mu '`
loop 26 [
    prin ++ c

It would be more obvious using a character literal for the predecessor of lowercase a:

c: #"`"
loop 26 [
    prin ++ c

But that doesn't "mush", so converting a word literal to a character passes for the same purpose. What I like about it, as with most Rebmu, is that it has the spirit of a sensible program despite the compression. (The Golfscript answer is shorter but doesn't map to the way a programmer would usually think when coding.)

share|improve this answer

PHP, HTML (50)

No 'aeiou':



share|improve this answer
@joar, I can't tell if you're trying to be humorous, it seems to have been lost on me. – zzzzBov Apr 27 '12 at 13:39
@joar, it's not magic, but it is valid PHP. You can't pipe anything through the PHP interpreter, you need to pipe valid characters in the correct encoding. HTML happens to be valid PHP because it's used as a subset of the language. – zzzzBov Apr 27 '12 at 13:53
Nope, HTML is a subset of PHP, PHP includes everything that HTML can do, in addition to other capabilities. PHP has to parse the entire contents of the page to find the <? tags, so the HTML is parsed, and then passed through. Hamlet can be piped through PHP in the same way that you can pipe Hamlet through an HTML file and have it be HTML. Comments are not the appropriate location for these extended discussions, so send me an email if you wish to resolve your confusion. – zzzzBov Apr 27 '12 at 14:16
PHP does not parse the HTML, it scans it for the next PHP block start tag. see the definitions of parse. – joar Apr 27 '12 at 14:43
PHP does indeed output the text. The problem is, this PHP program doesn't output the whole alphabet. It outputs some of the letters, along with various other characters like #. The entity decoding is done by HTML. You could use html_entity_decode to get around this (of course it has 3 vowels, so you'd need to deal with that). – Matthew Flaschen Apr 29 '12 at 3:32

protected by professorfish Oct 3 '14 at 14:24

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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