# There's a hole in the bottom of the sea

Whilst trying (and failing) have persuade my infant son to eat his dinner, I tried singing to him. Mid way through this song I realised the formulaic structure might lend itself well to code golfing!

The task is to write a program or function which accepts no input and produces the following text:

There's a hole in the bottom of the sea
There's a hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a log in the hole in the bottom of the sea
There's a log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a bump on the log in the hole in the bottom of the sea
There's a bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a frog on the bump on the log in the hole in the bottom of the sea
There's a frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea


Challenge rules:

• The text may be printed or returned as function output
• Each verse is separated by a single empty line
• Trailing whitespace is OK as long as it does not change the layout (so no leading whitespace or extra spaces between words)
• Trailing newlines are OK too.
• No leading newlines.
• All languages welcomed, and this is , so the shortest answer in bytes for each language wins!
• Similar to There Was an Old Lady (other similar challenges e.g. this have been closed as duplicates, although I don't think they necessarily should.) – Jonathan Allan Jan 30 at 16:33
• Ho, ro, the rattlin' bog, the bog down in the valley-o. – fəˈnɛtɪk Jan 30 at 22:22
• For comparison (though not a programming language) gzip -5 compresses it to 186 bytes (and bzip2 and xz seem to do worse). – Daniel Schepler Jan 30 at 23:34
• Congrats, from another developer parent :) – AJFaraday Jan 31 at 14:26
• I want to adapt this song to 05AB1E... "There's a hole in oh-five-ay-bee-one-ee!" – Magic Octopus Urn Jan 31 at 16:40

# SOGL, 10394 93 bytes

Ψ ~Δ№Q‘η¦»vζh‛←&M⁶╥7[P≈╔6≡⁸(φΔ\⅔Σ‚>≡ā⁷⁽○¹‘Ξ⁵K4s³‘⁽Bθ2n{@∑" the ”+Κ:bΚē‽:C}TPb"n@²‘+Tō, upcPøP


Try it here!

...‘                 push "bottom of the sea" - kept for the loop, here for
...‘             push "hole in log in bump on frog on wart on hair on fly on flea on smile on"
...‘         push "there's a "
⁽        uppercase the 1st letter of that
B       save "There's a " in B
θ      split the long data string on spaces
2n    split in arrays of length 2

{                     for each of those:
@∑                   join the current array with spaces - e.g. "hole in"
" the ”+           append " the " to it
Κ          prepend that to "bottom of the sea" (or whatever it is now)
:         create a copy
bΚ       prepend B to it - finishes current line
ē‽:C}  if (E++), save a copy of that in C (for the last line)

TP                   print the current line twice
b"...‘+            B + "hole" - "There's a hole"
T           output that, keeping item
ō,         output ", "
up      print the kept item lowercased
cP    print the contents of C
øP  print an empty line

• But....but how? – SomeShinyObject Jan 31 at 4:06
• Incredible. How even-- – Austin Burk Jan 31 at 5:04
• HNQ strikes again! :\ – Shaggy Feb 1 at 1:30
• Would you mind adding an explanation? Curious to see how it works. – Kevin Cruijssen Feb 1 at 8:18
• @KevinCruijssen added – dzaima Feb 1 at 15:20

# Stax, 9087 75 bytes

¥▌▼h4█☻■Ω1gçΔ¶Zjµ│☺X▄)/╞▄╒)¥jêLqα╧ñu┌⌂½╧ûⁿ↕O◘╔╪kl<æàbπïfuσ♪╫qΓ╪ûQ├╘Te♥Æó♣ƒE


Run and debug it

Unpacked, ungolfed, and commented it looks like this.

;$w]i"50h1&V~OP>F$            compressed literal for "There's a hole in the bottom of the sea"
X                               store in register X without popping
zG                              push an empty string and jump to the target (trailing })
hfUiVx}.|j~vG12])Bxk?v zFj    split "log bump frog wart hair fly flea smile" into array of words
F                               for each word, execute the following
i. o. i?                      (i ? " o" : " i") where i is the 0-based iteration index
+                             concatenate to the word
_o9!+                       concatenate "n the "
G                             jump to target below, resume next foreach iteration when finished
}                               this is the target of G, execution resumes when finished
As|@                          insert substring at position 10
QQ                            peek and print with newlines twice
x14(                          trim string to leftmost 14 characters
q                             peek and print without newlines
., p                          print ", " without newline
vP                            lowercase 14 characters and print with newline
xP                            push value of register X, then print with newline
zP                            print blank line


Run this one

• Would you mind adding an explanation? Curious to see how it works. – Kevin Cruijssen Feb 1 at 8:18
• I will but I still have the feeling that a totally different approach will do better. After I succeed or fail in that I'll explain whatever's left. – recursive Feb 1 at 15:50
• @KevinCruijssen: I had a feeling that that there was a much better approach. Sure enough, I totally re-wrote it, and saved another 12 bytes of bloat. I added some explanation as well. – recursive Feb 5 at 4:00

# Perl 5, 158 154 bytes

$_="There's a bottom of the sea ";for$,(<{{hole,log}" i",{bump,frog,wart,hair,fly,flea,smile}" o"}>){s/a/a $,n the/;say$_.$_.($t||=s/.{14}/$&, \l$&
$&/r)}  154 bytes 158 bytes • There's a bottom of the sea. The facts check out, +1 – Jo King Jan 31 at 13:33 • :), there's also this variation starting with There's a sea but it's longer – Nahuel Fouilleul Feb 1 at 13:25 # Python 2, 202190187185183182 181 bytes s="bottom of the sea\n" a="There's a " for w in'hole log bump frog wart hair fly flea smile'.split():s=w+" %sn the "%'io'['g'in s]+s;print(a+s)*2+a+"hole, t%shole\n"%a[1:]+a+s[-30:]  Try it online! Old alternatives to 'io'['g'in s] (13 bytes): • 14: 'oi'[s[5]<'n'] • 15: 'io'[len(s)>30], 'ioo'[len(s)%3], 'ooi'[len(s)%4], and 'io'[w[1]=='o'] Saved: • -1 byte, thanks to Jonathan Allan • -1 byte, thanks to Rod • -1 byte, thanks to Erik the Outgolfer • "hole, t%shole\n"%a[1:] saves a byte – Jonathan Allan Jan 30 at 16:29 • You can save a byte by dropping the zip – Rod Jan 30 at 18:26 • @JonathanAllan Thanks :) – TFeld Jan 30 at 18:55 • @Rod Thanks, :-) – TFeld Jan 30 at 18:55 • 'oi'[s[5]<'n'] will be an old alternative too: Featuring 'io'['g'in s]! – Erik the Outgolfer Jan 30 at 22:51 # C (gcc), 261246 236 bytes #define X" on the " char*a="smile"X"flea"X"fly"X"hair"X"wart"X"frog"X"bump"X"log in the hole in the bottom of the sea\n";f(i){for(i=0;i<9;)printf("T%s%sT%1$s%2$sT%1$shole, t%1$shole\nT%1$s%3$s\n","here's a ",a+"_TH<0$\31\r"[i++],a+95);}


-15 bytes, Thanks to Daniel Schepler
-10 bytes, Thanks to ceilingcat

Try it online!

• Could you write ,*b="_TH<0$\31\r" instead? – Daniel Schepler Jan 30 at 23:21 • Would it save any bytes to define " in the "? – OldBunny2800 Jan 31 at 19:51 • @OldBunny2800 no, it would be longer! in this case you need at least 6 occurrences to be effective... – Giacomo Garabello Feb 1 at 8:16 # 05AB1E, 10310099979693 92 bytes Saved a byte thanks to Kevin Cruijssen “¥ÊˆŽ bumpÑå‡îtíÁ¤†îÌea¹²“#v’T€Î's a ’s„oiN2‹èy“ÿ ÿn€€ ÿ“©“—è€‚€€í™“JDN_iDU}X14£Dl‚„, ýXõ»,®  Try it online! Explanation “¥ÊˆŽ bumpÑå‡îtíÁ¤†îÌea¹²“#v starts a loop over the list ["hole", "log", "bump", "frog", "wart", "hair", "fly", "flea", "smile"]. The words are compressed using the 05AB1E dictionary. On each we do: ’T€Î's a ’ # push the string "There's a " s # move the string from the previous iteration to the top of the stack # will be an empty string the first iteration since there is no input „oiN2‹è # push "i" for the first 2 iterations and "o" otherwise y # push the current word “ÿ ÿn€€ ÿ“ # use interpolacing to create the meat of the current iteration string # meaning "hole in the ", "log in the hole in the " and so on © # store a copy in the register for the next iteration “—è€‚€€í™“ # push the string "bottom of the sea" JD # join the whole line together and duplicate it N_iDU} # if this is the first iteration, store a copy of the line in X X14£ # push the first 14 chars of X, which is "There's a hole" Dl # make a lower-case copy ‚„, ý # join the original with the lowercase copy on ", ", forming line 3 X # push X which is line 4 õ # push and empty string, to create the line break between sections », # join the whole section on newlines and print ® # push the register for the next iteration  # PowerShell, 194188185180 174 bytes $z=$a="in the bottom of the sea"$b="here's a"
$h="$b hole"
echo hole log bump frog wart hair fly flea smile|%{,"T$b$_ $a"*2$a='oi'[!$j++]+"n the$_ $a" "T$h, t$h T$h $z "}  Try it online! Can't quite seem to catch Python... Basically, sets a few common strings to $h, $a, $z, and $b, then goes through a loop through each of the items (hole, log, ... flea, smile), each iteration outputting the appropriate verse. There's a little bit of logic with !$j++ in the middle to account for the in/on switch that happens. Otherwise, all the strings are just left on the pipeline, and the default Write-Output gives us newlines for free.

-6 bytes thanks to Arnauld.
-3 bytes thanks to mazzy.
-5 bytes thanks to Veskah.
-6 bytes thanks to mazzy.

• -3 bytes :) Try it online! – mazzy Jan 31 at 9:39
• @mazzy That's a clever trick. I'll need to keep that in mind, because I use -split quite a bit for getting words. – AdmBorkBork Jan 31 at 12:52
• Two forgotten bytes – Veskah Jan 31 at 21:43
• 180 bytes – Veskah Jan 31 at 23:40
• 174. Try it online! – mazzy Feb 1 at 17:14

# JavaScript (ES6),  201 194 189 188  187 bytes

Saved 1 byte thanks to @Shaggy

_=>14log4bump5frog5wart5hair5fly5flea5smile5.replace(/.+?\d/g,w=>T0${(p=w+3+p)+p}1, t01 T01432 .replace(/\d/g,n=>here's a |hole|bottom of the sea |n the | i| o.split|[n]),p=2T0)  Try it online! # JavaScript (ES6), 235 bytes Simply RegPack'ed. _=>[..."Z[]^_$cdjkqvxz{}~"].reduce((p,c)=>(l=p.split(c)).join(l.pop()),Tj{{}qq}}~~}dd}__}xx}cc}[[v~ frogz$}v Z{kZz on^x flyz_v], tj]Zkq log in^{k] in^ bottom of^ seajhere's ad wartz~c fleazx$ bumpzq_ hairzd^ the] hole[ smilezcZ
Tj)


Try it online!

# Japt -Rx, 126116113112111109 107 bytes

It turns out that golfing a string compression challenge while on your phone down the boozer is incredibly difficult - who'd've thunk?!

T's»dâ ÈÞ­omºfdÈ ardS
tE8
¯E
logn¿mpnfgnØnirnf§nf¤ÚèqÍË2ÆiAV¯E©8 iF¯E ÔqVri'oÃpW+v iSi,)UPÃc


Test it

                                              :The first 3 lines get assigned to variables U, V & W, respectively
...                                         :The compressed string "There'sdadholedindthedbottomdofdthedsea"
rdS                                      :Replace all "d"s with spaces
tE8                                           :Substring of U from 0-based index 14 (E), of length 8 (="  in the ")
¯E                                            :Slice U to index 14 (="There's a hole")
...                                         :The compressed string "lognbumpnfrognwartnhairnflynfleasmilent"
qÍ                                       :Split on "n" (note that the last element is irrelevant)
Ë                                      :Map each element at 0-based index E in array F
2Æ                                    :  Map the range [0,2)
iA                                  :    Insert the following in U at index 10
V¯                                :      V sliced to index
E©8                             :        Logical AND of E and 8 (=0 on first iteration, 8 on all others)
i                           :      Prepend
F¯E                        :        Slice F to index E
Ô                      :        Reverse
q                     :        Join with
Vri'o                :          Replace "i" with "o" in V
Ã               :  End map
p              :  Push
W+            :    W appended with
v           :      W lowercased
iSi,      :      Prepended with a space prepended with a comma
)     :    End append
UP   :    U and an empty string
Ã  :End map
c :Flatten
:Implicitly join with newlines, trim & output


# XML, 719673603514493 486 bytes

<!DOCTYPE a[<!ENTITY T "There's a"><!ENTITY O " on the"><!ENTITY a " hole in the bottom of the sea
"><!ENTITY b " log in the&a;"><!ENTITY c " bump&O;&b;"><!ENTITY d " frog&O;&c;"><!ENTITY e " wart&O;&d;"><!ENTITY f " hair&O;&e;"><!ENTITY g " fly&O;&f;"><!ENTITY i " flea&O;&g;"><!ENTITY z "&T; hole, there's a hole
&T;&a;
">]><a>&T;&a;&T;&a;&z;&T;&b;&T;&b;&z;&T;&c;&T;&c;&z;&T;&d;&T;&d;&z;&T;&e;&T;&e;&z;&T;&f;&T;&f;&z;&T;&g;&T;&g;&z;&T;&i;&T;&i;&z;&T; smile&O;&i;&T; smile&O;&i;&z;</a>


You can "execute" it with xmlstarlet sel -t -m '//a' -v . -n <xml_file_here>.

This would be a lot easier if XML wasn't so verbose, but on the bright side, this is less than 25% the size of the original text.

# Bash, 168 160 bytes

r="There's a bottom of the sea
";for i in {hole,log}\ in {bump,frog,wart,hair,fly,flea,smile}\ on;{
r=${r/a/a$i the};t=${r:0:14};echo "$r$r${u=$t,${t,}
$r}";}  160 bytes 168 bytes Translated from my other answer in Perl. # Retina 0.8.2, 150 bytes  THsmile oNflea oNfly oNhair oNwart oNfrog oNbump oNlog iNE N$&$'¶TH O^$

.+
$&¶$&¶THW, tHW¶THE¶
H
here's a
E
W iNbottom of the sea
W
hole
N
n the


Try it online! Explanation:


THsmile oNflea oNfly oNhair oNwart oNfrog oNbump oNlog iNE


Insert the last verse.

N
$&$'¶TH


Compute all the verses.

O^$  Put the verses in the correct order. .+$&¶$&¶THW, tHW¶THE¶  Complete each verse and add the chorus. H here's a E W iNbottom of the sea W hole N n the  Expand some placeholders. # C (gcc), 334328307 299 bytes char*s="here's a \0smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea\n";i;k=105;a[]={0,1,1,1,1,0,1,2,2};main(j){for(;i<9;k-=11+a[i++])do{printf("T%s%s",s,s+k);}while(j++&1||!printf("T%shole, t%shole\nT%s%s\n",s,s,s,s+105));}  Try it online! # Perl 6, 166 bytes ($/=@(($!="There's a")X [\R,](<hole log bump frog wart hair fly flea smile>Z(<i o>[$++>1]~"n the")xx*)X"bottom of the sea
")).map:{say "$_$_$! hole, {$!.lc} hole
$0"}  Try it online! # Japt-R, 142 bytes —¤clogc¿mpcfžgcØ ÖŽrcf§cf¤acsÚèqc ˆ e Þ­om  e a T”œ's a  £W+U¯YÄ ÔËE?"io"gE<Y +n e :P +DÃ¸+ {V}  ²+W+—¤, t”œ's a —¤ {W}—¤ {V+R  Try it online! # R, 237 231 bytes i=" in the " for(j in 0:8)cat(f<-c(t<-"There's a ",paste(c("log","bump","frog","wart","hair","fly","flea","smile")[j:0],collapse=" on the "),if(j)i,h<-"hole",i,b<-"bottom of the sea "),f,t,h,", there's a ",h," ",t,h,i,b," ",sep="")  Try it online! # Haskell, 243 215 bytes Reduced to 215 bytes with great help from nimi c[[l n,l n,'T'#h++", "++'t'#h,l 8,""]|n<-[8,7..0]] t#u=t:"here's a "++u h="hole" c=concat l n='T'#c(drop n$map(++" on the ")(words"smile flea fly hair wart frog bump")++["log in the ",h," in the bottom of the sea"])


Try it online!

(Old 243 byte version is here).

A quite straightforward solution.

-- main function producing a list of lines
v = concat [[
l n,
l n, -- second line of each verse equals to its first line
'T' # h ++ ", " ++ 't' # h,
l 8, -- last line of each verse is the same in all verses
""
] | n <- [8,7..0]]

-- a small helper to construct similar strings
t # u = t : "here's a " ++ u

h = "hole"

-- construct a first line of n-th verse (with n = 8 is the first and n = 0 is the last one)
-- Every such line begins with a constant prefix followed by expanding list of nested entities
l n = 'T' # concat (
drop n $map (++ " on the ") (words "smile flea fly hair wart frog bump") ++ ["log in the ", h, " in the bottom of the sea"] )  • Some tips: a) you use s only once, so you can inline it. b) you always prepend and append something to t, so you can make it a (infix) function: t#u=t:"here's a "++u. c) constructing the big list in function l with map(++" on the ")(words"smile flea ..." is shorter. Also: move everything appended to that list into the list itself. d) the list of numbers to drop now runs from 8 down to 0 (single digit numbers!) e) now inlining i also save some bytes. f) no need to name your main function. According to our meta, Haskell values are considered proper functions, so drop the v=. – nimi Jan 31 at 19:04 • ... All in all 215 bytes Try it online! – nimi Jan 31 at 19:04 • Another 3 bytes to save: instead of the list comprehension you can use >>= (concatMap) from the list monad and inline concat in function l. Try it online! – nimi Feb 1 at 17:14 # JavaScript (Babel Node), 239 bytes -7 bytes from @Oliver *.* (x=0,r='hole0log0bump0frog0wart0hair0fly0flea0smile'.split0).map(a=>(t=(i="There's a ")+a+r.slice(0,x++).reverse().map((h,_)=>${"io"[_<x-2|0]}n the ${h}).join+(o= in the bottom of the sea ))+t+(${k=i+"hole"}, ${k} )+k+o).join   Try it online! • Te second T on the 3rd line of each verse should be lowercase. – Shaggy Jan 31 at 14:16 # PHP, 180 178 bytes foreach([hole,log,bump,frog,wart,hair,fly,flea,smile]as$w)echo$a=T.($b="here's a ").($s="$w ".io[++$i>2]."n the$s").$c="bottom of the sea ",$a,T,$b.=hole,", t$b
T$b in the$c
";


Run with -nr or try it online.

Yields warnings in PHP 7.2; to fix, put quotes around
the array elements, io, hole and the two standalone T.

## Batch, 267 bytes

@echo off
set r=i
set t= There's a hole
set s=bottom of the sea
for %%w in (hole log bump frog wart hair fly flea smile)do call:c %%w
exit/b
:c
set s=%1 %r%n the %s%
echo%t:~,11%%s%
echo%t:~,11%%s%
echo%t%,%t:T=t%
echo%t%%s:~-25%
echo(
if %1==log set r=o


t contains a string repeated in the chorus, s contains most of the verse line, while r chooses between in the and on the. In the verses, only the first 11 characters of t is needed, while in the first chorus line the second copy of t has its T lowercased and the second chorus line reuses the last 25 characters of s.

# Ruby, 173 170 bytes

a="T#{["here's a hole"]*3*"%s"%[", t","
T"]+c=" in the "}bottom of the sea

"
b=a[31,39]
%w{log bump frog wart hair fly flea smile x}.map{|i|puts b,b,a;b[9]+=i+c;c[1]=?o}


Try it online!

# Clean, 267 bytes

import StdEnv,Text,Data.List
t="here's a "
h="hole"
b=" in the bottom of the sea"
f=foldr((+)o\s#p="T"+t+join" on the "(reverse s)+" in the "+h+b
=join"\n"[p,p,"T"+t+h+", t"+t+h+"\nT"+t+h+b+"\n\n"])""(tl(inits["log","bump","frog","wart","hair","fly","flea","smile"]))


Try it online!

# cQuents, 238 219 bytes

|@
#36::"T"~c1)~j\rbk));@ )~c2,Z,"T"~c1)~"hole, t"~c1)~"hole","T"~c1)~c2)~@

:"here's a ","hole in the bottom of the sea"," on the"


Try it online!

This challenge made me finally implement lists and strings in my language. This language is built for integer sequences, so it did pretty well!

## Explanation

:"here's a ","hole in the bottom of the sea"," on the"

helper line: c1), c2), and c3) access the three terms in this list

helper line: yields a list containing the first n terms in it, accessed with bx)
for example, the first three terms are:

so b3) would yield ["","log in the","bump on the"] (~ is concatenation and c3 is " on the")

|@
#36::"T"~c1)~j\rbk));@ )~c2,Z,"T"~c1)~"hole, t"~c1)~"hole","T"~c1)~c2)~@

|@
join sequence on literal newline
#36::                         output first 36 terms in sequence joined together
following are the 4 terms in the sequence, which will cycle through 9 times (for a total of 36 terms)
"T"~c1)~j\rbk));@ )~c2,       first term
"T"~c1)~                      "T" concat "here's a " concat
j\rbk));@ )           the first k terms of b, reversed, and joined on " "
~c2,       concat "hole in the bottom of the sea"
Z,                            second term - same as previous
"T"~c1)~"hole, t"~c1)~"hole", third term
"T"~c1)~                      "T" concat "here's a " concat
"hole, t"~c1)~"hole", "hole, t" concat "here's a " concat "hole"
"T"~c1)~c2)~@
fourth term - "T" concat "here's a " concat "hole on the bottom of the sea" concat newline


# Perl 5, 194 bytes

@ASCII-only shaved off 6 bytes with literal newlines and a \l trick I forgot about

$"=" on the ";say+($b=($e="There's a ").hole,$c=" in the bottom of the sea",$/)x2,$.="$b, \l$b
$b$c
";say"$e@a[-$_..-1] in the hole$c "x2,$.for 1..(@a=qw/smile flea fly hair wart frog bump log/)


Try it online!

• 194? – ASCII-only Jan 31 at 8:25
• Yup. Nice work. I should have remembered the newlines for certain. I've seen the \l before, but never had a reason to use it, so never thought of it. – Xcali Jan 31 at 23:59
• 190? – ASCII-only Feb 1 at 0:00
• – ASCII-only Feb 1 at 0:17
• closer – ASCII-only Feb 1 at 0:23

# Charcoal, 115 106 bytes

≔There's a holeθＥＥ⁹⁺…θχ⪫⮌…⪪”↶±∧⟲!↶⁼,(_⎇ＲB↧ω⪪zθⅉＱθ✳＆⬤⸿◧σ⁻y▷»ΣＫ▶↙⁻υＸSξQ6 /ι⁹Ｗq”x⁺²ιn the ⟦ιι⁺⁺θ, ↧θ⁺θ✂ι±²⁵


Try it online! Link is to verbose version of code. Edit: Saved 9 bytes by copying my Batch code for the last line of the chorus. Explanation:

≔There's a holeθ


Save the string There's a hole, which is used twice as-is, a third time in lower case, and also a fourth time but just the first 10 characters.

⪪”↶±∧⟲!↶⁼,(_⎇ＲB↧ω⪪zθⅉＱθ✳＆⬤⸿◧σ⁻y▷»ΣＫ▶↙⁻υＸSξQ6 /ι⁹Ｗq”x


Split the string bottom of the seaxhole ixlog ixbump oxfrog oxwart oxhair oxfly oxflea oxsmile o on xs.

Ｅ⁹⁺…θχ⪫⮌…...⁺²ιn the


Loop over the 9 verses, taking the first i+2 elements of the array, reversing them, joining them with n the, and prefixing There's a to the result.

Ｅ...⟦ιι⁺⁺θ, ↧θ⁺θ✂ι±²⁵


Expand each line into a verse by duplicating the line and constructing the chorus. Each line of the verse is then implicitly printed on each own line, and each verse is implicitly separated by a blank line.

# C# (Visual C# Interactive Compiler), 222 bytes

string b="There's a ",d="hole in the bottom of the sea\n",e,f;foreach(var s in" log bump frog wart hair fly flea smile".Split())Write((e=b+(f=s!=""?s+(f!=""?" o":" i")+"n the "+f:s)+d)+e+b+$@"hole, there's a hole {b+d} ");  Try it online! -5 bytes thanks to @ASCIIOnly! I have a small child and can assure you this song is equal parts catchy and annoying. • I'm sorry to have reminded you that it exists :o) – Sok Jan 31 at 8:21 • .Any() -> !=""? – ASCII-only Feb 1 at 1:42 • also 223 – ASCII-only Feb 1 at 1:44 • and you don't need the space after in in the foreach >_> – ASCII-only Feb 1 at 1:50 • @ASCIIOnly - Thanks for the tips :) – dana Feb 1 at 4:34 # V, 184 170 bytes 4iThere's a hole in the bottom of the sea kky5w5eá,lpD5brtHj4yyGp4w8ion the 2briilog 3bibump 3bifrog 3biwart 3bihair 3bifly 3biflea 3bismile 7ñ4yykp4wd3wñ8ñÄ5jñ  Try it online! ## Explanation: • 4iThere's a hole in the bottom of the sea<\n><esc> Insert "Theres' a hole in the bottom of the sea" 4 times. • kk Move to the third line • y5w copy "There's a hole" • 5eá, insert a comma after "There's a hole" • lp paste after the comma • D delete the rest of the line • 5brt lowercase the second T • Hj4yy copy 4 lines from the second line • Gp Paste everything after the first line • 4w8ion the <esc>(at the end of the first verse) move to first "hole" in second verse and insert "on the " 8 times • 2briilog <esc> move backwards to the last "on", replace the o with an i and then insert "log " • 3bibump <esc>3bifrog <esc>3biwart <esc>3bihair <esc>3bifly <esc>3biflea <esc>3bismile <esc> Move backwards through the line, inserting the appropriate words between each "on the" • 7ñ4yykp4wd3wñ execute 4yykp4wd3w 7 times • 4yykp duplicate the verse before this one • 4wd3w move to the first word after "There's a hole" and delete 3 words • 8ñÄ5jñ duplicate the first line of each verse after the first (there are 8 of these to do) # ///, 216 bytes /V/\/\///U/\/ VS/TCVR/iBVQUtheVPUoBVOUholeVN/RASVM/ASO, tCO SA VL/RMSVKUlog VJUbumpPKVIUfrogPJVHUwartPIVGUhairPHVFUflyPGVEUfleaPFVDUsmilePEVC/here's aVB/nQVA/O R bottom ofQ sea /SASMSKNKLJNJLINILHNHLGNGLFNFLENELDNDRM  Try it online! This sort of task is the one and only thing that /// is reasonably good at. :D Hey, the result is shorter than C, C# or Java! The output from this program ends in two trailing line breaks; hope that's not a deal-breaker. Anyway, there's no real cleverness here. I simply identified repeated strings and defined one-character shortcuts for them, and repeated until I didn't see any more repeated strings. I did this in a more-or-less naive and greedy fashion. I did, however, intentionally define a shortcut for "smile on the flea on the ... sea", followed by "flea on the fly on the ... sea", and so forth, in order to form a chain of shortcuts. The result is that the whole sequence of new nouns is clearly visible in the code, and I find that pretty pleasing. :) After V and U are replaced, we have the following more readable code: /S/TC//R/iB//Q/ the//P/ oB//O/ hole//N/RAS//M/ASO, tCO SA //L/RMS//K/ log //J/ bumpPK//I/ frogPJ//H/ wartPI//G/ hairPH//F/ flyPG//E/ fleaPF//D/ smilePE//C/here's a//B/nQ//A/O R bottom ofQ sea /SASMSKNKLJNJLINILHNHLGNGLFNFLENELDNDRM  # Shell, 291 bytes echo 'smile,flea,fly,hair,wart,frog,bump,log,hole'|awk -F, 'BEGIN{z="here'\''s a ";a="T"z;c=a "hole";b=" in the bottom of the sea"}function f(n){printf a$n;for(j=n+1;j<=NF;j++){printf " on the " \$j};print b;}{for(i=NF;i>=1;i--){printf (i<NF)?"\n":"";f(i);f(i);print c", t" z "hole";f(NF)}}'


I'm sure it can be golfed further (definitions of vars & function) ...

# Java (OpenJDK 8), 320 344 bytes

Long but wanted to try with java, no streams and java 8 things.

*Edited to fix some problems.

static String w(){String[]a={"hole","log","bump","frog","wart","hair","fly","flea","smile"};String n="T",m="t",q=" ",t="here's a ",s="bottom of the sea \n",y="in the ",o="on the ",b=t+a[0],f="",v,l="\n",c=y+s,h=a[0]+q+c,z=n+b+", "+m+b+q+l+n+b+q+c;for (int i=0;i<9;i++){v=n+t;for(int j=i;j>0;j--){v+=a[j]+q+(j>1?o:y);}v+=h;f+=v+v+z+l;}return f;}
`

Try it online!

• there are two problems the spaces before the commas and the uppercase after comma, otherwise you can check translation of my answers 282 bytes – Nahuel Fouilleul Jan 31 at 15:14
• 269 bytes using lambda notation – Nahuel Fouilleul Jan 31 at 15:18
• @Shaggy You are right, it is fixed now :) – Java Gonzar Jan 31 at 17:21
• @NahuelFouilleul 264 bytes – Kevin Cruijssen Feb 1 at 18:47
• 261 bytes – ceilingcat Feb 1 at 23:04