title: Print the Greek alphabet!

text:
# Question
Title: Print the Greek alphabet!
Fairly obviously, you have to print the Greek alphabet. But I thought I'd make it slightly more interesting, so there's a twist: when your program is ran with an argument (anything), it should output the Greek alphabet in lowercase.

**Information**

1. Greek alphabet (Capitals): `ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ`
2. Greek alphabet (Lowercase): `αβγδεζηθικλμνξοπρστυφχψω`

---

## Rules/Requirements

* Each submission must be a full program.
* Builtins to print the Greek alphabet are not permitted
* Standard loopholes apply
* You must print exactly what is shown.

## Scoring

Programs are scored according to bytes. If you are using a character set different to UTF-8 please specify. Try to get the least bytes out of everyone, this is !

## Test cases

```
./program
==> ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ

./program 1
==> αβγδεζηθικλμνξοπρστυφχψω

./program 'lower'
==> αβγδεζηθικλμνξοπρστυφχψω

./program 123897883421
==> αβγδεζηθικλμνξοπρστυφχψω

./program ""
==> αβγδεζηθικλμνξοπρστυφχψω

greek();
==> ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ

greek("blah");
==> αβγδεζηθικλμνξοπρστυφχψω

greek(123);
==> αβγδεζηθικλμνξοπρστυφχψω

```

## Submissions

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```
# Language Name, N bytes

```

where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:

```
# Ruby, <s>104</s> <s>101</s> 96 bytes

```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:

```
# Perl, 43 + 2 (-p flag) = 45 bytes

```

You can also make the language name a link which will then show up in the leaderboard snippet:

```
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

```

## Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

```
/* Configuration */

var QUESTION_ID = 97049; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 53406; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
```

```
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
```

```
<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>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</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>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<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>
```

# Answer
> 7 votes
# 05AB1E, 16 bytes

Uses CP-1252 encoding.

```
24Ý17K913+çJDl¹s

```

Try it online!

**Explanation**

```
24Ý               # push range [0 ... 24]
   17K            # remove 17
      913+        # add 913 to each
          ç       # convert from code point
           J      # join to string
            Dl    # push a lowercase copy
              ¹   # push the input
               s  # swap the top 2 elements of the stack
                  # implicitly display the top of the stack

```

# Answer
> 8 votes
# Ruby, 56 bytes

Full program. I don't think a function/lambda answer will be shorter than this for this language.

Dangit, sigma `ς`. This is why we can't have nice things. And you too, (unrenderable character that serves as a placeholder for "uppercase" `ς`)

```
print *($*[0]?([*?α..?ω]-[?ς]):[*?Α..?Ρ,*?Σ..?Ω])

```

# Answer
> 5 votes
# CJam, 16 bytes

```
25,H-ea'α'Α?f+

```

Try it online!

```
25,H-         e# 0 to 24 excluding 17.
ea'α'Α?       e# If the argument list is truthy (non-empty), alpha, otherwise Alpha.
f+            e# Return characters with each number added to the character code.

```

# Answer
> 5 votes
## JavaScript (ES6), ~~89~~ ~~83~~ 81 bytes

```
(...a)=>String.fromCharCode(...[...Array(24)].map((_,i)=>i*1.06+913+32*a.length))

```

If a character array is acceptable, then for ~~82~~ ~~80~~ 78 bytes:

```
(...a)=>[...Array(24)].map((_,i)=>String.fromCharCode(i*1.06+913+32*a.length))

```

Edit: Saved a bunch of bytes thanks to @ETHproductions.

# Answer
> 5 votes
# Haskell, ~~114~~ 108 bytes

```
import System.Environment
q[a,b]=[a..b]
f[]=q"ΑΡ"++q"ΣΩ"
f _=q"αρ"++q"σω"
main=f<$>getArgs>>=putStr

```

Thanks to @xnor for saving 6 bytes

This might win in the category of longest imports if nothing else…

# Answer
> 4 votes
# R, ~~104~~ ~~99~~ 92 bytes

```
g=function(x)for(i in sprintf("'\\u%04X'",913:937+32*!missing(x))[-18])cat(eval(parse(t=i)))

```

Golfing down on the second version I had previously. Work the same way as previous version.

Thanks to @JDL for shaving off 7 bytes!

**Old versions at 104 bytes:**

I have two different solutions with the same byte count:

```
f=function(x){a="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ";cat(if(missing(x))a else tolower(a))}

```

Or:

```
g=function(x)for(i in sprintf("'\\u%04X'",if(missing(x))913:937 else 945:969)[-18])cat(eval(parse(t=i)))

```

Explanations:

```
#First one is trivial
f=function(x){
     a="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ" #String to print
     #If argument missing, print uppercase else lowercase
     cat(if(missing(x))a else tolower(a))
     }
#Second one more interesting:
g=function(x)
     #Create escaped unicode strings (i. e. "'\\u03B1'" etc.), loop over them...
     for(i in sprintf("'\\u%04X'",if(missing(x))913:937 else 945:969)[-18])
          #...eval the strings
          cat(eval(parse(t=i)))

```

Usage:

```
> f()
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
> g()
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
> f(1)
αβγδεζηθικλμνξοπρστυφχψω
> g(1)
αβγδεζηθικλμνξοπρστυφχψω
> f("a")
αβγδεζηθικλμνξοπρστυφχψω
> g("a")
αβγδεζηθικλμνξοπρστυφχψω

```

For some reasons, it doesn't work on R-Fiddle (it changes `"` to `'` by default which makes the code throw an error) but you can try it out on Ideone.

# Answer
> 3 votes
## Pyke, ~~55~~ ~~21~~ 20 bytes

```
24Fi16>913s.C)sz!hAl

```

Try it here!

```
24F          )       -   for i in range(24):
   i16>              -       i > 16
       913s          -      sum(i, ^, 913)
           .C        -     chr(^)
              s      -  sum(^) - created uppercase alphabet
                  Al - [len, lower, upper][V](^)
                 h   -  V + 1
               z!    -   not input()

```

# Answer
> 3 votes
# Python 3, 73 bytes

```
import sys
x=25
while x:print(end=chr(906-x+32*len(sys.argv))[:x^8]);x-=1

```

Try it online!

This still may not be as low as it can go!

# Answer
> 2 votes
# Actually, 62 bytes

```
 "$ù"E"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"@ƒ.X

```

Try it online!

Because some of the uppercase Greek alphabet is not present in CP437, this solution is encoded in UTF-8 and scored accordingly. Here is a hexdump (reversible with `xxd -r`):

```
00000000: 2022 24c3 b922 4522 ce91 ce92 ce93 ce94   "$.."E"........
00000010: ce95 ce96 ce97 ce98 ce99 ce9a ce9b ce9c  ................
00000020: ce9d ce9e ce9f cea0 cea1 cea3 cea4 cea5  ................
00000030: cea6 cea7 cea8 cea9 2240 c692 2e58 0a    ........"@...X.

```

Explanation:

```
 "$ù"E"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"@ƒ.X
<space>                               push the number of items present on the stack
 `$ù`E                                select `ù` (lowercase) if the number of items is not 0, else `$` (stringify - does nothing to a string)
      "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"      push the uppercase Greek alphabet
                                @ƒ    call the selected function
                                  .   print
                                   X  discard

```

# Answer
> 2 votes
# Python 3, ~~80~~ ~~77~~ 76 bytes

```
import sys;a='ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ';print([a,a.lower()][-len(sys.argv)])

```

Old version:

```
import sys;a='ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ';print([a,a.lower()][len(sys.argv)-1])

```

Older version:

```
import sys;a='ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ';print(a.lower()if len(sys.argv)>1else a)

```

# Answer
> 2 votes
# Japt, ~~21~~ ~~19~~ 18 bytes

```
;Ckzir)c+816+32*NÊ

```

Test it (no input)
Test it (empty string input)

```
;Ckzir)c+816+32*NÊ     :Implicit input (or not)
;C                     :Lowercase alphabet.
  k                    :Remove
   zir                 :  "z" prepended with "r"
      )                :End remove
       c+              :Map charcodes and add
         816+32*       :  816 plus 32 multiplied by
                N      :   Array of all inputs
                 Ê     :   Length (0 if no input, 1 if a single input)

```

# Answer
> 2 votes
# PowerShell, 81 bytes

```
'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ'|%('*wer','*per')[!$args.Count]

```

Try it online!

# Answer
> 2 votes
# C (gcc), 68 bytes

```
j=24;main(i){for(setlocale(6,"");j--;)putwchar(968-1/i*32-j+(j<7));}

```

Try it online!

# Answer
> 2 votes
# , ~~96 53 51~~ 58 bytes

```
cat(intToUtf8((913:937)[-18]+32*!!length(commandArgs(T))))

```

Try it online!

I tried to make an R answer with command line args, but it's a bit longer(now a lot, lot shorter) than the loop based approach by plannapus. I used some of the tricks in their answer.

A crazy -43 bytes from Dominic Van Essen.

-2 more bytes from Dominic Van Essen.

+7 bytes after removing `ς`

# Answer
> 2 votes
# Julia 1.0, 42 bytes

```
print.(['Α':'Ρ';'Σ':'Ω'].+32(ARGS>[]))

```

Try it online!

-1 byte thanks to MarcMush: use `ARGS>[]` instead of `ARGS==[]`

# Answer
> 1 votes
# PHP, 84 Bytes

Online Version

```
<?=($argc<2?trim:mb_strtolower)("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ");

```

# PHP, 87 Bytes

```
$s="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ";echo$argc>1?mb_strtolower($s):$s;

```

# Answer
> 1 votes
# Scala, 82 bytes

```
print((('Α'to'Ρ')++('Σ'to'Ω')).mkString.map(& =>if(args.size<1)&else&toLower))

```

Ungolfed:

```
print((('Α'to'Ρ')++('Σ'to'Ω')).mkString.map(s=>if(args.size==0)s else s.toLower))

```

Sadly, `(('Α'to'Ρ')++('Σ'to'Ω'))` is a `Vector[Char]`, which would be printed as `Vector('Α', 'Β', ...`, so it has to be converted to a string with `mkString`.The argument to `map` is called `&` to save spaces between `&else`, `else&` and `& toLower`.

# Answer
> 1 votes
# Jelly, 21 bytes

```
,⁸Ea32µ24R%18T+912+µỌ

```

A full program

**TryItOnline!** \- note once run with an argument a refresh will be required to run with no argument.

### How?

```
,⁸Ea32µ24R%18T+912+µỌ - Main link
,⁸                    - pair (,) with left argument (defaults: left=0, ⁸=[])
                            no argument: [0,[]]
                               argument: [argument,argument]
  E                   - all items equal? -> no argument: 0; argument: 1
   a32                - and 32           -> no argument: 0; argument: 32
      µ               - monadic chain separation
       24R            - range(25)        -> [  1,  2,  3,..., 17, 18, 19,..., 25]
          %18         - mod 18           -> [  1,  1,  1,...,  1,  0,  1,...,  1]
             T        - truthy indices   -> [  1,  2,  3,..., 17,     19,..., 25]
              +912    - add 912          -> [913,914,915,...,929,    931,...,937]
                  +   - add the 0 or 32 (lowercase letters are 32 code points higher)
                   µ  - monadic chain separation
                    Ọ - cast to ordinals

```

# Answer
> 1 votes
## PowerShell v2+, 68 bytes

```
(($a=-join([char[]](913..929+931..937))).toLower(),$a)[!$args.count]

```

ASCII-only, but outputs in UTF-16. Constructs a `char`-array of the appropriate characters, `-join`s it together into a string, stores it into `$a`. Then, uses `!$args.count` as an index into the tuple, to output either `$a` if no arguments are present, or `$a.ToLower()` if there is at least one argument.

```
PS C:\Tools\Scripts\golfing> .\print-the-greek-alphabet.ps1
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ

PS C:\Tools\Scripts\golfing> .\print-the-greek-alphabet.ps1 ''
αβγδεζηθικλμνξοπρστυφχψω

```

# Answer
> 1 votes
# Python 3, 80 bytes

```
import sys;print(''.join(chr(x+881+len(sys.argv)*32)for x in range(25)if x!=17))

```

# Answer
> 1 votes
## C#, 174 bytes

Lazy implementation, can probably golf it a lot

```
class P{static void main(string[] a){System.Console.Write(a.Length>0?"αβγδεζηθικλμνξοπρστυφχψω":"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ");}}

```

# Answer
> 1 votes
# tcl, 73

```
 puts [expr $argc>0?"αβγδεζηθικλμνξοπρστυφχψω":"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"]

```

demo

# Answer
> 1 votes
# Braingolf, 24 bytes

```
l?#α:#Α|# 9->[.!@ 1+];

```

Try it online!

### Explanation:

```
l?#α:#Α|# 9->[.!@ 1+];  Implicit input of args to stack
l                       Push length of stack
 ?                      If last item (length) is != 0..
  #α                    ..Push lowercase alpha
    :                   else
     #Α                 ..Push uppercase alpha
       |                endif
        #<space>        Push 32 (ordinal of a space)
          9-            Subtract 9 (23)
            >           Move last item to start of stack
             [......]   Do-While loop, will run 24 times
              .         Duplicate last item
               !@       Print without popping
                  1     Push 1
                   +    Pop last 2 items (1 and duplicate) and push sum
                     ;  Suppress implicit output

```

# Answer
> 1 votes
# Retina, 55 bytes

```
.+
αβγδεζηθικλμνξοπρστυφχψω
^$
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ

```

**Try it online**

# Answer
> 1 votes
# APL (Dyalog Extended), 26 bytes

The normal way to pass multiple arguments to APL programs is through a lists. So this program prompts for such a list, which may have 0 or 1 arguments.

```
'ς΢'~⍨⍳'Ω'×~≢⎕

```

Try it online!

prompt for argument list

tally the number of arguments (0 or 1)

`~` negate that (1 or 0)

`'Ω'×` "multiply" Omega by that (1 keeps uppercase, 0 folds to lowercase)

All characters from `Α``Ω` or `α``ω` respectively

`'ς΢'~⍨` remove lowercase and "uppercase" final sigmas

# Answer
> 1 votes
# Python 3, 78 bytes

```
import sys;a=(len(sys.argv)-1)<<5;print(''.join(map(chr,range(a+913,a+938))))

```

## Explanation

`a` is an offset, 32 when an argument is given to use the lowercase range. 913 to 937 is the range of unicode values for the uppercase greek alphabet.

# Answer
> 1 votes
# Python 3, 88 bytes

```
import sys
s=945 if sys.argv[1:] else 913
for i in range(s,s+25):
  print(chr(i),end='')

```

# Answer
> 1 votes
# Python 3, 74 bytes

This an improvement to @HackerBoss es' answer (I don't have enough reputation to comment).

```
import sys;a=len(sys.argv)-1<<5;print(*map(chr,range(a+913,a+938)),sep='')

```

Subtraction has higher precedence than bit shift, so no need for parentheses, we save 2 bytes. Also instead of using `''.join()` we unpack the `map()` and set `print()`'s default seperator to an empty string to omit the spaces, that saves 1 byte.

# Answer
> 1 votes
# Zsh, 45 bytes

```
A=({Α..Ω})
((#))&&A=${(L)A}
tr -d \ -z<<<$A

```

Try it online!

# Answer
> 1 votes
# Rust, 134 bytes

```
fn main(){let mut s:String=('α'..'ϊ').collect();s.remove(34);print!("{}",if std::env::args().nth(1)==None{s.to_uppercase()}else{s})}

```

Try it on the Rust Playground!

ungolfed:

```
fn main() {                                    //full program
    let mut s: String = ('α'..'ϊ').collect();  //create a range of chars from 'α'(inclusive) to 'ϊ' (exclusive) and collect into string
    s.remove(34);                              //remove 'ς'
    print!(                                    //print
        "{}",                                  //with default formatting
        if std::env::args().nth(1) == None {   //if the 2nd arg doesn't exist (first is filename)
            s.to_uppercase()                   // uppercase string then return
        } else {                               // else
            s                                  // return unmodified string
        }
    )
}

```

This doesn't work on tio for some reason so this is on the playground, where you can't add input- turn the `==` to a `!=` to test lowercase version.

# Answer
> 1 votes
# Python, 81 Bytes

```
lambda*x,b="αβγδεζηθικλμνξοπρστυφχψω":(b.upper(),b)[x>()]

```

-6 from TheThonnu for using `*`.
-2 from TheThonnu for telling me that the brackets are unneeded.
-28 from mousetail for using an uppercasing function.
-7 from TheThonnu for assigning the greek letters to a variable.

# Answer
> 1 votes
# Thunno 2 `J`, ~~17 16 15~~ 14 bytes

```
24Ė17Ɗ913+C¤?L

```

-1 thanks to @TheThonnu :), saved 1 extra by using different method.

Explanation:

```
24Ė              # range [0, 24]
   17Ɗ           # remove index 17
      913+       # add 913 to each
          C      # convert to character array
           ¤?    # if there is input:
             L   #   convert to lowercase (vectorizes)
                 # J flag joins character array

```

Thunno 2 isn't on ATO yet, but I have confirmed that this works on my machine for both the input and no input versions.

# Answer
> 1 votes
# Raku, 53 bytes

```
{say @*ARGS??.lc!!$_}([~] flat 'Α'..'Ρ','Σ'..'Ω')

```

Try it online!

* `[~] flat 'Α'..'Ρ','Σ'..'Ω'` constructs the uppercase Greek alphabet.
* `{ say @*ARGS ?? .lc !! $_ }` is an anonymous function which receives the uppercase alphabet as an argument. If there are any command-line arguments, the alphabet is lowercased and printed, otherwise it is printed as-is.

# Answer
> 1 votes
# Japt `-P`, 17 bytes

```
25od913+H*NÊ fÏÉ7

```

Test it

### Explanation

```
25o                 map each n in range [0, 25):
   d                  convert the following codepoint to a character:
    913                 n + 913
       +H*NÊ            + (number of inputs * 32)
             fÏ     keep elements where the following is truthy:
               É7     subtract 17 from the index
                      (if index is 17, this will be 0 = falsy)
-P                  P flag joins the array to a string

```

The cool part of this is `fÏÉ7`: `É7` transforms to `-17` by using the shortcut for `-1` (i.e. decrement). The regular way of doing this would be something like `fÏ¶17` which is one byte longer.

# Answer
> 0 votes
# Python 2, 108 bytes

```
#coding=iso-8859-7
import sys;print'αβγδεζηθικλμνξοπρστυφχψω'if~-len(sys.argv)else'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ'

```

Terribly golfed, maybe :(

And no, I can't use `A.lower()`.

Thanks to 13285 (alexwlchan) for -11 bytes.

# Answer
> 0 votes
# Mathematica, 91 bytes

```
Print@{#&,ToLowerCase}[[Length@$ScriptCommandLine]][""<>"Α"~CharacterRange~"Ω"~Drop~{18}]

```

Script. Just takes the character range from `Α` to `Ω`, removes U+03A2/`ς`, either converts to lowercase or doesn't, and prints.

# Answer
> 0 votes
# Perl, 39 + 3 (`-C2` flag) = ~~44~~ 42 bytes

```
 perl -C2 -E 'say map{chr$_+954-!@ARGV*32}-9..7,9..15'

```

# Answer
> 0 votes
# JavaScript, 95 bytes

95 bytes, but only 71 characters. Byte counter. Using @Neil s way to determine if arguments are passed.

```
(...a)=>'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ'[`to${a.length?'Low':'Upp'}erCase`]()

```

# Answer
> 0 votes
## Pip, ~~21~~ 20 bytes

```
C:913+32*#g+Y,24RM17

```

This is a memorable day. Pip has ~~tied~~ beaten Jelly!1

1 And lost to two other golflangs, but whatever.

Try it online!

### Explanation

```
             ,25      Numbers 0 through 24
                RM17  Remove 17 (ς)
            Y         Yank (to get correct order of operations)
  913                 Char code of capital alpha
      32*#g           32 times number of cmdline args (must be 0 or 1)
     +     +          Add everything up
C:                    Convert to characters (using the compute-and-assign metaoperator to
                        lower the precedence of C)

```

# Answer
> 0 votes
# Java 7, 176 bytes

```
class M{public static void main(String[]a){System.out.print(a.length>0?"αβγδεζηθικλμνξοπρστυφχψω":"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ");}}

```

# Java 8, 173 bytes

```
interface M{static void main(String[]a){System.out.print(a.length>0?"αβγδεζηθικλμνξοπρστυφχψω":"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ");}}

```

# Answer
> 0 votes
# Groovy Script, ~~54~~ 51 bytes

```
((913..937)-930).each{print((char)(args?it+32:it))}

```

## Edit

Switched from `913..937` and `it==930?:` to `(913..937)-930`

# Answer
> 0 votes
# PHP, 79 bytes

```
for($i=944-32*!--$argc;$i++-9&31;$i+=$i%32==1)echo html_entity_decode("&#$i;");

```

generates unicode html entities and decodes them. Run with `-r`.

# Answer
> 0 votes
# MATLAB, 35 bytes

```
@(x)disp(char((913:937)+32*nargin))

```

Pretty self-explainatory, I think.

# Answer
> 0 votes
# PowerShell, 94 bytes

```
param($n)$k=((0..16)+(18..24)|%{[char]($_+913)})-join'';if($n){$k.tolower()}else{$k.toupper()}

```

Try it online!

# Answer
> 0 votes
# Excel, 48 bytes

```
=CONCAT(UNICHAR(ROW(1:24)*19/18+944-(A1="")*32))

```

Alternatively, you could put the upper case alphabet in B2 and use the formula below for a combined 47 bytes (or more depending on how you account for multiple cells)

```
=IF(A1="",B2,LOWER(B2))

```

# Answer
> 0 votes
# APL, 27 bytes

```
{⎕UCS(912+32×0∊⍴⍵)+18~⍨⍳25}

```

The program switched to uppercase, when empty array or empty string is received. Unfortunately, it is technically impossible to distinguish them.

# Answer
> 0 votes
# Scala, 171 bytes

Modified from @Value Ink's Ruby solution.

---

Golfed version. Try it online!

```
object Main{def main(args:Array[String])=println((if(args.nonEmpty)('α'to'ω').toSet.diff(Set('ς')).toList else('Α'to'Ρ').toList++('Σ'to 'Ω').toList).mkString(" "))}

```

Ungolfed version. Try it online!

```
object Main {
  def main(args: Array[String]): Unit = {
    val result = if (args.nonEmpty) ('α' to 'ω').toSet.diff(Set('ς')).toList
                 else ('Α' to 'Ρ').toList ++ ('Σ' to 'Ω').toList
    println(result.mkString(" "))
  }
}

```

# Answer
> -1 votes
## Perl under Windows -- console has no Unicode support -- (42 bytes, including spaces)

This is not my solution, *I am just merely adapting* the Perl solution of **Denis Ibaev** above, to Windows console Perl.

```
perl -E"say map{chr$_+151-!@ARGV*24}1..24"
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
$ perl -E"say map{chr$_+151-!@ARGV*24}1..24" with one or many arguments
αβγδεζηθικλμνξοπρσςτυφχψ

```

The console page code must be Greek of course:

```
chcp 737

```

NOTE: Just a small idea. On this page I can see that some of the answers use CHARACTERS that seem to been Unicode above 255. Therefore those characters take at least 2 bytes to code (perhaps 4 if one is using a console using 32bits Unicode chars?). Would not it be better if the contest measure was the CHARACTER unit (being Unicode or ASCII or EBCDIC ou whatever) rather than just BYTES? Would not it be simpler and more *unifying* (wonder if this adjectif exists in English, "unificateur" in French)?

---

Previous code in error: Does not print lowercase omega.

Corrected code (70 chars) :

```
perl -E"$i=!@ARGV+0;@a=73;pop@a if$i;say map{chr$_+151-$i*24}1..24,@a"
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
perl -E"$i=!@ARGV+0;@a=73;pop@a if$i;say map{chr$_+151-$i*24}1..24,@a" foo
αβγδεζηθικλμνξοπρσςτυφχψω

```

I know we are not supposed to print the 'end-of-word' sigma form ('ς') but as it is a mispelling error in ancient Greek to use regular sigma ('σ') at the end of a lowercase word, I choose to print it, as the tittle of this puzzle is "Print the Greek alphabet" and that this character is part of it...

---
Tags: code-golf, kolmogorov-complexity, alphabet
---


# Question
Title: Finding Exclusive Area in Circle Intersections
Here's a deceptively challenging geometry puzzle for you!

Given a circle `A`, and `n` other circles `B[n]`, find the total area contained within `A` that is *not* within any circle of `B`.

Your code should be as short as possible.

# Input

Your input should contain the following information:

* A floating-point number to represent the radius of circle `A`.
* A list of floating-point numbers to represent the radii of circles in `B`.
* A list of the centers of circles in `B`. Your program may expect the centers in either polar or Cartesian coordinates.
* Optionally, you may receive the number `n` of circles in B. **This input is not required.**

It shall be assumed that the center of circle `A` is the origin, that is, the point `(0, 0)`.

It is guaranteed that no two circles in `B` are identical, but it is **not** guaranteed that: all circles of `B` intersect `A`, all centers of `B` are outside `A`, or no two circles in `B` intersect each other. Ensure that your solution can handle various edge cases.

You may receive input in any order, and in the form of text input (through stdin or your language's equivalent), function parameters, or command-line arguments.

If you choose to receive text input, there should be one or two-character printable ASCII delimiters between pieces of input.

# Output

Your program or function should output a single floating-point number representing the total area of `A` not within any of the circles of `B`. Your answers should be accurate to at least three significant figures for all test cases.

General rules apply.

Your solution should not rely on sampling points within the circles to determine an area.

Built-ins that automatically locate intersections of circles, find areas within intersections of circles, or solve this problem immediately are disallowed.

# Test Cases

In each image, circle `A` is outlined in blue, with circles `B` outlined in green and filled black. The area that should be returned is filled red.

(Special thanks to Rainer P. for checking my solutions)

**Test case 1:**

```
A = {x: 0, y: 0, rad: 50}
B[0] = {x: 0, y: 0, rad: 100}

```

```
Result: 0.00

```

**Test case 2:**

```
A = {x: 0, y: 0, rad: 100.000000}
B[0] = {x: 100.000000, y: 0.000000, rad: 50.000000}
B[1] = {x: 30.901699, y: -95.105652, rad: 50.000000}
B[2] = {x: -80.901699, y: -58.778525, rad: 50.000000}
B[3] = {x: -80.901699, y: 58.778525, rad: 50.000000}
B[4] = {x: 30.901699, y: 95.105652, rad: 50.000000}

```

```
Result: 1.3878e+04

```

**Test case 3:**

```
A = {x: 0, y: 0, rad: 138}
B[0] = {x: 100, y: 0, rad: 100}
B[1] = {x: -50, y: -86, rad: 100}
B[2] = {x: -93, y: 135, rad: 50}

```

```
Result: 1.8969e+04

```

**Test case 4:**

```
A = {x: 0, y: 0, rad: 121.593585}
B[0] = {x: 81.000000, y: 107.000000, rad: 59.841457}
B[1] = {x: -152.000000, y: -147.000000, rad: 50.000000}
B[2] = {x: 43.000000, y: -127.000000, rad: 105.118980}
B[3] = {x: 0.000000, y: -72.000000, rad: 57.870545}
B[4] = {x: -97.000000, y: -81.000000, rad: 98.488578}
B[5] = {x: -72.000000, y: 116.000000, rad: 66.468037}
B[6] = {x: 2.000000, y: 51.000000, rad: 50.000000}

```

```
Result: 1.1264e+04

```

**Test case 5:**

```
A = {x: 0, y: 0, rad: 121.605921}
B[0] = {x: 0.000000, y: -293.000000, rad: 250.000000}
B[1] = {x: 0.000000, y: -56.000000, rad: 78.230429}
B[2] = {x: 0.000000, y: -102.000000, rad: 100.000000}

```

```
Result: 2.6742e+04

```

Suggested reading:

Fewell, M. P. "Area of Common Overlap of Three Circles." Oct. 2006. Web. http://dspace.dsto.defence.gov.au/dspace/bitstream/1947/4551/4/DSTO-TN-0722.PR.pdf.

# Answer
> 17 votes
# Python 2, 631 bytes

```
from cmath import*
C=input()
O,R=C[0]
def I(p,r,q,s):
 try:q-=p;d=abs(q*q);x=(r*r-s*s+d)/d/2;return[p+q*(x+z*(r*r/d-x*x)**.5)for z in-1j,1j]
 except:return[]
S=sorted
V=S(i.real for p,r in C for c in C for i in[p-r,p+r]+I(p,r,*c)if-R<=(i-O).real<=R)
A=pi*R*R
for l,r in zip(V,V[1:]):
 H=[]
 for p,t in C:
    try:
     for s in-1,1:a,b=[p.imag+s*(t*t-(p.real-x)**2)**.5for x in l,r];H+=[a+b,a,b,s,t,p],
    except:0
 a,b=H[:2];H=S(H[2:]);n=0;c=a
 for d in H:
    s=d[3];z=.5;H*=d<b
    for q,w,e,_,t,y in(c,min(d,b))*(n-s<(a<d)or[0]*n>H):\
g=phase((l+w*1j-y)/(r+e*1j-y));A-=abs(g-sin(g)).real*t*t/2-z*q*(r-l);z=-z
    n-=s
    if(a<d)*s*n==-1:c=d
print A

```

*Line-breaks preceded by `\` are for easy reading, and aren't counted in the score.*

Reads input through STDIN as a list of `(center, radius)` pairs, where `center` is a complex number in the form `X+Yj`. The first circle in the list is *A* (whose center doesn't have to be at the origin), and the rest of the list is *B*. Prints the result to STDOUT.

**Example**

```
Input:  (0+0j, 138),  (100+0j, 100), (-50+-86j, 100), (-93+135j, 50)
Output: 18969.6900901

```

## Explanation

This is a (longer, and much uglier :P) variation on my solution to Martin Büttner's Area of a Self-Intersecting Polygon challenge. It uses the same trick of breaking the problem down into small-enough pieces, for which it becomes more manageable.

We find the points of intersection between all pairs of circles (considering both *A*, and the circles in *B*), and pass a vertical line through each of them. Additionally, we pass all the vertical lines tangent to any of the circles. We throw away all the lines that don't intersect *A*, so that all the remaining lines are between the left and right tangents of *A*.

We're looking for the area of the intersection of *A* and the union of the circles in *B*—the dark red area in the illustration above. This is the area that we have to subtract from *A* to get the result.

Between each pair of consecutive vertical lines, this area can be broken down into a set of vertical trapezoids (or triangles, or line segments, as special cases of trapezoids), with an "excess" arc segment next to each leg. The fact that we pass as many vertical lines as we do guarantees that the bounded area is indeed no more complicated than that, since otherwise there would have to be an additional point of intersection, and hence an additional vertical line, between the two lines in question.

To find these trapezoids and arc segments, for each pair of consecutive vertical lines, we find the arc segments of each of the circles that properly lie between these two lines (of course, some circles may have no arc segment between a given pair of lines.) In the illustration below, these are the six (bright and dark) yellow arc segments, when considering the two red vertical lines. Note that, since we pass all vertical lines tangent to the circles, if a circle has an arc segment between the two lines, it necessarily intersects both lines, which simplifies the rest of the algorithm.

Not all of these arcs are relevant; we're only interested in the ones that are on the boundary of the intersection between *A* and the union of *B*. To find those, we sort the arcs top-to-bottom (note that the arcs may not properly intersect each other, since this would imply the existence of another vertical line between the two we're considering, and so it makes sense to talk about an arbitrary arc being above, or below, any other one.)

We traverse the arcs, in order, while keeping count of the number of *B* circles we're currently inside, *n*. If *n* changes from 0 to 1 while we're inside *A*, or if we're at the top arc of *A* while *n* is nonzero, then the current arc corresponds to one leg of a trapezoid. If *n* changes from 1 to 0 while we're inside *A*, or if we're at the bottom arc of *A* while *n* is nonzero, then the current arc corresponds to the other leg of the same trapezoid. Once we find such a pair of arcs (the two bright yellow arcs in the above illustration), we calculate the area of the corresponding trapezoid, and of the two arc segments, and add it to the total area to be subtracted from *A*.

Calculating the area of *A*, as well as the areas of the trapezoids, is fairly straight forward. The area of each arc segment is the area of the corresponding circular sector, minus the area of the triangle whose vertices are the two endpoints of the arc segment, and the center of the corresponding circle.

# Answer
> 5 votes
# Desmos, ~~458~~ 438 bytes

```
g(P,R,n)=E(P,R)-E(P[2...],R[2...])
I=[1...n]
M=[1,-1]
w=join(P.x+R,P.x-R,[P[u].x+h(V.xA+V.yS(4DR[u]^2-AA)^h)/DforS=M,u=I,v=I])
X=w[w=w].sort
a=X[t]
b=X[t+1]
J=I[a-R<P.x<b+R]
Y(s)=(P.y+s(RR-(P.x-h(a+b))^2)^h)[J]
E(P,R)=[\total((s(b-a)P.y+hRR(U((b-P.x)/R)-U((a-P.x)/R)))[J[0=\sum_{j=1}^n\{J=J[j]:0,Y(-1)[j]<Y(s)<Y(1)[j],0\}]])\for s=M,t=[1...X.\length]].\total
U(x)=xp+arctan(x/p)
p=(1-xx)^h
A=D+R[u]^2-R[v]^2
D=V.x^2+V.y^2
V=P[v]-P[u]
h=.5

```

Try it on Desmos!

*-20 bytes thanks to @Aiden Chow. Besides syntax, main optimization was converting `D=distance(V,(0,0))` to `D=V.x^2+V.y^2`, which saved a bunch since (old) `D` was squared a few times.*

The main function is `g(P,R,n)`, where `n` is the number of points (including A), `P` is the list of points (starting with A), and `R` is the corresponding list of radii.

This takes a similar approach as Ell (with the vertical slices). One big difference is that I ignore A pretty much immediately: the desired area is the area of the union of the discs, minus the area of the unions of the discs excluding A. Not sure if this saves bytes.

For reference, the graph before diving deep into syntax-golfing, and the graph when it only calculated the area of the union of discs, with readable variable names.

# Answer
> 1 votes
# Wolfram Language (Mathematica), 73 bytes

```
RegionMeasure@RegionDifference[Disk[{0,0},#1],RegionUnion[Disk@@#&/@#2]]&

```

Try it online!

Input: `RMax, {{{xc1, yc1}, r1}, {{xc2, yc2}, r2},...}`

---
Tags: code-golf, math, geometry, trigonometry
---


title: Tree traversal: Depth-first search

text:
# Question
Title: Tree traversal: Depth-first search
Write the shortest code that traverses a tree, depth-first.

**Input**

Any programmatical structure found in your language of choice: lists, tuples, queues etc.

**Output**

A list of "names" of the nodes in correct order as shown in Depth-first search article at Wikipedia.

**Requirement:**

A node should be able to contain an **infinite** number of child nodes.

Also, you're not required to actually print the result, just returning the correct result with the ability to use it in your program will do; I didn't really print mine below in my answer, the function simply returned a list.

# Answer
> 3 votes
## Haskell — 70 characters

```
data N a=N{v::a,c::[N a]}
d n=f[n][]
f(x:y)=f(c x++y).(++[v x])
f _=id

```

In a more readable format:

```
data Node a = Node {value::a, children::[Node a]}

dfs :: Node a -> [a]
dfs node = dfs' [node] []
  where dfs' [] result = result
        dfs' (x:xs) result = dfs' (children x ++ xs) (result ++ [value x])

```

Sample tree:

```
sampleTree =
    Node 1 [Node 2 [Node 3 [Node 4 [],
                            Node 5 []],
                    Node 6 []],
            Node 7 [],
            Node 8 [Node 9 [Node 10 [],
                            Node 11 []],
                    Node 12 []]]

```

Sample run:

```
*Main> dfs sampleTree
[1,2,3,4,5,6,7,8,9,10,11,12]

```

# Answer
> 3 votes
# Haskell, 35 bytes

```
data D a=T[D a]a
d(T l n)=n:(d=<<l)

```

Try it online!

`data D a=T[D a]a` defines a labelled tree data structure. Constructor `T` takes a list of sub-trees and same value of an arbitrary type `a` (which however must be consistent throughout each tree).

Here is an example of a tree labelled with integers and the way this tree can be defined using the data structure:

```
   4
 / | \
1  5  2
  / \
 3   0

tree = T[T[]1, T[T[]3, T[]0]5, T[]2]4

```

The function `d` takes such a tree and returns a list of the tree's labels in depth-first order: Calling `d tree` yields `[4,1,5,3,0,2]`.

# Answer
> 3 votes
# Vyxal, ~~10~~ 1, \>2 or 8 bytes

Thanks to @Shaggy and @Kevin Cruijssen!!

If name of nodes are just a primitives (numbers, string) and 1D array is accepted output, than just:

```
f

```

If we need to do something with nodes, than:

```
fƛ<todo>

```

And if *"A node should be able to contain an infinite number of child nodes"*:

```
ƛ:@[vx;f

```

Try it Online!

```
ƛ         # Start lambda map
 :        # Duplicate
  @       # Check is array or number (vectorized length==[] if a number)
   [      # Start If
    vx    # If array - vectorized recursive call of lambda
          # Else - do nothing (virtual "|" )
          # Close If (virtual "]" )
        ; # Close lambda
        f # Flatten

```

# Answer
> 2 votes
## Perl, 34

Perl 5.10 or later, run with `perl -E'code here'`:

```
sub f{ref()?f($_):say for@{$_[0]}}

```

For example, running `f [1,[2,[3,[4],[5]],[6]],[7],[8,[9,[10],[11]],[12]]]` produces:

```
1
2
3
4
5
6
7
8
9
10
11
12

```

# Answer
> 2 votes
# Japt, 1 byte

... It *seems* like simply flattening the array will to the job.

```
c

```

Try it

# Japt, 10 bytes

```
cÈ¶Ô?ßXÔ:X

```

Try it

```
cÈ¶Ô?ßXÔ:X     :Implicit input of multi-dimensional array
c              :Flat map by
 È             :Passing each X through the following function
  ¶            :  Is strictly equal to
   Ô           :  Its reverse, if it's an array, or maximum, if it's an integer (see more detailed explanation below)
    ?          :  If true
     ß         :    Recursive call with argument
      XÔ       :    X reversed (because reversing an array in JS mutates the original)
        :X     :  Else return X

```

---

To (try to) explain how the `Ô` (which is a shortcut for the `w` method, without any arguments) allows us to differentiate between arrays & numbers by testing for strict equality:

While it's true that in JavaScript 2 arrays containing the exact same elements are not strictly equal as they are 2 distinct objects, an array assigned to a variable is, of course, equal to itself. Add to that that the `reverse` method for arrays (`w` in Japt) mutates the original array and that explains how an array assigned to a variable (`X` in this case) can be strictly equal to its reverse.

As to why a number does not equal its maximum, that's down to a peculiarity of Japt. Firstly, when applied to a number, Japt's `w` method returns the maximum of that number and the arguments passed to the method, as a `Number`. However, if *no* arguments are passed to the `w` method then the number it's applied to is returned as excpected but, for some reason, Japt converts the returned value to an `Object` and a `Number` cannot be strictly equal to an `Object`

# Answer
> 1 votes
# PHP - 57 characters

```
<?function s($t){echo$t[0].'
';for(;$T=next($t);s($T));}

```

Test:

```
s(json_decode('[1,[2,[3,[4],[5]],[6]],[7],[8,[9,[10],[11]],[12]]]'));

```

Output:

```
1
2
3
4
5
6
7
8
9
10
11
12

```

# Answer
> 1 votes
# Ruby - ~~37~~ ~~35~~ ~~31~~ 25 characters

```
s=->t{p t.shift;t.map &s}

```

Test:

```
s[[1,[2,[3,[4],[5]],[6]],[7],[8,[9,[10],[11]],[12]]]]

```

# Answer
> 1 votes
# Scala, 125 bytes

Modified from @Laikoni's Haskell solution.

---

Golfed version. Try it online!

```
sealed trait D[A]
case class T[A](l:Seq[D[A]],v:A) extends D[A]
def d[A](t:D[A]):Seq[A]=t match{case T(l,v)=>v+:l.flatMap(d)}

```

Ungolfed version. Try it online!

```
object Main {
  sealed trait D[A]
  case class T[A](list: List[D[A]], value: A) extends D[A]

  def d[A](tree: D[A]): List[A] = tree match {
    case T(list, value) => value :: list.flatMap(d)
  }

  val t1 =
    T(
      List(
        T(List(), 1),
        T(
          List(
            T(List(), 3),
            T(List(), 0)
          ),
          5
        ),
        T(List(), 2)
      ),
      4
    )

  def main(args: Array[String]): Unit = {
    println(d(t1))
  }
}

```

# Answer
> 1 votes
# JavaScript, 29 bytes

```
f=a=>a.flatMap(x=>1/x?x:f(x))

```

Attempt This Online!

# Answer
> 1 votes
# 05AB1E, 2 (or 13) bytes

```
˜ε...

```

The `...` indicates something you'd want to do with the item 'name' we're traversing depth-first over.

Try it online with a print statement to verify it's in the correct order, or verify some more test cases.
Try it online with a ragged list containing infinite sub-items.

**Explanation:**

```
˜   # Flatten the (implicit) ragged input-list
 ε  # Map over each item:
    #  (do something)

```

The main rule that stops most other programming languages from using a similar approach is "*A node should be able to contain an **infinite** number of child nodes.*". Fortunately, 05AB1E (build in Elixir) supports infinite lists and can flatten them without too much trouble, allowing this approach.

But for completeness sake, here is also a (**13 bytes**) program if this wouldn't have been possible:

```
"Ddi...ë®δ.V"©.V

```

The `...` again indicates something you'd want to do with the item 'name' we're traversing depth-first over.
Assumes the 'names' of items used are positive integer ids.

Try it online with a print statement to verify it's in the correct order, or verify some more test cases.
Try it online with a ragged list containing infinite sub-items.

**Explanation:**

As always, 05AB1E is pretty bad at recursive functions over s, and will have to a use a string and evaluate to accomplish this..

```
"..."     # Push the recursive string explained below
     ©    # Store it in variable `®` (without popping)
      .V  # Evaluate and execute it as 05AB1E code,
          # using the (implicit) input as initial argument

D         # Duplicate the current value
 di       # Pop the copy, and if it's a (non-negative) integer:
   ...    #  (do something)
  ë       # Else (it's a list instead):
    δ     #  Map over the list:
   ® .V   #   Do a recursive call

```

# Answer
> 0 votes
# Go, 89 bytes

```
import."fmt"
type N struct{v int;c[]N}
func f(n N){Println(n.v)
for _,c:=range n.c{f(c)}}

```

Attempt This Online!

This code also includes the type definition of a node `N`. Without it, the code is **63 bytes**.

Prints node values to STDOUT, separated by newlines.

# Answer
> 0 votes
# Python 3, 52 bytes

```
def f(t):
 yield t[0]
 for s in t[1]:yield from f(s)

```

Each node in the tree structure is encoded as a 2-tuple containing a value and an iterable of child nodes. The child nodes iterable may be infinite. Returns a generator containing values. Attempt This Online!

### Explanation

```
def f(t):          # Define generator function f that takes tree t
 yield t[0]        # Yield the value of the root node
 for s in t[1]:    # For each subtree s:
  yield from f(s)  # Apply f to the subtree and yield each value in turn

```

---

Using itertools is never the answer.<sup>\[citation needed\]</sup> But in this case, it comes pretty close (**57 bytes**):

```
lambda t:chain(t[:1],*map(f,t[1]))
from itertools import*

```

---
Tags: code-golf, tree-traversal
---


title: Create an Alphabet Song

text:
# Question
Title: Create an Alphabet Song
Your goal is to create an alphabet song as text in the following form (in order):

```
A is for <word starting with A>
B is for <word starting with B>
C is for <word starting with C>
...
Z is for <word starting with Z>

```

### Example output:

```
A is for Apple
B is for Banana
C is for Carrot
D is for Door
E is for Elephant
F is for Frog
G is for Goat
H is for Hat
I is for Icicle
J is for Jelly
K is for Kangaroo
L is for Lovely
M is for Mom
N is for Never
O is for Open
P is for Paste
Q is for Queen
R is for Rice
S is for Star
T is for Test
U is for Underneath
V is for Very
W is for Water
X is for X-ray
Y is for Yellow
Z is for Zipper

```

### Rules:

* Each "letter" of the song has its own line, so there are 26 lines, and a possible trailing linefeed.
* The output is case-sensitive:

+ The letter at the start of each line must be capitalized.
    + `is for` is lowercase.
    + The chosen word does not need to be capitalized, but may be. All lines should be consistent.
* The chosen word for each line is up to you, but must be a valid English word with at least 3 letters, and it cannot be a conjunction (like `and` or `but`), interjection/exclamation (like `hey` or `yay`), abbreviation (like `XLS`), or a name (like `Jon`).
* Though I doubt anyone would find it shorter, I'd find it acceptable to use a phrase instead of a single word. So if for some reason `S is for Something smells fishy...` is shorter, go for it.
* Put your program's output in your answer, or at least the list of words you used (if there's a link to run your code online, we don't need to see the entire output).
* Shortest code wins

---

<sub>*This challenge was inspired by this video.*</sub>

# Answer
# SOGL 0.8.1, ~~60~~ 32 bytes

```
χ3½⌠↓-ζ⁄∞Nη6′⁵‘Z{t",t5~r‘ooKo to

```

Explanation:

```
χ3½⌠↓-ζ⁄∞Nη6′⁵‘                   push "niooaaoasoioaiaaaoiineeaei"
               Z{                 for each letter of the uppercase alphabet
                 t                output the letter in a newline (and disable implicit output)
                  ",t5~r‘o        append " is for "
                          o       append the letter
                           Ko     append the 1st letter of the 1st string (the 2nd letters) and remove it
                              to  append "t"

```

This is pretty much Jonathan Allan's answer, but ported to this language.

Old version: (SOGL 0.8.2)

```
Z"sηΒ…@Ν┘$JP6*š∙╬F▓÷Σ⁷4⌠    ⁹{Tīο⁾α⅝½Χ<▼½Ξμ‚‘θ’»∫wGKO",t5~r‘P≥o

Z                                                             push the uppercase alphabet
 "sηΒ…@Ν┘$JP6*š∙╬F▓÷Σ⁷4⌠    ⁹{Tīο⁾α⅝½Χ<▼½Ξμ‚‘                  push the 27 words separated by spaces using the languages english compression (BCD...XYZA)
                                          θ                   split on spaces
                                           ’»∫                repeat 27 times (push 0-based pointer)
                                              w               get the 1-indexed item of the array (so 0 = last, 1 = first, 2 = 2nd,...)
                                               G              put the 1st thing on stack ontop (the alphabet)
                                                K             get the 1st letter and remove it
                                                 O            output it
                                                  ",t5~r‘     push compressed " is for "
                                                         P    append that (and disable last auto-output)
                                                          ≥   put the 1st thing on the stack below everything
                                                           o  append the last thing (the word from the word list)

```

output:

```
A is for against
B is for being
C is for could
D is for down
E is for even
F is for first
G is for good
H is for had
I is for into
J is for just
K is for know
L is for little
M is for much
N is for nothing
O is for other
P is for project
Q is for quite
R is for right
S is for said
T is for their
U is for under
V is for very
W is for with
X is for xavier
Y is for you
Z is for zoo

```

This is not the shortest this language can do, but should be the best with the words hard coded.
> 3 votes

# Answer
# Bash (+coreutils), ~~81~~, ~~87~~, ~~82~~, 78 bytes

Uses the man page for , as the source of words.

**Golfed**

```
man xyst\  x|&grep -Po '\b[a-z]{4,} '|sed 's/\(.\)/\u\1 is for &/'|sort -uk1,1

```

*EDITS*

* Used a non-existing 'xyst' man page + `|&` to save 5 bytes;
* Saved 4 more bytes, by swapping *sed* and *sort*.

**Test**

```
%man xyst\  x|&grep -Po '\b[a-z]{4,} '|sed 's/\(.\)/\u\1 is for &/'|sort -uk1,1

A is for also
B is for build
C is for computing
D is for distribution
E is for entry
F is for following
G is for graphics
H is for hierarchical
I is for implementations
J is for just
K is for keyboard
L is for listing
M is for manual
N is for network
O is for output
P is for programs
Q is for quite
R is for runs
S is for system
T is for transparent
U is for used
V is for various
W is for window
X is for xyst
Y is for your
Z is for zeros

```
> 62 votes

# Answer
# Python 2, ~~88~~ 77 bytes

-11 bytes thanks to xnor (avoid the zip by traversing the string and counting `c` up from 65)

```
c=65
for x in'niooaauusoioaiuaaoiineeaei':print'%c is for %c%st'%(c,c,x);c+=1

```

**Try it online!**

(A port of my Jelly answer, when it was 56 bytes.)

```
A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

```
> 36 votes

# Answer
# Bash, ~~78~~, 69 bytes

### Aardvarks, Babushkas and Kamikazes !

**Golfed**

```
sed -nr '/^[a-z]{9}$/s/(.)/\u\1 is for &/p'</u*/*/*/words|sort -uk1,1

```

*EDITS*

* Got rid of grep, -9 bytes

**Test**

```
%sed -nr '/^[a-z]{9}$/s/(.)/\u\1 is for &/p'</u*/*/*/words|sort -uk1,1

A is for aardvarks
B is for babushkas
C is for cablecast
D is for dachshund
E is for eagerness
F is for fabricate
G is for gabardine
H is for habitable
I is for ibuprofen
J is for jabberers
K is for kamikazes
L is for labelling
M is for macaronis
N is for nailbrush
O is for obedience
P is for pacemaker
Q is for quadrants
R is for rabbinate
S is for sabotaged
T is for tableland
U is for ulcerated
V is for vacancies
W is for wackiness
X is for xylophone
Y is for yachtsman
Z is for zealously

```

Makes use of */usr/share/dict/words*:

> words is a standard file on all Unix and Unix-like operating systems, and is simply a newline-delimited list of dictionary words. It is used, for instance, by spell-checking programs.
> 31 votes

# Answer
# PowerShell, ~~150~~ ~~141~~ ~~117~~ 75 bytes

```
65..90|%{$i=[char]$_;"$i is for $i$('niooaauusoioaiuaaoiineeaei'[$_-65])t"}

```

Try it online!

Loops from `65` to `90` (i.e., ASCII `A` to `Z`). Each iteration, we turn the integer into the appropriate `char` (i.e., ASCII `65` for `A`), save that into `$i` for use later, string-concatenate that with `is for $i`, and then tack on the middle of the appropriate word. That's done by indexing into a lengthy string (borrowed from Jonathan Allan's answer). Finishes off with the letter `t` to make the three letter word.

The resulting strings are all left on the pipeline, and an implicit `Write-Output` at the end prints them with newlines in between.

*Saved a bunch of bytes thanks to Rod*
*Borrowed wordlist from Jonathan Allan's answer*
> 14 votes

# Answer
# Jelly, 39 bytes

```
;“ẉbẊWS»,⁸K;;”t
“¤ṁp}œḊṄæ®’b6ị“ʠȷ»ØAç"Y

```

**TryItOnline!**

Based on the 56 byte version (two below), but changed words to remove all middle letter `"u"`s so it can index into the dictionary word `"anisole"`\*, which has the convenience of having the letters we need all at indexes less than six: `1:a, 2:n 3:i, 4:s, 5:o (6:l), 0:e` (note the `"e"` on the right is at index zero \[also 7 and -7 and any other number congruent to 0 mod 7\]). It's also early in the dictionary so has only a two rather than the much more common three byte lookup index (`"anisogamete"` would also work for 2).

* The old-school name for the aromatic ether methoxybenzene, often used in perfumes.

```
A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Got
H is for Hat
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Oat
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

```

###How?

```
“¤ṁp}œḊṄæ®’b6ị“ʠȷ»ØAç"Y - Main link: no arguments
“¤ṁp}œḊṄæ®’             - base 250 compressed number -> 75711304811637630759
           b6           - convert to base 6 list
                          -> [           2  ,           3  ,           5  ,           5  ,           1  ,           1  ,           5  ,           1  ,           4  ,           5  ,           3  ,           5  ,           1  ,           3  ,           1  ,           1  ,           1  ,           5  ,           3  ,           3  ,           2  ,           0  ,           0  ,           1  ,           0  ,           3]
              “ʠȷ»      -     word from Jelly's dictionary, "anisole"
             ị          - index into that
                          -> [          "n" ,          "i" ,          "o" ,          "o" ,          "a" ,          "a" ,          "o" ,          "a" ,          "s" ,          "o" ,          "i" ,          "o" ,          "a" ,          "i" ,          "a" ,          "a" ,          "a" ,          "o" ,          "i" ,          "i" ,          "n" ,          "e" ,          "e" ,          "a" ,          "e" ,          "i"]
                  ØA    - get the uppercase alphabet
                          -> [          "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"]
                    ç"  - zip with last Link (1) as a dyad (i.e. get [f("A", "n"), f("B", "i"), ...]
                          -> ["A is for Ant","B is for Bit","C is for Cot","D is for Dot","E is for Eat","F is for Fat","G is for Got","H is for Hat","I is for Ist","J is for Jot","K is for Kit","L is for Lot","M is for Mat","N is for Nit","O is for Oat","P is for Pat","Q is for Qat","R is for Rot","S is for Sit","T is for Tit","U is for Unt","V is for Vet","W is for Wet","X is for Xat","Y is for Yet","Z is for Zit"]
                      Y - join with line feeds
                        - implicit print

;“ẉbẊWS»,⁸K;;”t - Link 1, make a song line: character X; character Y
 “ẉbẊWS»        - compressed string = " is for"
;               - X (e.g. "A") concatenate that ->  "A is for"
        ,       - pair that with
         ⁸      - the left argument (X) ---------> ["A is for","A"]
          K     - join with spaces -------------->  "A is for A"
           ;    - concatenate with Y (e.g. "n") ->  "A is for An"
             ”t - literal character = "t"
            ;   - concatenate ------------------->  "A is for Ant"

```

---

### Previous, 46

```
“¤ṪŻIð^ƥ’b4ị⁾sap⁾pt¤ØAż,@K¥€“ẉbẊWS»ØAżYF”e272¦

```

Words all have second letter "s" or "a" and last letter "p" or "t" using a base four lookup in a Cartesian product of "sa" and "pt". **Except** the "U" word, which the code changes to "Use" (using the relatively bulky `F”e272¦` on the end) - if I could find a word list like this that does not have such an exception we'd be looking at **39 bytes**.

Word list:

```
Asp, Bat, Cat, Dap, Eat, Fat, Gap, Hat, Ist, Jat, Kat, Lap, Mat, Nap, Oat, Pat, Qat, Rat, Sat, Tap, Use, Vat, Wat, Xat, Yap, Zap

```

try this one

---

###Previous 56 bytes

```
”tṁØA⁺,j“niooaauusoioaiuaaoiineeaei”œs3Z,@K¥€“ẉbẊWS»ØAżY

```

Word list:

```
Ant, Bit, Cot, Dot, Eat, Fat, Gut, Hut, Ist, Jot, Kit, Lot, Mat, Nit, Out, Pat, Qat, Rot, Sit, Tit, Unt, Vet, Wet, Xat, Yet, Zit

```

It is formatted, give it a go

---

###Previous, 83 bytes “ẉbẊWS»WṁØA⁺żż“¦ịfe$ɲVPġþ¹Øt@ƑƊŀqṁŒƑOɦ⁴ḍẊḤṁr}Ƭ¢b⁻?q&øIụNẎ9eƲi⁸'ıB.;%V,¦İ⁷ẓk½»s5¤K€Y ...let's play "Spot which letter does not have an animal!" there ~~is one, and only one - watch out for the red herring~~ *(a lie, the red herring was xenon, which is an element, obviously not an animal)*, are two five letter words here that are not animals (xenon being one):

```
Aphid, Bison, Camel, Dingo, Eagle, Finch, Gecko, Heron, Indri, Jabot, Koala, Lemur, Mouse, Nyala, Otter, Panda, Quail, Raven, Sloth, Tapir, Urial, Viper, Whale, Xenon, Yapok, Zebra

```

(of course this is formatted correctly, try it \- I just thought I'd save space)
> 14 votes

# Answer
# Retina, ~~89~~ 87 bytes

*Saved 2 bytes thanks to Martin Ender*

```

ApBaCaDoEaFaGeHaIkaJeKiLeMeNeOpPeQaRaSaTiUniVaWeXysYurZi
[A-Z]
¶$& is for $&
^¶

m`$
t

```

Try it online!

I picked a word for each letter that ends in `t` (some are pretty obscure).

**Explanation**

```

ApBaCaDoEaFaGeHaIkaJeKiLeMeNeOpPeQaRaSaTiUniVaWeXysYurZi
```

Replace the non-existent (empty) input with the text above.

```
[A-Z]
¶$& is for $&

```

Replace each capital letter with `(newline)(itself) is for (itself)`. This results in the text above being split into separate lines like

```
A is for Ap
B is for Ba
C is for Ca

```

... and so on

```
^¶

```

However, since the newline was placed *before* each capital, there is a leading newline that must be removed. It is removed in this stage.

```
m`$
t

```

Put a `t` at the end of every line, since every word used in the song ends in `t`.
> 10 votes

# Answer
## Retina, ~~92~~ 88 bytes

*Saved 4 bytes by borrowing an idea from Business Cat's answer.*

Byte count assumes ISO 8859-1 encoding.

```

AddBCDEelFGHItsJetKitLMNetOilPQatRSTUrnVatWXisYesZit
[A-Z]
¶$& is for $&
m` .$
$&ad
G`.

```

Try it online!

Based on AdmBorkBork's word list, but I've changed a few more words into ones that end in `ad` to save more bytes on the common suffix.

### Explanation

```

AddBCDEelFGHItsJetKitLMNetOilPQatRSTUrnVatWXisYesZit

```

Turn the empty (non-existent) input into this string. It contains all the letters as well as the rest of those words which *don't* end in `ad`.

```
[A-Z]
¶$& is for $&

```

Insert a linefeed before each upper case letter and then turn it into `X is for X`.

```
m` .$
$&ad

```

Match the letters which are now by themselves and append `ad` to complete the shortened words.

```
G`.

```

Discard the empty line that was created by inserting a linefeed before `A`.
> 8 votes

# Answer
# PHP, ~~122~~ ~~124~~ ~~127~~ ~~120~~ ~~115~~ 101 bytes

Follows the "standard" `<letter><filler>t` structure.
I tried to come up with words that weren't used before by anyone.
If you see a word that you want me to replace, tell me.

```
foreach(range(A,Z)as$k=>$c)echo"$c is for $c",ceaoaaei0eieeouoaaei0eeaei[$k]?:[I=>ka,U=>ni][$c],"t\n";

```

The newline is represented as `\n` but counted as 1 byte.

---

**Output:**

```
A is for Act
B is for Bet
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Get
H is for Hit
I is for Ikat
J is for Jet
K is for Kit
L is for Let
M is for Met
N is for Not
O is for Out
P is for Pot
Q is for Qat
R is for Rat
S is for Set
T is for Tit
U is for Unit
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

```

---

**Weird words:**

* ikat:
> Ikat, or ikkat, is a dyeing technique used to pattern textiles that employs resist dyeing on the yarns prior to dyeing and weaving the fabric.
* xat:
> A carved pole erected as a memorial to the dead by some Indians of western North America
* zit:
> a pimple; skin blemish.
* qat:
> Catha edulis (khat, qat) is a flowering plant native to the Horn of Africa and the Arabian Peninsula.
> 7 votes

# Answer
# 05AB1E, ~~45~~ ~~42~~ ~~39~~ ~~38~~ ~~37~~ 36 bytes

```
Au'Æå•à¡P°€kš¦zá®•Sè)øvy¬“ÿ€ˆ€‡ ÿt“,

```

Try it online!

**Explanation**

`Au` pushes the uppercase alphabet.
`'Æå` pushes the word `scenario`.
`•à¡P°€kš¦zá®•` pushes the base-10 number `36774474076746444766322426`.
uses those digits to index into `scenario`.
zips those strings together into the list `[An, Bi, Co, ..., Zi]`

```
v                  # for each element in the list
 y                 # push it
  ¬                # push it's first letter
   “ÿ€ˆ€‡ ÿt“      # push the string "ÿ is for ÿt"
                   # replacing ÿ with with the top element of the stack
             ,     # print with newline

```

Words used: `['Ant', 'Bit', 'Cot', 'Dot', 'Eat', 'Fat', 'Got', 'Hat', 'Ist', 'Jot', 'Kit', 'Lot', 'Mat', 'Nit', 'Oat', 'Pat', 'Qat', 'Rot', 'Sit', 'Tit', 'Unt', 'Vet', 'Wet', 'Xat', 'Yet', 'Zit']`

**33 byte version using some words I'm unsure about**

```
Au'†Ž•4Ãðzòç•3BSè)øvy¬“ÿ€ˆ€‡ ÿt“,

```

Words: `['Ant', 'Bat', 'Cat', 'Dat', 'Eat', 'Fat', 'Gat', 'Hat', 'Ist', 'Jat', 'Kat', 'Lat', 'Mat', 'Nat', 'Oat', 'Pat', 'Qat', 'Rat', 'Sat', 'Tat', 'Ust', 'Vat', 'Wat', 'Xat', 'Yat', 'Zat']`
> 7 votes

# Answer
# Japt, ~~52~~ 50 bytes

*Collaborated with @ETHproductions*

```
;B£[R`  f `Od"¥¥º"gY]qXÃx

```

Contains many unprintables. Test it online!

The word list is:

```
All Bar Can Dan Ear Fan Gas Has Ill Jar Kit Led Man Nit Oar Pan Qat Rat Sat Tan Udo Vat War Xis Yes Zit

```

Japt uses the shoco string compression library, which reduces common runs of lowercase letters into by a byte. Here is a full list of all two-letter runs that are condensed into one byte:

```
an,ar,as,at,be,bl,bo,bu,ca,ce,ch,co,da,de,di,do,ed,en,er,es,ha,he,hi,ho,im,in,is,it,le,li,ll,ly,ma,me,mi,mo,nd,ne,ng,nt,of,on,or,ou,ra,re,ri,ro,se,sh,si,st,te,th,ti,to,ul,ur,us,ut,wa,we,wh,wi

```

So the idea is to form a word with one of these pairs for each letter of the alphabet.

```
;B£   [R`  f `    Od"string"gY]qXÃ x
;BmXY{[R" is for "Od"string"gY]qX} x

;                                      // Among other things, set B to "ABC...XYZ".
 B                                     // Split B into chars.
    mXY{                           }   // Map each item X and index Y to the following:
                      "string"gY       //   Take the char at index Y in the compressed str.
                    Od                 //   Decompress.
        [R" is for "            ]      //   Put this in an array with a newline and " is for ".
                                 qX    //   Join on X, giving "\n{X} is for {word}".
                                    x  // Trim. This removes the leading newline.
                                       // Implicit: output result of last expression

```

One interesting thing to note is that while Japt can implicitly decompress a string wrapped in backticks, that's actually a byte longer here because you'd have to grab *two* chars in the decompressed string, rather than one.
> 6 votes

# Answer
## Pyke, ~~55~~ ~~51~~ 48 bytes

```
26.f[1R].C".d"R+E)DGjt@.^.Il 6>( F['h .dRdJl5

```

Try it here!

Link is for 3 length and doesn't qualify as words include conjunctives.

```
    [1R].C".d"R+E)                            - def function [i):
     1R]                                      -     [1, i]
        .C                                    -    chr(^)
          ".d"R+                              -   ".d"+ ^
                E                             -  eval(^) (dictionary lookup of length 1)
                                              -    gets the `i`th word in the dictionary

26.f[             DGjt@.^.Il 6>(              -  first_26():
    [                                         -     function(i)
                       .^                     -    ^.startswith(v)
                   Gjt@                       -     alphabet[current_iter-1]
                         .Il 6>               -   if ^:
                           l 6>               -    len(function(i)) > 6
                                 F['h .dRdJl5 - for i in ^:
                                  ['h         -     function(i)[0], function(i)
                                      .d      -    "is for" (unprintables 0x02, 0x07, 0x06)
                                        R     -    rotate(^, ^^)
                                         dJ   -   " ".join(^)
                                           l5 -  ^.capitalize()

```

Outputs:

```
A is for available
B is for because
C is for community
D is for download
E is for english
F is for features
G is for getting
H is for hardware
I is for increase
J is for jewelry
K is for kitchen
L is for locations
M is for manufacturer
N is for northern
O is for outdoor
P is for protein
Q is for quickly
R is for religion
S is for surgery
T is for thousands
U is for universal
V is for vehicles
W is for weekend
X is for xenical
Y is for youngest
Z is for zoofilia

```

You can test this outside of Pyke using same algorithm. Requires dictionary.json.

```
import json, string

with open("dictionary.json") as f_obj:
    words=json.load(f_obj)

rtn=[]
i=0
while len(rtn) != 26:
    cur_word=words[i]
    if cur_word[0]==string.lowercase[len(rtn)]:
        if len(cur_word) > 6:
            rtn.append(cur_word)
    i += 1

for i in rtn:
    print("{} is for {}".format(i[0].upper(), i))

```
> 6 votes

# Answer
## Ruby, ~~93 84 69 63 58~~ 62 bytes

```
?A.upto(?Z){|l|puts l+" is for #{"AnDoIsUn"[/#{l}./]||l+?a}t"}

```

**Output:**

```
A is for Ant
B is for Bat
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Gat
H is for Hat
I is for Ist
J is for Jat
K is for Kat
L is for Lat
M is for Mat
N is for Nat
O is for Oat
P is for Pat
Q is for Qat
R is for Rat
S is for Sat
T is for Tat
U is for Unt
V is for Vat
W is for Wat
X is for Xat
Y is for Yat
Z is for Zat

```

All 3-letter words ending with 't', most of them with 'at'.

## Using controversial words (iat, dat, amp. ump) - 55 bytes:

```
?A.upto(?Z){|l|puts l+" is for "+l+("AU"[l]?"mp":"at")}

```

Still trying to find a pattern, I think it's possible to use just 2 different endings, and simplify everything.

Thanks @Value Ink and @Business cat for helping.
> 6 votes

# Answer
## ///, 163 bytes

```
/2/ad//1/ is for /A1Add
B1B2
C1C2
D1D2
E1Eat
F1F2
G1Goo
H1H2
I1Irk
J1Job
K1Kob
L1L2
M1M2
N1Nob
O1Owl
P1P2
Q1Qat
R1R2
S1S2
T1T2
U1Use
V1Vat
W1W2
X1X-ray
Y1Yob
Z1Zoo

```

Try it online

> Yob - n. - A cruel and brutal fellow

Hm, learned something today...
> 6 votes

# Answer
# 05AB1E, ~~72~~ 68 bytes

### Code:

```
”–³æéÁéî¹àæÑåêÂ§µ™Ä‚æ†Í„Î¢×†™ƒÛÌ´ŸÄ«©‡¯†‚Ä²‚Ò„©É€ŠÛì„”#vy¬…ÿ€ˆ€‡ð«ì,

```

Uses the **CP-1252** encoding. Try it online!

### Explanation

The following code:

```
”–³æéÁéî¹àæÑåêÂ§µ™Ä‚æ†Í„Î¢×†™ƒÛÌ´ŸÄ«©‡¯†‚Ä²‚Ò„©É€ŠÛì„”#

```

pushes this array:

```
['Apple', 'Banana', 'Carol', 'Door', 'Elephant', 'Frog', 'Goat', 'Hat', 'Ice', 'January', 'Key', 'Love', 'Mom', 'Never', 'Open', 'Paste', 'Queen', 'Rice', 'Star', 'Test', 'Underwear', 'Very', 'Water', 'Xanax', 'Yellow', 'Zoloft']

```

And is processed using the following code:

```
vy¬…ÿ€ˆ€‡ð«ì,

vy              # For each string in the array
  ¬             # Get the first letter of that string
   …ÿ€ˆ€‡       # Push the string "ÿ is for" where 'ÿ' is the first letter of the string
         ð«     # Append a space character
           ì    # Prepend this string to the current string from the array
            ,   # Print with a newline

```
> 5 votes

# Answer
# Clojure, ~~159~~ 232 bytes

Well, now it's certainly non-competing solution as it would be far easier to hardcode the words used. Putting it out there just for the sake of having *correct* answer (and not using others' list of words).

```
(mapv #(println(str(char %)" is for"(first(re-seq(re-pattern(str" "(char(+ % 32))"+\\w{3,} "))
    (reduce(fn[a b](str a(with-out-str(load-string(str "(doc "b")")))))" xyst "(map str(keys(ns-publics 'clojure.core))))))))(range 65 91))

```

Basically still gets all the functions defined in `clojure.core` namespace, but after that evaluates `doc <function name>` and puts it into string. After that concatenates it into one huge string (with the word `xyst`) and finds appropriate words from there. Should be run in Clojure REPL.

Output:

```
A is for arbitrary
B is for being
C is for changes
D is for determined
E is for exception
F is for failed
G is for given
H is for held
I is for items
J is for java
K is for keys
L is for lazy
M is for must
N is for notified
O is for option
P is for performed
Q is for queued
R is for returns
S is for state
T is for true
U is for uses
V is for validator
W is for were
X is for xyst
Y is for yields
Z is for zero

```

Old solution:

```
(mapv #(println(str(char %)" is for "(some(fn[a](and(=(.charAt a 0)(char(+ % 32)))a))(conj(map str(keys(ns-publics 'clojure.core)))"orb""yes"))))(range 65 91))

```
> 4 votes

# Answer
# JavaScript (ES6), 82 bytes

```
_=>btoa`pb
è¡Záî"Âh*"è1£b:ãÚA¤hJ$âRu^YåÚaæb`.replace(/(.)./g,`$1 is for $&t
`)

```

An anonymous function returning a string. Contains unprintables; here's a version that doesn't:

```
_=>btoa`\x02pb
\x80è\x11¡Z\x18áî"Âh*"è1£b:ãÚA¤hJ$âRu^YåÚaæb`.replace(/(.)./g,`$1 is for $&t
`)

```

This uses @JonathanAllen's technique, using only three-letter words that end in `t`. The string decompresses to `AnBiCoDoEaFaGOHuIsJoKiLoMaNiOuPaQaRoSiTiUnVeWeXaYeZi`.

I tried chaining two-letter pairs like so:

```
Ace
 Bee
  Cee
   Dew
    Ewe
     ...

```

I've now made it all the way to `X` but got stuck on `Y`; as far as I can tell, the only attainable three-letter `X` word is `Xis`, and there's no three-letter word starting with `Ys`.

For the record, the full string was `ceeeweeereueaebiueeiziais`...
> 4 votes

# Answer
# Mathematica, 97 bytes

```
a@c_:={ToUpperCase@c," is for ",Select[WordList[],#~StringTake~1==c&][[3]],"
"};a/@Alphabet[]<>""

```

Looks in Mathematica's `WordList` for the third word beginning with each letter; this avoids one-letter words and interjections. Has a trailng newline.

```
A is for aardvark
B is for babble
C is for cabala
D is for dabbled
E is for eagerly
F is for fable
G is for gabble
H is for haberdashery
I is for iambus
J is for jabberer
K is for kaleidoscope
L is for label
M is for mac
N is for nacelle
O is for oak
P is for pabulum
Q is for quackery
R is for rabbinate
S is for sable
T is for tabbouleh
U is for udder
V is for vacant
W is for wad
X is for xenophobic
Y is for yachting
Z is for zapper

```
> 3 votes

# Answer
## Groovy, 76 73 bytes

(edited from 76 to 73 bytes, thank you cat)

Inspired by the ruby solution:

```
('A'..'Z').any{i->println"$i is for ${'AntIvyUse'.find(/$i../)?:i+'at'}"}

```

we use `any` instead of each as it is shorter and all the println statements return false. For the special cases in the string, we use String.find which in groovy returns the match or null. On null we use the elvis operator `?:` to return a word ending in `at` instead.

Prints out:

```
A is for Ant
B is for Bat
C is for Cat
D is for Dat
E is for Eat
F is for Fat
G is for Gat
H is for Hat
I is for Ivy
J is for Jat
K is for Kat
L is for Lat
M is for Mat
N is for Nat
O is for Oat
P is for Pat
Q is for Qat
R is for Rat
S is for Sat
T is for Tat
U is for Use
V is for Vat
W is for Wat
X is for Xat
Y is for Yat
Z is for Zat

```

## Groovy, recursion, 74 bytes

```
{i->println"$i is for ${'AntIvyUse'.find(/$i../)?:i+'at'}";call(++i)}('A')

```

prints out the text from the first answer and then throws a PatternFormatException. We call the closure recursively starting with 'A' and incrementing `++char` until the character after `Z` throws the error.

## Groovy, by cheating, 77 bytes

With the risk of being lynched:

```
print 'http://codegolf.stackexchange.com/q/109502'.toURL().text[21796..22189]

```

i.e. read the data in this page and print out the definition of a valid answer at the beginning. In my defense...it does print out the requested answer...now nobody edit the page...

## Groovy, using 'times', 81 bytes

Building on the python answer with the three letter word pattern:

```
26.times{i,c=i+65->printf"%c is for %c${'niooaauusoioaiuaaoiineeaei'[i]}t\n",c,c}

```

prints:

```
A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

```

## Groovy, by recursing on main(...), 83 bytes

Assuming we count newlines as one character.

```
i=args?args[0]:'A'
println"$i is for ${'AntIvyUse'.find(/$i../)?:i+'at'}"
main(++i)

```

prints out the text from the first answer and then throws a PatternSyntaxException.

## Groovy, using eachWithIndex, 88 bytes

```
'niooaauusoioaiuaaoiineeaei'.eachWithIndex{c,i->char x=i+65;println "$x is for $x${c}t"}

```

## Groovy, using transpose, 102 bytes

```
['A'..'Z','niooaauusoioaiuaaoiineeaei'as List].transpose().each{println it[0]+" is for ${it.join()}t"}

```
> 3 votes

# Answer
# SmileBASIC, ~~131~~ ~~113~~ ~~82~~ 81 bytes

```
FOR I=1TO 26L$=CHR$(I+64)?L$;" is for ";L$;@niooaauusoioaiuaaoiineeaei[I];"t
NEXT

```

Now using words that in `t`
> 2 votes

# Answer
# 05AB1E, 77 bytes

```
•‹T1qA‹rËöf#ùqÈ$>M©ÈñM£r°§°Ü]€¡3¸/©#bÍ'ò7DÉø½D—¹û©˜Ò×•36B3ôvy™¬"ÿ is for ÿ"}»

```

Try it online!

Uses the following string compressed:

ASSBINCATDOTEATFATGOTHATILLJOTKITLOTMETNOTOATPATQUEROTSETTITUSEVATWETXISYIPZAP

Converted to Base-214:

```
‹T1qA‹rËöf#ùqÈ$>M©ÈñM£r°§°Ü]€¡3¸/©#bÍ'ò7DÉø½D—¹û©˜Ò×

```

---

Used a list of 3-letter scrabble words: http://wordfinder.yourdictionary.com/letter-words/3

Output is as follows:

```
A is for Ass
B is for Bin
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Got
H is for Hat
I is for Ill
J is for Jot
K is for Kit
L is for Lot
M is for Met
N is for Not
O is for Oat
P is for Pat
Q is for Que
R is for Rot
S is for Set
T is for Tit
U is for Use
V is for Vat
W is for Wet
X is for Xis
Y is for Yip
Z is for Zap

```

Had a 70 byte version, but 2-letter words aren't allowed.

---

Explained:

```
•‹T1qA‹rËöf#ùqÈ$>M©ÈñM£r°§°Ü]€¡3¸/©#bÍ'ò7DÉø½D—¹û©˜Ò×• # Compressed String

36B3ô                   # Decompress, split into 3s.
     v               }  # For each word...
      y™¬"ÿ is for ÿ"   # Take first letter of word, interpolate.
                      » # Print with newlines.

```
> 2 votes

# Answer
## Lithp, 136 125 117 bytes

```
((import lists)(each(split "niooaauusoioaiuaaoiineeaei" "")
#X,C::((print(chr(+ 65 C))"is for"(+(chr(+ 65 C))X "t"))))

```

(Split for readability)

Try it online!

This is pretty much a port of the Python answer

* Saved 11 bytes by using `each`'s index
* Saved 8 bytes by removing useless call to `(scope #)`

**Output:**

```
A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

```
> 2 votes

# Answer
# Perl 5, 72 bytes

```
say"$_ is for $_",(niooaaoasoioaiaaaoiineeaei=~/./g)[-65+ord],t for A..Z

```

Try it online!
> 2 votes

# Answer
## Batch, 250 bytes

```
@set s=ABCDEFGHIJKLMNOPQRSTUVWXYZ
@for %%w in (eon dellium zar jinn lbow hon nat our rk unta not lama nemonic domo uija sycho uay ye ee sunami rn ex rap enophobe ou ugzwang)do @call:c %%w
@exit/b
:c
@echo %s:~0,1% is for %s:~0,1%%1
@set s=%s:~1%

```

Since I was never going to get a decent score, I went for the shortest *humorous* words that I could find:

```
A is for Aeon
B is for Bdellium
C is for Czar
D is for Djinn
E is for Elbow
F is for Fhon
G is for Gnat
H is for Hour
I is for Irk
J is for Junta
K is for Knot
L is for Llama
M is for Mnemonic
N is for Ndomo
O is for Ouija
P is for Psycho
Q is for Quay
R is for Rye
S is for See
T is for Tsunami
U is for Urn
V is for Vex
W is for Wrap
X is for Xenophobe
Y is for You
Z is for Zugzwang

```
> 1 votes

# Answer
# stacked, 72 bytes

There are *two* for 72 bytes!

```
65@i$'niooaauusoioaiuaaoiineeaei'{!i#::' is for '+\n+'t'+ +out i 1+@i}"!
{!n#::' is for '+\'niooaauusoioaiuaaoiineeaei'n 65-#+'t'+ +out}65 90 for

```

Try it online! Using that awesome pattern. (Before you ask, `++` would be a single token, so `+ +` is used instead.)

Both work by iterating from `65` to `90` and getting the correct character sequence. Notes:

* `#:` is an alias for `chr`
* `#` is an alias for `get`
* `{!...}` is the same as `{ n : ... }` (lambda with `n` as an parameter)

For 73 bytes:

```
'niooaauusoioaiuaaoiineeaei'toarr{e i:65 i+#::' is for '+\e+'t'+ +out}map

```
> 1 votes

# Answer
# Java 7, ~~124~~ 121 bytes

```
String c(){String r="";for(char c=65;c<91;r+=c+" is for "+c+"baaonaiineioaeaoaaeileeaoi".charAt(c++-65)+"t\n");return r;}

```

Based on *@JonathanAllen*'s answer, since Java has no fancy built-in dictionary. ;) I tried to find another ending letter for the entire alphabet (like `s` or `n` or `y`), or a middle letter (like `a` or `e`), but most were missing just one or two words, so I ended up using `t` as well. Words are manually chosen from wordhippo.com.

**Ungolfed:**

Try it here.

```
class M{
  static String c(){String r="";for(char c=65;c<91;r+=c+" is for "+c+"baaonaiineioaeaoaaeileeaoi".charAt(c++-65)+"t\n");return r;}

  public static void main(String[] a){
    System.out.println(c());
  }
}

```

**Output:**

```
A is for Abt
B is for Bat
C is for Cat
D is for Dot
E is for Ent
F is for Fat
G is for Git
H is for Hit
I is for Int
J is for Jet
K is for Kit
L is for Lot
M is for Mat
N is for Net
O is for Oat
P is for Pot
Q is for Qat
R is for Rat
S is for Set
T is for Tit
U is for Ult
V is for Vet
W is for Wet
X is for Xat
Y is for Yot
Z is for Zit

```
> 1 votes

# Answer
# Python 3, ~~145~~ ~~137~~ 135 bytes

I sacrificed some bytes to pseudo-randomise the output with each run. The idea is to look for lowercase words of at least 3 characters in `/usr/share/dict/words` and then pick one from that list using `id([x])%99`.

```
import re
for x in range(65,91):print("%c is for "%x+re.findall("\n(%c.{3,})"%(x+32),open('/usr/share/dict/words').read())[id([x])%99])

```

Edits

* Removed `title()` as words don't have to be capitalised.
* Changed the regex to `"\n(%c.{3,})"` (+ 3 bytes) to allow removal of `,re.M` (- 5 bytes).

Example output:

```
A is for abacinate
B is for bacchantic
C is for caback
D is for dactylosternal
E is for eagless
F is for factful
G is for gabbroic
H is for hackneyed
I is for iambize
J is for jacutinga
K is for kadaya
L is for labra
M is for macaco
N is for nailwort
O is for oakenshaw
P is for pachysomia
Q is for quachil
R is for racer
S is for sabbath
T is for tabulable
U is for ubication
V is for vagabondism
W is for wabe
X is for xenobiosis
Y is for yacca
Z is for zeed

```
> 1 votes

# Answer
## Mathematica 93 Bytes

```
ToUpperCase@#<>" is for "<>Cases[WordList[],s_/; s~StringPart~1==#][[9]]&/@Alphabet[]//Column

```

yields

```
A is for abandoned
B is for babushka
C is for cabin
D is for dactylic
E is for eardrum
F is for fabricator
G is for gadabout
H is for habitation
I is for ice
J is for jackal
K is for kappa
L is for laboratory
M is for macaroni
N is for nagger
O is for oarsman
P is for pachysandra
Q is for quadratic
R is for rabidness
S is for saccharin
T is for tableland
U is for ulcer
V is for vacationist
W is for wadi
X is for xylene
Y is for yammer
Z is for zebra

```
> 1 votes

# Answer
# Groovy, 72 bytes

```
c=65;"niooaauusoioaiuaaoiineeaei".any{printf"%c is for %<c%st\n",c++,it}

```

**Output**

```
A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

```
> 1 votes

# Answer
## GNU sed, 81 + 1(r flag) = 82 bytes

This is a sed implementation of the word list from Jonathan Allan's answer.

```
s:$:AnBiCoDoEaFaGuHuIsJoKiLoMaNiOuPaQaRoSiTiUnVeWeXaYeZi:
s:(.).:\1 is for &t\n:g

```

The words, except the shared ending letter `t`, are given in concatenated form on line 1, and then printed in the requested format by line 2. A trailing newline is present.

**Run**:

```
sed -rf alphabet_song.sed <<< ""

```
> 1 votes

# Answer
# PHP, ~~91~~ ~~87~~ ~~86~~ 76 bytes

based on Jonathan Allan´s word list:

```
for($a=A;$i<26;)echo"$a is for ",$a++,neaoaaeiseioeuuoaaiineiaei[$i++],"t
";

```

older versions, 86 bytes:

```
for($a=A;a&$c=reaoaaei0eioeuuoaaii0eiaei[$i++];)echo"$a is for ",$a++,$c?$c.t:nto,"
";

```

or

```
for($a=A;$c=reaoaaeiHeioeuuoaaiiHeiaei[$i++];)echo"$a is for ",$a++,$c^x?$c.t:nto,"
";

```

Run with `-nr`.

**output**

```
A is for Art
B is for Bet
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Get
H is for Hit
I is for Into
J is for Jet
K is for Kit
L is for Lot
M is for Met
N is for Nut
O is for Out
P is for Pot
Q is for Qat
R is for Rat
S is for Sit
T is for Tit
U is for Unto
V is for Vet
W is for Wit
X is for Xat
Y is for Yet
Z is for Zit

```

For the weird words, see Ismael´s answer
> 1 votes

# Answer
# Vyxal `j`, 38 bytes

```
»hrZ⌈∪≠ẏ¡ɽ»`…„ṙµ`τkAZƛ÷:ðJ«⁼Ė⁼|«Jpp\tJ

```

Try it Online!

Port of Jelly answer.

## How?

```
»hrZ⌈∪≠ẏ¡ɽ»`…„ṙµ`τkAZƛ÷:ðJ«⁼Ė⁼|«Jpp\tJ
»hrZ⌈∪≠ẏ¡ɽ»                             # Push compressed number 1849391794619481940361
           `…„ṙµ`                       # Push dictionary compressed string "anisole"
                 τ                      # Convert to custom base (this will result in "niooaaoasoioaiaaaoiineeaei")
                  kAZ                   # Zip with the uppercase alphabet
                     ƛ÷:                # For each item, push both to the stack and duplicate the top item (e.g. stack: "n", "A", "A")
                        ðJ              # Add a space to the end of the alphabet letter
                          «⁼Ė⁼|«J       # Concatenate compressed string "is for " to it
                                 pp     # Concatenate the alphabet letter and the other letter to the end (e.g. stack: "A is for An")
                                   \tJ  # Append the letter "t" to the end
                                        # j flag joins the top of the stack on newlines

```
> 1 votes

# Answer
# Python 2, 112 bytes

```
for x in range(26):y=chr(x+65);print y+' is for '+y+'naaoaaeaneieaiaaaaairaeeei'[x:x+1]+('t','n')[x in(8,20,23)]

```

Try it online!

All of the words end with 't' except for 3 which end with 'n' so we just store the middle letters of the three letter words and indexes of the 3 'n' words and sort out the 'misfits' at the end.
> 0 votes

# Answer
# Python 2.X, 147 bytes

Yet another try in python using **nltk** \-

```
from nltk.corpus import*;k=lambda y:filter(lambda x:y in x[0],words.words());print'\n'.join([chr(i)+' is for '+k(chr(i))[64]for i in range(65,91)])

```

## Output -

```
A is for Abranchiata
B is for Baconic
C is for Cahokia
D is for Damara
E is for Echium
F is for Fascista
G is for Galenic
H is for Halawi
I is for Ichthyornithidae
J is for Jamaica
K is for Kanauji
L is for Lahontan
M is for Macropodinae
N is for Nankingese
O is for Odelsthing
P is for Palaeeudyptes
Q is for Quintius
R is for Rambo
S is for Sac
T is for Tagula
U is for Ulyssean
V is for Vanguardist
W is for Wallon
X is for Xiphodontidae
Y is for Yazoo
Z is for Zea

```

## Ungolfed

```
from nltk.corpus import*
k=lambda y:filter(lambda x:y in x[0],words.words())
print'\n'.join([chr(i)+' is for '+k(chr(i))[27]for i in range(65,91)])

```
> 0 votes

# Answer
# Befunge-93, 73 bytes

This just uses three-letter words, where the last letter is always `t`.

```
naaoaauanoioaefeauoosaeaei:0\55+\"t"\:0g\"A"+:," rof si ">:#,_$1+:55*`#@_

```

Try it online!

But with an additional two bytes, we can vary the last letter between `t` and `e` and get a more interesting selection.

```
teuowaeocoaooudouaeosaoaei:"A"+:,0" rof si ">:#,_$,:0g,1+:2%0g,55+,:55*`#@_

```

Try it online!
> 0 votes

# Answer
# Jelly, 153 bytes (hardcoded words)

```
“¢r£ẒẸv⁽Ẋ⁷ƥḷṢ⁴kṣe]Ȧ½ṇZṅẸȥɓ!ṗẒ/¿`-¤ḅṘẠṗıBṖ²}çSṘ¦qḤAi\Ḃɲ=T¿?İ®ʋÇIZ(ṅ/ß+oŻ#⁽ƙ©Ḷ!&ẋṡU7FocĊ¶€¢¦ḥLØṀ¿;ȥż!Ọerṫ÷1Ẹjẏ8Ƙ&£ṃṾḊ¿Ṅ⁾ị°ÑBḅQ²€œðḤDẊj£ṅĠsṿBsƤȤ»ṣ”%j“ẉbẊWS»

```

Try it online!

```
A is for Apple
B is for Bald
C is for Cabin
D is for Dairy
E is for Eagle
F is for Fact
G is for Gauge
H is for Humid
I is for Iamb
J is for Jar
K is for Keg
L is for Lad
M is for Music
N is for Nose
O is for Oak
P is for Page
Q is for Quart
R is for Rag
S is for Sock
T is for Taco
U is for Udon
V is for Vault
W is for Week
X is for Xylophone
Y is for Yard
Z is for Zoo

```
> 0 votes

# Answer
# Scala, 85 bytes

Based on *@JonathanAllen*'s answer

---

Golfed version. Try it online!

```
var c=65
for(x<-"niooaauusoioaiuaaoiineeaei"){println(f"$c%c is for $c%c$x%st");c+=1}

```

Ungolfed version. Try it online!

```
object Main {
  def main(args: Array[String]): Unit = {
    var c = 65
    val input = "niooaauusoioaiuaaoiineeaei"
    for (x <- input) {
      val output = f"$c%c is for $c%c$x%st"
      println(output)
      c += 1
    }
  }
}

```
> 0 votes

---
Tags: code-golf, kolmogorov-complexity, alphabet
---