57
\$\begingroup\$

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


This challenge was inspired by this video.

\$\endgroup\$
12
  • 2
    \$\begingroup\$ Given some of the answers, this song by Barenaked Ladies seems relevant. \$\endgroup\$ Feb 8, 2017 at 19:21
  • 1
    \$\begingroup\$ @JonathanAllan No slang. Dictionaries contain a lot of things that aren't technically words. Abbreviations is one, slang is another. \$\endgroup\$
    – mbomb007
    Feb 8, 2017 at 19:34
  • 4
    \$\begingroup\$ It's too bad that this devolved into finding 3 letter words that end in the same letter. \$\endgroup\$
    – 12Me21
    Feb 9, 2017 at 0:33
  • 1
    \$\begingroup\$ @12Me21 how is that devolution, is this not code-golf?! If you can find a way to access longer words with fewer bytes just do it! Edit - Find a list of 3-letter words using a set of two middle letters and a set of two end letters and you can beat the single enders (which use a set of seven middles). \$\endgroup\$ Feb 9, 2017 at 12:32
  • 1
    \$\begingroup\$ There's a couple of answers using an external dictionary. Shouldn't they have to add the size of that file to their code? \$\endgroup\$
    – pipe
    Feb 9, 2017 at 15:30

37 Answers 37

1
2
1
\$\begingroup\$

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

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

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

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

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.

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

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!

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

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

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

\$\endgroup\$
1
2

Your Answer

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

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