| Bytes | Lang | Time | Link |
|---|---|---|---|
| 457 | AWK | 241202T170247Z | xrs |
| 279 | Japt R | 180215T164153Z | Shaggy |
| 898 | Powershell 898 Bytes | 190222T161637Z | Add-TheN |
| 399 | Perl 6 | 190222T115756Z | Jo King |
| 342 | Pyth | 190221T164110Z | Sok |
| 480 | Python 3 | 160719T115416Z | aaaantoi |
| 424 | JavaScript | 180219T175641Z | Shaggy |
| 413 | Perl 5 | 180214T202556Z | Xcali |
| 552 | C clang | 180214T072530Z | gastropn |
| 366 | PHP | 160724T204615Z | 1133261 |
| 497 | Haskell 497 Bytes | 160720T183724Z | user2845 |
| 311 | 05AB1E | 160719T152014Z | Emigna |
| 647 | Batch | 160719T160837Z | Neil |
| 535 | LUA | 160721T140515Z | CHlM3RA |
| 572 | C# | 160720T141547Z | Derpcode |
| 456 | R | 160719T102748Z | Robert M |
| 512 | /// | 160719T142618Z | Erik the |
| 581 | QB64 QuickBASIC | 160721T045112Z | GuitarPi |
| 441 | Python 3 | 160720T061303Z | RootTwo |
| 519 | Swift2 | 160721T005017Z | Vagner |
| 387 | Dyalog APL | 160719T055409Z | Adá |
| 552 | F# | 160719T132304Z | asibahi |
| nan | Java | 160720T100630Z | user9023 |
| 454 | Python 2 | 160719T221326Z | Cowabung |
| 526 | clojure | 160719T190901Z | Chris F |
| 493 | C# | 160719T142852Z | aloisdg |
| 596 | C | 160719T123727Z | owacoder |
| nan | Emacs Lisp | 160719T081431Z | Lord Yuu |
| 402 | Bash + zcat | 160719T132607Z | Hastur |
| 384 | Pyth 384 Bytes | 160719T071724Z | KoreanwG |
| 412 | PHP | 160719T054734Z | Titus |
| 497 | JavaScript | 160719T043731Z | charredg |
AWK, 457 bytes
END{split("Polar Bear,Lion,Hippopotamus,Flamingo,Zebra,Boa Constrictor,Elephant,Leopard,Peacock,Walrus,Zookeeper",a,",")
split("growling roaring snorting fluting braying hissing trumpeting snarling yelping bellowing whistling",b)
for(;i++<11;){printf a[i]", "a[i]", what do you hear?\nI hear ";printf i<11?tolower(a[i+1])" "b[i+1]" in my ear.\n\n":"children...\n\n..."}for(;j++<10;){print b[j]" like a "tolower(a[j]) (j<10?",":"...\nthat\'s what I hear.")}}
Japt -R, 308 303 299 295 288 280 294 289 286 279 bytes
6 years later, I find myself embarrassed by this mess! Will come back to it in the new year to try a completely fresh approach.
`Pol BÁLiyHippopotam«yFlaÚÁoyZeßBoa CÆqÎtyE¤pÊCyLeopÂýPea¬ckyWalr«yZookeep`qy
`gwÓ2ÂüÍdfl©dßdÊdtruÛFdsnÓ)lpdÞ)owdØtl`qd
Ë+`, {D}, Ø º y Ê#?
I Ê# {E<A?[E¶5?``:'aSUg°E v SVgE `g my e.`R]¬:[`å,Á`Q='.³R²QU¯J £[Vv `g ¦ke `Y¶6?``:'aSXv]¬Ãq`,
` QR`È 's Ø I Ê#.`]¬
Powershell 921 889 886 898 Bytes
it's not perfect, but it saves 300 Bytes :)
EDIT: Thanks Jonathan Frech, i saved 32 Bytes. And thank you Veskah for correcting the Output.
filter Z($1,$2){while($1){$x,$1=$1
$y,$2=$2
[tuple]::Create($x,$y)}}
$0="ing"
$$="hear"
$1="I $$ a "
$3='in my ear.'
$a='Polar Bear'
$b='Lion'
$c='Hippopotamus'
$d='Flamingo'
$e='Zebra'
$f='Boa Constrictor'
$g='Elephant'
$h='Leopard'
$i='Peacock'
$j='Walrus'
$k='Zookeeper'
$v="children"
$2="roar$0"
$4="snort$0"
$5="flut$0"
$6="bray$0"
$7="hiss$0"
$8="trumpet$0"
$9="snarl$0"
$x="yelp$0"
$y="bellow$0"
$^="whistl$0"
$l="$1$b $2$3"
$m="$1$c $4$3"
$n="$1$d $5$3"
$o="$1$e $6$3"
$p="$1$f $7$3"
$q="I $$ an $g $8$3"
$r="$1$h $9$3"
$s="$1$i $x$3"
$t="$1$j $y$3"
$u="$1$k $^$3"
$z=' like a '
$w="I $$ $v..."
z $a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k $l,$m,$n,$o,$p,$q,$r,$s,$t,$u,$w|%{"$($_.item1),"*2+"what do you $$?";$_.item2;""}
"...growl$0$z$a,"
z $b,$c,$d,$e,$f $2,$4,$5,$6,$7|%{$_.item2+$z+$_.item1+","}
"$8 like an $g,"
z $h,$i $9,$x,$y|%{$_.item2+$z+$_.item1+","}
$y+$z+"Walrus..."
"that's what I $$."
Perl 6, 400 399 bytes
((my \a=<<"Polar Bear"Lion Hippopotamus Flamingo Zebra"Boa Constrictor"Elephant Leopard Peacock Walrus Zookeeper>>)>>.&{"$_, $_, what do you hear?
I hear a {a[++$!].lc} {($/=<growl roar snort flut bray hiss trumpet snarl yelp bellow whistl>)[$!]}ing in my ear.
"},"...{a[^10]>>.&{$/[$++]~"ing like a",.lc}.join(",
")}...
that's what I hear.")>>.trans(["a e",/a\s\s.*r/]=>["an e","children.."])>>.say
Sub-400 bytes!
Pyth, 342 bytes
L:b"a e""an e"y>sm.F"
I hear a {1} {0} in my ear.
{2}, {2}, what do you hear?"+dr3edJC,+R"ing"c"growl
roar
snort
flut
bray
hiss
trumpet
snarl
yelp
bellow
whistl"bc"polar bear
lion
hippopotamus
flamingo
zebra
boa constrictor
elephant
leopard
peacock
walrus
zookeeper"b42"I hear children...
"jPPysm+j" like a "d",
"PJc2*6\."that's what I hear.
Try it online here.
Explanation to follow.
Python 3, 497 484 480 bytes
P=print
N=lambda m:"an"[:("E"==m[0])+1]+" "+m.lower()
h="I hear "
A=[a.split("|")for a in"Polar Bear|growl:Lion|roar:Hippopotamus|snort:Flamingo|flut:Zebra|bray:Boa Constrictor|hiss:Elephant|trumpet:Leopard|snarl:Peacock|yelp:Walrus|bellow:Zookeeper|whistl".split(":")]
for i in range(11):
a,b=A[i]
if i:P(h+N(a)+" "+b+"ing in my ear.\n")
a+=", ";P(a+a+"what do you hear?")
P(h+"children...\n\n..."+",\n".join([z+"ing like "+N(y)for y,z in A[:-1]])+"...\nthat's what I hear.")
(Credit for 13 bytes saved should go to Gábor Fekete, and an additional 4 bytes were saved by Taylor Lopez.)
So you could probably guess I was going to use a language like Python as a teaching tool. This was the program before I started golfing it.
def startsWithVowel(name):
firstLetter = name[0]
return firstLetter in ["A", "E", "I", "O", "U"]
def aOrAn(name):
return "an" if startsWithVowel(name) else "a"
animals = [
# NAME (0), SOUND (1)
("Polar Bear", "growling"),
("Lion", "roaring"),
("Hippopotamus", "snorting"),
("Flamingo", "fluting"),
("Zebra", "braying"),
("Boa Constrictor", "hissing"),
("Elephant", "trumpeting"),
("Leopard", "snarling"),
("Peacock", "yelping"),
("Walrus", "bellowing"),
("Robot Dragon", "screeching"),
("Owl", "hooting"),
("Monkey", "laughing"),
("Zookeeper", "whistling")]
NAME = 0
SOUND = 1
for animalNumber in range(len(animals)):
thisAnimal = animals[animalNumber]
if animalNumber + 1 < len(animals):
nextAnimal = animals[animalNumber + 1]
else:
nextAnimal = None
print("{n}, {n}, what do you hear?".format(n=thisAnimal[NAME]))
if nextAnimal != None:
print("I hear {a} {n} {s} in my ear.".format(n=nextAnimal[NAME].lower(),
s=nextAnimal[SOUND],
a=aOrAn(nextAnimal[NAME])))
else:
print("I hear children...")
children = []
for animal in animals[:-1]:
children.append("{s} like {a} {n}".format(n=animal[NAME].lower(),
s=animal[SOUND],
a=aOrAn(animal[NAME])))
print("...{}...".format(",\n".join(children)))
print("that's what I hear.")
JavaScript, 424 bytes
f=(x=0,a=btoa`>Z¯ ^j¼Ëó*i¢-jk¬ÌYZ)à£6^n¶³²
춸¶óW©©íÌ·¨¥ªÝÌ÷r$Íf¥®ë3f$yê^¯0`[s=`split`]`y`.join` `[s]`z`,g=z=>n[z]+`ing like `+h(17)+l(z)+(z>9?`...
that's what I hear.`:`,
`+g(++z)),h=m=>++x%m?`a `:`an `,l=y=>a[y].toLowerCase(n=btoa`º0:èj¼ìíÍùn·6ëk,áË3¶»¦¥ës²v«<ÛzYhÃ<!ËeÌ`[s]`z`))=>a[x]+`, ${a[x]}, what do you hear?
I hear `+(x>9?`children...
...`+g(0):h(6)+l(x)+` ${n[x]}ing in my ear.
`+f(x))
Perl 5, 413 bytes
@t=('Polar Bear',growl,Lion,roar,Hippopotamus,snort,Flamingo,flut,Zebra,bray,'Boa Constrictor',hiss,Elephant,trumpet,Leopard,snarl,Peacock,yelp,Walrus,bellow,Zookeeper,whistl);say$_=$t[$i],", $_, what do you hear?
I hear ",/Zo/?"children...
":"a".n x(/C/).lc" $t[$i+=2] $t[$i+1]ing in my ear.
"while!/Zo/;pop@t;pop@t;print'...';say+(shift@t)."ing like a ".lc.(@t?",":'...')while$_=shift@t;say"that's what I hear."
C (clang), 552 bytes
(*P)()=printf;l(char*s){for(;*s;s++)putchar(*s>64?*s|32:*s);}char*a[]={"Zookeeper","Walrus","Peacock","Leopard","Elephant","Boa Constrictor","Zebra","Flamingo","Hippopotamus","Lion","Polar Bear"},*s[]={"whistl","bellow","yelp","snarl","trumpet","hiss","bray","flut","snort","roar","growl"};f(i){for(i=11;i--;)P("%s, %s, what do you hear?\nI hear%s ",a[i],a[i],i?i^5?" a":" an":""),i?l(a[i-1]):0,P(i?" %sing in my ear.\n\n":"children...\n\n...",s[i-1]);for(i=11;--i;)P("%sing like a%s ",s[i],i^4?"":"n"),l(a[i]),P(i-1?",\n":"...\nthat's what I hear.");}
PHP, 366 bytes
Lazy answer, but why write a custom decompressor when gzip is available?
Hex dump of PHP code (can be saved with xxd -r)
0000000: 3c3f 3d67 7a69 6e66 6c61 7465 2827 7d53 <?=gzinflate('}S
0000010: c16a 8430 10bd e72b e6d6 cbe0 2f14 b6b4 .j.0...+..../...
0000020: b4d0 c3de 0abd 8d6e baca c64c 1823 62bf .......n...L.#b.
0000030: be51 3354 1472 58f3 76de f864 e6bd 5cd9 .Q3T.rX.v..d..\.
0000040: 91c0 c592 20ec f1d4 5284 1bc3 cc23 b4a9 .... ...R....#..
0000050: f26c 3ed6 1308 5cc7 1e84 493a 7f87 ce43 .l>...\...I:...C
0000060: 3f43 222a 633e 1381 b03d 0bef b75d 081c ?C"*c>...=...]..
0000070: 3852 3f0e 3078 9678 147a df75 20ec ff15 8R?.0x.x.z.u ...
0000080: 857f 1cf5 498a 1318 4f9a 6f99 4450 54d4 ....I...O.o.DPT.
0000090: fab5 b510 a4df 7c14 fa5e 1884 7c14 246a ......|..^..|.$j
00000a0: 2668 d80f 51ba 26b2 a4b9 87e1 2876 6182 &h..Q.&.....(va.
00000b0: 97ff 1e84 63a1 f001 0fd6 d9d0 928f 1065 ....c..........e
00000c0: ec83 3dcd fc9a 7904 4565 632d 0792 5bf2 ..=...y.Eec-..[.
00000d0: 84c4 9dcc dd48 0405 25a5 60a9 e1e6 01b3 .....H..%.`.....
00000e0: 75e1 2874 dd38 0405 25a1 899c a494 d4d6 u.(t.8..%.......
00000f0: 399e 8e4a 5f2b 89a0 67c9 4ee6 87b5 c10a 9..J_+..g.N.....
0000100: 4cc9 86e8 4ea6 2a8f a0b0 b4fb a6ed dc4d L...N.*........M
0000110: acaf aaf4 6e7a dc85 a755 d375 0fbb ccbf ....nz...U.u....
0000120: dea4 3ab5 a211 2651 2adf 1e34 1a7b adb6 ..:...&Q*..4.{..
0000130: fb8c 1bcd 6f26 35d7 6896 3c2a a121 45a3 ....o&5.h.<*.!E.
0000140: c1ca d543 eed0 683a b465 971c 34d9 6ca5 ...C..h:.e..4.l.
0000150: 3404 68d4 3b1d 29bb 65b2 17ca a847 cb2a 4.h.;.).e....G.*
0000160: 624b f169 d8d6 b66d aa32 7f27 293b bK.i...m.2.');
I used a few iterations of zopfli to convert the source text to 349 bytes of compressed data, avoiding the ' character which would otherwise have to be escaped with backslashes.
Haskell 537 499 497 Bytes
import Data.Char
a&b=a++b
b=putStr
c=concat
d=init
e('E':s)="an e"&s
e s="a "&map toLower s
f="I hear "
l=zip(lines"Polar Bear\nLion\nHippopotamus\nFlamingo\nZebra\nBoa Constrictor\nElephant\nLeopard\nPeacock\nWalrus\nZookeeper")$words"growl roar snort flut bray hiss trumpet snarl yelp bellow whistl"
main=(b.drop 41.c)[f&e n&" "&v&"ing in my ear.\n\n"&n&", "&n&", what do you hear?\n"|(n,v)<-l]>>b(f&"children...\n\n..."&(d.d.c)[v&"ing like "&e n&",\n"|(n,v)<-d l]&"...\nthat's what I hear.\n")
Using the convention that a solution does not have be executable, only produce the output via some function, this can be shortened to 479 Bytes. The output is in g:
import Data.Char
a&b=a++b
c=concat
d=init
e('E':s)="an e"&s
e s="a "&map toLower s
f="I hear "
l=zip(lines"Polar Bear\nLion\nHippopotamus\nFlamingo\nZebra\nBoa Constrictor\nElephant\nLeopard\nPeacock\nWalrus\nZookeeper")$words"growl roar snort flut bray hiss trumpet snarl yelp bellow whistl"
g=(drop 41.c)[f&e n&" "&v&"ing in my ear.\n\n"&n&", "&n&", what do you hear?\n"|(n,v)<-l]&f&"children...\n\n..."&(d.d.c)[v&"ing like "&e n&",\n"|(n,v)<-d l]&"...\nthat's what I hear.\n"
05AB1E, 349 331 330 322 314 311 bytes
•4i;kV_†©:š×Îj€Yå—‚‘%˜ESδþ¤çÑ9¶‹{Å€7¾à{Ì®qA•35B0¡…ing«lV•7ü[¿‘¢wÀ¶à-‚¤î„jHâ™ÐJ'µ‡ÀÂý6›ü‚š¸€%NtÅýµL›fU¥ì€€uîT¡›Ÿ{!œ>'Ì&ý§¨Ü?é>•36B1ð:0¡™D©„, «D‚ø“€À€·€î—«?“¶«¸â€˜€JU¦“„¾“‚˜lv„I “—«0€†€¯¶å.“«0¡`yð«Y¦õ‚˜Nè«sr„ aN5Qi'n«}ð«N9›ijrj¨ðs«…...«}srJˆ}X¯‚ø€Jvy,¶?}…...DU?Y¨vN__i',¶}yð“€è€…“N6Qi'n«}ð®NèJl?}X,“€Š's€À I—«.“?
Explanation
•4i;kV_†©:š×Îj€Yå—‚‘%˜ESδþ¤çÑ9¶‹{Å€7¾à{Ì®qA•
Packed string containing the sounds GROWL0ROAR0SNORT0FLUT0BRAY0HISS0TRUMPET0SNARL0YELP0BELLOW0WHISTL
35B0¡…ing«lV
Unpack, split on 0, add "ing" to each word, convert to lower and store in variable Y
•7ü[¿‘¢wÀ¶à-‚¤î„jHâ™ÐJ'µ‡ÀÂý6›ü‚š¸€%NtÅýµL›fU¥ì€€uîT¡›Ÿ{!œ>'Ì&ý§¨Ü?é>•
Packed string containing the animals POLAR1BEAR0LION0HIPPOPOTAMUS0FLAMINGO0ZEBRA0BOA1CONSTRICTOR0ELEPHANT0LEOPARD0PEACOCK0WALRUS0ZOOKEEPER
36B1ð:0¡™
Unpack, replace 1 with space, split on 0 and convert to title case
D©„, «D‚ø
Duplicate, save to register for later use, add ", " to one copy, duplicate that and zip.
“€À€·€î—«?“¶«¸
Dictionary words "what do you hear?", followed by a new line, added to a new list
‘€JU
Cartesian product of list of "Animal, Animal, " and "what do you hear?\n", flattened and joined and stores it in variable X.
Pruduces list of strings of the form "Animal, Animal, what do you hear?n".
¦“„¾“‚˜l
Take the remaining list of animals from before, remove the zookeeper and add children, convert to lower case.
v
For each animal:
„I “—«0€†€¯¶å.“«0¡`
Push "I hear0 in my ear.", split on 0 and push as separate strings.
yð«Y¦õ‚˜Nè«
Push "animal sound" with children having no sound
sr„ a
Push "a" in correct place
N5Qi'n«}
If the animal is "Elephant" add "n"
ð«
Add space.
N9›ijrj¨ðs«…...«}
If animal is children, remove space and add "..."
srJˆ}
Join the sentence "I hear a(n) animal sound in my ear." (as well as the children one), store in global array and end loop
X¯‚ø€J
Retrieve the first lines, zip and join producing the first part of the rhyme "Animal, Animal, what do you hear?\nI hear a(n) animal sound in my ear."
vy,¶?}
Print followed by new line.
…...DU?
Print "..." and store a copy in variable X.
Y¨v
For each sound except "whistling":
N__i',¶} For each line except the first one, start it with ",\n" (making the comma go on previous line)
yð“€è€…“
Push sound, space and "like a"
N6Qi'n«}
If Elephant add "n".
ð®NèJl?}X,
Retrieve the animal saved in register, join everything, print and end loop followed by "...".
This produces the "sound like a(n) animal," lines.
“€Š's€À I—«.“?
Print dictionary string "that's what I hear."
Batch, 650 647 bytes
@echo off
set e=echo(
set s=shift
call:d a "polar bear" ...growl "Polar Bear" a lion roar Lion a hippopotamus snort Hippopotamus a flamingo flut Flamingo a zebra bray Zebra a "boa constrictor" hiss "Boa Constrictor" an elephant trumpet Elephant a leopard snarl Leopard a peacock yelp Peacock a walrus bellow
exit/b
:d
call:v %* Walrus a zookeeper whistl Zookeeper
%e%I hear children...
%e%
:l
%e%%3ing like %1 %~2,
%s%
%s%
%s%
%s%
if not "%5"=="" goto l
%e%%3ing like a %2...
%e%that's what I hear.
exit/b
:v
%e%%~4, %~4, what do you hear?
if "%5"=="" exit/b
%e%I hear %5 %~6 %7ing in my ear.
%e%
%s%
%s%
%s%
%s%
goto v
Because %* is the nearest thing Batch has to an array. If I can use Polar bear and Boa constrictor then I can save 10%... but I'm still more than 50% of the original text...
Edit: Saved 3 bytes by setting e=echo( with a ( instead of a space, which allows me to use it to echo blank lines, although I then have to write out @echo off in full.
LUA 535 bytes
p=print a="growl.roar.snort.flut.bray.hiss.trumpet.snarl.yelp.bellow.whist"b="polar bear.lion.hippopotamus.flamingo.zebra.boa constrictor.elephant.leopard.peacock.walrus.zookeeper."z=a.gmatch(a,"%P+")x=b.gmatch(b,"%P+")w=''for j=1,11 do i=x()v=z()e=j==7 and'n 'or' 'p(j==1 and''or'I hear a'..e..i..' '..v..'ing in my ear.\n')w=w..(j>10 and''or v..'ing like a'..e..i..(j>9 and'...'or',')..'\n')y=i:gsub("^%l",a.upper):gsub("%s%l",a.upper)p(y..', '..y..' what do you hear?')end p('I hear children...\n')p('...'..w.."that's what I hear.")
ungolfed:
sound_list = "growl.roar.snort.flut.bray.hiss.trumpet.snarl.yelp.bellow.whist"
animal_list = "polar bear.lion.hippopotamus.flamingo.zebra.boa constrictor.elephant.leopard.peacock.walrus.zookeeper."
sound_it = string.gmatch(sound_list, "%P+")
animal_it = string.gmatch(animal_list, "%P+")
part_2 = ''
for i = 1, 11 do
animal = animal_it()
sound = sound_it()
aORan = i == 7 and 'n ' or ' '
print(i == 1 and '' or 'I hear a'..aORan..animal..' '..sound..'ing in my ear.\n')
part_2 = part_2..(i > 10 and '' or sound..'ling like a'..aORan..animal..(i > 9 and '...' or ',')..'\n')
big_animal = animal:gsub("^%l", string.upper):gsub("%s%l", string.upper)
print(big_animal..', '..big_animal..' what do you hear?')
end
print('I hear children...\n')
print('...'..part_2.."that's what I hear.")
C#, 592 572 Bytes
using System;class p{static void Main(){string[] s={"","","Polar Bear","Lion","Hippopotamus","Flamingo","Zebra","Boa Contrictor","Elephant","Leopard","Peacock","Walrus","Zookeeper","growl","roar","snort","flut","bray","hiss","trumpet","snarl","yelp","bellow","whistl"};for(int i=2;i<13;i++){s[0]+=(s[i]+", "+s[i]+", what do you hear?\nI hear "+(i<12?"a"+(i==7?"n ":" ")+s[i+1].ToLower()+" "+s[i+12]+"ing in my ear.\n\n":"children...\n\n..."));if(i<12)s[1]+=s[i+11]+"ing like a"+(i==8?"n ":" ")+s[i].ToLower()+(i<11?",\n":"...\nthat's what I hear.\n");}Console.Write(s[0]+s[1]);}}
Had such a great time taking this challenge with my colleague! Thanks for the idea.
Formatted:
using System;
class p {
static void Main() {
string[] s = { "", "", "Polar Bear", "Lion", "Hippopotamus", "Flamingo", "Zebra", "Boa Contrictor", "Elephant", "Leopard", "Peacock", "Walrus", "Zookeeper", "growl", "roar", "snort", "flut", "bray", "hiss", "trumpet", "snarl", "yelp", "bellow", "whistl" };
for (int i = 2; i < 13; i++) {
s[0] += (s[i] + ", " + s[i] + ", what do you hear?\nI hear " + (i < 12 ? "a" + (i == 7 ? "n " : " ") + s[i + 1].ToLower() + " " + s[i + 12] + "ing in my ear.\n\n" : "children...\n\n..."));
if (i < 12) s[1] += s[i + 11] + "ing like a" + (i == 8 ? "n " : " ") + s[i].ToLower() + (i < 11 ? ",\n" : "...\nthat's what I hear.\n");
}
Console.Write(s[0] + s[1]);
Console.ReadKey();
}
}
EDIT: Thank you for your numerous and awesome tips, they helped a lot and I'll try to get the other ones working as well.
R 518 509 482 477 474 465 452 456 bytes
Link to R-Fiddle to try code
a=c("Polar Bear","Lion","Hippopotamus","Flamingo","Zebra","Boa Constrictor","Elephant","Leopard","Peacock","Walrus","Zookeeper")
b=c("...growl","roar","snort","flut","bray","hiss","trumpet","snarl","yelp","bellow","whistl")
d=c(rep("a ",6),"an ")
f=tolower(a)
cat(c(paste0(a,", ",a,", what do you hear?\nI hear ",c(paste0(d,f," ",b,"ing in my ear.")[-1],"children..."),"\n\n"),paste0(b,"ing like ",d,f,c(rep(",\n",9),"...\nthat's what I hear."))[-11]))
- Moved
childrenout of the vectora, and got rid of corresponding entry in thedvector to save 8 bytes - More tidying up and removing of subscripts made redundant by moving
children, saved further 27 bytes. - Globalised the
tolowerfunction, saved 5 bytes - Replace
writeLineswithcatand reformatted appropriately (added\nin places) saved 3 bytes - Realised that if
dis only 7 elements not the full 11, R will just loop back to the start again. As 11 < 14 then this works for us. Saved 9 bytes. - globalised subscripts, saved 13 bytes.
catfunction was separating with" ", changed back towriteLines. Added 4 bytes (catcan be fixed by adding,sep=""to the function)
///, 523 512 bytes
/_/\/\///:/ar_!/, what do you he:?
I he: _$/!a_#/ing in my e:.
_%/ing like a_&/, _*/,
_0/Pol: Be:_1/ion_2/ippopotamus_3/lamingo_4/ebra_5/oa _S/onstrictor_6/lephant_7/eopard_8/eacock_9/alrus_Q/ookeeper_R/trumpet/0&0$ l1 ro:#L1&L1$ h2 snort#H2&H2$ f3 flut#F3&F3$ z4 bray#Z4&Z4$ b5cS hiss#B5CS&B5CS$n e6 R#E6&E6$ l7 snarl#L7&L7$ p8 yelp#P8&P8$ w9 bellow#W9&W9$ zQ whistl#ZQ&ZQ!children...
...growl% pol: be:*ro:% l1*snort% h2*flut% f3*bray% z4*hiss% b5cS*R%n e6*snarl% l7*yelp% p8*bellow% w9...
that's what I he:.
608 bytes less than the actual message (1120), this is less than half of it (560)!
QB64 (QuickBASIC), 581 bytes
The code expands a bit when you throw it in the interpreter, but this source file is valid to load as-is. If you want to see the whole output before it scrolls past, then you'll need to add a width 80,46 statement to the beginning.
READ a$,v$
FOR x=0 TO 10
?a$+", "+a$+", what do you hear?"
IF x>9THEN
?"I hear children...":?:?"...";
RESTORE
FOR y=0 TO 9
READ a$,v$
?v$+"ing like ";
CALL j(a$)
IF y<9THEN?", "ELSE?"...":?"that's what I hear."
NEXT
END
ELSE
READ a$,v$
?"I hear ";
CALL j(a$)
?" "+v$+"ing in my ear."
?
END IF
NEXT
DATA"Polar Bear","growl","Lion","roar","Hippopotamus","snort","Flamingo","flut","Zebra","bray","Boa Constrictor","hiss","Elephant","trumpet","Leopard","snarl","Peacock","yelp","Walrus","bellow","Zookeper","whistl"
SUB j (A$)
?"a";
IF LEFT$(A$,1)="E"THEN?"n";
?" "+LCASE$(A$);
END SUB
Python 3, 442 441 bytes
h=t=''
for n,s in zip('polar bear,lion,hippopotamus,flamingo,zebra,boa constrictor,elephant,leopard,peacock,walrus,zookeeper'.split(','),'...growl roar snort flut bray hiss trumpet snarl yelp bellow whistl'.split()):u='n'[:'el'in n],n,s,n.title();h+="I hear a{0} {1} {2}ing in my ear.\n\n{3}, {3} what do you hear?\n".format(*u);t+="{2}ing like a{0} {1},\n".format(*u)
print((h+'I hear children...\n\n'+t)[44:-30]+"...\nthat's what I hear.")
ungolfed:
animals = 'polar bear,lion,hippopotamus,flamingo,zebra,boa constrictor,elephant,leopard,peacock,walrus,zookeeper'.split(',')
sounds = '...growl roar snort flut bray hiss trumpet snarl yelp bellow whistl'.split()
h=t=''
for n,s in zip(animals,sounds):
u='n'[:'el'in n], n, s, n.title()
h+="I hear a{0} {1} {2}ing in my ear.\n\n{3}, {3} what do you hear?\n".format(*u)
t+="{2}ing like a{0} {1},\n".format(*u)
print((h+'I hear children...\n\n'+t)[44:-30]+"...\nthat's what I hear.")
Basically, just a loop that builds up two strings representing the two parts of the story. The 'n'[:'el'in n] handles the "an" for elephant. The [44:-30] chops off the leading "I hear a polar bear growling in my ear" and the trailing "whistling like a zookeeper".
Swift2, 519 bytes
var a=["Polar Bear","Lion","Hippopotamus","Flamingo","Zebra","Boa Constrictor","Elephant","Leopard","Peacock","Warlus","Zookeeper"],b=["...growl","roar","snort","flut","bray","hiss","trumpet","snarl","yelp","bellow","whistl"].map{"\($0)ing"},c=a.enumerate().map{"\($0.0==6 ?"an":"a") \($0.1)".lowercaseString},i=0,j=0
while i<11{print("\(a[i]), \(a[i++]), what do you hear?\nI hear \(i>10 ?"children...":"\(c[i]) \(b[i]) in my ear")\n")}
while j<10{print("\(b[j]) like \(c[j++])\(j>9 ?"...\nthat's what I hear.":",")")}
Dyalog APL, 387 bytes
⎕UCS¯2(219⌶)¯128+⎕UCS'øZýÓÁî°üÁ~`Û¯ß(4Õ+ÖjáïvXô ¶Dhkë ©4¹³`LxÖ4¢gͼ4ªBáDÚN¼ùV ÂÅF]@¸hÆà bKÚ¸_oQãÔÝ ¸$8§ú_ÔÈxÖ ~6*ãªd ¿ð>¥ÐB8þôÍxwÄ6Å
ô¡é¢wBlDµ¯ë
Ãbqè+ý+ÜÈýgu!gWËØ#0="«ë"HDÝÀV·¦/ÕMÆí}h<àì7å ÝÒëëñX³ýM <dÄ<ëmµñqP]¥c¬l¾¤ìÚã/$ÝÕqÙÞîCLéMÝÏ}OÔϤr$¤è©~ì2[¢{·YWÒ俦à¶)YØ©;s÷¬¥+ó&¿ÉâgËr
,Ýî©)¥Ö2è´ÝÅd{úK5·Õ}ýÚ'
To ease reading: ⎕UCS¯2(219⌶)¯128+⎕UCS'...'
⎕UCS '...' convert string to Unicode code points
¯128+ subtract 128 to get -128 ≤ n ≤ 127
¯2(219⌶) un-zlib
⎕UCS convert Unicode code points to string
The source string is the following 365 bytes of zlib'ed Unicode code points:
F8 5A FD D3 C1 EE 04 B0 8C FC C1 7E 60 DB AF 91 DF 28 34 D5 2B D6 6A E1 EF 15 76 96 58 F4 09 B6 44 11 93 04 68 6B EB A0 A9 94 34 B9 10 98 0F B3 60 4C 78 0C D6 91 1C 34 A2 89 67 CD BC 34 AA 42 95 E1 44 9E DA 4E BC 0B 0F F9 87 85 56 20 83 C2 C5 46 5D 40 B8 68 C6 E0 20 92 62 13 81 89 4B DA B8 5F 9A 6F 51 E3 D4 DD 9F A0 B8 24 38 A7 FA 5F D4 C8 78 7F D6 A0 7E 36 2A E3 AA 64 20 BF F0 3E A5 D0 42 9A 95 38 FE F4 CD 8A 78 99 77 C4 17 89 11 10 36 82 C5 0D 8A 9A F4 A1 12 E9 A2 92 77 9D 42 1E 6C 44 B5 AF EB 0D 04 C3 62 71 87 9C E8 2B FD 2B DC 04 C8 FD 67 75 21 67 57 04 CB D8 23 12 30 9A 3D 22 AB EB 22 48 9E 44 DD C0 56 B7 87 85 A6 2F D5 03 4D 9D C6 ED 7D 1E 68 3C E0 EC 37 9C 94 08 86 E5 09 DD D2 EB EB F1 58 B3 FD 4D 20 04 3C 17 64 C4 3C EB 6D B5 F1 11 89 71 50 5D A5 63 AC 6C 9A BE A4 EC DA E3 2F 24 DD D5 71 D9 DE EE 04 43 4C E9 4D DD CF 7D 4F 13 D4 CF 13 A4 72 24 A4 E8 1A 9E A9 7E EC 1F 32 5B 19 10 A2 7B B7 01 59 57 D2 E4 BF A6 E0 B6 29 94 59 D8 A9 3B 73 1D 94 9B F7 AC A5 2B F3 26 BF C9 E2 67 7F CB 72 0A 2C DD EE A9 29 A5 D6 AD 92 32 E8 B4 DD C5 64 7B FA 8A 4B 35 AD B7 D5 7D 82 0F FD 1 DA
F#, 591 589 579 576 573 567 552 bytes
This is my first try at code golfing with a language i like. I bet there are some ways this could be made shorter. Runs in FSI, so no need for .NET boilerplate.
Edit: Shaved 10 bytes by removing \r. It still renders fine in VSCode so go figure. Cut another three bytes with function composition, and another three with a lambda, then six with a for loop instead of Seq.iter (getting rid of the lambda). Finally 15 bytes were cut by rearranging a(s:string)
let A="Polar Bear,Lion,Hippopotamus,Flamingo,Zebra,Boa Constrictor,Elephant,Leopard,Peacock,Walrus,Zookeeper".Split(',')
let S="growl,roar,snort,flut,bray,hiss,trumpet,snarl,yelp,bellow,whistl".Split(',')
let a(s:string)=(if s.[0]='E'then"an "else"a ")+s.ToLower()
let f i=sprintf"%s, %s, what do you hear?\nI hear "A.[i]A.[i]
for i in 0..9 do printfn"%s%s %sing in my ear.\n"(f i)(a A.[i+1])S.[i+1]
printf"%schildren...\n\n..."(f 10)
let t i=sprintf"%sing like %s"S.[i](a A.[i])
Seq.iter(t>>printfn"%s,")[0..8]
printfn"%s...\nthat's what I hear."(t 9)
Java, 571 555 538 or 516 Bytes
String p(){String r="",z="...",b,x;String[]a="Polar Bear!Lion!Hippopotamus!Flamingo!Zebra!Boa Constrictor!Elephant!Leopard!Peacock!Walrus!Zookeeper!growling!roaring!snorting!fluting!braying!hissing!trumpeting!snarling!yelping!bellowing!whistling".split("!");for(int i=1;i<11;i++){b=i==6?"n ":" ";x=a[i-1];z+=a[i+10]+" like a"+b+x+(i==10?"...":"\n");r+=x+" , "+x+", what do you hear?\n I hear a"+b+a[i].toLowerCase()+" "+a[i+11]+" in my ear.\n\n";}r+=a[10]+" what do you hear?\n\tI hear children...\n"+z+"\nthat's what I hear.";return r;}
But only 516 bytes is required to get result in JShell
String r="",z="...",b,x;String[]a="Polar Bear!Lion!Hippopotamus!Flamingo!Zebra!Boa Constrictor!Elephant!Leopard!Peacock!Walrus!Zookeeper!growling!roaring!snorting!fluting!braying!hissing!trumpeting!snarling!yelping!bellowing!whistling".split("!");for(int i=1;i<11;i++){b=i==6?"n ":" ";x=a[i-1];z+=a[i+10]+" like a"+b+x+(i==10?"...":"\n");r+=x+" , "+x+", what do you hear?\n I hear a"+b+a[i].toLowerCase()+" "+a[i+11]+" in my ear.\n\n";}r+=a[10]+" what do you hear?\n\tI hear children...\n"+z+"\nthat's what I hear."
Python 2 - 454 bytes
a="polar bear,lion,hippopotamus,flamingo,zebra,boa constrictor,elephant,leopard,peacock,walrus,zookeeper,whistl,bellow,yelp,snarl,trumpet,hiss,bray,flut,snort,roar,growl".split(',')
e='...\n\n'
r=range
print'\n'.join([(a[i].title()+', ')*2+"what do you hear?\nI hear "+((i<10)*("a%s %sing in my ear.\n"%("n "[i!=5:]+a[i+1],a[~-~i]))or"children%s..."%e+",\n".join(a[~j]+"ing like a"+"n "[j!=6:]+a[j]for j in r(10))+e+"that's what I hear.")for i in r(11)])
clojure, 526 bytes
(use 'clojure.string)(let[l lower-case
a(partition 2(split"Polar Bear,...growl,Lion,roar,Hippopotamus,snort,Flamingo,flut,Zebra,bray,Boa Constrictor,hiss,Elephant,trumpet,Leopard,snarl,Peacock,yelp,Walrus,bellow,Zookeeper,whistl,children,x"#","))b(map(fn[[w x][y e]][(str
w", "w", what do you hear?
I hear a "(l y)" "e"ing in my ear.
")(str x"ing like a "(l w))])a(rest a))r
replace](print(r(str(r(join""(map first b))#".*x.*""I hear children...")(join",
"(butlast(map last b)))"...
that's what I hear.")#"(?i)a(?= e)""an")))
Here's my initial attempt. Gotta love the formatting and how unreadable it is. Hope the warnings from use 'clojure.string are acceptable.
Formatted code:
(use 'clojure.string)
(let [animal-sound (partition 2 (split "Polar Bear,...growl,Lion,roar,Hippopotamus,snort,Flamingo,flut,Zebra,bray,Boa Constrictor,hiss,Elephant,trumpet,Leopard,snarl,Peacock,yelp,Walrus,bellow,Zookeeper,whistl,children,x" #","))
sentences (map (fn [[animal-1 sound-1] [animal-2 sound-2]]
[(str animal-1 ", " animal-1 ", what do you hear?\nI hear a "
(lower-case animal-2) " " sound-2 "ing in my ear.\n\n") (str sound-1 "ing like a " (lower-case animal-1))])
animal-sound (rest animal-sound))]
(print (replace (str
(replace (join "" (map first sentences)) #".*x.*" "I hear children...")
(join ",\n" (butlast (map last sentences)))
"...\nthat's what I hear.") #"(?i)a(?= e)" "an")))
C#, 575 525 520 526 507 504 497 494 493 bytes
()=>{var t="growl,Polar Bear,roar,Lion,snort,Hippopotamus,flut,Flamingo,bray,Zebra,hiss,Boa Constrictor,trumpet,Elephant,snarl,Leopard,yelp,Peacock,bellow,Walrus,whistl,Zookeeper".Split(',');string r="",s="",z="a ",n="an ";for(int i=0,j=0;i<21;r+=t[++i]+$", {t[i]}, what do you hear?\nI hear "+(i>19?@"children...
...":(i==11?n:z)+t[++i+1].ToLower()+$" {t[i]}ing in my ear.\n\n"))s+=j<20?t[j]+"ing like "+(j==12?n:z)+t[++j].ToLower()+(++j<20?@",
":@"...
"):"that's what I hear.";return r+s;};
C# lambda where the output is a string.
Explanation
- Init
tas a string with the formatnoise,animal,noise,animal,...and split by,. - Declare
rands.ris the first part of the song andsthe last part.zandnare here to handleElephant. - Walk
tand buildrandsin the same loop. Weird ternary+interpolated stuff. - Return the first part of the song followed by the last part.
Code
()=>{
var t="growl,Polar Bear,roar,Lion,snort,Hippopotamus,flut,Flamingo,bray,Zebra,hiss,Boa Constrictor,trumpet,Elephant,snarl,Leopard,yelp,Peacock,bellow,Walrus,whistl,Zookeeper".Split(',');
string r="",s="",z="a ",n="an ";
for(int i=0,j=0;i<21;r+=t[++i]+$", {t[i]}, what do you hear?\nI hear "+(i>19?@"children...
...":(i==11?n:z)+t[++i+1].ToLower()+$" {t[i]}ing in my ear.\n\n"))
s+=j<20?t[j]+"ing like "+(j==12?n:z)+t[++j].ToLower()+(++j<20?@",
":@"...
"):"that's what I hear.";
return r+s;
};
C, 596 bytes
Call f() without any arguments.
This is not the best golf in the world, I probably can shrink it more.
f(n){char*t,a[99][99]={"Polar Bear","Lion","Hippopotamus","Flamingo","Zebra","Boa Constrictor","Elephant","Leopard","Peacock","Walrus","Zookeeper","growl","roar","snort","flut","bray","hiss","trumpet","snarl","yelp","bellow","whistl"};for(n=0;n<11;){strcpy(t=a[n+30],n^6?" ":"n ");strcat(t,a[n++]);for(;*t=tolower(*t);++t);}for(n=0;printf("%s, %s, what do you hear?\n",a[n],a[n]),n<10;++n)printf("I hear a%s %sing in my ear.\n\n",a[n+31],a[12+n]);puts("I hear children...\n");for(n=11;n<21;++n)printf("%s%sing like a%s%s\n",n^11?"":"...",a[n],a[n+19],n^20?",":"...");puts("that's what I hear.");}
Emacs Lisp, 576 (621) bytes
(let*((a'("polar bear""lion""hippopotamus""flamingo""zebra""boa constrictor""elephant""leopard""peacock""walrus""zookeeper"))(l(length a))(m(- l 1))(s'("growl""roar""snort""flut""bray""hiss""trumpet""snarl""yelp""bellow""whistl")))(dotimes(i l)(message"%s, what do you hear?"(let((a(capitalize(nth i a))))(concat a", "a)))(if(not(eq i m))(message "I hear a %s %sing in my ear.\n"(nth(1+ i)a)(nth(1+ i)s))(message"I hear children...\n")(dotimes(j m)(message(concat(when(eq j 0)"...")"%sing like a %s"(if(eq(1+ j)m)"..."","))(nth j s)(nth j a)))(message"That's what I hear."))))
When fixing "an elephant", it takes slightly longer:
(let*((a'("polar bear""lion""hippopotamus""flamingo""zebra""boa constrictor""elephant""leopard""peacock""walrus""zookeeper"))(l(length a))(m(- l 1))(s'("growl""roar""snort""flut""bray""hiss""trumpet""snarl""yelp""bellow""whistl")))(dotimes(i l)(message"%s, what do you hear?"(let((a(capitalize(nth i a))))(concat a", "a)))(if(not(eq i m))(message "I hear a %s %sing in my ear.\n"(nth(1+ i)a)(nth(1+ i)s))(message"I hear children...\n")(dotimes(j m)(message(concat(when(eq j 0)"...")"%sing like a"(and(string-match-p"^[aeiou]"(nth j a))"n")" %s"(if(eq(1+ j)m)"..."","))(nth j s)(nth j a)))(message"That's what I hear."))))
Ungolfed:
(let* ((animals '("polar bear"
"lion"
"hippopotamus"
"flamingo"
"zebra"
"boa constrictor"
"elephant"
"leopard"
"peacock"
"walrus"
"zookeeper"))
(l (length animals))
(m(- l 1))
(sounds '("growl"
"roar"
"snort"
"flut"
"bray"
"hiss"
"trumpet"
"snarl"
"yelp"
"bellow"
"whistl")))
(dotimes (i l)
(message "%s, what do you hear?"
(let ((animal (capitalize (nth i animals))))
(concat animal ", " animal)))
(if (not (eq i m))
(message "I hear a %s %sing in my ear.\n"
(nth (1+ i) animals)
(nth (1+ i) sounds))
(message "I hear children...\n")
(dotimes (j m)
(message
(concat
(when (eq j 0) "...")
"%sing like a"
(and (string-match-p"^[aeiou]" (nth j animals)) "n")
" %s"
(if (eq (1+ j) m) "..." ","))
(nth j sounds )
(nth j animals)))
(message"That's what I hear."))))
Bash + zcat, 402 bytes
Just a joke:
a 2 lines bash script that tails itself and pipe the second line to zcat.
The second line is the gzipped text.
How to prepare it: all the text in a file a. Then
echo "tail -n+2 \$0|zcat;exit" > go.sh
gzip a ;
cat a.gz >> go.sh
chomod u+x go.sh
The file so created when executed returns the starting text, 402 Bytes.
Pyth - 427 384 Bytes
=G"1, 1, what do you hear?\nI hear a 2 in my ear.\n"=Hc"growling/Polar Bear/roaring/Lion/snorting/Hippopotamus/fluting/Flamingo/braying/Zebra/hissing/Boa Constrictor/trumpeting/Elephant/snarling/Leopard/yelping/Peacock/bellowing/Walrus/whistling/Zookeeper"\/FNT
::G\1@H+yN1\2++r@H+yN3Zd@H+yN2)p+::G"I(.|\n)*"k\1@H20"I hear children...\n\n..."FN9
::"1 like a 2,"\1@HyN\2r@H+yN1Z)p"bellowing like a walrus...\nthat's what I hear.
J"%s, %s, what do you hear?"K"I hear a%sing in my ear.\n"=Hc"Polar Bear/roar/Lion/snort/Hippopotamus/flut/Flamingo/bray/Zebra/hiss/Boa Constrictor/trumpet/Elephant/snarl/Leopard/yelp/Peacock/bellow/Walrus/whistl/Zookeeper/growl"\/FN11
%J*2[@HyN)?qNT"I hear children...\n"%Kjd[?qN5\nkr@H+yN2Z@HhyN))p"..."FN9
+%=J"%sing like a%s"[@HtyN+?qN5\nk+dr@HyNZ)?qN8"..."\,)
"that's what I hear"
Try it here - permalink
PHP, 420 414 434 414 412 bytes
call from CLI or prepend <pre> to output.
$v=[growl,roar,snort,flut,bray,hiss,trumpet,snarl,yelp,bellow,whistl];$a[6]=n;foreach($n=['polar bear',lion,hippopotamus,flamingo,zebra,'boa constrictor',elephant,leopard,peacock,walrus,zookeeper]as$i=>$p)echo$i?"I hear a$a[$i] $p $v[$i]ing in my ear.
":"",$q=ucwords($p),", $q, what do you hear?
",$i>9?"I hear children...
...":""&$z[]="$v[$i]ing like a$a[$i] $p";echo join(",
",$z),"...
that's what I hear.";
- a couple of notices for undefined constants; PHP´s implicit cast to literal string kicks in again
- adding the "n" for "an elephant" took 20 bytes ... hmpf.
- got the 20 bytes back by reordering stuff :)
breakdown
$n=['polar bear',lion,hippopotamus,flamingo,zebra,'boa constrictor',elephant,leopard,peacock,walrus,zookeeper];
$v=[growl,roar,snort,flut,bray,hiss,trumpet,snarl,yelp,bellow,whistl];
$a[6]=n;
// loop through nouns with index $i
foreach($n as$i=>$p) echo
// print first part:
// not first noun: print second line to previous step
$i?"I hear a$a[$i] $p $v[$i]ing in my ear.\n\n":"",
// uppercase the first letter of each word in the noun, print
$q=ucwords($p),
// print uppercase noun again and the rest of the line
", $q, what do you hear?\n",
// for last noun print bridge, else print nothing
$i>9?"I hear children...\n\n...":""
// ... AND add line to second part
&$z[]="$v[$i]ing like a$a[$i] $p"
;
// print second part and final line
echo join(",\n",$z),"...\nthat's what I hear.";
JavaScript, 545 541 497 bytes
a="Polar Bear|Lion|Hippopotamus|Flamingo|Zebra|Boa Constrictor|Elephant|Leopard|Peacock|Walrus|Zookeeper".split`|`;s=btoa`º0:èj¼ìíÍùn·6ëk,áË3¶»¦¥ës²v«<ÛzYhÃ<!Ëe`.split`z`;a.map((m,n)=>{console.log(m+", "+m+", what do you hear?\n "+((n>9)?"I hear children...\n":"I hear a"+(n==5?"n ":" ")+a[n+1].toLowerCase()+" "+s[n+1]+"ing in my ear.\n"))});p="...";a.map((m,n)=>{if(n>9)return;p+=s[n]+"ing like a"+(n==6?"n ":" ")+m.toLowerCase()+(n>8?"...\nthat's what I hear.":",\n")});console.log(p)
Quite a fun challenge!
Thanks Downgoat for saving me 27 a ton of bytes using atob, and Titus for 4 bytes!
Ungolfed:
a="Polar Bear|Lion|Hippopotamus|Flamingo|Zebra|Boa Constrictor|Elephant|Leopard|Peacock|Walrus|Zookeeper".split`|`;
s=btoa`º0:èj¼ìíÍùn·6ëk,áË3¶»¦¥ës²v«<ÛzYhÃ<!Ëe`.split`z`;
a.map((m,n)=>{
console.log(m+", "+m+", what do you hear?\n "+((n==10)?"I hear children...\n":"I hear a" + (n==5?"n ":" ") + a[n+1].toLowerCase() + " " + s[n+1] + "ing in my ear.\n"))
});
p="...";a.map((m,n)=>{
if(n==10) return;
p+=s[n] + "ing like a" + (n==6?"n ":" ") + m.toLowerCase() + (n==9?"...\nthat's what I hear.":",\n")
});
console.log(p);