65
\$\begingroup\$

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

uppercase and 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.

Automatic leaderboard (experimental)

var QUESTION_ID=2078;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&r.indexOf('non-competing')===-1&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],lang:/<a/.test(a[1])?jQuery(a[1]).text():a[1],link:s.share_link})}),e.sort(function(e,s){var d=e.lang[0].toLowerCase(),a=s.lang[0].toLowerCase();return(d>a)-(d<a)||e.size-s.size});var s={},a=null,n="A";e.forEach(function(e){n=e.lang[0].toUpperCase(),a=e.size;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+" is for").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.lang,p=o[0].toUpperCase();s[p]=s[p]||{language:e.language,lang:e.lang,letter:p,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return(e.letter>s.letter)-(e.letter<s.letter)});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.language).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),jQuery("#languages").append(jQuery(i))}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*(?:<[^>]+>)?(?:[^]+?for )?((?:<a[^>]*?>)?(?:(?! [(=→-])[^\n,:])*[^\s,:])(?:[,:]| [(=→-]).*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} /* font fix */ body {font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;} /* #language-list x-pos fix */ #answer-list {margin-right: 200px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Winners by Letter</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <h2>Everything</h2> <table class="answer-list"> <thead> <tr><td></td><td>Language</td><td>Author</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

\$\endgroup\$
  • \$\begingroup\$ Are we allowed to print junk to stderr? \$\endgroup\$ – Peter Taylor Apr 18 '11 at 22:02
  • \$\begingroup\$ @Peter Taylor: Go nuts. To answer your question, yes, printing junk to stderr is fine (as long as stdout is correct). \$\endgroup\$ – Joey Adams Apr 18 '11 at 22:05
  • \$\begingroup\$ Is it OK to print the alphabet IN BIG LETTERS? \$\endgroup\$ – dorukayhan Jun 21 '16 at 18:25
  • \$\begingroup\$ Funge is distinct from Befunge. Surely my pedanticism will be rewarded on a site dedicated to feats of it! \$\endgroup\$ – tngreene Mar 23 '17 at 19:53
  • \$\begingroup\$ Is anyone going to update the rankings? \$\endgroup\$ – 12Me21 Feb 1 '18 at 15:17

120 Answers 120

3
\$\begingroup\$

S is for Scheme, 37 -> Score: 43

(display"abcdefghijklmnopqrstuvwxyz")
\$\endgroup\$
3
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – manatwork Oct 20 '14 at 10:17
  • 1
    \$\begingroup\$ Thanks. This way is much easier to spot out count mistakes: i.stack.imgur.com/qezQZ.png Seems you included in both cases the final newline character in the count. That is unnecessary. \$\endgroup\$ – manatwork Oct 20 '14 at 10:29
  • \$\begingroup\$ @manatwork do you happen to have that userscript lying around anywhere...? the dl link is borked :/ \$\endgroup\$ – cat Dec 23 '15 at 19:20
  • \$\begingroup\$ 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. \$\endgroup\$ – manatwork Dec 23 '15 at 19:34
  • \$\begingroup\$ You can remove 2 bytes (and obfuscate) by using ("").char in place of string.char. \$\endgroup\$ – cyclaminist Dec 23 '18 at 12:52
2
\$\begingroup\$

P is for PostScript, 29 chars → Score: 39

(abcdefghijklmnopqrstuvwxyz)=
\$\endgroup\$
2
\$\begingroup\$

B, 45 -> Score: 46

main(){auto i;i=95;while(i++<122)putchar(i);}
\$\endgroup\$
2
\$\begingroup\$

E, 28 characters → Score: 29

for x in 0..25{print('a'+x)}
\$\endgroup\$
2
\$\begingroup\$

Q is for QBasic, 29 characters → Score: 35

?"abcdefghijklmnopqrstuvwxyz"

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

\$\endgroup\$
  • \$\begingroup\$ You can get injured while riding a bike. I dare you to drop that space before the quotation mark. \$\endgroup\$ – Joey Adams Apr 18 '11 at 22:38
  • \$\begingroup\$ Nah, that would look too much like "optimized" BASIC programs... \$\endgroup\$ – ninjalj Apr 18 '11 at 22:43
  • 2
    \$\begingroup\$ You can use ? instead of print ... \$\endgroup\$ – Joey Apr 18 '11 at 23:06
  • \$\begingroup\$ Feel free to edit, I haven't programmed in BASIC for more than a decade. \$\endgroup\$ – ninjalj Apr 18 '11 at 23:11
  • 1
    \$\begingroup\$ You can drop the last quotation mark - QBasic will fix that for you! \$\endgroup\$ – steenbergh Dec 23 '18 at 9:07
2
\$\begingroup\$

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

(print"abcdefghijklmnopqrstuvwxyz")
\$\endgroup\$
2
\$\begingroup\$

L#, 28 characters → Score: 30

"abcdefghijklmnopqrstuvwxyz"
\$\endgroup\$
2
\$\begingroup\$

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

echo abcdefghijklmnopqrstuvwxyz
\$\endgroup\$
2
\$\begingroup\$

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

97[$123\>][$,1+]#
\$\endgroup\$
2
\$\begingroup\$

U is for Unicon, 50 + 6 = 56

procedure main();every writes(char(97 to 122));end
\$\endgroup\$
2
\$\begingroup\$

c,34 characaters -> score : 35

main(a){for(;a++<27;putch(95+a));}
\$\endgroup\$
  • 2
    \$\begingroup\$ 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 ;-) \$\endgroup\$ – Joey Adams Apr 20 '11 at 16:35
  • \$\begingroup\$ @Joey: Shouldn't any C example be classified under the compiler name, then? \$\endgroup\$ – Joey Apr 24 '11 at 21:11
  • \$\begingroup\$ @Joey, @avinashse: I went ahead and reluctantly added this to the scoreboard. \$\endgroup\$ – Joey Adams Apr 25 '11 at 18:10
  • 1
    \$\begingroup\$ 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);} :) \$\endgroup\$ – bebe Jul 14 '14 at 20:13
2
\$\begingroup\$

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
\$\endgroup\$
  • \$\begingroup\$ What is the Q programming language? Could you provide a link? \$\endgroup\$ – Joey Adams Mar 7 '12 at 16:58
  • \$\begingroup\$ 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. \$\endgroup\$ – sinedcm Mar 8 '12 at 12:29
  • \$\begingroup\$ 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. \$\endgroup\$ – Joey Adams Mar 8 '12 at 14:28
  • \$\begingroup\$ Unfortunately it isn't possible in Q, How about a 2 point penalty for the extra characters in the output? :) \$\endgroup\$ – sinedcm Mar 8 '12 at 16:43
  • 1
    \$\begingroup\$ For 8 characters, -1@.Q.a; \$\endgroup\$ – skeevey May 30 '12 at 14:25
2
\$\begingroup\$

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"
\$\endgroup\$
  • 3
    \$\begingroup\$ You can crunch the loop method to 27+3 by using ? for print and ; to make it not insert a newline. for i=65to 90:?chr(i);:next \$\endgroup\$ – JesterBLUE Jul 15 '14 at 12:57
2
\$\begingroup\$

A is for awk: 37 characters -> score 40

BEGIN{for(i=96;i++<122;)printf"%c",i}
\$\endgroup\$
2
\$\begingroup\$

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.

a 
abcdefghijklmnopqrstuvwxyz  ok
\$\endgroup\$
  • \$\begingroup\$ Or even : b ." abcdefghijklmnopqrstuvwxyz" ; at 36 characters \$\endgroup\$ – leancz Dec 16 '13 at 12:17
  • \$\begingroup\$ 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! \$\endgroup\$ – Darren Stone Dec 17 '13 at 9:46
  • \$\begingroup\$ @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. \$\endgroup\$ – leancz Dec 17 '13 at 10:12
  • \$\begingroup\$ 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! \$\endgroup\$ – Darren Stone Dec 17 '13 at 10:21
2
\$\begingroup\$

A is for APL, 9 characters → Score: 12

17↓43↑⎕av

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

(Tested in Dyalog APL)

\$\endgroup\$
  • \$\begingroup\$ Are you sure this works in a version of Dyalog that predates the question? \$\endgroup\$ – lirtosiast Feb 3 '16 at 20:53
  • \$\begingroup\$ I checked via archive.org 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. \$\endgroup\$ – Koneke Feb 3 '16 at 21:30
  • \$\begingroup\$ Sounds good; I'd appreciate if you test it though. \$\endgroup\$ – lirtosiast Feb 3 '16 at 21:38
  • 1
    \$\begingroup\$ 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 :) twitter.com/dyalogapl/status/695184773266960384 \$\endgroup\$ – Koneke Feb 4 '16 at 12:20
2
\$\begingroup\$

G is for GP, 30 characters -> score 32

Strchr(vectorsmall(26,i,96+i))

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

"abcdefghijklmnopqrstuvwxyz"

which would be printed in gp.

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

A is for APL, 2 → 5

⎕a

Works on MicroAPL's APLX.

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

m4, 26 characters -> Score: 28

abcdefghijklmnopqrstuvwxyz

(Hey, shinh lists it as a supported language)

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

Xtal, 31 characters -> Score: 35

"abcdefghijklmnopqrstuvwxyz".p;
\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – Joey Adams Apr 18 '11 at 23:37
  • \$\begingroup\$ 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 \$\endgroup\$ – ninjalj Apr 18 '11 at 23:48
2
\$\begingroup\$

V is for Vim, 9+3 → Score: 12

:h<_<CR>LY<C-^>P

The screen must be exactly 66 characters wide, and 8 lines high. You can check this with tput cols and tput lines.

The program should be executed with:

echo>file.txt && /bin/vim -u NONE $'+normal :h<_\xALYZQP' '+wq' file.txt && cat file.txt

As discussed in this vim scoring meta post

\$\endgroup\$
  • 1
    \$\begingroup\$ Since a trailing newline is optional, you might as well drop the V to save a byte, and replace the p by P \$\endgroup\$ – oktupol Jan 25 '18 at 9:48
2
\$\begingroup\$

G is for Groovy, 25 -> Score: 31

('a'..'z').each{print it}
\$\endgroup\$
2
\$\begingroup\$

P is for Pyth, 1 -> Score: 5 (non-competing)

G

My language is too new to count, by the way.

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

C is (actually) for Cornflakes - Score: 11 (non-competing)

a

In Cornflakes, a adds the lowercase English alphabet to the stack & then implicitly outputs it.

\$\endgroup\$
  • 1
    \$\begingroup\$ I am marking this as non-compeating because cornflakes was made in 2016, and the question explicitly says that it has to be older than April 2011 \$\endgroup\$ – BlackCap Jan 27 '18 at 16:15
2
\$\begingroup\$

B is for Brainfuck, 42 Bytes + 9 = Score 51

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

Ungolfed and commented

+++++++++[>+++++++++++>+++<<-]  Leaves the tape with the values 99 and 27.
>--                             Subtracts 2 from 99 to make 97, the ASCII Code for an "a".
>-                              Subtracts 1 from 27 to make 26, the number of letters in the alphabet.
[-<.+>]                         Outputs the letter, adds 1 and decrements from the number of letters remaining.
                                When no letters are remaining, the loop Exits.
\$\endgroup\$
2
\$\begingroup\$

brainfuck, 60 -> 69

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

Try it online!

-2 bytes thanks to Dust

\$\endgroup\$
  • \$\begingroup\$ Consider doing the addition at the beginning (the first 3 chars) later in the code. You could golf 2 bytes with +++++[>+++++<-]>+>++++++++[>+++[>++++<-]<-]>>+<<<[>>>.+<<<-]. \$\endgroup\$ – Dust Jan 28 '18 at 9:09
2
\$\begingroup\$

B is for brainfuck, 32 31 + 9 = 40

-1 byte thanks to Jo King

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

Try it online!

-[>++>+<<-----]> is derived from the initialization part for 51 and generates the following layout: 102|51. The next part >----->+ changes this to 97|52 where 52 is double the amount of letters in the alphabet and 97 is the charcode of a. The final loop [<.+>--] prints a letter and increments the charcode and decrements the counter twice.

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

K is for Keg, 9 bytes -> Score: 12

a(|:,1+)

The control character 0x0C should be added between ( and |.

\$\endgroup\$
  • \$\begingroup\$ Is there supposed to be a trailing newline? I only count 8 bytes. \$\endgroup\$ – mbomb007 Jun 6 at 19:19
  • \$\begingroup\$ There should not be a trailing newline. \$\endgroup\$ – A _ Jun 7 at 2:03
  • \$\begingroup\$ By the way, the control character is the number of times the loop should be run. The control character 0x0C should be added between ( and |. The control characters cannot be put into this website, due to technical limitations. \$\endgroup\$ – A _ Jun 7 at 2:04
  • 1
    \$\begingroup\$ That should be explained in the answer itself. Please update it. \$\endgroup\$ – tripleee Jun 7 at 4:53
1
\$\begingroup\$

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

echo abcdefghijklmnopqrstuvwxyz
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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