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

Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose name starts with that letter.

Input: none



(trailing newline optional)


  • The scoring metric is the length of the programming language name, plus the length of the code. Hence, C will be assessed a "penalty" of 1, while GolfScript will be assessed a penalty of 10.
  • One language/implementation per answer. Multiple answers are encouraged.
  • The programming language should have existed prior to the writing of this post, on this eighteenth of April 2011.
  • If a programming language name's first letter is not an English letter, it should not be coerced into one. It will be treated as a separate letter (meaning less competition).
  • No answer will be accepted until every English letter has a solution.

Current rankings:

Tell me if I'm missing anybody.

share|improve this question
It's not my lord, what should I do? – Joey Apr 18 '11 at 20:56
Are we allowed to print junk to stderr? – Peter Taylor Apr 18 '11 at 22:02
@Peter Taylor: Go nuts. To answer your question, yes, printing junk to stderr is fine (as long as stdout is correct). – Joey Adams Apr 18 '11 at 22:05
So much for points. This is a wiki now. – Joey Adams Apr 18 '11 at 22:45
Joey: I flagged it for moderator attention regarding CW, for the following reasons: (1) The task is trivial in any programming language, there is no challenge nor any difficulty. (2) It is more akin to a collection of implementations in as many languages as possible, not actually a real contest (honestly: there isn't much room to golf here). Since how the task is designed it encourages plenty of answers that can be churned out in dozens I didn't think this was something that should follow the usual rules of a golf or challenge. Apparently at least one mod agrees with me. – Joey Apr 18 '11 at 23:11

86 Answers 86

up vote 10 down vote accepted

K is for K, 12 characters -> Score: 13

share|improve this answer
Surely you can adapt one of your solutions to A+, right? – Joey Apr 19 '11 at 6:48
Setting up A+ is a little funky. I've done it before but I don't really feel like it. (Owl, newLISP and zshell were all turnkey.) – Jesse Millikan Apr 19 '11 at 6:53
i assume that's k2 or k3. in k4/q, you can do it in 7 chars with 1 .Q.a;. – Aaron Davies Jan 20 '14 at 10:10

P is for Perl, 10 characters -> Score: 14

print a..z
share|improve this answer
What about say a..z? – mbx Jul 5 '11 at 14:03

Y is for Yoix, 44 characters → Score: 48

int x;for(;++x<27;)yoix.stdio.putchar(96+x);
share|improve this answer
+1 Great find ! – ninjalj Apr 18 '11 at 23:43

P is (actually) for Piet - 57 codels

Large version (codel size = 6)

p is for piet - big

Small version (codel size = 1)

p is for piet - small

Tested with Erik's piet interpreter npiet and developed with Piet Creator.

Edit: Here is a "trace" version (generated with npiet -tpf) so you can see how it works.

Execution starts in the top left and goes around the border clockwise. The top edge and right edge are setup (calculating the value of a (97) takes quite a few codels). The loop starts on the bottom edge and goes to the left edge. When the value of z is reached the program turns right into the cross section under the first P and terminates.

Click the image to enlarge and see details

share|improve this answer
Oooh, Piet is always a nice one. And you don't happen to have a working Windows binary of Piet Creator lying around, do you? (I was too lazy to hunt all dependencies and prerequisites just to play around a bit again.) – Joey Apr 24 '11 at 21:01
And aren't that actually 400 codels and 57 coding codels? (I don't think we had a consensus how to count Piet here, though) – Joey Apr 24 '11 at 21:04
@Joey I'll see if I can cook up a build of Piet Creator for windows. It's been awhile since I tested it there. You're right about the codels. If I was to lay the program out in a line it would be 57 codels (give or take a few), the version above is more eye friendly (like whitespace in other langs). Perhaps Piet submissions should have both minimal and eye-catching sources. We better decide, because I'm planning many more Piet answers :) – Casey Apr 24 '11 at 21:16
Well, you could open a question on meta to ask for clarification how Piet code should be handled :-). I would have submitted Piet solutions too, long ago. Except pietdev was quite buggy and for Piet Creator I needed Qt and a few other things just to build it ;-). And just using a bitmap editor is quite ... cumbersome ... – Joey Apr 24 '11 at 21:20
@Joey Piet Creator still needs several important enhancements to be truly awesome, hopefully I can add those soon. I end up using mainly Piet Creator, and then use Paint or the GIMP to move blocks of color around. Pietdev was my main inspiration for PC. Getting some feedback on PC would be great, I'll get on that windows build ASAP. – Casey Apr 24 '11 at 23:55

W is for Whitespace, 51 characters -> Score: 61



share|improve this answer
I would have thought that it was obvious from the now-deleted comment along with my solution that I've never written any Whitespace before. Apparently not. – Gareth Apr 24 '11 at 10:04

G is for Golfscript, 8 characters -> Score: 18

share|improve this answer

A is for APL,  14  11 chars/bytes* → score 14

⎕UCS 96+⍳26

This works at least in Dyalog and Nars2000.

* APL can be written in its own (legacy) single-byte charset that maps APL symbols to the upper 128 byte values. Therefore, for the purpose of scoring, a program of N chars that only uses ASCII characters and APL symbols can be considered to be N bytes long.

share|improve this answer

R is for Ruby, 13 characters -> Score: 17

A Ruby 1.9 solution Matma Rex came up with:

print *?a..?z

My original Ruby 1.8 solution (15 characters -> Score: 19):

share|improve this answer
This one doesn't match the criteria? Output contains additional characters. Also, if it's OK, it'd be $><<[*?a..?z] for Ruby 1.9 (shaving off 2 chars). – Matma Rex Apr 19 '11 at 17:17
Shortest correct version I can conceive is print *?a..?z. It's the same length and the one I suggested above. We can't use $><< because << has some weird precedence rules and everything blows up. We can't use p or puts instead of print since they print every letter on separate line. – Matma Rex Apr 19 '11 at 17:26
Sorry, should've mentioned that this is for Ruby 1.8. In Ruby 1.8, Array#to_s is the same as Array#join, so it'll just print the alphabet with no extra characters. But your 1.9 solution is indeed shorter. – Ventero Apr 19 '11 at 18:50
Output is: – Nathan Osman Jul 5 '11 at 15:54
@George: Your output is from Ruby 1.8 (which can be verified here: As the post mentions, this is a solution for Ruby 1.9. – Ventero Jul 5 '11 at 18:14

F is for Fish (<><), 19 chars -> Score: 23

Because it's a damn beautiful language!

share|improve this answer
Isn't this answer scored 22 because <>> is only three characters long, not four. Is there a reason you used the longer name in the score. – ppperry Oct 15 '15 at 18:08
@ppperry Well the language name can't both start with an F and be <><. – flornquake Jan 5 at 18:38
The name of the language is ><>, not <>< – TùxCräftîñg Jun 19 at 16:48

R is for R, 19 → Score: 20

share|improve this answer
Alternatively (20 characters): cat(letters,sep="") – Paolo Mar 7 '12 at 16:10
@Paolo: Ah, thanks! – Joey Adams Mar 7 '12 at 17:03

P is for Python, 33 chars -> Score: 39

share|improve this answer
This is the same length as print'abcdefghijklmnopqrstuvwxyz'... – nneonneo Jul 14 '14 at 22:45
@nneonneo So... It is still the smallest one! (sharing the position with this other boring and trivial code). – JBernardo Jul 15 '14 at 7:42

D is for DC

share|improve this answer

O is for Owl, 11 characters -> Score: 14

share|improve this answer

P is for Python, 42 characters → Score: 48

import string
print string.ascii_lowercase
share|improve this answer
print 'abcdefhijklmnopqrstuvwxyz' – Charles Beattie Jul 4 '11 at 10:15
print'abcdefhijklmnopqrstuvwxyz' – nneonneo Jul 14 '14 at 22:45

B is for Befunge → 18 characters

share|improve this answer

P is for Python, 41 characters → Score: 47

print''.join(chr(i+97)for i in range(26))
share|improve this answer

C is for C, 36 characters → Score: 37

share|improve this answer
You can drop 2 characters by assuming a (argc) equals one rather than having to initialize it. – Joey Adams Apr 18 '11 at 22:35
But this doesn't even compile... – dcousens Apr 24 '11 at 14:33
Best I could get to compile was 59, or 42 without the include: #include<stdio.h> main(){for(int a=27;--a;)putchar(96+a);} – dcousens Apr 24 '11 at 14:41
Daniel, it works with MSVC 10 here. – Joey Apr 24 '11 at 20:51

S is for Scala, 16 chars => score 21


18 chars => score 23


22 chars => score 27

('a'to'z')map(print _)

share|improve this answer

B is for bc - 2 + 28 = 30

share|improve this answer

W is for Windows PowerShell, 22 characters → Score: 40

share|improve this answer
Hmm, not sure whether to make this W or P. – Joey Adams Apr 18 '11 at 21:11
Technically it's W, since the correct name of the language (and product) is Windows PowerShell. Yes, it bugs me too. – Joey Apr 18 '11 at 21:12

L is for Logo, 26 characters → Score: 30

for[i 97 122][type char i]
share|improve this answer

T is for Thue, 35 characters → Score: 39

share|improve this answer

A is for AppleScript, 41 -> Score: 52

display alert"abcdefghijklmnopqrstuvwxyz"
share|improve this answer
I know this is a long time since posting, but you can use "abcdefghijklmnopqrstuvwxyz", since the return value is output to the results pane. – VTCAKAVSMoACE Feb 3 at 20:45

M for Matlab, 13 chars, Score 19


M for Matlab, 18 chars, Score 24

share|improve this answer
I don't have matlab at hand but I think you need disp(..) to prevent this outputting ans = . – Nabb Apr 24 '11 at 6:06
Correct, changed in the answer. – jpjacobs Apr 26 '11 at 8:31

B is for BrainF***, 38 + 9 = 47


Can be reduced to 31+9 = 40, if cells wrap around at 256:

share|improve this answer

B is for Bash: 4 + 16 = 20 or 15

printf %s {a..z}

or just:

echo {a..z}

if output of the form a b c ... is allowed (as seen in many other answers).

share|improve this answer
I don't think so. Linefeed is optional, output is "abcdefghijklmnopqrstuvwxyz" – user unknown Apr 19 '11 at 4:30

I is for Inform 6, 41 + 6 = 47

[Main i;for(i=26:i--:)print(char)'z'-i;];
share|improve this answer

U is for Unlambda - 8 + 79 = 87

share|improve this answer

J is for J, 14 characters -> Score: 15

echo u:97+i.26
share|improve this answer
Why bother with echo? u:97+i.26 is a complete J program. – Gregory Higley Apr 26 '11 at 5:34
Because that has no output when run as a script (for me, anyway). – Jesse Millikan Apr 26 '11 at 6:06

H is for Haskell, 21 characters → Score: 28

share|improve this answer

Your Answer


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.