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

0
\$\begingroup\$

vimscript

What does output mean?

Assuming output to the current vim buffer is ok:

:norm aabcdefghijklmnopqrstuvwxyz

Otherwise, output to stdout:

:!echo abcdefghijklmnopqrstuvwxyz
\$\endgroup\$
0
\$\begingroup\$

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
\$\endgroup\$
0
\$\begingroup\$

AWK,33+3(Penalty)

END{for(;i<26;)printf"%c",97+i++}
\$\endgroup\$
0
\$\begingroup\$

J is for Java: 4 + 157 = 161

package alphabet;

public class Alphabet {
 public static void main(String[] args) {
  for(char c = 'a'; c <= 'z'; c++){
   System.out.print(c);
  }        
 }    
}
\$\endgroup\$
  • 3
    \$\begingroup\$ Please note that code-golf challenges are not about nice code and good habits. Your code could be shortened by removing indentation, using shorter variable names, but first of all, by forgetting packaging. See Tips for golfing in Java for more. In meantime a 96 character version of your code: public class A{public static void main(String[]a){for(char c='a';c<'{';)System.out.print(c++);}}. \$\endgroup\$ – manatwork Oct 20 '14 at 10:10
  • 1
    \$\begingroup\$ @manatwork You can golf that some more by removing the public before the class, and changing 'a' to 97. \$\endgroup\$ – Kevin Cruijssen Feb 3 '17 at 7:46
0
\$\begingroup\$

T is for TI-BASIC, 27 + 8 = 35

"ABCDEFGHIJKLMNOPQRSTUVWXYZ

Can be run from command line, as a standalone program, or called as a function.

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

S is for Scala, Score: 40

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

D is for D2, 2 + 6 = 8 (non-competing)

!a[.+]

Non-competing because D2 is newer than the challenge.

!a expand to 10 +, setting the current cell to 10 (a in base 36), and [.+] print the current cell as a base 36 string and increment the cell. Since the maximum value a cell can hold is 35, at 36 the cell is zeroed and the loop stop.

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

S is for Swift, 98 characters -> Score: 103

var my_string=""
for i in 97...122{my_string.append((Character(UnicodeScalar(i))))}
print(my_string)
\$\endgroup\$
  • 1
    \$\begingroup\$ Isn't it easier to just print a string containing the alphabet? \$\endgroup\$ – acrolith Oct 21 '16 at 16:41
  • \$\begingroup\$ Of course, but that just wouldn't be as fun \$\endgroup\$ – heratyian Oct 21 '16 at 17:57
0
\$\begingroup\$

B is for Bash, 25 bytes

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

(21 bytes of code plus 4 for the language name)

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

B is for Braingolf, 12 + 9 = 21 bytes [non-competing]

5*#a[!@ 1+];

Try it online!

Explanation

5*#a[!@ 1+];
5*            Push 5, monadic multiply, square 5
  #a          Push charcode of a
    [.....]   Do-while loop, will run 26 times
     !@       Print last item on stack as char without popping
        1+    Increment last item on stack
\$\endgroup\$
  • \$\begingroup\$ You need to add the length of the language name to your score. \$\endgroup\$ – Wossname Jun 5 '17 at 9:18
  • \$\begingroup\$ Ah yeah missed that \$\endgroup\$ – Skidsdev Jun 5 '17 at 9:19
0
\$\begingroup\$

R is for REXX, 15 characters → Score: 19

say xrange(a,z)
\$\endgroup\$
0
\$\begingroup\$

U is for uBASIC, 36 bytes → Score: 42

1 PRINT "abcdefghijklmnopqrstuvwxyz"

Try it online!

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

V is for VBA, 28 + 3 = 31

Anonymous VBE immediate window function that takes no input and outputs abcdefghijklmnopqrstuvwxyz to the VBE immediate window.

The two solutions below are of equal length and produce the same output

For i=97To 122:?Chr(i);:Next

Or

?"abcdefghijklmnopqrstuvwxyz
\$\endgroup\$
0
\$\begingroup\$

U is for uBASIC, 30 + 6 = 36

Anonymous function that takes no input and outputs abcdefghijklmnopqrstuvwxyz

0?"abcdefghijklmnopqrstuvwxyz"

Try it online!

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

S is for SmileBASIC, 27 bytes + 10 = 37

FOR I=65TO 90?CHR$(I);
NEXT

Prints the alphabet in uppercase. (I'm not sure whether this is allowed, but other people are doing it so...)

Just 1 character shorter than the (even more) boring answer:

?"abcdefghijklmnopqrstuvwxyz
\$\endgroup\$
0
\$\begingroup\$

F is for FALSE, 15 bytes +5 = 20

97[$'{-][$,1+]#

Doesn't use any letters!

Explanation:

97 {push 97 (ASCII for 'a')}
  [ {function start}
   $'{- {subtract '{' from the current letter}
       ] {function end}
        [ {function start}
         $, {print the current letter}
           1+ {add 1}
             ] {function end}
              # {while loop. Run the second function while the first doesn't return 0}
\$\endgroup\$
0
\$\begingroup\$

JavaScript, 34 + 10 = 44

alert('abcdefghijklmnopqrstuvwxyz')
\$\endgroup\$
0
\$\begingroup\$

PHP, 26 + 3 = 29

<?=implode('',range(a,z));
\$\endgroup\$
0
\$\begingroup\$

Racket, 46 bytes (score 52)

(for((i 26))(display(integer->char(+ i 97))))
\$\endgroup\$
0
\$\begingroup\$

I is for ICI, 37+3 bytes → 40

printf("abcdefghijklmnopqrstuvwxyz");
\$\endgroup\$
0
\$\begingroup\$

I is for Io, 35+2 bytes → 37

"abcdefghijklmnopqrstuvwxyz"println
\$\endgroup\$
0
\$\begingroup\$

Y is for Yorick, 30+6 bytes → 36

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

Z is for Zsh, 21+3 → 24 bytes

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

Try It Online!

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

Q is for QBIC, 18 bytes, score 22 (non-competing)

[97,122|?chr$(a)';

Added '; to suppress newlines between PRINT statements.

\$\endgroup\$
  • 1
    \$\begingroup\$ I've added the (non-competing) marker to your header because the challenge explicitly states that languages used must have existed as of 18 Apr 2011. (Please correct me if the language is in fact old enough) \$\endgroup\$ – ETHproductions Jan 27 '18 at 19:02
  • \$\begingroup\$ @ETHproductions I didn't feel it was necessary because that clause is a kind of 'standard loophole', and one we've explicitly allowed in the recent past. But if you think new languages are NC when old questions specify so, I'll accept it. \$\endgroup\$ – steenbergh Jan 29 '18 at 18:19
0
\$\begingroup\$

H if for HTML -> 4+31

<HTML/>abcdefghijklmnopqrstuvwxyz

ps: browser will interpret the missing end tag

\$\endgroup\$
  • 1
    \$\begingroup\$ ABCDEFGHIJKLMNOPQRSTUVWXYZ is far better at 30. \$\endgroup\$ – Erik the Outgolfer Aug 3 '16 at 9:52
0
\$\begingroup\$

A is for Ahead, 7 characters -> Score: 12

"az"EW@

Try it online!

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

Z is for Z80Golf, 9 bytes + 7 = 16

00000000: 3e61 061a ff3c 10fc 76                   >a...<..v

Try it online!

According to the Web Archive, Z80Golf code golf machine was created (at least) in December 2007.

Disassembly

start:
  ld a, 97  ; the char to print
  ld b, 26  ; loop count
loop:
  rst $38   ; 1-byte alias for putchar
  inc a
  djnz loop ; decrement b and jump to `loop` if nonzero
  halt      ; end program
\$\endgroup\$
0
\$\begingroup\$

C is for Cubix, 15 bytes, Score -> 20 (non-competing)

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

Try it online!

Cubified

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

Watch it run

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

C is for Common Lisp, Score 35 + 11 => 46

(princ"abcdefghijklmnopqrstuvwxyz")

Try it online!

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

Runic Enchantments, 15 + 5 = 20

'a:$1+k:'{(3*?;

Try it online!

Despite what TIO calls it, the "Enchantments" part of is what I was intending to use the language for and is not actually part of the language's name (its just what I called the original project and git repot).

Does not score better than the existing Ruby leader (at 17), but still pretty good. The main two killers are all the necessary ToS dups and the 3* to skip over the stack initializer. 'a:$1+k:'{(?;2? is the same length, just makes the initializer-skip more apparent.

\$\endgroup\$
  • \$\begingroup\$ You could always ask Dennis to change the name \$\endgroup\$ – Jo King Jun 7 at 6:26
  • \$\begingroup\$ It literally wasn't important enough until this answer. Even now I'm kind of "eh" about having it changed. \$\endgroup\$ – Draco18s Jun 7 at 16:43

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.