74
\$\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.
  • 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\$
9
  • 1
    \$\begingroup\$ Are we allowed to print junk to stderr? \$\endgroup\$ Commented Apr 18, 2011 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
    Commented Apr 18, 2011 at 22:05
  • \$\begingroup\$ Is it OK to print the alphabet IN BIG LETTERS? \$\endgroup\$
    – SE is dead
    Commented Jun 21, 2016 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
    Commented Mar 23, 2017 at 19:53
  • 7
    \$\begingroup\$ Is *0*5AB1E the same as *o*sabie :P? \$\endgroup\$ Commented Jun 6, 2019 at 14:58

164 Answers 164

2
\$\begingroup\$

B is for Brachylog, 2 bytes → Score: 11

Ạẉ

Try it online!

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

C is for Cubix, 15 bytes, Score -> 20

uo)U"z`"-?@./;/

Try it online!

Cubified

    u o
    ) U
" z ` " - ? @ .
/ ; / . . . . .
    . .
    . .

Watch it run

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

K is for Keg, 3 + 3 bytes - > 6

azɧ

Try it online!

It seems that the rule disallowing newer languages to be posted has been removed. Let me know if this is somehow invalid.

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

T is for Triangular, 19 bytes → 19+10 = 29

,5,D@"*i.jC>"dj>F+/

Try it online!

Ungolfed:

     , 
    5 , 
   D @ " 
  * i . j 
 C > " d j 
> F + /

The process here is,

  • Push 65
  • Push 27
  • j is a conditional NorthWest IP switch; it changes to NW if the top value of the stack is not 0. This means we have the equivalent of looping from 26 to 0 (because we decrement prior to entering the loop)
  • Decrement → j → Swap top 2 stack values → Print, don't pop → Increment → Swap → Repeat

This turns out to be 1 byte shorter with capital letters than lower case due to 97 being prime.

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

M is for MAWP, 20 characters - Score: 24

[!43W8WM;1M!93WA?.%]

Explanation:

[        start of loop
!        duplicate top of stack
43W8W    push 96 to stack (4*3*8)
M        add 96 to number below
;        output top of stack as ASCII char
1M       add 1 to top of stack
!        duplicate top of stack
93W      push 27 to stack (9*3)
A        Difference of top two stack values
?.       is equal to zero, then terminate program
%        pop top of stack
]        end of loop
\$\endgroup\$
2
\$\begingroup\$

X is for x86-16 MS-DOS machine code - 16 bytes

This is hexdump from .COM file :

00000000  b4 02 b9 1a 00 b7 61 8a  d7 cd 21 fe c7 e2 f8 cd  |......a...!.....|
00000010  20                                                | |
00000011

Code I wrote :

.model small
.code
org 100h

start:

    mov ah, 02h
    mov cx, 26 
    mov bh, 97

.loop:
    mov dl, bh
    int 21h
    inc bh
    loop .loop
    int 20h

end start

I use DOSBOX to run this proram

enter image description here

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

P is for Python 3, 32 chars -> Score: 38

print('%c'*26%(*range(97,123),))

Using uppercase letters, this can be made shorter

print('%c'*26%(*range(65,91),))

This is based in my 2011 answer which is before Python 3.5 added starred tuple unpacking, making it smaller that that one....

EXCEPT for Python 2 also got a smaller version today which is unbeatable :)

Unless Python adds range expressions to the language, which I am proposing here

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

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

echo abcdefghijklmnopqrstuvwxyz
\$\endgroup\$
1
\$\begingroup\$

Ada, 92 characters -> Score: 95

with ada.text_io;use ada.text_io;procedure a is begin put("abcdefghijklmnopqrstuvwxyz");end;
\$\endgroup\$
1
\$\begingroup\$

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

printf("abcdefghijklmnopqrstuvwxyz")
\$\endgroup\$
1
\$\begingroup\$

E, 26 characters → Score: 27

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

This is based off Joey's answer.

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

Tcl - 31 + 3 = 34

puts abcdefghijklmnopqrstuvwxyz
\$\endgroup\$
1
  • \$\begingroup\$ My shortest iterative is longer, 45 :time {puts [format %c [expr [incr i]+96]]} 26 \$\endgroup\$
    – sergiol
    Commented Jul 21, 2017 at 18:41
1
\$\begingroup\$

P is for PHP - 33 characters - Score: 36

echo implode("",range("a", "z"));
\$\endgroup\$
0
1
\$\begingroup\$

C++: 32+3 = 35

char c=96;while(c++<122)cout<<c;
\$\endgroup\$
2
  • \$\begingroup\$ I almost want to score this as 32, given that your code contains "c++". Alas, I didn't put this in the original rules. \$\endgroup\$
    – Joey Adams
    Commented Jul 15, 2014 at 20:44
  • \$\begingroup\$ @JoeyAdams You're right, I corrected it :) \$\endgroup\$
    – padawan
    Commented Jul 15, 2014 at 21:00
1
\$\begingroup\$

U is for Unix Shell, 21 Characters → Score: 31

echo {a..z}|tr -d " "
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I think printf '%s' {a..z} would shave off some chars \$\endgroup\$ Commented Jun 21, 2020 at 6:04
1
\$\begingroup\$

V is for VBScript, 40 Characters → Score: 48

for i=97 to 122:a=a+chr(i):next:MsgBox a
\$\endgroup\$
1
\$\begingroup\$

P is, in fact, for PHP - 23 chars / 27 score

<?=join('',range(a,z));
\$\endgroup\$
1
\$\begingroup\$

C is for Clojure - (39 or 53) + 7 = 46 or 60

No, it doesn't stand for C. In Clojure, all functions form closures, so I would argue this is a complete answer, in 39 bytes.

(doseq[c(range 97 123)](print(char c)))

But if you really want it with the main function, 53 bytes.

(defn -main[](doseq[c(range 97 123)](print(char c))))

But, this isn't a Clojuric way to solve this problem. Let's try something simpler (could be golfed for 4 bytes).

(print (apply str (map char (range 97 123))))

Much better, isn't it?

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

N is for Nu, 35 Characters → Score: 37

(puts 'abcdefghijklmnopqrstuvwxyz')
\$\endgroup\$
1
\$\begingroup\$

N is for Nim, 31 → Score: 34

for x in'a'..'z':stdout.write x
\$\endgroup\$
1
\$\begingroup\$

Mouse, 26 + 5 = 31

97a:(a.123<^a.&DUP !'1+a:)

Which outputs:

abcdefghijklmnopqrstuvwxyz

Note the lame way would be:

"abcdefghijklmnopqrstuvwxyz"

Which gets printed implicitly immediately (as string literals do, unfortunately), but it's 28 bytes.

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

J is for Java - score: 84 characters + 4 = 88

interface a{static void main(String[]A){for(char c=65;c<91;System.out.print(c++));}}

This prints ABCDEFGHIJKLMNOPQRSTUVWXYZ instead of abcdefghijklmnopqrstuvwxyz. If it's disallowed, one can simply set c to 97 (a) and loop until it reaches 123 ({) at the cost of one extra byte:

interface a{static void main(String[]A){for(char c=97;c<123;System.out.print(c++));}}
\$\endgroup\$
1
\$\begingroup\$

V for VBA: 60

Sub VforVBA()
For i=1 To 26: a=a & Chr(64+i): Next: Debug.Print a
End Sub
\$\endgroup\$
5
  • 1
    \$\begingroup\$ Can you remove any of the spaces between the tokens? E.g. For i=1To26:a=a&Chr(64+i):Next:Debug.Print a \$\endgroup\$
    – Joey Adams
    Commented Jul 15, 2014 at 17:44
  • \$\begingroup\$ @JoeyAdams edited as suggest \$\endgroup\$
    – Alex
    Commented Jul 15, 2014 at 22:00
  • 1
    \$\begingroup\$ Did you test this? Is "Fori" treated as "For i"? \$\endgroup\$
    – Joey Adams
    Commented Jul 16, 2014 at 13:52
  • 1
    \$\begingroup\$ @joeyAdams Yea you're correct, indeed the 1To26 and other parts won't work as well. I have changed it back to origin answer \$\endgroup\$
    – Alex
    Commented Jul 16, 2014 at 14:08
  • \$\begingroup\$ @Alex I think you can remove some spaces (i = 1, : a = a & Chr(64 + i), : Next: Debug) \$\endgroup\$ Commented Aug 3, 2016 at 9:54
1
\$\begingroup\$

S is for seed7, 137 114 78 characters → Score: 83

const proc: main is func begin writeln("abcdefghijklmnopqrstuvwxyz");end func;
\$\endgroup\$
0
1
\$\begingroup\$

F is for Funge → 19 chars + 5 = 24

'\`#;1+::,"@9"+\`#@_;

Something that makes this unique is that it doesn't contain a single letter of the alphabet! Hence why I didn't shorten it by replacing "@9"+ with 'y. I'll take the points hit for it.

Try it with my interpreter here: BefungeSharp.

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

Python, 36 + 6 = 42

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

Not the shortest...

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

R, 26 bytes (score 27)

paste(letters,collapse="")

Output:

[1] "abcdefghijklmnopqrstuvwxyz"
\$\endgroup\$
1
\$\begingroup\$

Y is for Yorick, 30+6 bytes → 36

system,"echo {a..z}|tr -d ' '"
\$\endgroup\$
1
\$\begingroup\$

Z is for Zsh, 21+3 → 24 bytes

echo {a..z}|tr -d ' '

Try It Online!

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

B is for Bash, 11 -> 15 24

echo {a..z}

echo {a..z}|tr -d \ 
                   ^
                 space
\$\endgroup\$
3
  • 3
    \$\begingroup\$ Already posted by Eelvex, but sadly it is not valid, because not produces the exact required output. \$\endgroup\$
    – manatwork
    Commented Apr 27, 2016 at 15:17
  • \$\begingroup\$ Don't take it the wrong way. Keep trying, keep posting. If you found this independently, you're very good. In the future, try answering less popular challenges. :-) \$\endgroup\$
    – wizzwizz4
    Commented Apr 28, 2016 at 16:59
  • \$\begingroup\$ ETHproductions, done. \$\endgroup\$
    – Scotow
    Commented Jan 27, 2018 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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