Tell me more ×
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.

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

Output:

abcdefghijklmnopqrstuvwxyz

(trailing newline optional)

Rules:

  • 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
12  
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
3  
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
show 9 more comments

59 Answers

1 2

m4

abcdefghijklmnopqrstuvwxyz

(Hey, shinh lists it as a supported language)

share|improve this answer

C, 36 characters → Score: 37

main(a){for(;++a<28;)putchar(95+a);}
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... – Daniel 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);} – Daniel Apr 24 '11 at 14:41
Daniel, it works with MSVC 10 here. – Joey Apr 24 '11 at 20:51

H is for Haskell, 21 characters → Score: 28

main=putStr['a'..'z']
share|improve this answer

Xtal

"abcdefghijklmnopqrstuvwxyz".p;
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 golf.shinh.org: code.google.com/p/xtal-language , you can see some post-mortems at golf.shinh.org/l.rb?xtal – ninjalj Apr 18 '11 at 23:48

E, 28 characters → Score: 29

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

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

(print"abcdefghijklmnopqrstuvwxyz")
share|improve this answer

L#, 28 characters → Score: 30

"abcdefghijklmnopqrstuvwxyz"
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

97[$123\>][$,1+]#
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

main(a){for(;a++<27;putch(95+a));}
share|improve this answer
1  
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

G is for Groovy 25 -> Score: 31

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

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

.Q.a 

Output:

"abcdefghijklmnopqrstuvwxyz"

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:

`$.Q.a

Output:

`abcdefghijklmnopqrstuvwxyz
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

BEGIN{for(i=96;i++<122;)printf"%c",i}
share|improve this answer

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

echo abcdefghijklmnopqrstuvwxyz
share|improve this answer

PHP, 26 characters -> Score: 29

abcdefghijklmnopqrstuvwxyz
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

U is for Unlambda - 8 + 79 = 87

``````````````````````````.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.zr
share|improve this answer

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

printf("abcdefghijklmnopqrstuvwxyz")
share|improve this answer

Wake

all: "abcdefghijklmnopqrstuvwxyz"
share|improve this answer

Q is for QBasic, 29 characters → Score: 35

?"abcdefghijklmnopqrstuvwxyz"

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

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

print''.join(map(chr,range(97,123)))

Not the shortest...

share|improve this answer

Tcl - 31 + 3 = 34

puts abcdefghijklmnopqrstuvwxyz
share|improve this answer

vimscript

What does output mean?

Assuming output to the current vim buffer is ok:

:norm aabcdefghijklmnopqrstuvwxyz

Otherwise, output to stdout:

:!echo abcdefghijklmnopqrstuvwxyz
share|improve this answer

Groovy:(JVM Language)

println 'a'..'z' 

Edit, This doesn't work, it produces the following output:

[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]

not the required output:

abcdefghijklmnopqrstuvwxyz
share|improve this answer

R for R, 8 characters → Score: 9

Using built in array of chars but there isn't rule that disallow it.

letters
share|improve this answer
This does not produce the required output format. The existing R answer has to work around it by using cat. – Joey Adams Mar 7 '12 at 20:54

V is for VBA - 43 (40+3) or 32 (29+3)

(formatted to run in the immediate window)

40 chars

For b=65 To 90:c=c & Chr(b):Next:Print c

And shorter, but no thinking involved:

29 chars

?"abcdefghijklmnopqrstuvwxyz"
share|improve this answer

PHP 26 + 3 = 29

<?=implode('',range(a,z));
share|improve this answer
1 2

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.