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.

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

84 Answers 84

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

L is for LUA: 3 + 40 = 43

repeat n=1+(n or 96)print(("%c"):format(n))until(n>122)

-> 55

repeat n=1+(n or 96)print(string.char(n))until(n>122)

-> 53

for i=97,122 do print(string.char(i))end

-> 40

share|improve this answer
Please keep the code blocks clean, so user scripts like Code Golf UserScript Enhancement Pack which insert code block sizes in the document can show correct values. I mean, please post separate solutions in separate code blocks and specify the code length outside the code block. – manatwork Oct 20 '14 at 10:17
Thanks. This way is much easier to spot out count mistakes: Seems you included in both cases the final newline character in the count. That is unnecessary. – manatwork Oct 20 '14 at 10:29
@manatwork do you happen to have that userscript lying around anywhere...? the dl link is borked :/ – cat Dec 23 '15 at 19:20
Sorry @cat, I used to mention that one in the comments, as I consider it the official one, but I use a simple one written for my own need. – manatwork Dec 23 '15 at 19:34

P is for PostScript, 29 chars → Score: 39

share|improve this answer

B, 45 -> Score: 46

main(){auto i;i=95;while(i++<122)putchar(i);}
share|improve this answer



(Hey, shinh lists it as a supported language)

share|improve this answer


share|improve this answer
Awesome, thanks for filling in X with something interesting! I guess you mean Gnu Xtal System (found with a Google search), but I'm not sure. Could you add a link? – Joey Adams Apr 18 '11 at 23:37
It's actually Xtal as used in , you can see some post-mortems at – ninjalj Apr 18 '11 at 23:48

E, 28 characters → Score: 29

for x in 0..25{print('a'+x)}
share|improve this answer

Q is for QBasic, 29 characters → Score: 35


Untested, but programming is like riding a bike, right?

share|improve this answer
You can get injured while riding a bike. I dare you to drop that space before the quotation mark. – Joey Adams Apr 18 '11 at 22:38
Nah, that would look too much like "optimized" BASIC programs... – ninjalj Apr 18 '11 at 22:43
You can use ? instead of print ... – Joey Apr 18 '11 at 23:06
Feel free to edit, I haven't programmed in BASIC for more than a decade. – ninjalj Apr 18 '11 at 23:11
Done :-). Tested now, even. – Joey Apr 18 '11 at 23:42

N is for newLISP, 35 characters -> Score: 42

share|improve this answer

L#, 28 characters → Score: 30

share|improve this answer

Z is for zsh, 31 characters -> Score: 38

echo abcdefghijklmnopqrstuvwxyz
share|improve this answer

F is for False, 17 characters -> Score: 22

share|improve this answer

U is for Unicon, 50 + 6 = 56

procedure main();every writes(char(97 to 122));end
share|improve this answer

c,34 characaters -> score : 35

share|improve this answer
putch isn't in standard C, and isn't present on my system. Thus, I'm not going to add this to the rankings, at least not under C. Arguably, you could change the language name to "VC" (for (Microsoft) Visual C) and put it under V ;-) – Joey Adams Apr 20 '11 at 16:35
@Joey: Shouldn't any C example be classified under the compiler name, then? – Joey Apr 24 '11 at 21:11
@Joey, @avinashse: I went ahead and reluctantly added this to the scoreboard. – Joey Adams Apr 25 '11 at 18:10
talking about vc++... if you set the entry point to f and the subsystem to console, you get a breathtaking 1 + 30 = 31 f(a){26-a&&f(putch(a+97)-96);} :) – bebe Jul 14 '14 at 20:13

G is for Groovy 25 -> Score: 31

('a'..'z').each{print it}
share|improve this answer

Q is for Q (4 characters) -> Score 5




If this isn't valid base don the rules I'm afraid Q doesn't actually permit strings to be outputted. The closest it can get is to cast as a symbol:



share|improve this answer
What is the Q programming language? Could you provide a link? – Joey Adams Mar 7 '12 at 16:58
Yeah sure here is a link to the wikipedia page for the language, and the trial version can be downloaded here for personal/non-commercial use. – sinedcm Mar 8 '12 at 12:29
Nice find! I really want to put this on the scoreboard and accept it, but it doesn't match the required output format. Is there a way to get rid of the quote characters? The current winner has a score of 13, so you have 7 characters of breathing room. – Joey Adams Mar 8 '12 at 14:28
Unfortunately it isn't possible in Q, How about a 2 point penalty for the extra characters in the output? :) – sinedcm Mar 8 '12 at 16:43
For 8 characters, -1@.Q.a; – slackwear May 30 '12 at 14:25

A is for awk: 37 characters -> score 40

share|improve this answer

Forth, 29 + 5 Score: 34

: a 123 97 do i emit loop ; a

Previous (Forth, 48 + 5 Score: 53 (unclean score = 48))

: a 97 begin dup emit 1 + dup 123 = until drop ;

This is the clean version.

: a 97 begin dup emit 1 + dup 123 = until ;

The second one leaves stuff on the stack.

abcdefghijklmnopqrstuvwxyz  ok
share|improve this answer
Or even : b ." abcdefghijklmnopqrstuvwxyz" ; at 36 characters – leancz Dec 16 '13 at 12:17
If uppercase output were permitted then you could drop a character with 91 65 do ... I have to say you should probably include the word a (+2 chars) at the end of your line for these to be "programs", otherwise nothing is actually executed or printed. :( I do like golfing in Forth but it often carries that penalty! – Darren Stone Dec 17 '13 at 9:46
@DarrenStone OK, I've changed it - I do wonder about that though as I see, for example C source code in code golf that would also not print anything without being compiled and executed at a command line. I'm just starting out at code golf and trying to remember Forth from my youth. It is fun. – leancz Dec 17 '13 at 10:12
Yeah, it sucks that control structures (IF, LOOP, etc.) can't be used in interpreted mode, only in a word definition. Shaving down your string constant idea, the following would be a program and requires no word definition/execution penalty. ." abcdefghijklmnopqrstuvwxyz" Unfortunately, it's 30 chars! Happy Forthing! – Darren Stone Dec 17 '13 at 10:21

A is for APL, 9 characters → Score: 12


Take the first 43 characters from ⎕av, then drop the first 17 of those.

(Tested in Dyalog APL)

share|improve this answer
Are you sure this works in a version of Dyalog that predates the question? – lirtosiast Feb 3 at 20:53
I checked via what the current version was in February, 2011, which was 12.1. Checking the manual for that shows that ⎕av was a feature, so it should work. – Koneke Feb 3 at 21:30
Sounds good; I'd appreciate if you test it though. – lirtosiast Feb 3 at 21:38
Couldn't get hold of a 12.1 myself, but I asked the developers of Dyalog, and they tried it and confirmed that it worked the same all the way back to 10.0, which should be well before the question was posted :) – Koneke Feb 4 at 12:20

G is for GP, 30 characters -> score 32


If I stole the 36-character C code I could submit it as a score-40 submission for PARI -- though maybe at that point I'd be required to #include <pari/pari.h> at the painful cost of an additional 23 characters.

I'm too embarrassed to submit


which would be printed in gp.

share|improve this answer

B is for Batch File, 31 characters → Score: 41

echo abcdefghijklmnopqrstuvwxyz
share|improve this answer

PHP, 26 characters -> Score: 29

share|improve this answer

Ada, 92 characters -> Score: 95

with ada.text_io;use ada.text_io;procedure a is begin put("abcdefghijklmnopqrstuvwxyz");end;
share|improve this answer

F is for F#, 36 characters -> Score: 38

share|improve this answer


all: "abcdefghijklmnopqrstuvwxyz"
share|improve this answer

E, 26 characters → Score: 27

for x in'a'..'z'{print(x)}

This is based off Joey's answer.

share|improve this answer

Python 36+6 = 42


Not the shortest...

share|improve this answer

Tcl - 31 + 3 = 34

puts abcdefghijklmnopqrstuvwxyz
share|improve this answer

C++, 32 + 3penalty = 35

I could not find C++. So this is my option for it:

char a=96;while(a++<122)cout<<a;

the output is:


PS. It's my first golf, pls comment if i did something wrong

share|improve this answer

P is for posting an answer way too late Powershell

19 + 10 = 29

Because I'm bored at the moment, I hope you don't mind if I put up a quick PS that wouldn't have contended anyways...


Simple char typecasting. You can shave off one byte by doing the alphabet in all caps.

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.