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


Current rankings (06 Mar 2014):

\$\endgroup\$
  • 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 '12 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 '12 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 '12 at 21:17
  • 2
    \$\begingroup\$ Is uppercase output allowed? \$\endgroup\$ – Erik the Outgolfer Sep 16 '16 at 11:09
  • 2
    \$\begingroup\$ I'm the OP. Uppercase not allowed. \$\endgroup\$ – shamp00 Sep 17 '16 at 5:21

111 Answers 111

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\$
  • \$\begingroup\$ I was wondering when a Brainfuck solution would rear its head... +1 \$\endgroup\$ – WallyWest Jun 2 '15 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\$
  • \$\begingroup\$ I think this is 94 bytes (unless there was whitespace originally that wasn't put into your answer). \$\endgroup\$ – monopole Sep 30 '14 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\$
  • \$\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 '15 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 '15 at 13:17
2
\$\begingroup\$

Burlesque, 12 characters

'`'zr@[-\[sh

(see here in action.)

With a:

'a'zr@\[sh

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

05AB1E, 4 bytes (non-competing?)

žpRl

Try it online!

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

A
\$\endgroup\$
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\$

Keg, 8 bytes (SBCS)

b;(|:1+

TIO

\$\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\$
  • \$\begingroup\$ With the same method, you could shorten a lot with "abcd%cfg.... \$\endgroup\$ – ugoren Jun 3 '12 at 19:55
  • \$\begingroup\$ Yes, but the the array was more intimidating. That's half comprehensible. \$\endgroup\$ – walpen Jun 3 '12 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\$
  • \$\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 '13 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 '13 at 21:55
  • \$\begingroup\$ Another variant of the 39-character script. Same length. 97..122|%{$s+=new-object string($_)};$s \$\endgroup\$ – Iszi Dec 12 '13 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 '14 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\$
  • \$\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 '14 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\$ – Braden Best Jan 30 '14 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\$ – Braden Best Jan 30 '14 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\$
  • 1
    \$\begingroup\$ CJam was created after this challenge was posted. \$\endgroup\$ – lirtosiast Aug 18 '15 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 '15 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\$

Simplex v.0.7, 3 bytes

Noncompeting, as Simplex postdates question

^lg
^l  ~~ sets current byte to the alphabet [a-z]
  g ~~ output as string
\$\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\$
1
\$\begingroup\$

Groovy, 15 + 10 = 25 bytes

{'\u0061'..'z'}

Defines an anonymous function that returns the alphabet. Does not use a, e, i or o.

{'a'..'z'}

Defines an anonymous function that returns the alphabet. Does not use e, i, o or u.

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

Jelly, 7 chars

”Ø;97ỌV

Try it online!

Seems like this should (not (non-competing)) be accepted instead of GolfScript.

Note:

Ø and are not O, so this is valid. Here is how I built it:

My initial program (2 bytes) was:

Øa

But, since it contained an a, I had to change it.

This could have been a valid 6-char program if uppercase output was allowed:

65r90Ọ
\$\endgroup\$
  • \$\begingroup\$ The language is way newer than the challenge, so no, it should not be accepted instead of Golfscript. See this meta \$\endgroup\$ – Sanchises Sep 16 '16 at 14:31
  • \$\begingroup\$ @sanchises Oh, if it is newer, then OK. I thought it was appropriate, since I neither knew when the first commit was made nor when the required commit for this to work was made. \$\endgroup\$ – Erik the Outgolfer Sep 16 '16 at 14:40
  • \$\begingroup\$ I guess the purpose of that rule is also to prevent flooding of old challenges with new languages - golfing languages are now much more commonplace. \$\endgroup\$ – Sanchises Sep 16 '16 at 15:38
  • \$\begingroup\$ @sanchises I don't think it's there for that reason; it's there to prevent cheating by creating languages which just do the task on encountering the empty program. \$\endgroup\$ – Erik the Outgolfer Sep 16 '16 at 21:04
  • \$\begingroup\$ Note: "I guess (...) also (...)". I know what the main reason is for the rule, but it's strictness has some side effects that I'm sure were considered, and not seen as a deal-breaker for making the rule so strict, which generally means the side-effects were considered at least somewhat beneficent. But that's just my interpretation of ppcg politics. ;) \$\endgroup\$ – Sanchises Sep 16 '16 at 21:17
1
\$\begingroup\$

Python 2, 91 bytes

Vowels are escaped with octal where necessary.

No ae

print"\141bcd\145fghijklmnopqrstuvwxyz"

No iou

exec"pr\151nt''.j\157\151n(map(chr,range(97,123)))"
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 4 bytes

žpRl

Try it online!

Explanation:

žp     Push 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
  R    Reverse string - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   l   Lowercase - 'abcdefghijklmnopqrstuvwxyz'
       Implicitly print
\$\endgroup\$
1
\$\begingroup\$

Perl 6, 49 bytes

("a".."z").map(*.print) # 23 bytes, no E, O, or U
$*OUT.put((97..122)>>.chr) # 26 bytes, no A, E, or I
\$\endgroup\$

protected by user16402 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.