Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

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
1  
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
3  
@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
5  
@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
2  
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
1  
What if the shebang contain vowels? #/usr/bin/perl -w at least 3 vowels? –  F. Hauri Dec 12 '13 at 13:31

71 Answers 71

up vote 41 down vote accepted

Golfscript - 8 chars

123,97>+
share|improve this answer
7  
damn, really can't beat golfscript in terms of conciseness... –  padde Apr 25 '12 at 11:12
13  
That being said, the readability stinks like crazy. –  Andrew Gray Apr 9 '13 at 17:25
3  
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 at 16:38

Brainfuck, 38 chars

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

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

share|improve this answer
1  
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:

\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

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

Ruby (v1.8) 18 bytes

$><<[*97.chr..'z']
share|improve this answer
    
I'm not sure I understand how this works. Could I get an explanation? –  GigaWatt Apr 25 '12 at 18:22
    
When applied to a string, the ~ operator inverts all of the bits. Here I've inverted abc...xyz. Because there are no symbols characters (or whitespace) in the binary string, quotes are not necessary either. –  primo Apr 25 '12 at 18:31
1  
You may want to specify an encoding for what you have there. –  Joey Apr 26 '12 at 5:36
1  
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

Ruby (24 22)

Edit: parentheses can be omitted, 2 chars less:

$><<'%c'*26%[*97..122]

24 chars in Ruby:

$><<('%c'*26)%[*97..122]

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
1  
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 :) –  padde 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

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.

2(3!:4)96+#\26$1

Previously:

a.{~96++/\26$1
u:97+i.26

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

JavaScript (100)

No 'aeou':

this['\x61l\x65rt']('\x61bcd\x65fghijklmn\x6fpqrst\x75vwxyz')

No 'i':

alert('abcdefgh\x69jklmnopqrstuvwxyz')
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
1  
@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

K,9

_26#.Q.b6

K,10

"c"$97+!26

K,14

.:".Q.","c"$97
share|improve this answer
    
and a silly way to do it with no letters at all (12 chars): (@$`)$97+!26 –  Aaron Davies Jan 20 at 9:56

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
2  
Nice use of shell globbing! –  Mechanical snail May 19 '12 at 21:48

R, 17 + 19 = 36 characters

no ae (17):

intToUtf8(97:122)

no iou (19):

cat(letters,sep="")
share|improve this answer

Golfscript, 10 characters

26,{97+}%+
share|improve this answer
13  
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
4  
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

MATLAB, 12+20=32 characters

No eiou (12):

char(97:122)

No aeou (20)

fprintf('%s',97:122)
share|improve this answer

Ruby, 20 chars

$><<[*97.chr..?z]*''
  • 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
1  
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

Perl 5, 22 characters

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

-Esay+a..z

(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

Powershell, 75 62 characters

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

'{0}bcd{1}fgh{2}jklmn{3}pqrst{4}vwxyz'-f"$(1|gm)"[8,10,0,5,31]

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
2  
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
2  
I used -f (String.Format) and array indexing to significantly reduce the code length. –  Tim Lewis Mar 4 at 20:03

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
1  
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
1  
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

dc: 18 17 characters

97[dP1+dBD>m]dsmx

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
3  
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

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:

⎕A
share|improve this answer
2  
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 at 9:31

JavaScript (154)

(1) Only contains i (99 chars):

t=this;s=-t+t+t.b;z=s[1]+'bcd'+s[7]+'fghijklmn'+s[4]+'pqrst'+s[21]+'vwxyz';t[s[1]+'l'+s[7]+'rt'](z)

(2) Only contains aeou (55 chars):

t=0;s=''+t.b;alert('abcdefgh'+s[5]+'jklmnopqrstuvwxyz')

Demo: http://jsfiddle.net/SvN5n/

share|improve this answer

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:

print"%cbcd%cfghijklmn%cpqrst%cvwxyz"%(97,101,111,117)

This one avoids using i for 104 chars:

eval("sys.stdout.wr%cte"%105,{'sys':eval("__%cmport__('sys')"%105)})("%c"*26%tuple(range(97,123))+"\n")

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:

vars(vars().values()[0])['pr%cnt'%105]("%c"*26%tuple(range(97,123)))

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

print"%cbcd%cfghijklmnopqrst%cvwxyz"%(97,101,117)
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

$><<"\x61bcd\x65fgh\x69jklmn\x6Fpqrst\x75vwxyz"
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. –  padde Apr 25 '12 at 11:13
    
@padde you are both right; changed. –  w0lf Apr 25 '12 at 11:52
1  
@padde I used your $><<, so +1 for that and congratulations; your version is much better –  w0lf Apr 25 '12 at 11:54

Ruby, 22

$><<[*?`..?{][1,26]*''

No letters whatsoever :)

share|improve this answer

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:

print"abcd\x65fghijklmnopqrstuvwxyz"
share|improve this answer

Rebmu: 15 characters

Ctc'`L26[pn++C]

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':

&#97;bcd&#101;fgh&#105;jklmn&#111;pqrst&#117;vwxyz

abcdefghijklmnopqrstuvwxyz

share|improve this answer
1  
@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
1  
@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
1  
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
1  
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
4  
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

Postscript, 46 45

(\141bcd\145fgh\151jklmn\157pqrst\165vwxyz)=
share|improve this answer
    
You can shorten that by one character by removing the space. –  Joey Apr 26 '12 at 9:00

Scala,38+17=55

No 'aeio':

'\u0061't\u006f'z'm\u0061p pr\u0069nt

No 'u':

'a'to'z'map print

Output: abcdefghijklmnopqrstuvwxyz

share|improve this answer
2  
Your answer only satisfies 'e' and 'u'. You need to add a version that does not use 'a', 'i' and 'o'. –  shamp00 Apr 26 '12 at 9:55
    
@shamp00: +1 Now fixed –  Prince John Wesley Apr 26 '12 at 12:18
1  
You still need the no 'u' version too. The task is to have as many programs as necessary to cover all 5 vowels. Then you add the lengths together for the total score. –  shamp00 Apr 26 '12 at 13:09
    
Regarding what @shamp00 says, just add back in your ('b'-1).toChar to'z'map print and you're good to go! –  Gaffi Apr 27 '12 at 12:23
    
@Gaffi: ok. let me add my original version. –  Prince John Wesley Apr 28 '12 at 1:58

Ruby, 47 characters

(1) Only contains 'a' and 'u', 24 chars:

puts [*97..122].pack'c*'

(2) Only contains 'o' and 'i', 23 chars:

$><<[*97.chr..'z'].join

There's a slight difference in output in that the first one adds a newline and the second doesn't. Could add the newline to the second at a cost of 4 characters; removing it from the first would be harder.

share|improve this answer

Haskell, 12

['\97'..'z']

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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