Duck, duck, gone!Tips for golfing in PythonPrint My Block ScheduleCan I Choose Not to Fly?Four is the magic numberRisky Phone PlanWhich Day of Christmas is it?Little Boxes on the HillsidePrint “Hey Jude” from The Beatles

Email loop false positive

How to add new line between `ls -l` output

Is this the correct pronunciation of "heinous" in any English-speaking country?

Is Yoda made using CGI in the original Star Wars or is it practical effects?

What are the ways my non-monk character can improve their unarmed damage?

What principles should I follow when entering data into a complex relational database?

Conceptual distinction between " strength" , " force" and " power"?

Is there a simpler way to write the limit I need?

What does this "ICAgICAg…" mean in public key certificates and messages?

Is it acceptable to say that a divergent series that tends to infinity is 'equal to' infinity?

Odd wiring setup in light switch

How to solve system equations with sum and vectors

Name for geostationary orbit around another planet

Does an action-reaction pair always contain the same kind of force?

How to move directory into a directory with the same name?

Configuring iPad's to not require passwords routinely

tikz: place a mark on a straight line

How can baseline humanity survive on its own in the future?

Why are the Londoners so excited in the hunt without feeling the horror of war?

Two congruent triangles

Are there any surviving Ancient Greek letters (epistolary)?

Why does California spend so much on healthcare?

How Can NASA Images/Videos Not Be Copyrighted?

What are basic concepts of fusion kitchen?



Duck, duck, gone!


Tips for golfing in PythonPrint My Block ScheduleCan I Choose Not to Fly?Four is the magic numberRisky Phone PlanWhich Day of Christmas is it?Little Boxes on the HillsidePrint “Hey Jude” from The Beatles






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









40















$begingroup$


Here is the (quite scary) Five little ducks song(it is not long):



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.

Four little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only three little ducks came back.

Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.

Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.

One little duck went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but none of the little ducks came back.

Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Your task is not to output this song. You should take a verse and output the next verse (the next verse of the last verse is the first verse).



Rules



  • No standard loopholes, please.

  • Input/output will be taken via our standard input/output methods.

  • The exact verse must be outputted, and there should be no differences when compared to the song lyrics. The input will not be different when it is compared to the song lyrics too.

Examples



Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Expected:



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.



Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.


Expected:



Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.









share|improve this question











$endgroup$










  • 22




    $begingroup$
    I remember the words to this being slightly different when I was young, many moons ago. But I also remember being traumatised by it! Where were those missing ducklings for all those days?! Why was nobody out looking for them?! And what sort of irresponsible mother manages to lose so many children and keeps letting the rest of them out to play?! The horror!
    $endgroup$
    – Shaggy
    Sep 24 at 9:58






  • 8




    $begingroup$
    Possible duplicate. Just kidding :)
    $endgroup$
    – Night2
    Sep 24 at 12:28






  • 7




    $begingroup$
    You just petrified me.
    $endgroup$
    – A̲̲
    Sep 24 at 12:30






  • 2




    $begingroup$
    That song lyrics sure made me go through a roller coaster of emotions.
    $endgroup$
    – Num Lock
    Sep 25 at 10:04






  • 3




    $begingroup$
    Any reason the capitalization on "Mother duck" and "Mother Duck" is different in the 2 places it is used in the last verse?
    $endgroup$
    – Chill
    Sep 26 at 18:00

















40















$begingroup$


Here is the (quite scary) Five little ducks song(it is not long):



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.

Four little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only three little ducks came back.

Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.

Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.

One little duck went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but none of the little ducks came back.

Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Your task is not to output this song. You should take a verse and output the next verse (the next verse of the last verse is the first verse).



Rules



  • No standard loopholes, please.

  • Input/output will be taken via our standard input/output methods.

  • The exact verse must be outputted, and there should be no differences when compared to the song lyrics. The input will not be different when it is compared to the song lyrics too.

Examples



Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Expected:



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.



Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.


Expected:



Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.









share|improve this question











$endgroup$










  • 22




    $begingroup$
    I remember the words to this being slightly different when I was young, many moons ago. But I also remember being traumatised by it! Where were those missing ducklings for all those days?! Why was nobody out looking for them?! And what sort of irresponsible mother manages to lose so many children and keeps letting the rest of them out to play?! The horror!
    $endgroup$
    – Shaggy
    Sep 24 at 9:58






  • 8




    $begingroup$
    Possible duplicate. Just kidding :)
    $endgroup$
    – Night2
    Sep 24 at 12:28






  • 7




    $begingroup$
    You just petrified me.
    $endgroup$
    – A̲̲
    Sep 24 at 12:30






  • 2




    $begingroup$
    That song lyrics sure made me go through a roller coaster of emotions.
    $endgroup$
    – Num Lock
    Sep 25 at 10:04






  • 3




    $begingroup$
    Any reason the capitalization on "Mother duck" and "Mother Duck" is different in the 2 places it is used in the last verse?
    $endgroup$
    – Chill
    Sep 26 at 18:00













40













40









40


5



$begingroup$


Here is the (quite scary) Five little ducks song(it is not long):



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.

Four little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only three little ducks came back.

Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.

Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.

One little duck went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but none of the little ducks came back.

Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Your task is not to output this song. You should take a verse and output the next verse (the next verse of the last verse is the first verse).



Rules



  • No standard loopholes, please.

  • Input/output will be taken via our standard input/output methods.

  • The exact verse must be outputted, and there should be no differences when compared to the song lyrics. The input will not be different when it is compared to the song lyrics too.

Examples



Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Expected:



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.



Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.


Expected:



Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.









share|improve this question











$endgroup$




Here is the (quite scary) Five little ducks song(it is not long):



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.

Four little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only three little ducks came back.

Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.

Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.

One little duck went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but none of the little ducks came back.

Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Your task is not to output this song. You should take a verse and output the next verse (the next verse of the last verse is the first verse).



Rules



  • No standard loopholes, please.

  • Input/output will be taken via our standard input/output methods.

  • The exact verse must be outputted, and there should be no differences when compared to the song lyrics. The input will not be different when it is compared to the song lyrics too.

Examples



Mother duck herself went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
and all of the little ducks came back.


Expected:



Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.



Three little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only two little ducks came back.


Expected:



Two little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only one little duck came back.






code-golf string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 24 at 11:19







A̲̲

















asked Sep 24 at 9:45









A̲̲A̲̲

5,0771 gold badge11 silver badges42 bronze badges




5,0771 gold badge11 silver badges42 bronze badges










  • 22




    $begingroup$
    I remember the words to this being slightly different when I was young, many moons ago. But I also remember being traumatised by it! Where were those missing ducklings for all those days?! Why was nobody out looking for them?! And what sort of irresponsible mother manages to lose so many children and keeps letting the rest of them out to play?! The horror!
    $endgroup$
    – Shaggy
    Sep 24 at 9:58






  • 8




    $begingroup$
    Possible duplicate. Just kidding :)
    $endgroup$
    – Night2
    Sep 24 at 12:28






  • 7




    $begingroup$
    You just petrified me.
    $endgroup$
    – A̲̲
    Sep 24 at 12:30






  • 2




    $begingroup$
    That song lyrics sure made me go through a roller coaster of emotions.
    $endgroup$
    – Num Lock
    Sep 25 at 10:04






  • 3




    $begingroup$
    Any reason the capitalization on "Mother duck" and "Mother Duck" is different in the 2 places it is used in the last verse?
    $endgroup$
    – Chill
    Sep 26 at 18:00












  • 22




    $begingroup$
    I remember the words to this being slightly different when I was young, many moons ago. But I also remember being traumatised by it! Where were those missing ducklings for all those days?! Why was nobody out looking for them?! And what sort of irresponsible mother manages to lose so many children and keeps letting the rest of them out to play?! The horror!
    $endgroup$
    – Shaggy
    Sep 24 at 9:58






  • 8




    $begingroup$
    Possible duplicate. Just kidding :)
    $endgroup$
    – Night2
    Sep 24 at 12:28






  • 7




    $begingroup$
    You just petrified me.
    $endgroup$
    – A̲̲
    Sep 24 at 12:30






  • 2




    $begingroup$
    That song lyrics sure made me go through a roller coaster of emotions.
    $endgroup$
    – Num Lock
    Sep 25 at 10:04






  • 3




    $begingroup$
    Any reason the capitalization on "Mother duck" and "Mother Duck" is different in the 2 places it is used in the last verse?
    $endgroup$
    – Chill
    Sep 26 at 18:00







22




22




$begingroup$
I remember the words to this being slightly different when I was young, many moons ago. But I also remember being traumatised by it! Where were those missing ducklings for all those days?! Why was nobody out looking for them?! And what sort of irresponsible mother manages to lose so many children and keeps letting the rest of them out to play?! The horror!
$endgroup$
– Shaggy
Sep 24 at 9:58




$begingroup$
I remember the words to this being slightly different when I was young, many moons ago. But I also remember being traumatised by it! Where were those missing ducklings for all those days?! Why was nobody out looking for them?! And what sort of irresponsible mother manages to lose so many children and keeps letting the rest of them out to play?! The horror!
$endgroup$
– Shaggy
Sep 24 at 9:58




8




8




$begingroup$
Possible duplicate. Just kidding :)
$endgroup$
– Night2
Sep 24 at 12:28




$begingroup$
Possible duplicate. Just kidding :)
$endgroup$
– Night2
Sep 24 at 12:28




7




7




$begingroup$
You just petrified me.
$endgroup$
– A̲̲
Sep 24 at 12:30




$begingroup$
You just petrified me.
$endgroup$
– A̲̲
Sep 24 at 12:30




2




2




$begingroup$
That song lyrics sure made me go through a roller coaster of emotions.
$endgroup$
– Num Lock
Sep 25 at 10:04




$begingroup$
That song lyrics sure made me go through a roller coaster of emotions.
$endgroup$
– Num Lock
Sep 25 at 10:04




3




3




$begingroup$
Any reason the capitalization on "Mother duck" and "Mother Duck" is different in the 2 places it is used in the last verse?
$endgroup$
– Chill
Sep 26 at 18:00




$begingroup$
Any reason the capitalization on "Mother duck" and "Mother Duck" is different in the 2 places it is used in the last verse?
$endgroup$
– Chill
Sep 26 at 18:00










18 Answers
18






active

oldest

votes


















3

















$begingroup$


Stax, 115 111 bytes



τ*^&k─Zè0µ9┬$█◘çl╟☼:Drσ59ò╠▄┴╢Q♂╔¡ô╜Oa╣▀yèA÷╨%^♀█Ö+╡◄ì=∙%╧o▌Θ<▲Çα¿╗√;1°┼╤V◘ú┐♥▒ÇM☼b╩░o]YaL4░ƒ%(Æ♫Q0æÆä⌂¡╘○Eâó╪¡


Run and debug it



All the verses as test cases






share|improve this answer












$endgroup$









  • 1




    $begingroup$
    When you run it with "One little duck", it responds "little ducknd little duckll of the little ducks came back." in the last line.
    $endgroup$
    – Dorian
    Oct 2 at 10:25






  • 1




    $begingroup$
    The bug has been fixed at no cost in size. It was actually about a 2-byte cost, and and offsetting 2-byte savings elsewhere, although bytes are kind of hard to measure here, since the changes aren't exactly byte aligned inside compressed string literals, or even in the final program.
    $endgroup$
    – recursive
    Oct 2 at 16:26


















19

















$begingroup$

JavaScript (ES9), 227 bytes



This is similar to the Node version below but uses a formula based on parseInt() instead of Buffer() to identify the input verse.



This is ES2018 (aka ES9) because we're using a regular expression with the /s flag (dotAll).



s=>'Mother duck herself1and all23,,Three4two3,Five4four3,Four4three3,One01but none23,Two4one0'.split`,`[parseInt(s,30)&7].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


Try it online!



How?



In this version, we parse the entire input verse as base 30 (0 to t) and perform a bitwise AND with 7. The parsing stops on the first invalid character, leading to:



 verse | valid part | base 30 -> decimal | AND 7
-------+------------+--------------------+-------
0 | 'fi' | 468 | 4
1 | 'fo' | 474 | 2
2 | 'three' | 23973734 | 6
3 | 't' | 29 | 5
4 | 'one' | 22304 | 0
5 | 'mother' | 554838747 | 3




JavaScript (Node.js),  233 231  227 bytes



Saved 2 bytes thanks to @Shaggy



s=>'Three4two3,Four4three3,Mother duck herself1and all23,One01but none23,,,Two4one0,,Five4four3'.split`,`[Buffer(s)[2]%9].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


Try it online!



How?



The third character of each input verse can be used as a unique identifier. By taking its ASCII code modulo 9, we get:



 verse | 3rd char. | ASCII code | MOD 9
-------+-----------+------------+-------
0 | 'v' | 118 | 1
1 | 'u' | 117 | 0
2 | 'r' | 114 | 6
3 | 'o' | 111 | 3
4 | 'e' | 101 | 2
5 | 't' | 116 | 8


The output verses are encoded with the following templates:



 verse | template
-------+---------------------------------
0 | 'Five4four3'
1 | 'Four4three3'
2 | 'Three4two3'
3 | 'Two4one0'
4 | 'One01but none23'
5 | 'Mother duck herself1and all23'


Where each digit is replaced with a string according to the following table:



 digit | replaced with
-------+---------------------------------------------------
0 | ' little duck'
1 | / w.*n/s.exec(s)
2 | ' of the'
3 | ' little ducks'
4 | ' little ducks' + / w.*n/s.exec(s) + 'but only '


Where the regular expression / w.*n/s extracts this common part from the input:



 went out one day,[LF]
over the hills and up away.[LF]
Mother Duck said, "Quack Quack Quack Quack",[LF]


We finally add the last 11 characters of the input, which is " came back.".






share|improve this answer












$endgroup$













  • $begingroup$
    231
    $endgroup$
    – Shaggy
    Sep 24 at 12:00






  • 1




    $begingroup$
    @Shaggy Nicely done. Thanks!
    $endgroup$
    – Arnauld
    Sep 24 at 12:08






  • 2




    $begingroup$
    Was just posting another comment to suggest exec when the page reloaded. Great minds ... !
    $endgroup$
    – Shaggy
    Sep 24 at 12:14


















11

















$begingroup$


Python 3, 267 263 254 bytes



4 bytes saved thanks to @ovs



def f(s):
for a in zip(T[2:]+T,T):s=s.replace(*a)
return s
T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
T=T.split(':')


Try it online!



Works by replacing the relevant parts by the respective parts of the next verse.



After the preinitialisation, T is ['8', '9', 'and all of the little ducks', 'One little duck', 'but none of the little ducks', 'Two little ducks', 'but only one little duck', 'Three little ducks', 'but only two little ducks', 'Four little ducks', 'but only three little ducks', 'Five little ducks', 'but only four little ducks', 'Mother duck herself'].



Alternative Python 2, 252 bytes



by @ovs



lambda s:reduce(lambda s,a:s.replace(*a),zip(T[2:]+T,T),s)
T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
T=T.split(':')


Try it online!






share|improve this answer












$endgroup$













  • $begingroup$
    for a in zip(T,T[-2:]+T):s=s.replace(*a) for 264 bytes.
    $endgroup$
    – ovs
    Sep 24 at 11:17











  • $begingroup$
    Or lambda s:reduce(lambda s,a:s.replace(*a),zip(T,T[-2:]+T),s) for 262 bytes in Python 2.
    $endgroup$
    – ovs
    Sep 24 at 11:19










  • $begingroup$
    @ovs Thanks, I got it to 263 with reodering some things and using T[2:] instead of T[-2:]
    $endgroup$
    – Black Owl Kai
    Sep 24 at 13:18


















9

















$begingroup$


QuadR, 257 242 bytes



-14 thanks to Black Owl Kai, -1 thanks to Kevin Cruijssen





ive
Four
hree
Two( little duck)s
One little( duck)
Mother( duck) herself
four
two( little duck)s
only on(e little duck)
but none
and all of the
our
Three
wo
One1
Mother1 herself
Five little1s
three
one1
none of th1s
and all
but only four


Try it online!






share|improve this answer












$endgroup$









  • 1




    $begingroup$
    243 bytes
    $endgroup$
    – Black Owl Kai
    Sep 24 at 13:24






  • 1




    $begingroup$
    242 bytes
    $endgroup$
    – Kevin Cruijssen
    Sep 24 at 13:29


















7

















$begingroup$

Java 10, 347 bytes





s->String L=" little duck",M="Mother duck herself";int i=9;for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))s=s.replace(t,++i+"");for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))s=s.replace(i--+"",t);return s;


Try it online.



Explanation:



We first replace all parts one by one with integers in the range $[10,21]$, and then these integers back to their replacements. The reason this is done in two steps, is because we would otherwise replace replacements.



s-> // Method with String as both parameter and return-type
String L=" little duck",M="Mother duck herself";
// Two temp strings to save bytes
int i=9; // Temp replacement integer, starting at 9
for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))
// Loop over the parts to replace:
s=s.replace(t, // Replace the part,
++i+""); // with the integer pre-incremented by 1
for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))
// Then loop over the parts to replace with in reverse:
s=s.replace(i--+"", // Replace the (post-decrementing) integer,
t); // with the replacement-part
return s; // And then return the modified String as result





share|improve this answer










$endgroup$





















    7

















    $begingroup$

    T-SQL, 407 390 388 382 bytes



    DECLARE @ CHAR(999)=REPLACE(REPLACE('SELECT CASE LEFT(v,2)WHEN''Fi74,''Four''),122,4,''three'')WHEN''Fo74,''Three''),123,5,''two'')WHEN''Th75,''Two''),121,16,''on#'')WHEN''Tw716,''On#''),115,20,''none of th#s'')WHEN''On715,''Mother duck herself''),115,8,''and all'')WHEN''Mo719,''Fiv#s''),113,14,''but only four'')END FROM i',7,'''THEN STUFF(STUFF(v,1,'),'#','e little duck')EXEC(@)


    Input is via a pre-existing table $i$ with VARCHAR(MAX) field $v$, per our IO rules.



    After a couple of byte-saving REPLACEs, executes the following as dynamic SQL:



    SELECT CASE LEFT(v,2)
    WHEN'Fi'THEN STUFF(STUFF(v,1,4,'Four'),122,4,'three')
    WHEN'Fo'THEN STUFF(STUFF(v,1,4,'Three'),123,5,'two')
    WHEN'Th'THEN STUFF(STUFF(v,1,5,'Two'),121,16,'one little duck')
    WHEN'Tw'THEN STUFF(STUFF(v,1,16,'One little duck'),115,20,'none of the little ducks')
    WHEN'On'THEN STUFF(STUFF(v,1,15,'Mother duck herself'),115,8,'and all')
    WHEN'Mo'THEN STUFF(STUFF(v,1,19,'Five little ducks'),113,14,'but only four')END
    FROM i


    Uses a CASE statement and STUFF commands to insert/overwrite characters at the listed positions.



    EDITS:



    1. Replace original (below) with an entirely different strategy

    2. Saved two bytes by switching to LEFT instead of SUBSTRING and eliminating a space

    3. Saved 6 bytes by changing variable to CHAR and moving an extra letter into the second REPLACE (thanks, @CDC!)

    Here's my first version, using a different method (post-replacement, formatted):



    DECLARE @ VARCHAR(MAX)
    SELECT @=v FROM i
    SELECT @=REPLACE(@,PARSENAME(value,2),PARSENAME(value,1))
    FROM string_split('e.but none.and all
    -e.One little duck.Mother duck herself
    -o.only one little duck.none of the little ducks
    -o.Two little ducks.One little duck
    -r.two little ducks.one little duck
    -r.Three.Two
    -u.three.two
    -u.Four.Three
    -v.four.three
    -v.Five.Four
    -t.and all of the.but only four
    -t.Mother duck herself.Five little ducks','-')
    WHERE LEFT(value,1)=SUBSTRING(@,3,1)
    PRINT @


    STRING_SPLIT and PARSENAME are used to break a string into rows and columns via - and . separators.



    The first column is a key character that is matched against the 3rd letter of the input verse (thanks for the idea, @Night2). The second and third are the replacements being performed for that verse.






    share|improve this answer












    $endgroup$













    • $begingroup$
      First solution, if you use "CHAR(700)" instead of "VARCHAR(MAX)" you can save 3 bytes. Also in your " little duck", you can instead do "e little duck" and remove the e before # on each replacement to get another 3.
      $endgroup$
      – CDC
      Sep 27 at 19:26










    • $begingroup$
      BTW, really fun solution. I used formatmessage to get very close to you, but not quite.
      $endgroup$
      – CDC
      Sep 27 at 19:28










    • $begingroup$
      Good suggestions, @CDC, thanks!
      $endgroup$
      – BradC
      Sep 27 at 19:49


















    6

















    $begingroup$


    Python 2, 1034 bytes



    This is my code! It employs a simple dictionary. After running this code, you can enter any verse and it will output the next verse.



    PS: I am new to this channel and this is my first post. I really liked this challenge so decided to give it a try. Please feel free to correct me.



    import sys
    i=sys.stdin.readlines()
    s="Mother":"""Five little ducks went out one day,
    over the hills and up away.
    Mother Duck said, "Quack Quack Quack Quack",
    but only four little ducks came back.""",
    "Five":"""Four little ducks went out one day,
    over the hills and up away.
    Mother Duck said, "Quack Quack Quack Quack",
    but only three little ducks came back.""",
    "Four":"""Three little ducks went out one day,
    over the hills and up away.
    Mother Duck said, "Quack Quack Quack Quack",
    but only two little ducks came back.""",
    "Three":"""Two little ducks went out one day,
    over the hills and up away.
    Mother Duck said, "Quack Quack Quack Quack",
    but only one little duck came back.""",
    "Two":"""One little duck went out one day,
    over the hills and up away.
    Mother Duck said, "Quack Quack Quack Quack",
    but none of the little ducks came back.""",
    "One":"""Mother duck herself went out one day,
    over the hills and up away.
    Mother Duck said, "Quack Quack Quack Quack",
    and all of the little ducks came back."""
    print s[i[0].split(" ")[0]]





    share|improve this answer












    $endgroup$









    • 11




      $begingroup$
      Welcome to the site! Usually we would count the dictionary as part of the source. Part of the challenge would be to try and make this as small as possible. There are also a few ways you could shorten this. 1) Since you don't get any points for being readable you can use single character variable names (e.g. x or a) 2) Python is pretty permissive with whitespace so I would try removing some of your whitespace also. For example you don't need spaces around =. Lastly We have a page for golfing in python you can visit to up your game.
      $endgroup$
      – Wheat Wizard
      Sep 24 at 22:22










    • $begingroup$
      wow @SriotchilismO'Zaic! that's helpful..thank you! :)
      $endgroup$
      – Prachiti Prakash Prabhu
      Sep 24 at 22:44







    • 1




      $begingroup$
      You can easily golf this by removing unnecessary whitespace and variables, avoiding importing sys by using e.g. raw_input(), shortening the key of the dictionary, etc. You should most definitely take out the repeated sections of the song and add them seperately
      $endgroup$
      – Jo King
      Sep 26 at 5:38










    • $begingroup$
      @JoKing as I mentioned this is my very first post and I didn't put much thought into this. Just wanted to give it a try, but I now get the idea. My next post is going to be much much better and shorter than this--all thanks to you guys..helping me out! :)
      $endgroup$
      – Prachiti Prakash Prabhu
      Sep 26 at 17:34


















    6

















    $begingroup$


    PHP (7.4), 253 247 bytes



    -6 bytes by improving how the replacements array is built with more help from "Unpacking inside arrays".





    <?=strtr($argv[1],array_combine([0,1,...$a=[Five.$l=($o=" little duck").s,($b="but only ").four.$l,Four.$l,$b.three.$l,Three.$l,$b.two.$l,Two.$l,$b.one.$o,One.$o,"but none of the$l","Mother duck herself","and all of the$l"]],[...$a,$a[0],$a[1]]));


    Try it online!



    This creates an array of every possible replacement (12 used + 2 unused) in a key=>value format. Example: ['Mother duck herself' => 'Five little ducks', etc...] and then just replaces those using strtr.



    The only interesting thing is my first ever usage of "Unpacking inside arrays" which is a new feature in PHP 7.4.





    PHP, 264 bytes





    <?=str_replace(($a=[[Five.$l=($o=" little duck").s,($b="but only ").four.$l],[Four.$l,$b.three.$l],[Three.$l,$b.two.$l],[Two.$l,$b.one.$o],[One.$o,"but none of the$l"],["Mother duck herself","and all of the$l"]])[$i=strpos(vuroet,($v=$argv[1])[2])],$a[++$i%6],$v);


    Try it online!



    I have stored different words of each verse in an array. I find which verse the input is using third character of the input as it is unique (vuroet). Then I simply replace different words of that verse with different words of the next verse.






    share|improve this answer












    $endgroup$





















      5

















      $begingroup$


      Clean, 352 bytes



      import StdEnv,Text
      $n=#"Five"+e+"four"+d,"Four"+e+"three"+d,"Three"+e+"two"+d,"Two"+e+"one"+a,"One"+a+b+"but none"+f,"Mother duck herself"+b+"and all"+f.[indexOfn.[2]"tvuroe"]+" came back."
      a=" little duck"
      b=" went out one day,nover the hills and up away.nMother Duck said, "Quack Quack Quack Quack",n"
      d=a+"s"
      e=d+b+"but only "
      f=" of the"+d


      Try it online!






      share|improve this answer










      $endgroup$





















        5

















        $begingroup$


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





        x=>$@"l[g=x[2]*37%724%7]g-5:; little duckg-4: herself;s; went out one day,
        (x=x.Split('n'))[1]
        x[2]
        g-5:and;but g-4:all;only;none (g>3?"of the":l[g+1].ToLower()) little ducg%3:ks;;k came back.";var l=" Four Three Two One Mother".Split();int g


        Try it online!






        share|improve this answer












        $endgroup$





















          3

















          $begingroup$


          PowerShell, 356 343 340 336 bytes



          param($p)$l,$M=' little duck','Mother duck herself'
          ("ive!our;four!three;hree!wo;Four!Three;two!one;s c! c;Two!One;s w! w;only one!none of the;k c!ks c;One$l!$M;but none!and all;$M!Five$l`s;and all of the!but only four"-split';')[$(switch -r($p)^Fi0,1^Fo2,3^Th2,4,5^Tw6..9^O10,11^M12,13)]|%$p=$p-creplace($_-split'!')
          $p


          Try it online.



          More readable version:



          param($p)
          $l, $M = ' little duck', 'Mother duck herself'
          $replacements = @"
          ive!our
          four!three
          hree!wo
          Four!Three
          two!one
          s c! c
          Two!One
          s w! w
          only one!none of the
          k c!ks c
          One$l!$M
          but none!and all
          $M!Five$l`s
          and all of the!but only four
          "@ -split 'n'
          $i = switch -regex ($p) ^Fi 0, 1
          ^Fo 2, 3
          ^Th 2, 4, 5
          ^Tw 6..9
          ^O 10, 11
          ^M 12, 13
          $replacements[$i] | % $p = $p -creplace ( $_ -split '!' )
          $p





          share|improve this answer












          $endgroup$





















            3

















            $begingroup$


            PowerShell, 265 263 255 251 246 bytes





            $d='Five1four2s,Four1three2s,Three1two2s,Two1one2,One23but none52s,Mother duck herself3and all52s'-split','
            '2s34',' little duck',-join($args-split'(s)')[5..39],'but only ',' of the'|%$d=$d-replace++$i,$_
            $d[+"$args"[2]*37%724%7]+' came back.'


            Try it online!



            I used the brute force to find the expression +"$args"[2]*37%724%7.



             verse | 3rd char. | ASCII code | *37%724%7
            -------+-----------+------------+-----------
            0 | 'v' | 118 | 1
            1 | 'u' | 117 | 2
            2 | 'r' | 114 | 3
            3 | 'o' | 111 | 4
            4 | 'e' | 101 | 5
            5 | 't' | 116 | 0


            Thanks @Arnauld for the 3rd char.






            share|improve this answer












            $endgroup$





















              2

















              $begingroup$


              Japt v2.0a0, 143 bytes



              Tried encoding a single verse with replacements but, in the end, adapting Arnauld's solution ended up being shorter. Have another idea that might, hopefully, work out shorter again but don't know when I'll get to try it.



              tBn)i`Fr4È(e3
              Two4e0
              MÇ@r Ýõ Êelf1d a¥23
              O01¿t Í
              23
              TËG4two3
              Five4fr3`·g`v`b¢Î)rdÈ°g[V=` Ò¤ Ýõ`W=Uf/ w.*n/s ` e`V±'sV+W+`¿t § `]


              Try it - includes all verses






              share|improve this answer










              $endgroup$





















                2

















                $begingroup$


                Bash, 373 355 bytes



                Nothing too crazy here. An easy few byte reduction would be to replace the two-character variables (a1,a2,a3,e1..e6) with single character ones.





                read a1..3 b
                read c
                read d
                read e1..6
                W="$e1 $e2"
                X="$e3^ $a2 $a3"
                Y="$e5 $e6"
                Z="$e4 $Y"
                p=$X
                case $a1 in M*)p="Five $Y::12";s="but only four $Y";;O*)p="$d::11 herself";s="and all of $Z";;Tw*)p=$X/s;s="$e1 none of the $a2 ducks $e6";;Th*)s="$W one $e4 duck $e6";;Fo*)s="$W two $Z";;Fi*)s="$W three $Z";;esac
                echo $p $b;echo $c;echo $d;echo $s


                Try it online!



                Try it online!






                share|improve this answer












                $endgroup$





















                  2

















                  $begingroup$


                  05AB1E, 134 bytes



                  “€µ‚•„í†ìˆÈ“#’ „ê Ðœs’δJ樅î¥Ðœº¶s‚ìðδJD…€³€É δ쨦“€ƒ€Ÿ€‚€€““€³Šª€‚€€“‚’ „ê Ðœs ’δJ셋邃.δJU.•4Ôāl•|н2èk©è.ª?I„ 
                  ý#3.$17£ðý„
                  ¶:,X®è?


                  Try it online!



                  Since i'm relatively new to 05AB1E, this can maybe be golfed a lot



                   ### Preparation of the output strings ###
                  “€µ‚•„í†ìˆÈ“ push "one two three four five"
                  # split that by spaces
                  ’ „ê Ðœs’ push " little ducks"
                  δJ join each number with " little ducks"
                  ć¨ separate "one little ducks" and drop the "s"
                  …î¥Ðœº¶ push "mother duck herself"
                  s swap it with "one little duck"
                  ‚ì prepend both strings to the list ["mother duck herself", "one little duck", "two little ducks" ... ]
                  ðδJ append a space to each list entry
                  D duplicate it
                  …€³€É push "but only "
                  δì prepend "but only " to each list entry
                  ¨¦ drop the first and last list entry
                  “€ƒ€Ÿ€‚€€“ push "and all of the"
                  “€³Šª€‚€€“ push "but none of the"
                  ‚ push the two strings into a list
                  ’ „ê Ðœs ’δJ append " little ducks " to each
                  ì prepend it to the sentence list ["and all of the little ducks ", "but none of the little ducks ", "but only one little duck " ...]
                  …‹é‚ƒ. push "came back."
                  δJ append that to each list entry
                  U save that list in X for later use

                  ### Determine which verse has to be answered ###
                  .•4Ôāl• push "eoruvt"
                  |н2è get the third letter of the input
                  k get the index of that letter in "eoruvt". Now we know which verse we must return
                  © save that index in ® for later use

                  ### Print the answer strings ###
                  è.ª? print that index of the first sentence list (first three words of answer)
                  I„ join the four input strings by <space><newline>
                  ý
                  # split that by spaces
                  3.$ cut off the first three words
                  17£ keep only the next 17 words
                  ðý join remaining words by spaces

                  ¶: replace <space><newline> by only <newline>
                  , print that ("went out ... Quack",")
                  X®è? print the last line of answer





                  share|improve this answer










                  $endgroup$





















                    1

















                    $begingroup$


                    Perl 6, 247 bytes





                    S:i/nesl.*?<(s//om/..(.)(S*)**3%s(.**92).*(.**11)/;[(my$l=" little ducks")~$3 XR~"Mother duck herself$2and all of the","One$l~=$2but none of the","Five$l~="but only "four","Four$lthree","Three$ltwo","Two$lone"]["eotvur".index($0)]


                    Try it online!



                    Definitely golfable, especially the last 5 elements in the list in the form "num $l num-1", or the starting regex that matches the right parts of the old input.






                    share|improve this answer












                    $endgroup$





















                      1

















                      $begingroup$


                      Charcoal, 156 bytes



                      ≔⌕tvuroe§θ²δ§⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸⸿η⸿ζ⸿§⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                      Try it online! Link is to verbose version of code. Explanation:



                      ≔⌕tvuroe§θ²δ


                      Look at the third character of the first line to work out which verse we want.



                      §⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸


                      Output the first part of the first line by indexing into the list of strings Five, Four, Three, Two, One, Mother duck herself. Then print little duck and s as appropriate, followed by the last 18 characters of the input line (which are always the same on each verse).



                      ⸿η⸿ζ⸿


                      The middle two lines are always the same on each verse.



                      §⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                      For the last line it turns out to be golfier to include little ducks in the list of alternatives for some reason, but the last 11 characters are still copied from the input.






                      share|improve this answer










                      $endgroup$





















                        1

















                        $begingroup$


                        ink, 353 bytes



                        =d(v)
                        ~temp n=(v?"Fi")+(v?"F")*4+(v?"Th")+(v?"T")*2+(v?"O")
                        n-1:n:n-5:n-4:n-3:One little duckn-2:s went out one day,
                        over the hills and up away,
                        Mother Duck said "Quack Quack Quack Quack",
                        and all of the little duckn-3:s came back.


                        Try it online!



                        First, uses substring checks to figure out what verse we're in - that's easy enough thanks to the capitalisation of the numbers at the start - F, T and O don't occur in any other places, and you can distinguish the second and fourth verse from the first and third by also checking for Fi and Th respectively.



                        Then we just do what ink does best and print plain text specked with conditionals. I tried using switch statements at first, but while that looked nicer, it actually ended up longer.

                        You'd think the Quacks would be a good place to use variables, what with a string being repeated a bunch, but variables come with enough overhead that every way I tried to do that made the code longer. Maybe that's a sign I'm not supposed to golf in ink.






                        share|improve this answer










                        $endgroup$















                          Your Answer






                          StackExchange.ifUsing("editor", function ()
                          StackExchange.using("externalEditor", function ()
                          StackExchange.using("snippets", function ()
                          StackExchange.snippets.init();
                          );
                          );
                          , "code-snippets");

                          StackExchange.ready(function()
                          var channelOptions =
                          tags: "".split(" "),
                          id: "200"
                          ;
                          initTagRenderer("".split(" "), "".split(" "), channelOptions);

                          StackExchange.using("externalEditor", function()
                          // Have to fire editor after snippets, if snippets enabled
                          if (StackExchange.settings.snippets.snippetsEnabled)
                          StackExchange.using("snippets", function()
                          createEditor();
                          );

                          else
                          createEditor();

                          );

                          function createEditor()
                          StackExchange.prepareEditor(
                          heartbeatType: 'answer',
                          autoActivateHeartbeat: false,
                          convertImagesToLinks: false,
                          noModals: true,
                          showLowRepImageUploadWarning: true,
                          reputationToPostImages: null,
                          bindNavPrevention: true,
                          postfix: "",
                          imageUploader:
                          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                          allowUrls: true
                          ,
                          onDemand: true,
                          discardSelector: ".discard-answer"
                          ,immediatelyShowMarkdownHelp:true
                          );



                          );














                          draft saved

                          draft discarded
















                          StackExchange.ready(
                          function ()
                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f193467%2fduck-duck-gone%23new-answer', 'question_page');

                          );

                          Post as a guest















                          Required, but never shown


























                          18 Answers
                          18






                          active

                          oldest

                          votes








                          18 Answers
                          18






                          active

                          oldest

                          votes









                          active

                          oldest

                          votes






                          active

                          oldest

                          votes









                          3

















                          $begingroup$


                          Stax, 115 111 bytes



                          τ*^&k─Zè0µ9┬$█◘çl╟☼:Drσ59ò╠▄┴╢Q♂╔¡ô╜Oa╣▀yèA÷╨%^♀█Ö+╡◄ì=∙%╧o▌Θ<▲Çα¿╗√;1°┼╤V◘ú┐♥▒ÇM☼b╩░o]YaL4░ƒ%(Æ♫Q0æÆä⌂¡╘○Eâó╪¡


                          Run and debug it



                          All the verses as test cases






                          share|improve this answer












                          $endgroup$









                          • 1




                            $begingroup$
                            When you run it with "One little duck", it responds "little ducknd little duckll of the little ducks came back." in the last line.
                            $endgroup$
                            – Dorian
                            Oct 2 at 10:25






                          • 1




                            $begingroup$
                            The bug has been fixed at no cost in size. It was actually about a 2-byte cost, and and offsetting 2-byte savings elsewhere, although bytes are kind of hard to measure here, since the changes aren't exactly byte aligned inside compressed string literals, or even in the final program.
                            $endgroup$
                            – recursive
                            Oct 2 at 16:26















                          3

















                          $begingroup$


                          Stax, 115 111 bytes



                          τ*^&k─Zè0µ9┬$█◘çl╟☼:Drσ59ò╠▄┴╢Q♂╔¡ô╜Oa╣▀yèA÷╨%^♀█Ö+╡◄ì=∙%╧o▌Θ<▲Çα¿╗√;1°┼╤V◘ú┐♥▒ÇM☼b╩░o]YaL4░ƒ%(Æ♫Q0æÆä⌂¡╘○Eâó╪¡


                          Run and debug it



                          All the verses as test cases






                          share|improve this answer












                          $endgroup$









                          • 1




                            $begingroup$
                            When you run it with "One little duck", it responds "little ducknd little duckll of the little ducks came back." in the last line.
                            $endgroup$
                            – Dorian
                            Oct 2 at 10:25






                          • 1




                            $begingroup$
                            The bug has been fixed at no cost in size. It was actually about a 2-byte cost, and and offsetting 2-byte savings elsewhere, although bytes are kind of hard to measure here, since the changes aren't exactly byte aligned inside compressed string literals, or even in the final program.
                            $endgroup$
                            – recursive
                            Oct 2 at 16:26













                          3















                          3











                          3







                          $begingroup$


                          Stax, 115 111 bytes



                          τ*^&k─Zè0µ9┬$█◘çl╟☼:Drσ59ò╠▄┴╢Q♂╔¡ô╜Oa╣▀yèA÷╨%^♀█Ö+╡◄ì=∙%╧o▌Θ<▲Çα¿╗√;1°┼╤V◘ú┐♥▒ÇM☼b╩░o]YaL4░ƒ%(Æ♫Q0æÆä⌂¡╘○Eâó╪¡


                          Run and debug it



                          All the verses as test cases






                          share|improve this answer












                          $endgroup$




                          Stax, 115 111 bytes



                          τ*^&k─Zè0µ9┬$█◘çl╟☼:Drσ59ò╠▄┴╢Q♂╔¡ô╜Oa╣▀yèA÷╨%^♀█Ö+╡◄ì=∙%╧o▌Θ<▲Çα¿╗√;1°┼╤V◘ú┐♥▒ÇM☼b╩░o]YaL4░ƒ%(Æ♫Q0æÆä⌂¡╘○Eâó╪¡


                          Run and debug it



                          All the verses as test cases







                          share|improve this answer















                          share|improve this answer




                          share|improve this answer








                          edited Oct 2 at 16:24

























                          answered Sep 30 at 1:31









                          recursiverecursive

                          8,56615 silver badges32 bronze badges




                          8,56615 silver badges32 bronze badges










                          • 1




                            $begingroup$
                            When you run it with "One little duck", it responds "little ducknd little duckll of the little ducks came back." in the last line.
                            $endgroup$
                            – Dorian
                            Oct 2 at 10:25






                          • 1




                            $begingroup$
                            The bug has been fixed at no cost in size. It was actually about a 2-byte cost, and and offsetting 2-byte savings elsewhere, although bytes are kind of hard to measure here, since the changes aren't exactly byte aligned inside compressed string literals, or even in the final program.
                            $endgroup$
                            – recursive
                            Oct 2 at 16:26












                          • 1




                            $begingroup$
                            When you run it with "One little duck", it responds "little ducknd little duckll of the little ducks came back." in the last line.
                            $endgroup$
                            – Dorian
                            Oct 2 at 10:25






                          • 1




                            $begingroup$
                            The bug has been fixed at no cost in size. It was actually about a 2-byte cost, and and offsetting 2-byte savings elsewhere, although bytes are kind of hard to measure here, since the changes aren't exactly byte aligned inside compressed string literals, or even in the final program.
                            $endgroup$
                            – recursive
                            Oct 2 at 16:26







                          1




                          1




                          $begingroup$
                          When you run it with "One little duck", it responds "little ducknd little duckll of the little ducks came back." in the last line.
                          $endgroup$
                          – Dorian
                          Oct 2 at 10:25




                          $begingroup$
                          When you run it with "One little duck", it responds "little ducknd little duckll of the little ducks came back." in the last line.
                          $endgroup$
                          – Dorian
                          Oct 2 at 10:25




                          1




                          1




                          $begingroup$
                          The bug has been fixed at no cost in size. It was actually about a 2-byte cost, and and offsetting 2-byte savings elsewhere, although bytes are kind of hard to measure here, since the changes aren't exactly byte aligned inside compressed string literals, or even in the final program.
                          $endgroup$
                          – recursive
                          Oct 2 at 16:26




                          $begingroup$
                          The bug has been fixed at no cost in size. It was actually about a 2-byte cost, and and offsetting 2-byte savings elsewhere, although bytes are kind of hard to measure here, since the changes aren't exactly byte aligned inside compressed string literals, or even in the final program.
                          $endgroup$
                          – recursive
                          Oct 2 at 16:26













                          19

















                          $begingroup$

                          JavaScript (ES9), 227 bytes



                          This is similar to the Node version below but uses a formula based on parseInt() instead of Buffer() to identify the input verse.



                          This is ES2018 (aka ES9) because we're using a regular expression with the /s flag (dotAll).



                          s=>'Mother duck herself1and all23,,Three4two3,Five4four3,Four4three3,One01but none23,Two4one0'.split`,`[parseInt(s,30)&7].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          In this version, we parse the entire input verse as base 30 (0 to t) and perform a bitwise AND with 7. The parsing stops on the first invalid character, leading to:



                           verse | valid part | base 30 -> decimal | AND 7
                          -------+------------+--------------------+-------
                          0 | 'fi' | 468 | 4
                          1 | 'fo' | 474 | 2
                          2 | 'three' | 23973734 | 6
                          3 | 't' | 29 | 5
                          4 | 'one' | 22304 | 0
                          5 | 'mother' | 554838747 | 3




                          JavaScript (Node.js),  233 231  227 bytes



                          Saved 2 bytes thanks to @Shaggy



                          s=>'Three4two3,Four4three3,Mother duck herself1and all23,One01but none23,,,Two4one0,,Five4four3'.split`,`[Buffer(s)[2]%9].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          The third character of each input verse can be used as a unique identifier. By taking its ASCII code modulo 9, we get:



                           verse | 3rd char. | ASCII code | MOD 9
                          -------+-----------+------------+-------
                          0 | 'v' | 118 | 1
                          1 | 'u' | 117 | 0
                          2 | 'r' | 114 | 6
                          3 | 'o' | 111 | 3
                          4 | 'e' | 101 | 2
                          5 | 't' | 116 | 8


                          The output verses are encoded with the following templates:



                           verse | template
                          -------+---------------------------------
                          0 | 'Five4four3'
                          1 | 'Four4three3'
                          2 | 'Three4two3'
                          3 | 'Two4one0'
                          4 | 'One01but none23'
                          5 | 'Mother duck herself1and all23'


                          Where each digit is replaced with a string according to the following table:



                           digit | replaced with
                          -------+---------------------------------------------------
                          0 | ' little duck'
                          1 | / w.*n/s.exec(s)
                          2 | ' of the'
                          3 | ' little ducks'
                          4 | ' little ducks' + / w.*n/s.exec(s) + 'but only '


                          Where the regular expression / w.*n/s extracts this common part from the input:



                           went out one day,[LF]
                          over the hills and up away.[LF]
                          Mother Duck said, "Quack Quack Quack Quack",[LF]


                          We finally add the last 11 characters of the input, which is " came back.".






                          share|improve this answer












                          $endgroup$













                          • $begingroup$
                            231
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:00






                          • 1




                            $begingroup$
                            @Shaggy Nicely done. Thanks!
                            $endgroup$
                            – Arnauld
                            Sep 24 at 12:08






                          • 2




                            $begingroup$
                            Was just posting another comment to suggest exec when the page reloaded. Great minds ... !
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:14















                          19

















                          $begingroup$

                          JavaScript (ES9), 227 bytes



                          This is similar to the Node version below but uses a formula based on parseInt() instead of Buffer() to identify the input verse.



                          This is ES2018 (aka ES9) because we're using a regular expression with the /s flag (dotAll).



                          s=>'Mother duck herself1and all23,,Three4two3,Five4four3,Four4three3,One01but none23,Two4one0'.split`,`[parseInt(s,30)&7].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          In this version, we parse the entire input verse as base 30 (0 to t) and perform a bitwise AND with 7. The parsing stops on the first invalid character, leading to:



                           verse | valid part | base 30 -> decimal | AND 7
                          -------+------------+--------------------+-------
                          0 | 'fi' | 468 | 4
                          1 | 'fo' | 474 | 2
                          2 | 'three' | 23973734 | 6
                          3 | 't' | 29 | 5
                          4 | 'one' | 22304 | 0
                          5 | 'mother' | 554838747 | 3




                          JavaScript (Node.js),  233 231  227 bytes



                          Saved 2 bytes thanks to @Shaggy



                          s=>'Three4two3,Four4three3,Mother duck herself1and all23,One01but none23,,,Two4one0,,Five4four3'.split`,`[Buffer(s)[2]%9].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          The third character of each input verse can be used as a unique identifier. By taking its ASCII code modulo 9, we get:



                           verse | 3rd char. | ASCII code | MOD 9
                          -------+-----------+------------+-------
                          0 | 'v' | 118 | 1
                          1 | 'u' | 117 | 0
                          2 | 'r' | 114 | 6
                          3 | 'o' | 111 | 3
                          4 | 'e' | 101 | 2
                          5 | 't' | 116 | 8


                          The output verses are encoded with the following templates:



                           verse | template
                          -------+---------------------------------
                          0 | 'Five4four3'
                          1 | 'Four4three3'
                          2 | 'Three4two3'
                          3 | 'Two4one0'
                          4 | 'One01but none23'
                          5 | 'Mother duck herself1and all23'


                          Where each digit is replaced with a string according to the following table:



                           digit | replaced with
                          -------+---------------------------------------------------
                          0 | ' little duck'
                          1 | / w.*n/s.exec(s)
                          2 | ' of the'
                          3 | ' little ducks'
                          4 | ' little ducks' + / w.*n/s.exec(s) + 'but only '


                          Where the regular expression / w.*n/s extracts this common part from the input:



                           went out one day,[LF]
                          over the hills and up away.[LF]
                          Mother Duck said, "Quack Quack Quack Quack",[LF]


                          We finally add the last 11 characters of the input, which is " came back.".






                          share|improve this answer












                          $endgroup$













                          • $begingroup$
                            231
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:00






                          • 1




                            $begingroup$
                            @Shaggy Nicely done. Thanks!
                            $endgroup$
                            – Arnauld
                            Sep 24 at 12:08






                          • 2




                            $begingroup$
                            Was just posting another comment to suggest exec when the page reloaded. Great minds ... !
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:14













                          19















                          19











                          19







                          $begingroup$

                          JavaScript (ES9), 227 bytes



                          This is similar to the Node version below but uses a formula based on parseInt() instead of Buffer() to identify the input verse.



                          This is ES2018 (aka ES9) because we're using a regular expression with the /s flag (dotAll).



                          s=>'Mother duck herself1and all23,,Three4two3,Five4four3,Four4three3,One01but none23,Two4one0'.split`,`[parseInt(s,30)&7].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          In this version, we parse the entire input verse as base 30 (0 to t) and perform a bitwise AND with 7. The parsing stops on the first invalid character, leading to:



                           verse | valid part | base 30 -> decimal | AND 7
                          -------+------------+--------------------+-------
                          0 | 'fi' | 468 | 4
                          1 | 'fo' | 474 | 2
                          2 | 'three' | 23973734 | 6
                          3 | 't' | 29 | 5
                          4 | 'one' | 22304 | 0
                          5 | 'mother' | 554838747 | 3




                          JavaScript (Node.js),  233 231  227 bytes



                          Saved 2 bytes thanks to @Shaggy



                          s=>'Three4two3,Four4three3,Mother duck herself1and all23,One01but none23,,,Two4one0,,Five4four3'.split`,`[Buffer(s)[2]%9].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          The third character of each input verse can be used as a unique identifier. By taking its ASCII code modulo 9, we get:



                           verse | 3rd char. | ASCII code | MOD 9
                          -------+-----------+------------+-------
                          0 | 'v' | 118 | 1
                          1 | 'u' | 117 | 0
                          2 | 'r' | 114 | 6
                          3 | 'o' | 111 | 3
                          4 | 'e' | 101 | 2
                          5 | 't' | 116 | 8


                          The output verses are encoded with the following templates:



                           verse | template
                          -------+---------------------------------
                          0 | 'Five4four3'
                          1 | 'Four4three3'
                          2 | 'Three4two3'
                          3 | 'Two4one0'
                          4 | 'One01but none23'
                          5 | 'Mother duck herself1and all23'


                          Where each digit is replaced with a string according to the following table:



                           digit | replaced with
                          -------+---------------------------------------------------
                          0 | ' little duck'
                          1 | / w.*n/s.exec(s)
                          2 | ' of the'
                          3 | ' little ducks'
                          4 | ' little ducks' + / w.*n/s.exec(s) + 'but only '


                          Where the regular expression / w.*n/s extracts this common part from the input:



                           went out one day,[LF]
                          over the hills and up away.[LF]
                          Mother Duck said, "Quack Quack Quack Quack",[LF]


                          We finally add the last 11 characters of the input, which is " came back.".






                          share|improve this answer












                          $endgroup$



                          JavaScript (ES9), 227 bytes



                          This is similar to the Node version below but uses a formula based on parseInt() instead of Buffer() to identify the input verse.



                          This is ES2018 (aka ES9) because we're using a regular expression with the /s flag (dotAll).



                          s=>'Mother duck herself1and all23,,Three4two3,Five4four3,Four4three3,One01but none23,Two4one0'.split`,`[parseInt(s,30)&7].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          In this version, we parse the entire input verse as base 30 (0 to t) and perform a bitwise AND with 7. The parsing stops on the first invalid character, leading to:



                           verse | valid part | base 30 -> decimal | AND 7
                          -------+------------+--------------------+-------
                          0 | 'fi' | 468 | 4
                          1 | 'fo' | 474 | 2
                          2 | 'three' | 23973734 | 6
                          3 | 't' | 29 | 5
                          4 | 'one' | 22304 | 0
                          5 | 'mother' | 554838747 | 3




                          JavaScript (Node.js),  233 231  227 bytes



                          Saved 2 bytes thanks to @Shaggy



                          s=>'Three4two3,Four4three3,Mother duck herself1and all23,One01but none23,,,Two4one0,,Five4four3'.split`,`[Buffer(s)[2]%9].replace(/d/g,n=>[x=' little duck',y=/ w.*n/s.exec(s),' of the',x+='s',x+y+'but only '][n])+s.slice(-11)


                          Try it online!



                          How?



                          The third character of each input verse can be used as a unique identifier. By taking its ASCII code modulo 9, we get:



                           verse | 3rd char. | ASCII code | MOD 9
                          -------+-----------+------------+-------
                          0 | 'v' | 118 | 1
                          1 | 'u' | 117 | 0
                          2 | 'r' | 114 | 6
                          3 | 'o' | 111 | 3
                          4 | 'e' | 101 | 2
                          5 | 't' | 116 | 8


                          The output verses are encoded with the following templates:



                           verse | template
                          -------+---------------------------------
                          0 | 'Five4four3'
                          1 | 'Four4three3'
                          2 | 'Three4two3'
                          3 | 'Two4one0'
                          4 | 'One01but none23'
                          5 | 'Mother duck herself1and all23'


                          Where each digit is replaced with a string according to the following table:



                           digit | replaced with
                          -------+---------------------------------------------------
                          0 | ' little duck'
                          1 | / w.*n/s.exec(s)
                          2 | ' of the'
                          3 | ' little ducks'
                          4 | ' little ducks' + / w.*n/s.exec(s) + 'but only '


                          Where the regular expression / w.*n/s extracts this common part from the input:



                           went out one day,[LF]
                          over the hills and up away.[LF]
                          Mother Duck said, "Quack Quack Quack Quack",[LF]


                          We finally add the last 11 characters of the input, which is " came back.".







                          share|improve this answer















                          share|improve this answer




                          share|improve this answer








                          edited Sep 24 at 16:53

























                          answered Sep 24 at 11:10









                          ArnauldArnauld

                          104k7 gold badges115 silver badges400 bronze badges




                          104k7 gold badges115 silver badges400 bronze badges














                          • $begingroup$
                            231
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:00






                          • 1




                            $begingroup$
                            @Shaggy Nicely done. Thanks!
                            $endgroup$
                            – Arnauld
                            Sep 24 at 12:08






                          • 2




                            $begingroup$
                            Was just posting another comment to suggest exec when the page reloaded. Great minds ... !
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:14
















                          • $begingroup$
                            231
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:00






                          • 1




                            $begingroup$
                            @Shaggy Nicely done. Thanks!
                            $endgroup$
                            – Arnauld
                            Sep 24 at 12:08






                          • 2




                            $begingroup$
                            Was just posting another comment to suggest exec when the page reloaded. Great minds ... !
                            $endgroup$
                            – Shaggy
                            Sep 24 at 12:14















                          $begingroup$
                          231
                          $endgroup$
                          – Shaggy
                          Sep 24 at 12:00




                          $begingroup$
                          231
                          $endgroup$
                          – Shaggy
                          Sep 24 at 12:00




                          1




                          1




                          $begingroup$
                          @Shaggy Nicely done. Thanks!
                          $endgroup$
                          – Arnauld
                          Sep 24 at 12:08




                          $begingroup$
                          @Shaggy Nicely done. Thanks!
                          $endgroup$
                          – Arnauld
                          Sep 24 at 12:08




                          2




                          2




                          $begingroup$
                          Was just posting another comment to suggest exec when the page reloaded. Great minds ... !
                          $endgroup$
                          – Shaggy
                          Sep 24 at 12:14




                          $begingroup$
                          Was just posting another comment to suggest exec when the page reloaded. Great minds ... !
                          $endgroup$
                          – Shaggy
                          Sep 24 at 12:14











                          11

















                          $begingroup$


                          Python 3, 267 263 254 bytes



                          4 bytes saved thanks to @ovs



                          def f(s):
                          for a in zip(T[2:]+T,T):s=s.replace(*a)
                          return s
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!



                          Works by replacing the relevant parts by the respective parts of the next verse.



                          After the preinitialisation, T is ['8', '9', 'and all of the little ducks', 'One little duck', 'but none of the little ducks', 'Two little ducks', 'but only one little duck', 'Three little ducks', 'but only two little ducks', 'Four little ducks', 'but only three little ducks', 'Five little ducks', 'but only four little ducks', 'Mother duck herself'].



                          Alternative Python 2, 252 bytes



                          by @ovs



                          lambda s:reduce(lambda s,a:s.replace(*a),zip(T[2:]+T,T),s)
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!






                          share|improve this answer












                          $endgroup$













                          • $begingroup$
                            for a in zip(T,T[-2:]+T):s=s.replace(*a) for 264 bytes.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:17











                          • $begingroup$
                            Or lambda s:reduce(lambda s,a:s.replace(*a),zip(T,T[-2:]+T),s) for 262 bytes in Python 2.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:19










                          • $begingroup$
                            @ovs Thanks, I got it to 263 with reodering some things and using T[2:] instead of T[-2:]
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:18















                          11

















                          $begingroup$


                          Python 3, 267 263 254 bytes



                          4 bytes saved thanks to @ovs



                          def f(s):
                          for a in zip(T[2:]+T,T):s=s.replace(*a)
                          return s
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!



                          Works by replacing the relevant parts by the respective parts of the next verse.



                          After the preinitialisation, T is ['8', '9', 'and all of the little ducks', 'One little duck', 'but none of the little ducks', 'Two little ducks', 'but only one little duck', 'Three little ducks', 'but only two little ducks', 'Four little ducks', 'but only three little ducks', 'Five little ducks', 'but only four little ducks', 'Mother duck herself'].



                          Alternative Python 2, 252 bytes



                          by @ovs



                          lambda s:reduce(lambda s,a:s.replace(*a),zip(T[2:]+T,T),s)
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!






                          share|improve this answer












                          $endgroup$













                          • $begingroup$
                            for a in zip(T,T[-2:]+T):s=s.replace(*a) for 264 bytes.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:17











                          • $begingroup$
                            Or lambda s:reduce(lambda s,a:s.replace(*a),zip(T,T[-2:]+T),s) for 262 bytes in Python 2.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:19










                          • $begingroup$
                            @ovs Thanks, I got it to 263 with reodering some things and using T[2:] instead of T[-2:]
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:18













                          11















                          11











                          11







                          $begingroup$


                          Python 3, 267 263 254 bytes



                          4 bytes saved thanks to @ovs



                          def f(s):
                          for a in zip(T[2:]+T,T):s=s.replace(*a)
                          return s
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!



                          Works by replacing the relevant parts by the respective parts of the next verse.



                          After the preinitialisation, T is ['8', '9', 'and all of the little ducks', 'One little duck', 'but none of the little ducks', 'Two little ducks', 'but only one little duck', 'Three little ducks', 'but only two little ducks', 'Four little ducks', 'but only three little ducks', 'Five little ducks', 'but only four little ducks', 'Mother duck herself'].



                          Alternative Python 2, 252 bytes



                          by @ovs



                          lambda s:reduce(lambda s,a:s.replace(*a),zip(T[2:]+T,T),s)
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!






                          share|improve this answer












                          $endgroup$




                          Python 3, 267 263 254 bytes



                          4 bytes saved thanks to @ovs



                          def f(s):
                          for a in zip(T[2:]+T,T):s=s.replace(*a)
                          return s
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!



                          Works by replacing the relevant parts by the respective parts of the next verse.



                          After the preinitialisation, T is ['8', '9', 'and all of the little ducks', 'One little duck', 'but none of the little ducks', 'Two little ducks', 'but only one little duck', 'Three little ducks', 'but only two little ducks', 'Four little ducks', 'but only three little ducks', 'Five little ducks', 'but only four little ducks', 'Mother duck herself'].



                          Alternative Python 2, 252 bytes



                          by @ovs



                          lambda s:reduce(lambda s,a:s.replace(*a),zip(T[2:]+T,T),s)
                          T="8:9:and allHO1BnoneHT2No1T3Nt2F4Nt3FiveINf4MotherD herself"
                          for r in "H of theI,4ourI,3hreeI,2woI,1neL:,ILs:,L littleD,D duck,NBonly ,Bbut ".split(','):T=T.replace(r[0],r[1:])
                          T=T.split(':')


                          Try it online!







                          share|improve this answer















                          share|improve this answer




                          share|improve this answer








                          edited Oct 2 at 15:16

























                          answered Sep 24 at 10:40









                          Black Owl KaiBlack Owl Kai

                          9201 silver badge13 bronze badges




                          9201 silver badge13 bronze badges














                          • $begingroup$
                            for a in zip(T,T[-2:]+T):s=s.replace(*a) for 264 bytes.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:17











                          • $begingroup$
                            Or lambda s:reduce(lambda s,a:s.replace(*a),zip(T,T[-2:]+T),s) for 262 bytes in Python 2.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:19










                          • $begingroup$
                            @ovs Thanks, I got it to 263 with reodering some things and using T[2:] instead of T[-2:]
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:18
















                          • $begingroup$
                            for a in zip(T,T[-2:]+T):s=s.replace(*a) for 264 bytes.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:17











                          • $begingroup$
                            Or lambda s:reduce(lambda s,a:s.replace(*a),zip(T,T[-2:]+T),s) for 262 bytes in Python 2.
                            $endgroup$
                            – ovs
                            Sep 24 at 11:19










                          • $begingroup$
                            @ovs Thanks, I got it to 263 with reodering some things and using T[2:] instead of T[-2:]
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:18















                          $begingroup$
                          for a in zip(T,T[-2:]+T):s=s.replace(*a) for 264 bytes.
                          $endgroup$
                          – ovs
                          Sep 24 at 11:17





                          $begingroup$
                          for a in zip(T,T[-2:]+T):s=s.replace(*a) for 264 bytes.
                          $endgroup$
                          – ovs
                          Sep 24 at 11:17













                          $begingroup$
                          Or lambda s:reduce(lambda s,a:s.replace(*a),zip(T,T[-2:]+T),s) for 262 bytes in Python 2.
                          $endgroup$
                          – ovs
                          Sep 24 at 11:19




                          $begingroup$
                          Or lambda s:reduce(lambda s,a:s.replace(*a),zip(T,T[-2:]+T),s) for 262 bytes in Python 2.
                          $endgroup$
                          – ovs
                          Sep 24 at 11:19












                          $begingroup$
                          @ovs Thanks, I got it to 263 with reodering some things and using T[2:] instead of T[-2:]
                          $endgroup$
                          – Black Owl Kai
                          Sep 24 at 13:18




                          $begingroup$
                          @ovs Thanks, I got it to 263 with reodering some things and using T[2:] instead of T[-2:]
                          $endgroup$
                          – Black Owl Kai
                          Sep 24 at 13:18











                          9

















                          $begingroup$


                          QuadR, 257 242 bytes



                          -14 thanks to Black Owl Kai, -1 thanks to Kevin Cruijssen





                          ive
                          Four
                          hree
                          Two( little duck)s
                          One little( duck)
                          Mother( duck) herself
                          four
                          two( little duck)s
                          only on(e little duck)
                          but none
                          and all of the
                          our
                          Three
                          wo
                          One1
                          Mother1 herself
                          Five little1s
                          three
                          one1
                          none of th1s
                          and all
                          but only four


                          Try it online!






                          share|improve this answer












                          $endgroup$









                          • 1




                            $begingroup$
                            243 bytes
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:24






                          • 1




                            $begingroup$
                            242 bytes
                            $endgroup$
                            – Kevin Cruijssen
                            Sep 24 at 13:29















                          9

















                          $begingroup$


                          QuadR, 257 242 bytes



                          -14 thanks to Black Owl Kai, -1 thanks to Kevin Cruijssen





                          ive
                          Four
                          hree
                          Two( little duck)s
                          One little( duck)
                          Mother( duck) herself
                          four
                          two( little duck)s
                          only on(e little duck)
                          but none
                          and all of the
                          our
                          Three
                          wo
                          One1
                          Mother1 herself
                          Five little1s
                          three
                          one1
                          none of th1s
                          and all
                          but only four


                          Try it online!






                          share|improve this answer












                          $endgroup$









                          • 1




                            $begingroup$
                            243 bytes
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:24






                          • 1




                            $begingroup$
                            242 bytes
                            $endgroup$
                            – Kevin Cruijssen
                            Sep 24 at 13:29













                          9















                          9











                          9







                          $begingroup$


                          QuadR, 257 242 bytes



                          -14 thanks to Black Owl Kai, -1 thanks to Kevin Cruijssen





                          ive
                          Four
                          hree
                          Two( little duck)s
                          One little( duck)
                          Mother( duck) herself
                          four
                          two( little duck)s
                          only on(e little duck)
                          but none
                          and all of the
                          our
                          Three
                          wo
                          One1
                          Mother1 herself
                          Five little1s
                          three
                          one1
                          none of th1s
                          and all
                          but only four


                          Try it online!






                          share|improve this answer












                          $endgroup$




                          QuadR, 257 242 bytes



                          -14 thanks to Black Owl Kai, -1 thanks to Kevin Cruijssen





                          ive
                          Four
                          hree
                          Two( little duck)s
                          One little( duck)
                          Mother( duck) herself
                          four
                          two( little duck)s
                          only on(e little duck)
                          but none
                          and all of the
                          our
                          Three
                          wo
                          One1
                          Mother1 herself
                          Five little1s
                          three
                          one1
                          none of th1s
                          and all
                          but only four


                          Try it online!







                          share|improve this answer















                          share|improve this answer




                          share|improve this answer








                          edited Sep 24 at 15:42

























                          answered Sep 24 at 13:03









                          AdámAdám

                          39.4k2 gold badges89 silver badges230 bronze badges




                          39.4k2 gold badges89 silver badges230 bronze badges










                          • 1




                            $begingroup$
                            243 bytes
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:24






                          • 1




                            $begingroup$
                            242 bytes
                            $endgroup$
                            – Kevin Cruijssen
                            Sep 24 at 13:29












                          • 1




                            $begingroup$
                            243 bytes
                            $endgroup$
                            – Black Owl Kai
                            Sep 24 at 13:24






                          • 1




                            $begingroup$
                            242 bytes
                            $endgroup$
                            – Kevin Cruijssen
                            Sep 24 at 13:29







                          1




                          1




                          $begingroup$
                          243 bytes
                          $endgroup$
                          – Black Owl Kai
                          Sep 24 at 13:24




                          $begingroup$
                          243 bytes
                          $endgroup$
                          – Black Owl Kai
                          Sep 24 at 13:24




                          1




                          1




                          $begingroup$
                          242 bytes
                          $endgroup$
                          – Kevin Cruijssen
                          Sep 24 at 13:29




                          $begingroup$
                          242 bytes
                          $endgroup$
                          – Kevin Cruijssen
                          Sep 24 at 13:29











                          7

















                          $begingroup$

                          Java 10, 347 bytes





                          s->String L=" little duck",M="Mother duck herself";int i=9;for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))s=s.replace(t,++i+"");for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))s=s.replace(i--+"",t);return s;


                          Try it online.



                          Explanation:



                          We first replace all parts one by one with integers in the range $[10,21]$, and then these integers back to their replacements. The reason this is done in two steps, is because we would otherwise replace replacements.



                          s-> // Method with String as both parameter and return-type
                          String L=" little duck",M="Mother duck herself";
                          // Two temp strings to save bytes
                          int i=9; // Temp replacement integer, starting at 9
                          for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))
                          // Loop over the parts to replace:
                          s=s.replace(t, // Replace the part,
                          ++i+""); // with the integer pre-incremented by 1
                          for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))
                          // Then loop over the parts to replace with in reverse:
                          s=s.replace(i--+"", // Replace the (post-decrementing) integer,
                          t); // with the replacement-part
                          return s; // And then return the modified String as result





                          share|improve this answer










                          $endgroup$


















                            7

















                            $begingroup$

                            Java 10, 347 bytes





                            s->String L=" little duck",M="Mother duck herself";int i=9;for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))s=s.replace(t,++i+"");for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))s=s.replace(i--+"",t);return s;


                            Try it online.



                            Explanation:



                            We first replace all parts one by one with integers in the range $[10,21]$, and then these integers back to their replacements. The reason this is done in two steps, is because we would otherwise replace replacements.



                            s-> // Method with String as both parameter and return-type
                            String L=" little duck",M="Mother duck herself";
                            // Two temp strings to save bytes
                            int i=9; // Temp replacement integer, starting at 9
                            for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))
                            // Loop over the parts to replace:
                            s=s.replace(t, // Replace the part,
                            ++i+""); // with the integer pre-incremented by 1
                            for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))
                            // Then loop over the parts to replace with in reverse:
                            s=s.replace(i--+"", // Replace the (post-decrementing) integer,
                            t); // with the replacement-part
                            return s; // And then return the modified String as result





                            share|improve this answer










                            $endgroup$
















                              7















                              7











                              7







                              $begingroup$

                              Java 10, 347 bytes





                              s->String L=" little duck",M="Mother duck herself";int i=9;for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))s=s.replace(t,++i+"");for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))s=s.replace(i--+"",t);return s;


                              Try it online.



                              Explanation:



                              We first replace all parts one by one with integers in the range $[10,21]$, and then these integers back to their replacements. The reason this is done in two steps, is because we would otherwise replace replacements.



                              s-> // Method with String as both parameter and return-type
                              String L=" little duck",M="Mother duck herself";
                              // Two temp strings to save bytes
                              int i=9; // Temp replacement integer, starting at 9
                              for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))
                              // Loop over the parts to replace:
                              s=s.replace(t, // Replace the part,
                              ++i+""); // with the integer pre-incremented by 1
                              for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))
                              // Then loop over the parts to replace with in reverse:
                              s=s.replace(i--+"", // Replace the (post-decrementing) integer,
                              t); // with the replacement-part
                              return s; // And then return the modified String as result





                              share|improve this answer










                              $endgroup$



                              Java 10, 347 bytes





                              s->String L=" little duck",M="Mother duck herself";int i=9;for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))s=s.replace(t,++i+"");for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))s=s.replace(i--+"",t);return s;


                              Try it online.



                              Explanation:



                              We first replace all parts one by one with integers in the range $[10,21]$, and then these integers back to their replacements. The reason this is done in two steps, is because we would otherwise replace replacements.



                              s-> // Method with String as both parameter and return-type
                              String L=" little duck",M="Mother duck herself";
                              // Two temp strings to save bytes
                              int i=9; // Temp replacement integer, starting at 9
                              for(var t:("ive;Four;hree;Two"+L+"s;One"+L+";four;two"+L+"s;only one"+L+";but none;and all of the;"+M).split(";"))
                              // Loop over the parts to replace:
                              s=s.replace(t, // Replace the part,
                              ++i+""); // with the integer pre-incremented by 1
                              for(var t:("Five"+L+"s;but only four;and all;none of the"+L+"s;one"+L+";three;"+M+";One"+L+";wo;Three;our").split(";"))
                              // Then loop over the parts to replace with in reverse:
                              s=s.replace(i--+"", // Replace the (post-decrementing) integer,
                              t); // with the replacement-part
                              return s; // And then return the modified String as result






                              share|improve this answer













                              share|improve this answer




                              share|improve this answer










                              answered Sep 25 at 9:24









                              Kevin CruijssenKevin Cruijssen

                              62.7k7 gold badges89 silver badges257 bronze badges




                              62.7k7 gold badges89 silver badges257 bronze badges
























                                  7

















                                  $begingroup$

                                  T-SQL, 407 390 388 382 bytes



                                  DECLARE @ CHAR(999)=REPLACE(REPLACE('SELECT CASE LEFT(v,2)WHEN''Fi74,''Four''),122,4,''three'')WHEN''Fo74,''Three''),123,5,''two'')WHEN''Th75,''Two''),121,16,''on#'')WHEN''Tw716,''On#''),115,20,''none of th#s'')WHEN''On715,''Mother duck herself''),115,8,''and all'')WHEN''Mo719,''Fiv#s''),113,14,''but only four'')END FROM i',7,'''THEN STUFF(STUFF(v,1,'),'#','e little duck')EXEC(@)


                                  Input is via a pre-existing table $i$ with VARCHAR(MAX) field $v$, per our IO rules.



                                  After a couple of byte-saving REPLACEs, executes the following as dynamic SQL:



                                  SELECT CASE LEFT(v,2)
                                  WHEN'Fi'THEN STUFF(STUFF(v,1,4,'Four'),122,4,'three')
                                  WHEN'Fo'THEN STUFF(STUFF(v,1,4,'Three'),123,5,'two')
                                  WHEN'Th'THEN STUFF(STUFF(v,1,5,'Two'),121,16,'one little duck')
                                  WHEN'Tw'THEN STUFF(STUFF(v,1,16,'One little duck'),115,20,'none of the little ducks')
                                  WHEN'On'THEN STUFF(STUFF(v,1,15,'Mother duck herself'),115,8,'and all')
                                  WHEN'Mo'THEN STUFF(STUFF(v,1,19,'Five little ducks'),113,14,'but only four')END
                                  FROM i


                                  Uses a CASE statement and STUFF commands to insert/overwrite characters at the listed positions.



                                  EDITS:



                                  1. Replace original (below) with an entirely different strategy

                                  2. Saved two bytes by switching to LEFT instead of SUBSTRING and eliminating a space

                                  3. Saved 6 bytes by changing variable to CHAR and moving an extra letter into the second REPLACE (thanks, @CDC!)

                                  Here's my first version, using a different method (post-replacement, formatted):



                                  DECLARE @ VARCHAR(MAX)
                                  SELECT @=v FROM i
                                  SELECT @=REPLACE(@,PARSENAME(value,2),PARSENAME(value,1))
                                  FROM string_split('e.but none.and all
                                  -e.One little duck.Mother duck herself
                                  -o.only one little duck.none of the little ducks
                                  -o.Two little ducks.One little duck
                                  -r.two little ducks.one little duck
                                  -r.Three.Two
                                  -u.three.two
                                  -u.Four.Three
                                  -v.four.three
                                  -v.Five.Four
                                  -t.and all of the.but only four
                                  -t.Mother duck herself.Five little ducks','-')
                                  WHERE LEFT(value,1)=SUBSTRING(@,3,1)
                                  PRINT @


                                  STRING_SPLIT and PARSENAME are used to break a string into rows and columns via - and . separators.



                                  The first column is a key character that is matched against the 3rd letter of the input verse (thanks for the idea, @Night2). The second and third are the replacements being performed for that verse.






                                  share|improve this answer












                                  $endgroup$













                                  • $begingroup$
                                    First solution, if you use "CHAR(700)" instead of "VARCHAR(MAX)" you can save 3 bytes. Also in your " little duck", you can instead do "e little duck" and remove the e before # on each replacement to get another 3.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:26










                                  • $begingroup$
                                    BTW, really fun solution. I used formatmessage to get very close to you, but not quite.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:28










                                  • $begingroup$
                                    Good suggestions, @CDC, thanks!
                                    $endgroup$
                                    – BradC
                                    Sep 27 at 19:49















                                  7

















                                  $begingroup$

                                  T-SQL, 407 390 388 382 bytes



                                  DECLARE @ CHAR(999)=REPLACE(REPLACE('SELECT CASE LEFT(v,2)WHEN''Fi74,''Four''),122,4,''three'')WHEN''Fo74,''Three''),123,5,''two'')WHEN''Th75,''Two''),121,16,''on#'')WHEN''Tw716,''On#''),115,20,''none of th#s'')WHEN''On715,''Mother duck herself''),115,8,''and all'')WHEN''Mo719,''Fiv#s''),113,14,''but only four'')END FROM i',7,'''THEN STUFF(STUFF(v,1,'),'#','e little duck')EXEC(@)


                                  Input is via a pre-existing table $i$ with VARCHAR(MAX) field $v$, per our IO rules.



                                  After a couple of byte-saving REPLACEs, executes the following as dynamic SQL:



                                  SELECT CASE LEFT(v,2)
                                  WHEN'Fi'THEN STUFF(STUFF(v,1,4,'Four'),122,4,'three')
                                  WHEN'Fo'THEN STUFF(STUFF(v,1,4,'Three'),123,5,'two')
                                  WHEN'Th'THEN STUFF(STUFF(v,1,5,'Two'),121,16,'one little duck')
                                  WHEN'Tw'THEN STUFF(STUFF(v,1,16,'One little duck'),115,20,'none of the little ducks')
                                  WHEN'On'THEN STUFF(STUFF(v,1,15,'Mother duck herself'),115,8,'and all')
                                  WHEN'Mo'THEN STUFF(STUFF(v,1,19,'Five little ducks'),113,14,'but only four')END
                                  FROM i


                                  Uses a CASE statement and STUFF commands to insert/overwrite characters at the listed positions.



                                  EDITS:



                                  1. Replace original (below) with an entirely different strategy

                                  2. Saved two bytes by switching to LEFT instead of SUBSTRING and eliminating a space

                                  3. Saved 6 bytes by changing variable to CHAR and moving an extra letter into the second REPLACE (thanks, @CDC!)

                                  Here's my first version, using a different method (post-replacement, formatted):



                                  DECLARE @ VARCHAR(MAX)
                                  SELECT @=v FROM i
                                  SELECT @=REPLACE(@,PARSENAME(value,2),PARSENAME(value,1))
                                  FROM string_split('e.but none.and all
                                  -e.One little duck.Mother duck herself
                                  -o.only one little duck.none of the little ducks
                                  -o.Two little ducks.One little duck
                                  -r.two little ducks.one little duck
                                  -r.Three.Two
                                  -u.three.two
                                  -u.Four.Three
                                  -v.four.three
                                  -v.Five.Four
                                  -t.and all of the.but only four
                                  -t.Mother duck herself.Five little ducks','-')
                                  WHERE LEFT(value,1)=SUBSTRING(@,3,1)
                                  PRINT @


                                  STRING_SPLIT and PARSENAME are used to break a string into rows and columns via - and . separators.



                                  The first column is a key character that is matched against the 3rd letter of the input verse (thanks for the idea, @Night2). The second and third are the replacements being performed for that verse.






                                  share|improve this answer












                                  $endgroup$













                                  • $begingroup$
                                    First solution, if you use "CHAR(700)" instead of "VARCHAR(MAX)" you can save 3 bytes. Also in your " little duck", you can instead do "e little duck" and remove the e before # on each replacement to get another 3.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:26










                                  • $begingroup$
                                    BTW, really fun solution. I used formatmessage to get very close to you, but not quite.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:28










                                  • $begingroup$
                                    Good suggestions, @CDC, thanks!
                                    $endgroup$
                                    – BradC
                                    Sep 27 at 19:49













                                  7















                                  7











                                  7







                                  $begingroup$

                                  T-SQL, 407 390 388 382 bytes



                                  DECLARE @ CHAR(999)=REPLACE(REPLACE('SELECT CASE LEFT(v,2)WHEN''Fi74,''Four''),122,4,''three'')WHEN''Fo74,''Three''),123,5,''two'')WHEN''Th75,''Two''),121,16,''on#'')WHEN''Tw716,''On#''),115,20,''none of th#s'')WHEN''On715,''Mother duck herself''),115,8,''and all'')WHEN''Mo719,''Fiv#s''),113,14,''but only four'')END FROM i',7,'''THEN STUFF(STUFF(v,1,'),'#','e little duck')EXEC(@)


                                  Input is via a pre-existing table $i$ with VARCHAR(MAX) field $v$, per our IO rules.



                                  After a couple of byte-saving REPLACEs, executes the following as dynamic SQL:



                                  SELECT CASE LEFT(v,2)
                                  WHEN'Fi'THEN STUFF(STUFF(v,1,4,'Four'),122,4,'three')
                                  WHEN'Fo'THEN STUFF(STUFF(v,1,4,'Three'),123,5,'two')
                                  WHEN'Th'THEN STUFF(STUFF(v,1,5,'Two'),121,16,'one little duck')
                                  WHEN'Tw'THEN STUFF(STUFF(v,1,16,'One little duck'),115,20,'none of the little ducks')
                                  WHEN'On'THEN STUFF(STUFF(v,1,15,'Mother duck herself'),115,8,'and all')
                                  WHEN'Mo'THEN STUFF(STUFF(v,1,19,'Five little ducks'),113,14,'but only four')END
                                  FROM i


                                  Uses a CASE statement and STUFF commands to insert/overwrite characters at the listed positions.



                                  EDITS:



                                  1. Replace original (below) with an entirely different strategy

                                  2. Saved two bytes by switching to LEFT instead of SUBSTRING and eliminating a space

                                  3. Saved 6 bytes by changing variable to CHAR and moving an extra letter into the second REPLACE (thanks, @CDC!)

                                  Here's my first version, using a different method (post-replacement, formatted):



                                  DECLARE @ VARCHAR(MAX)
                                  SELECT @=v FROM i
                                  SELECT @=REPLACE(@,PARSENAME(value,2),PARSENAME(value,1))
                                  FROM string_split('e.but none.and all
                                  -e.One little duck.Mother duck herself
                                  -o.only one little duck.none of the little ducks
                                  -o.Two little ducks.One little duck
                                  -r.two little ducks.one little duck
                                  -r.Three.Two
                                  -u.three.two
                                  -u.Four.Three
                                  -v.four.three
                                  -v.Five.Four
                                  -t.and all of the.but only four
                                  -t.Mother duck herself.Five little ducks','-')
                                  WHERE LEFT(value,1)=SUBSTRING(@,3,1)
                                  PRINT @


                                  STRING_SPLIT and PARSENAME are used to break a string into rows and columns via - and . separators.



                                  The first column is a key character that is matched against the 3rd letter of the input verse (thanks for the idea, @Night2). The second and third are the replacements being performed for that verse.






                                  share|improve this answer












                                  $endgroup$



                                  T-SQL, 407 390 388 382 bytes



                                  DECLARE @ CHAR(999)=REPLACE(REPLACE('SELECT CASE LEFT(v,2)WHEN''Fi74,''Four''),122,4,''three'')WHEN''Fo74,''Three''),123,5,''two'')WHEN''Th75,''Two''),121,16,''on#'')WHEN''Tw716,''On#''),115,20,''none of th#s'')WHEN''On715,''Mother duck herself''),115,8,''and all'')WHEN''Mo719,''Fiv#s''),113,14,''but only four'')END FROM i',7,'''THEN STUFF(STUFF(v,1,'),'#','e little duck')EXEC(@)


                                  Input is via a pre-existing table $i$ with VARCHAR(MAX) field $v$, per our IO rules.



                                  After a couple of byte-saving REPLACEs, executes the following as dynamic SQL:



                                  SELECT CASE LEFT(v,2)
                                  WHEN'Fi'THEN STUFF(STUFF(v,1,4,'Four'),122,4,'three')
                                  WHEN'Fo'THEN STUFF(STUFF(v,1,4,'Three'),123,5,'two')
                                  WHEN'Th'THEN STUFF(STUFF(v,1,5,'Two'),121,16,'one little duck')
                                  WHEN'Tw'THEN STUFF(STUFF(v,1,16,'One little duck'),115,20,'none of the little ducks')
                                  WHEN'On'THEN STUFF(STUFF(v,1,15,'Mother duck herself'),115,8,'and all')
                                  WHEN'Mo'THEN STUFF(STUFF(v,1,19,'Five little ducks'),113,14,'but only four')END
                                  FROM i


                                  Uses a CASE statement and STUFF commands to insert/overwrite characters at the listed positions.



                                  EDITS:



                                  1. Replace original (below) with an entirely different strategy

                                  2. Saved two bytes by switching to LEFT instead of SUBSTRING and eliminating a space

                                  3. Saved 6 bytes by changing variable to CHAR and moving an extra letter into the second REPLACE (thanks, @CDC!)

                                  Here's my first version, using a different method (post-replacement, formatted):



                                  DECLARE @ VARCHAR(MAX)
                                  SELECT @=v FROM i
                                  SELECT @=REPLACE(@,PARSENAME(value,2),PARSENAME(value,1))
                                  FROM string_split('e.but none.and all
                                  -e.One little duck.Mother duck herself
                                  -o.only one little duck.none of the little ducks
                                  -o.Two little ducks.One little duck
                                  -r.two little ducks.one little duck
                                  -r.Three.Two
                                  -u.three.two
                                  -u.Four.Three
                                  -v.four.three
                                  -v.Five.Four
                                  -t.and all of the.but only four
                                  -t.Mother duck herself.Five little ducks','-')
                                  WHERE LEFT(value,1)=SUBSTRING(@,3,1)
                                  PRINT @


                                  STRING_SPLIT and PARSENAME are used to break a string into rows and columns via - and . separators.



                                  The first column is a key character that is matched against the 3rd letter of the input verse (thanks for the idea, @Night2). The second and third are the replacements being performed for that verse.







                                  share|improve this answer















                                  share|improve this answer




                                  share|improve this answer








                                  edited Sep 27 at 19:48

























                                  answered Sep 24 at 17:21









                                  BradCBradC

                                  6,0191 gold badge9 silver badges31 bronze badges




                                  6,0191 gold badge9 silver badges31 bronze badges














                                  • $begingroup$
                                    First solution, if you use "CHAR(700)" instead of "VARCHAR(MAX)" you can save 3 bytes. Also in your " little duck", you can instead do "e little duck" and remove the e before # on each replacement to get another 3.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:26










                                  • $begingroup$
                                    BTW, really fun solution. I used formatmessage to get very close to you, but not quite.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:28










                                  • $begingroup$
                                    Good suggestions, @CDC, thanks!
                                    $endgroup$
                                    – BradC
                                    Sep 27 at 19:49
















                                  • $begingroup$
                                    First solution, if you use "CHAR(700)" instead of "VARCHAR(MAX)" you can save 3 bytes. Also in your " little duck", you can instead do "e little duck" and remove the e before # on each replacement to get another 3.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:26










                                  • $begingroup$
                                    BTW, really fun solution. I used formatmessage to get very close to you, but not quite.
                                    $endgroup$
                                    – CDC
                                    Sep 27 at 19:28










                                  • $begingroup$
                                    Good suggestions, @CDC, thanks!
                                    $endgroup$
                                    – BradC
                                    Sep 27 at 19:49















                                  $begingroup$
                                  First solution, if you use "CHAR(700)" instead of "VARCHAR(MAX)" you can save 3 bytes. Also in your " little duck", you can instead do "e little duck" and remove the e before # on each replacement to get another 3.
                                  $endgroup$
                                  – CDC
                                  Sep 27 at 19:26




                                  $begingroup$
                                  First solution, if you use "CHAR(700)" instead of "VARCHAR(MAX)" you can save 3 bytes. Also in your " little duck", you can instead do "e little duck" and remove the e before # on each replacement to get another 3.
                                  $endgroup$
                                  – CDC
                                  Sep 27 at 19:26












                                  $begingroup$
                                  BTW, really fun solution. I used formatmessage to get very close to you, but not quite.
                                  $endgroup$
                                  – CDC
                                  Sep 27 at 19:28




                                  $begingroup$
                                  BTW, really fun solution. I used formatmessage to get very close to you, but not quite.
                                  $endgroup$
                                  – CDC
                                  Sep 27 at 19:28












                                  $begingroup$
                                  Good suggestions, @CDC, thanks!
                                  $endgroup$
                                  – BradC
                                  Sep 27 at 19:49




                                  $begingroup$
                                  Good suggestions, @CDC, thanks!
                                  $endgroup$
                                  – BradC
                                  Sep 27 at 19:49











                                  6

















                                  $begingroup$


                                  Python 2, 1034 bytes



                                  This is my code! It employs a simple dictionary. After running this code, you can enter any verse and it will output the next verse.



                                  PS: I am new to this channel and this is my first post. I really liked this challenge so decided to give it a try. Please feel free to correct me.



                                  import sys
                                  i=sys.stdin.readlines()
                                  s="Mother":"""Five little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only four little ducks came back.""",
                                  "Five":"""Four little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only three little ducks came back.""",
                                  "Four":"""Three little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only two little ducks came back.""",
                                  "Three":"""Two little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only one little duck came back.""",
                                  "Two":"""One little duck went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but none of the little ducks came back.""",
                                  "One":"""Mother duck herself went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  and all of the little ducks came back."""
                                  print s[i[0].split(" ")[0]]





                                  share|improve this answer












                                  $endgroup$









                                  • 11




                                    $begingroup$
                                    Welcome to the site! Usually we would count the dictionary as part of the source. Part of the challenge would be to try and make this as small as possible. There are also a few ways you could shorten this. 1) Since you don't get any points for being readable you can use single character variable names (e.g. x or a) 2) Python is pretty permissive with whitespace so I would try removing some of your whitespace also. For example you don't need spaces around =. Lastly We have a page for golfing in python you can visit to up your game.
                                    $endgroup$
                                    – Wheat Wizard
                                    Sep 24 at 22:22










                                  • $begingroup$
                                    wow @SriotchilismO'Zaic! that's helpful..thank you! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 24 at 22:44







                                  • 1




                                    $begingroup$
                                    You can easily golf this by removing unnecessary whitespace and variables, avoiding importing sys by using e.g. raw_input(), shortening the key of the dictionary, etc. You should most definitely take out the repeated sections of the song and add them seperately
                                    $endgroup$
                                    – Jo King
                                    Sep 26 at 5:38










                                  • $begingroup$
                                    @JoKing as I mentioned this is my very first post and I didn't put much thought into this. Just wanted to give it a try, but I now get the idea. My next post is going to be much much better and shorter than this--all thanks to you guys..helping me out! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 26 at 17:34















                                  6

















                                  $begingroup$


                                  Python 2, 1034 bytes



                                  This is my code! It employs a simple dictionary. After running this code, you can enter any verse and it will output the next verse.



                                  PS: I am new to this channel and this is my first post. I really liked this challenge so decided to give it a try. Please feel free to correct me.



                                  import sys
                                  i=sys.stdin.readlines()
                                  s="Mother":"""Five little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only four little ducks came back.""",
                                  "Five":"""Four little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only three little ducks came back.""",
                                  "Four":"""Three little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only two little ducks came back.""",
                                  "Three":"""Two little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only one little duck came back.""",
                                  "Two":"""One little duck went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but none of the little ducks came back.""",
                                  "One":"""Mother duck herself went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  and all of the little ducks came back."""
                                  print s[i[0].split(" ")[0]]





                                  share|improve this answer












                                  $endgroup$









                                  • 11




                                    $begingroup$
                                    Welcome to the site! Usually we would count the dictionary as part of the source. Part of the challenge would be to try and make this as small as possible. There are also a few ways you could shorten this. 1) Since you don't get any points for being readable you can use single character variable names (e.g. x or a) 2) Python is pretty permissive with whitespace so I would try removing some of your whitespace also. For example you don't need spaces around =. Lastly We have a page for golfing in python you can visit to up your game.
                                    $endgroup$
                                    – Wheat Wizard
                                    Sep 24 at 22:22










                                  • $begingroup$
                                    wow @SriotchilismO'Zaic! that's helpful..thank you! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 24 at 22:44







                                  • 1




                                    $begingroup$
                                    You can easily golf this by removing unnecessary whitespace and variables, avoiding importing sys by using e.g. raw_input(), shortening the key of the dictionary, etc. You should most definitely take out the repeated sections of the song and add them seperately
                                    $endgroup$
                                    – Jo King
                                    Sep 26 at 5:38










                                  • $begingroup$
                                    @JoKing as I mentioned this is my very first post and I didn't put much thought into this. Just wanted to give it a try, but I now get the idea. My next post is going to be much much better and shorter than this--all thanks to you guys..helping me out! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 26 at 17:34













                                  6















                                  6











                                  6







                                  $begingroup$


                                  Python 2, 1034 bytes



                                  This is my code! It employs a simple dictionary. After running this code, you can enter any verse and it will output the next verse.



                                  PS: I am new to this channel and this is my first post. I really liked this challenge so decided to give it a try. Please feel free to correct me.



                                  import sys
                                  i=sys.stdin.readlines()
                                  s="Mother":"""Five little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only four little ducks came back.""",
                                  "Five":"""Four little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only three little ducks came back.""",
                                  "Four":"""Three little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only two little ducks came back.""",
                                  "Three":"""Two little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only one little duck came back.""",
                                  "Two":"""One little duck went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but none of the little ducks came back.""",
                                  "One":"""Mother duck herself went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  and all of the little ducks came back."""
                                  print s[i[0].split(" ")[0]]





                                  share|improve this answer












                                  $endgroup$




                                  Python 2, 1034 bytes



                                  This is my code! It employs a simple dictionary. After running this code, you can enter any verse and it will output the next verse.



                                  PS: I am new to this channel and this is my first post. I really liked this challenge so decided to give it a try. Please feel free to correct me.



                                  import sys
                                  i=sys.stdin.readlines()
                                  s="Mother":"""Five little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only four little ducks came back.""",
                                  "Five":"""Four little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only three little ducks came back.""",
                                  "Four":"""Three little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only two little ducks came back.""",
                                  "Three":"""Two little ducks went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but only one little duck came back.""",
                                  "Two":"""One little duck went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  but none of the little ducks came back.""",
                                  "One":"""Mother duck herself went out one day,
                                  over the hills and up away.
                                  Mother Duck said, "Quack Quack Quack Quack",
                                  and all of the little ducks came back."""
                                  print s[i[0].split(" ")[0]]






                                  share|improve this answer















                                  share|improve this answer




                                  share|improve this answer








                                  edited Sep 26 at 0:55









                                  Jo King

                                  36.1k4 gold badges78 silver badges151 bronze badges




                                  36.1k4 gold badges78 silver badges151 bronze badges










                                  answered Sep 24 at 22:09









                                  Prachiti Prakash PrabhuPrachiti Prakash Prabhu

                                  1613 bronze badges




                                  1613 bronze badges










                                  • 11




                                    $begingroup$
                                    Welcome to the site! Usually we would count the dictionary as part of the source. Part of the challenge would be to try and make this as small as possible. There are also a few ways you could shorten this. 1) Since you don't get any points for being readable you can use single character variable names (e.g. x or a) 2) Python is pretty permissive with whitespace so I would try removing some of your whitespace also. For example you don't need spaces around =. Lastly We have a page for golfing in python you can visit to up your game.
                                    $endgroup$
                                    – Wheat Wizard
                                    Sep 24 at 22:22










                                  • $begingroup$
                                    wow @SriotchilismO'Zaic! that's helpful..thank you! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 24 at 22:44







                                  • 1




                                    $begingroup$
                                    You can easily golf this by removing unnecessary whitespace and variables, avoiding importing sys by using e.g. raw_input(), shortening the key of the dictionary, etc. You should most definitely take out the repeated sections of the song and add them seperately
                                    $endgroup$
                                    – Jo King
                                    Sep 26 at 5:38










                                  • $begingroup$
                                    @JoKing as I mentioned this is my very first post and I didn't put much thought into this. Just wanted to give it a try, but I now get the idea. My next post is going to be much much better and shorter than this--all thanks to you guys..helping me out! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 26 at 17:34












                                  • 11




                                    $begingroup$
                                    Welcome to the site! Usually we would count the dictionary as part of the source. Part of the challenge would be to try and make this as small as possible. There are also a few ways you could shorten this. 1) Since you don't get any points for being readable you can use single character variable names (e.g. x or a) 2) Python is pretty permissive with whitespace so I would try removing some of your whitespace also. For example you don't need spaces around =. Lastly We have a page for golfing in python you can visit to up your game.
                                    $endgroup$
                                    – Wheat Wizard
                                    Sep 24 at 22:22










                                  • $begingroup$
                                    wow @SriotchilismO'Zaic! that's helpful..thank you! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 24 at 22:44







                                  • 1




                                    $begingroup$
                                    You can easily golf this by removing unnecessary whitespace and variables, avoiding importing sys by using e.g. raw_input(), shortening the key of the dictionary, etc. You should most definitely take out the repeated sections of the song and add them seperately
                                    $endgroup$
                                    – Jo King
                                    Sep 26 at 5:38










                                  • $begingroup$
                                    @JoKing as I mentioned this is my very first post and I didn't put much thought into this. Just wanted to give it a try, but I now get the idea. My next post is going to be much much better and shorter than this--all thanks to you guys..helping me out! :)
                                    $endgroup$
                                    – Prachiti Prakash Prabhu
                                    Sep 26 at 17:34







                                  11




                                  11




                                  $begingroup$
                                  Welcome to the site! Usually we would count the dictionary as part of the source. Part of the challenge would be to try and make this as small as possible. There are also a few ways you could shorten this. 1) Since you don't get any points for being readable you can use single character variable names (e.g. x or a) 2) Python is pretty permissive with whitespace so I would try removing some of your whitespace also. For example you don't need spaces around =. Lastly We have a page for golfing in python you can visit to up your game.
                                  $endgroup$
                                  – Wheat Wizard
                                  Sep 24 at 22:22




                                  $begingroup$
                                  Welcome to the site! Usually we would count the dictionary as part of the source. Part of the challenge would be to try and make this as small as possible. There are also a few ways you could shorten this. 1) Since you don't get any points for being readable you can use single character variable names (e.g. x or a) 2) Python is pretty permissive with whitespace so I would try removing some of your whitespace also. For example you don't need spaces around =. Lastly We have a page for golfing in python you can visit to up your game.
                                  $endgroup$
                                  – Wheat Wizard
                                  Sep 24 at 22:22












                                  $begingroup$
                                  wow @SriotchilismO'Zaic! that's helpful..thank you! :)
                                  $endgroup$
                                  – Prachiti Prakash Prabhu
                                  Sep 24 at 22:44





                                  $begingroup$
                                  wow @SriotchilismO'Zaic! that's helpful..thank you! :)
                                  $endgroup$
                                  – Prachiti Prakash Prabhu
                                  Sep 24 at 22:44





                                  1




                                  1




                                  $begingroup$
                                  You can easily golf this by removing unnecessary whitespace and variables, avoiding importing sys by using e.g. raw_input(), shortening the key of the dictionary, etc. You should most definitely take out the repeated sections of the song and add them seperately
                                  $endgroup$
                                  – Jo King
                                  Sep 26 at 5:38




                                  $begingroup$
                                  You can easily golf this by removing unnecessary whitespace and variables, avoiding importing sys by using e.g. raw_input(), shortening the key of the dictionary, etc. You should most definitely take out the repeated sections of the song and add them seperately
                                  $endgroup$
                                  – Jo King
                                  Sep 26 at 5:38












                                  $begingroup$
                                  @JoKing as I mentioned this is my very first post and I didn't put much thought into this. Just wanted to give it a try, but I now get the idea. My next post is going to be much much better and shorter than this--all thanks to you guys..helping me out! :)
                                  $endgroup$
                                  – Prachiti Prakash Prabhu
                                  Sep 26 at 17:34




                                  $begingroup$
                                  @JoKing as I mentioned this is my very first post and I didn't put much thought into this. Just wanted to give it a try, but I now get the idea. My next post is going to be much much better and shorter than this--all thanks to you guys..helping me out! :)
                                  $endgroup$
                                  – Prachiti Prakash Prabhu
                                  Sep 26 at 17:34











                                  6

















                                  $begingroup$


                                  PHP (7.4), 253 247 bytes



                                  -6 bytes by improving how the replacements array is built with more help from "Unpacking inside arrays".





                                  <?=strtr($argv[1],array_combine([0,1,...$a=[Five.$l=($o=" little duck").s,($b="but only ").four.$l,Four.$l,$b.three.$l,Three.$l,$b.two.$l,Two.$l,$b.one.$o,One.$o,"but none of the$l","Mother duck herself","and all of the$l"]],[...$a,$a[0],$a[1]]));


                                  Try it online!



                                  This creates an array of every possible replacement (12 used + 2 unused) in a key=>value format. Example: ['Mother duck herself' => 'Five little ducks', etc...] and then just replaces those using strtr.



                                  The only interesting thing is my first ever usage of "Unpacking inside arrays" which is a new feature in PHP 7.4.





                                  PHP, 264 bytes





                                  <?=str_replace(($a=[[Five.$l=($o=" little duck").s,($b="but only ").four.$l],[Four.$l,$b.three.$l],[Three.$l,$b.two.$l],[Two.$l,$b.one.$o],[One.$o,"but none of the$l"],["Mother duck herself","and all of the$l"]])[$i=strpos(vuroet,($v=$argv[1])[2])],$a[++$i%6],$v);


                                  Try it online!



                                  I have stored different words of each verse in an array. I find which verse the input is using third character of the input as it is unique (vuroet). Then I simply replace different words of that verse with different words of the next verse.






                                  share|improve this answer












                                  $endgroup$


















                                    6

















                                    $begingroup$


                                    PHP (7.4), 253 247 bytes



                                    -6 bytes by improving how the replacements array is built with more help from "Unpacking inside arrays".





                                    <?=strtr($argv[1],array_combine([0,1,...$a=[Five.$l=($o=" little duck").s,($b="but only ").four.$l,Four.$l,$b.three.$l,Three.$l,$b.two.$l,Two.$l,$b.one.$o,One.$o,"but none of the$l","Mother duck herself","and all of the$l"]],[...$a,$a[0],$a[1]]));


                                    Try it online!



                                    This creates an array of every possible replacement (12 used + 2 unused) in a key=>value format. Example: ['Mother duck herself' => 'Five little ducks', etc...] and then just replaces those using strtr.



                                    The only interesting thing is my first ever usage of "Unpacking inside arrays" which is a new feature in PHP 7.4.





                                    PHP, 264 bytes





                                    <?=str_replace(($a=[[Five.$l=($o=" little duck").s,($b="but only ").four.$l],[Four.$l,$b.three.$l],[Three.$l,$b.two.$l],[Two.$l,$b.one.$o],[One.$o,"but none of the$l"],["Mother duck herself","and all of the$l"]])[$i=strpos(vuroet,($v=$argv[1])[2])],$a[++$i%6],$v);


                                    Try it online!



                                    I have stored different words of each verse in an array. I find which verse the input is using third character of the input as it is unique (vuroet). Then I simply replace different words of that verse with different words of the next verse.






                                    share|improve this answer












                                    $endgroup$
















                                      6















                                      6











                                      6







                                      $begingroup$


                                      PHP (7.4), 253 247 bytes



                                      -6 bytes by improving how the replacements array is built with more help from "Unpacking inside arrays".





                                      <?=strtr($argv[1],array_combine([0,1,...$a=[Five.$l=($o=" little duck").s,($b="but only ").four.$l,Four.$l,$b.three.$l,Three.$l,$b.two.$l,Two.$l,$b.one.$o,One.$o,"but none of the$l","Mother duck herself","and all of the$l"]],[...$a,$a[0],$a[1]]));


                                      Try it online!



                                      This creates an array of every possible replacement (12 used + 2 unused) in a key=>value format. Example: ['Mother duck herself' => 'Five little ducks', etc...] and then just replaces those using strtr.



                                      The only interesting thing is my first ever usage of "Unpacking inside arrays" which is a new feature in PHP 7.4.





                                      PHP, 264 bytes





                                      <?=str_replace(($a=[[Five.$l=($o=" little duck").s,($b="but only ").four.$l],[Four.$l,$b.three.$l],[Three.$l,$b.two.$l],[Two.$l,$b.one.$o],[One.$o,"but none of the$l"],["Mother duck herself","and all of the$l"]])[$i=strpos(vuroet,($v=$argv[1])[2])],$a[++$i%6],$v);


                                      Try it online!



                                      I have stored different words of each verse in an array. I find which verse the input is using third character of the input as it is unique (vuroet). Then I simply replace different words of that verse with different words of the next verse.






                                      share|improve this answer












                                      $endgroup$




                                      PHP (7.4), 253 247 bytes



                                      -6 bytes by improving how the replacements array is built with more help from "Unpacking inside arrays".





                                      <?=strtr($argv[1],array_combine([0,1,...$a=[Five.$l=($o=" little duck").s,($b="but only ").four.$l,Four.$l,$b.three.$l,Three.$l,$b.two.$l,Two.$l,$b.one.$o,One.$o,"but none of the$l","Mother duck herself","and all of the$l"]],[...$a,$a[0],$a[1]]));


                                      Try it online!



                                      This creates an array of every possible replacement (12 used + 2 unused) in a key=>value format. Example: ['Mother duck herself' => 'Five little ducks', etc...] and then just replaces those using strtr.



                                      The only interesting thing is my first ever usage of "Unpacking inside arrays" which is a new feature in PHP 7.4.





                                      PHP, 264 bytes





                                      <?=str_replace(($a=[[Five.$l=($o=" little duck").s,($b="but only ").four.$l],[Four.$l,$b.three.$l],[Three.$l,$b.two.$l],[Two.$l,$b.one.$o],[One.$o,"but none of the$l"],["Mother duck herself","and all of the$l"]])[$i=strpos(vuroet,($v=$argv[1])[2])],$a[++$i%6],$v);


                                      Try it online!



                                      I have stored different words of each verse in an array. I find which verse the input is using third character of the input as it is unique (vuroet). Then I simply replace different words of that verse with different words of the next verse.







                                      share|improve this answer















                                      share|improve this answer




                                      share|improve this answer








                                      edited Sep 28 at 10:59

























                                      answered Sep 24 at 11:16









                                      Night2Night2

                                      5,3941 gold badge7 silver badges43 bronze badges




                                      5,3941 gold badge7 silver badges43 bronze badges
























                                          5

















                                          $begingroup$


                                          Clean, 352 bytes



                                          import StdEnv,Text
                                          $n=#"Five"+e+"four"+d,"Four"+e+"three"+d,"Three"+e+"two"+d,"Two"+e+"one"+a,"One"+a+b+"but none"+f,"Mother duck herself"+b+"and all"+f.[indexOfn.[2]"tvuroe"]+" came back."
                                          a=" little duck"
                                          b=" went out one day,nover the hills and up away.nMother Duck said, "Quack Quack Quack Quack",n"
                                          d=a+"s"
                                          e=d+b+"but only "
                                          f=" of the"+d


                                          Try it online!






                                          share|improve this answer










                                          $endgroup$


















                                            5

















                                            $begingroup$


                                            Clean, 352 bytes



                                            import StdEnv,Text
                                            $n=#"Five"+e+"four"+d,"Four"+e+"three"+d,"Three"+e+"two"+d,"Two"+e+"one"+a,"One"+a+b+"but none"+f,"Mother duck herself"+b+"and all"+f.[indexOfn.[2]"tvuroe"]+" came back."
                                            a=" little duck"
                                            b=" went out one day,nover the hills and up away.nMother Duck said, "Quack Quack Quack Quack",n"
                                            d=a+"s"
                                            e=d+b+"but only "
                                            f=" of the"+d


                                            Try it online!






                                            share|improve this answer










                                            $endgroup$
















                                              5















                                              5











                                              5







                                              $begingroup$


                                              Clean, 352 bytes



                                              import StdEnv,Text
                                              $n=#"Five"+e+"four"+d,"Four"+e+"three"+d,"Three"+e+"two"+d,"Two"+e+"one"+a,"One"+a+b+"but none"+f,"Mother duck herself"+b+"and all"+f.[indexOfn.[2]"tvuroe"]+" came back."
                                              a=" little duck"
                                              b=" went out one day,nover the hills and up away.nMother Duck said, "Quack Quack Quack Quack",n"
                                              d=a+"s"
                                              e=d+b+"but only "
                                              f=" of the"+d


                                              Try it online!






                                              share|improve this answer










                                              $endgroup$




                                              Clean, 352 bytes



                                              import StdEnv,Text
                                              $n=#"Five"+e+"four"+d,"Four"+e+"three"+d,"Three"+e+"two"+d,"Two"+e+"one"+a,"One"+a+b+"but none"+f,"Mother duck herself"+b+"and all"+f.[indexOfn.[2]"tvuroe"]+" came back."
                                              a=" little duck"
                                              b=" went out one day,nover the hills and up away.nMother Duck said, "Quack Quack Quack Quack",n"
                                              d=a+"s"
                                              e=d+b+"but only "
                                              f=" of the"+d


                                              Try it online!







                                              share|improve this answer













                                              share|improve this answer




                                              share|improve this answer










                                              answered Sep 24 at 23:48









                                              ΟurousΟurous

                                              7,9061 gold badge11 silver badges36 bronze badges




                                              7,9061 gold badge11 silver badges36 bronze badges
























                                                  5

















                                                  $begingroup$


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





                                                  x=>$@"l[g=x[2]*37%724%7]g-5:; little duckg-4: herself;s; went out one day,
                                                  (x=x.Split('n'))[1]
                                                  x[2]
                                                  g-5:and;but g-4:all;only;none (g>3?"of the":l[g+1].ToLower()) little ducg%3:ks;;k came back.";var l=" Four Three Two One Mother".Split();int g


                                                  Try it online!






                                                  share|improve this answer












                                                  $endgroup$


















                                                    5

















                                                    $begingroup$


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





                                                    x=>$@"l[g=x[2]*37%724%7]g-5:; little duckg-4: herself;s; went out one day,
                                                    (x=x.Split('n'))[1]
                                                    x[2]
                                                    g-5:and;but g-4:all;only;none (g>3?"of the":l[g+1].ToLower()) little ducg%3:ks;;k came back.";var l=" Four Three Two One Mother".Split();int g


                                                    Try it online!






                                                    share|improve this answer












                                                    $endgroup$
















                                                      5















                                                      5











                                                      5







                                                      $begingroup$


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





                                                      x=>$@"l[g=x[2]*37%724%7]g-5:; little duckg-4: herself;s; went out one day,
                                                      (x=x.Split('n'))[1]
                                                      x[2]
                                                      g-5:and;but g-4:all;only;none (g>3?"of the":l[g+1].ToLower()) little ducg%3:ks;;k came back.";var l=" Four Three Two One Mother".Split();int g


                                                      Try it online!






                                                      share|improve this answer












                                                      $endgroup$




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





                                                      x=>$@"l[g=x[2]*37%724%7]g-5:; little duckg-4: herself;s; went out one day,
                                                      (x=x.Split('n'))[1]
                                                      x[2]
                                                      g-5:and;but g-4:all;only;none (g>3?"of the":l[g+1].ToLower()) little ducg%3:ks;;k came back.";var l=" Four Three Two One Mother".Split();int g


                                                      Try it online!







                                                      share|improve this answer















                                                      share|improve this answer




                                                      share|improve this answer








                                                      edited Sep 28 at 18:41

























                                                      answered Sep 25 at 4:34









                                                      Embodiment of IgnoranceEmbodiment of Ignorance

                                                      6,5284 silver badges33 bronze badges




                                                      6,5284 silver badges33 bronze badges
























                                                          3

















                                                          $begingroup$


                                                          PowerShell, 356 343 340 336 bytes



                                                          param($p)$l,$M=' little duck','Mother duck herself'
                                                          ("ive!our;four!three;hree!wo;Four!Three;two!one;s c! c;Two!One;s w! w;only one!none of the;k c!ks c;One$l!$M;but none!and all;$M!Five$l`s;and all of the!but only four"-split';')[$(switch -r($p)^Fi0,1^Fo2,3^Th2,4,5^Tw6..9^O10,11^M12,13)]|%$p=$p-creplace($_-split'!')
                                                          $p


                                                          Try it online.



                                                          More readable version:



                                                          param($p)
                                                          $l, $M = ' little duck', 'Mother duck herself'
                                                          $replacements = @"
                                                          ive!our
                                                          four!three
                                                          hree!wo
                                                          Four!Three
                                                          two!one
                                                          s c! c
                                                          Two!One
                                                          s w! w
                                                          only one!none of the
                                                          k c!ks c
                                                          One$l!$M
                                                          but none!and all
                                                          $M!Five$l`s
                                                          and all of the!but only four
                                                          "@ -split 'n'
                                                          $i = switch -regex ($p) ^Fi 0, 1
                                                          ^Fo 2, 3
                                                          ^Th 2, 4, 5
                                                          ^Tw 6..9
                                                          ^O 10, 11
                                                          ^M 12, 13
                                                          $replacements[$i] | % $p = $p -creplace ( $_ -split '!' )
                                                          $p





                                                          share|improve this answer












                                                          $endgroup$


















                                                            3

















                                                            $begingroup$


                                                            PowerShell, 356 343 340 336 bytes



                                                            param($p)$l,$M=' little duck','Mother duck herself'
                                                            ("ive!our;four!three;hree!wo;Four!Three;two!one;s c! c;Two!One;s w! w;only one!none of the;k c!ks c;One$l!$M;but none!and all;$M!Five$l`s;and all of the!but only four"-split';')[$(switch -r($p)^Fi0,1^Fo2,3^Th2,4,5^Tw6..9^O10,11^M12,13)]|%$p=$p-creplace($_-split'!')
                                                            $p


                                                            Try it online.



                                                            More readable version:



                                                            param($p)
                                                            $l, $M = ' little duck', 'Mother duck herself'
                                                            $replacements = @"
                                                            ive!our
                                                            four!three
                                                            hree!wo
                                                            Four!Three
                                                            two!one
                                                            s c! c
                                                            Two!One
                                                            s w! w
                                                            only one!none of the
                                                            k c!ks c
                                                            One$l!$M
                                                            but none!and all
                                                            $M!Five$l`s
                                                            and all of the!but only four
                                                            "@ -split 'n'
                                                            $i = switch -regex ($p) ^Fi 0, 1
                                                            ^Fo 2, 3
                                                            ^Th 2, 4, 5
                                                            ^Tw 6..9
                                                            ^O 10, 11
                                                            ^M 12, 13
                                                            $replacements[$i] | % $p = $p -creplace ( $_ -split '!' )
                                                            $p





                                                            share|improve this answer












                                                            $endgroup$
















                                                              3















                                                              3











                                                              3







                                                              $begingroup$


                                                              PowerShell, 356 343 340 336 bytes



                                                              param($p)$l,$M=' little duck','Mother duck herself'
                                                              ("ive!our;four!three;hree!wo;Four!Three;two!one;s c! c;Two!One;s w! w;only one!none of the;k c!ks c;One$l!$M;but none!and all;$M!Five$l`s;and all of the!but only four"-split';')[$(switch -r($p)^Fi0,1^Fo2,3^Th2,4,5^Tw6..9^O10,11^M12,13)]|%$p=$p-creplace($_-split'!')
                                                              $p


                                                              Try it online.



                                                              More readable version:



                                                              param($p)
                                                              $l, $M = ' little duck', 'Mother duck herself'
                                                              $replacements = @"
                                                              ive!our
                                                              four!three
                                                              hree!wo
                                                              Four!Three
                                                              two!one
                                                              s c! c
                                                              Two!One
                                                              s w! w
                                                              only one!none of the
                                                              k c!ks c
                                                              One$l!$M
                                                              but none!and all
                                                              $M!Five$l`s
                                                              and all of the!but only four
                                                              "@ -split 'n'
                                                              $i = switch -regex ($p) ^Fi 0, 1
                                                              ^Fo 2, 3
                                                              ^Th 2, 4, 5
                                                              ^Tw 6..9
                                                              ^O 10, 11
                                                              ^M 12, 13
                                                              $replacements[$i] | % $p = $p -creplace ( $_ -split '!' )
                                                              $p





                                                              share|improve this answer












                                                              $endgroup$




                                                              PowerShell, 356 343 340 336 bytes



                                                              param($p)$l,$M=' little duck','Mother duck herself'
                                                              ("ive!our;four!three;hree!wo;Four!Three;two!one;s c! c;Two!One;s w! w;only one!none of the;k c!ks c;One$l!$M;but none!and all;$M!Five$l`s;and all of the!but only four"-split';')[$(switch -r($p)^Fi0,1^Fo2,3^Th2,4,5^Tw6..9^O10,11^M12,13)]|%$p=$p-creplace($_-split'!')
                                                              $p


                                                              Try it online.



                                                              More readable version:



                                                              param($p)
                                                              $l, $M = ' little duck', 'Mother duck herself'
                                                              $replacements = @"
                                                              ive!our
                                                              four!three
                                                              hree!wo
                                                              Four!Three
                                                              two!one
                                                              s c! c
                                                              Two!One
                                                              s w! w
                                                              only one!none of the
                                                              k c!ks c
                                                              One$l!$M
                                                              but none!and all
                                                              $M!Five$l`s
                                                              and all of the!but only four
                                                              "@ -split 'n'
                                                              $i = switch -regex ($p) ^Fi 0, 1
                                                              ^Fo 2, 3
                                                              ^Th 2, 4, 5
                                                              ^Tw 6..9
                                                              ^O 10, 11
                                                              ^M 12, 13
                                                              $replacements[$i] | % $p = $p -creplace ( $_ -split '!' )
                                                              $p






                                                              share|improve this answer















                                                              share|improve this answer




                                                              share|improve this answer








                                                              edited Sep 25 at 18:48

























                                                              answered Sep 25 at 16:49









                                                              Andrei OdegovAndrei Odegov

                                                              8993 silver badges7 bronze badges




                                                              8993 silver badges7 bronze badges
























                                                                  3

















                                                                  $begingroup$


                                                                  PowerShell, 265 263 255 251 246 bytes





                                                                  $d='Five1four2s,Four1three2s,Three1two2s,Two1one2,One23but none52s,Mother duck herself3and all52s'-split','
                                                                  '2s34',' little duck',-join($args-split'(s)')[5..39],'but only ',' of the'|%$d=$d-replace++$i,$_
                                                                  $d[+"$args"[2]*37%724%7]+' came back.'


                                                                  Try it online!



                                                                  I used the brute force to find the expression +"$args"[2]*37%724%7.



                                                                   verse | 3rd char. | ASCII code | *37%724%7
                                                                  -------+-----------+------------+-----------
                                                                  0 | 'v' | 118 | 1
                                                                  1 | 'u' | 117 | 2
                                                                  2 | 'r' | 114 | 3
                                                                  3 | 'o' | 111 | 4
                                                                  4 | 'e' | 101 | 5
                                                                  5 | 't' | 116 | 0


                                                                  Thanks @Arnauld for the 3rd char.






                                                                  share|improve this answer












                                                                  $endgroup$


















                                                                    3

















                                                                    $begingroup$


                                                                    PowerShell, 265 263 255 251 246 bytes





                                                                    $d='Five1four2s,Four1three2s,Three1two2s,Two1one2,One23but none52s,Mother duck herself3and all52s'-split','
                                                                    '2s34',' little duck',-join($args-split'(s)')[5..39],'but only ',' of the'|%$d=$d-replace++$i,$_
                                                                    $d[+"$args"[2]*37%724%7]+' came back.'


                                                                    Try it online!



                                                                    I used the brute force to find the expression +"$args"[2]*37%724%7.



                                                                     verse | 3rd char. | ASCII code | *37%724%7
                                                                    -------+-----------+------------+-----------
                                                                    0 | 'v' | 118 | 1
                                                                    1 | 'u' | 117 | 2
                                                                    2 | 'r' | 114 | 3
                                                                    3 | 'o' | 111 | 4
                                                                    4 | 'e' | 101 | 5
                                                                    5 | 't' | 116 | 0


                                                                    Thanks @Arnauld for the 3rd char.






                                                                    share|improve this answer












                                                                    $endgroup$
















                                                                      3















                                                                      3











                                                                      3







                                                                      $begingroup$


                                                                      PowerShell, 265 263 255 251 246 bytes





                                                                      $d='Five1four2s,Four1three2s,Three1two2s,Two1one2,One23but none52s,Mother duck herself3and all52s'-split','
                                                                      '2s34',' little duck',-join($args-split'(s)')[5..39],'but only ',' of the'|%$d=$d-replace++$i,$_
                                                                      $d[+"$args"[2]*37%724%7]+' came back.'


                                                                      Try it online!



                                                                      I used the brute force to find the expression +"$args"[2]*37%724%7.



                                                                       verse | 3rd char. | ASCII code | *37%724%7
                                                                      -------+-----------+------------+-----------
                                                                      0 | 'v' | 118 | 1
                                                                      1 | 'u' | 117 | 2
                                                                      2 | 'r' | 114 | 3
                                                                      3 | 'o' | 111 | 4
                                                                      4 | 'e' | 101 | 5
                                                                      5 | 't' | 116 | 0


                                                                      Thanks @Arnauld for the 3rd char.






                                                                      share|improve this answer












                                                                      $endgroup$




                                                                      PowerShell, 265 263 255 251 246 bytes





                                                                      $d='Five1four2s,Four1three2s,Three1two2s,Two1one2,One23but none52s,Mother duck herself3and all52s'-split','
                                                                      '2s34',' little duck',-join($args-split'(s)')[5..39],'but only ',' of the'|%$d=$d-replace++$i,$_
                                                                      $d[+"$args"[2]*37%724%7]+' came back.'


                                                                      Try it online!



                                                                      I used the brute force to find the expression +"$args"[2]*37%724%7.



                                                                       verse | 3rd char. | ASCII code | *37%724%7
                                                                      -------+-----------+------------+-----------
                                                                      0 | 'v' | 118 | 1
                                                                      1 | 'u' | 117 | 2
                                                                      2 | 'r' | 114 | 3
                                                                      3 | 'o' | 111 | 4
                                                                      4 | 'e' | 101 | 5
                                                                      5 | 't' | 116 | 0


                                                                      Thanks @Arnauld for the 3rd char.







                                                                      share|improve this answer















                                                                      share|improve this answer




                                                                      share|improve this answer








                                                                      edited Sep 26 at 6:31

























                                                                      answered Sep 25 at 19:51









                                                                      mazzymazzy

                                                                      4,4221 gold badge6 silver badges21 bronze badges




                                                                      4,4221 gold badge6 silver badges21 bronze badges
























                                                                          2

















                                                                          $begingroup$


                                                                          Japt v2.0a0, 143 bytes



                                                                          Tried encoding a single verse with replacements but, in the end, adapting Arnauld's solution ended up being shorter. Have another idea that might, hopefully, work out shorter again but don't know when I'll get to try it.



                                                                          tBn)i`Fr4È(e3
                                                                          Two4e0
                                                                          MÇ@r Ýõ Êelf1d a¥23
                                                                          O01¿t Í
                                                                          23
                                                                          TËG4two3
                                                                          Five4fr3`·g`v`b¢Î)rdÈ°g[V=` Ò¤ Ýõ`W=Uf/ w.*n/s ` e`V±'sV+W+`¿t § `]


                                                                          Try it - includes all verses






                                                                          share|improve this answer










                                                                          $endgroup$


















                                                                            2

















                                                                            $begingroup$


                                                                            Japt v2.0a0, 143 bytes



                                                                            Tried encoding a single verse with replacements but, in the end, adapting Arnauld's solution ended up being shorter. Have another idea that might, hopefully, work out shorter again but don't know when I'll get to try it.



                                                                            tBn)i`Fr4È(e3
                                                                            Two4e0
                                                                            MÇ@r Ýõ Êelf1d a¥23
                                                                            O01¿t Í
                                                                            23
                                                                            TËG4two3
                                                                            Five4fr3`·g`v`b¢Î)rdÈ°g[V=` Ò¤ Ýõ`W=Uf/ w.*n/s ` e`V±'sV+W+`¿t § `]


                                                                            Try it - includes all verses






                                                                            share|improve this answer










                                                                            $endgroup$
















                                                                              2















                                                                              2











                                                                              2







                                                                              $begingroup$


                                                                              Japt v2.0a0, 143 bytes



                                                                              Tried encoding a single verse with replacements but, in the end, adapting Arnauld's solution ended up being shorter. Have another idea that might, hopefully, work out shorter again but don't know when I'll get to try it.



                                                                              tBn)i`Fr4È(e3
                                                                              Two4e0
                                                                              MÇ@r Ýõ Êelf1d a¥23
                                                                              O01¿t Í
                                                                              23
                                                                              TËG4two3
                                                                              Five4fr3`·g`v`b¢Î)rdÈ°g[V=` Ò¤ Ýõ`W=Uf/ w.*n/s ` e`V±'sV+W+`¿t § `]


                                                                              Try it - includes all verses






                                                                              share|improve this answer










                                                                              $endgroup$




                                                                              Japt v2.0a0, 143 bytes



                                                                              Tried encoding a single verse with replacements but, in the end, adapting Arnauld's solution ended up being shorter. Have another idea that might, hopefully, work out shorter again but don't know when I'll get to try it.



                                                                              tBn)i`Fr4È(e3
                                                                              Two4e0
                                                                              MÇ@r Ýõ Êelf1d a¥23
                                                                              O01¿t Í
                                                                              23
                                                                              TËG4two3
                                                                              Five4fr3`·g`v`b¢Î)rdÈ°g[V=` Ò¤ Ýõ`W=Uf/ w.*n/s ` e`V±'sV+W+`¿t § `]


                                                                              Try it - includes all verses







                                                                              share|improve this answer













                                                                              share|improve this answer




                                                                              share|improve this answer










                                                                              answered Sep 26 at 11:27









                                                                              ShaggyShaggy

                                                                              23.6k3 gold badges21 silver badges73 bronze badges




                                                                              23.6k3 gold badges21 silver badges73 bronze badges
























                                                                                  2

















                                                                                  $begingroup$


                                                                                  Bash, 373 355 bytes



                                                                                  Nothing too crazy here. An easy few byte reduction would be to replace the two-character variables (a1,a2,a3,e1..e6) with single character ones.





                                                                                  read a1..3 b
                                                                                  read c
                                                                                  read d
                                                                                  read e1..6
                                                                                  W="$e1 $e2"
                                                                                  X="$e3^ $a2 $a3"
                                                                                  Y="$e5 $e6"
                                                                                  Z="$e4 $Y"
                                                                                  p=$X
                                                                                  case $a1 in M*)p="Five $Y::12";s="but only four $Y";;O*)p="$d::11 herself";s="and all of $Z";;Tw*)p=$X/s;s="$e1 none of the $a2 ducks $e6";;Th*)s="$W one $e4 duck $e6";;Fo*)s="$W two $Z";;Fi*)s="$W three $Z";;esac
                                                                                  echo $p $b;echo $c;echo $d;echo $s


                                                                                  Try it online!



                                                                                  Try it online!






                                                                                  share|improve this answer












                                                                                  $endgroup$


















                                                                                    2

















                                                                                    $begingroup$


                                                                                    Bash, 373 355 bytes



                                                                                    Nothing too crazy here. An easy few byte reduction would be to replace the two-character variables (a1,a2,a3,e1..e6) with single character ones.





                                                                                    read a1..3 b
                                                                                    read c
                                                                                    read d
                                                                                    read e1..6
                                                                                    W="$e1 $e2"
                                                                                    X="$e3^ $a2 $a3"
                                                                                    Y="$e5 $e6"
                                                                                    Z="$e4 $Y"
                                                                                    p=$X
                                                                                    case $a1 in M*)p="Five $Y::12";s="but only four $Y";;O*)p="$d::11 herself";s="and all of $Z";;Tw*)p=$X/s;s="$e1 none of the $a2 ducks $e6";;Th*)s="$W one $e4 duck $e6";;Fo*)s="$W two $Z";;Fi*)s="$W three $Z";;esac
                                                                                    echo $p $b;echo $c;echo $d;echo $s


                                                                                    Try it online!



                                                                                    Try it online!






                                                                                    share|improve this answer












                                                                                    $endgroup$
















                                                                                      2















                                                                                      2











                                                                                      2







                                                                                      $begingroup$


                                                                                      Bash, 373 355 bytes



                                                                                      Nothing too crazy here. An easy few byte reduction would be to replace the two-character variables (a1,a2,a3,e1..e6) with single character ones.





                                                                                      read a1..3 b
                                                                                      read c
                                                                                      read d
                                                                                      read e1..6
                                                                                      W="$e1 $e2"
                                                                                      X="$e3^ $a2 $a3"
                                                                                      Y="$e5 $e6"
                                                                                      Z="$e4 $Y"
                                                                                      p=$X
                                                                                      case $a1 in M*)p="Five $Y::12";s="but only four $Y";;O*)p="$d::11 herself";s="and all of $Z";;Tw*)p=$X/s;s="$e1 none of the $a2 ducks $e6";;Th*)s="$W one $e4 duck $e6";;Fo*)s="$W two $Z";;Fi*)s="$W three $Z";;esac
                                                                                      echo $p $b;echo $c;echo $d;echo $s


                                                                                      Try it online!



                                                                                      Try it online!






                                                                                      share|improve this answer












                                                                                      $endgroup$




                                                                                      Bash, 373 355 bytes



                                                                                      Nothing too crazy here. An easy few byte reduction would be to replace the two-character variables (a1,a2,a3,e1..e6) with single character ones.





                                                                                      read a1..3 b
                                                                                      read c
                                                                                      read d
                                                                                      read e1..6
                                                                                      W="$e1 $e2"
                                                                                      X="$e3^ $a2 $a3"
                                                                                      Y="$e5 $e6"
                                                                                      Z="$e4 $Y"
                                                                                      p=$X
                                                                                      case $a1 in M*)p="Five $Y::12";s="but only four $Y";;O*)p="$d::11 herself";s="and all of $Z";;Tw*)p=$X/s;s="$e1 none of the $a2 ducks $e6";;Th*)s="$W one $e4 duck $e6";;Fo*)s="$W two $Z";;Fi*)s="$W three $Z";;esac
                                                                                      echo $p $b;echo $c;echo $d;echo $s


                                                                                      Try it online!



                                                                                      Try it online!







                                                                                      share|improve this answer















                                                                                      share|improve this answer




                                                                                      share|improve this answer








                                                                                      edited Sep 30 at 15:53

























                                                                                      answered Sep 25 at 22:41









                                                                                      spuckspuck

                                                                                      6397 bronze badges




                                                                                      6397 bronze badges
























                                                                                          2

















                                                                                          $begingroup$


                                                                                          05AB1E, 134 bytes



                                                                                          “€µ‚•„í†ìˆÈ“#’ „ê Ðœs’δJ樅î¥Ðœº¶s‚ìðδJD…€³€É δ쨦“€ƒ€Ÿ€‚€€““€³Šª€‚€€“‚’ „ê Ðœs ’δJ셋邃.δJU.•4Ôāl•|н2èk©è.ª?I„ 
                                                                                          ý#3.$17£ðý„
                                                                                          ¶:,X®è?


                                                                                          Try it online!



                                                                                          Since i'm relatively new to 05AB1E, this can maybe be golfed a lot



                                                                                           ### Preparation of the output strings ###
                                                                                          “€µ‚•„í†ìˆÈ“ push "one two three four five"
                                                                                          # split that by spaces
                                                                                          ’ „ê Ðœs’ push " little ducks"
                                                                                          δJ join each number with " little ducks"
                                                                                          ć¨ separate "one little ducks" and drop the "s"
                                                                                          …î¥Ðœº¶ push "mother duck herself"
                                                                                          s swap it with "one little duck"
                                                                                          ‚ì prepend both strings to the list ["mother duck herself", "one little duck", "two little ducks" ... ]
                                                                                          ðδJ append a space to each list entry
                                                                                          D duplicate it
                                                                                          …€³€É push "but only "
                                                                                          δì prepend "but only " to each list entry
                                                                                          ¨¦ drop the first and last list entry
                                                                                          “€ƒ€Ÿ€‚€€“ push "and all of the"
                                                                                          “€³Šª€‚€€“ push "but none of the"
                                                                                          ‚ push the two strings into a list
                                                                                          ’ „ê Ðœs ’δJ append " little ducks " to each
                                                                                          ì prepend it to the sentence list ["and all of the little ducks ", "but none of the little ducks ", "but only one little duck " ...]
                                                                                          …‹é‚ƒ. push "came back."
                                                                                          δJ append that to each list entry
                                                                                          U save that list in X for later use

                                                                                          ### Determine which verse has to be answered ###
                                                                                          .•4Ôāl• push "eoruvt"
                                                                                          |н2è get the third letter of the input
                                                                                          k get the index of that letter in "eoruvt". Now we know which verse we must return
                                                                                          © save that index in ® for later use

                                                                                          ### Print the answer strings ###
                                                                                          è.ª? print that index of the first sentence list (first three words of answer)
                                                                                          I„ join the four input strings by <space><newline>
                                                                                          ý
                                                                                          # split that by spaces
                                                                                          3.$ cut off the first three words
                                                                                          17£ keep only the next 17 words
                                                                                          ðý join remaining words by spaces

                                                                                          ¶: replace <space><newline> by only <newline>
                                                                                          , print that ("went out ... Quack",")
                                                                                          X®è? print the last line of answer





                                                                                          share|improve this answer










                                                                                          $endgroup$


















                                                                                            2

















                                                                                            $begingroup$


                                                                                            05AB1E, 134 bytes



                                                                                            “€µ‚•„í†ìˆÈ“#’ „ê Ðœs’δJ樅î¥Ðœº¶s‚ìðδJD…€³€É δ쨦“€ƒ€Ÿ€‚€€““€³Šª€‚€€“‚’ „ê Ðœs ’δJ셋邃.δJU.•4Ôāl•|н2èk©è.ª?I„ 
                                                                                            ý#3.$17£ðý„
                                                                                            ¶:,X®è?


                                                                                            Try it online!



                                                                                            Since i'm relatively new to 05AB1E, this can maybe be golfed a lot



                                                                                             ### Preparation of the output strings ###
                                                                                            “€µ‚•„í†ìˆÈ“ push "one two three four five"
                                                                                            # split that by spaces
                                                                                            ’ „ê Ðœs’ push " little ducks"
                                                                                            δJ join each number with " little ducks"
                                                                                            ć¨ separate "one little ducks" and drop the "s"
                                                                                            …î¥Ðœº¶ push "mother duck herself"
                                                                                            s swap it with "one little duck"
                                                                                            ‚ì prepend both strings to the list ["mother duck herself", "one little duck", "two little ducks" ... ]
                                                                                            ðδJ append a space to each list entry
                                                                                            D duplicate it
                                                                                            …€³€É push "but only "
                                                                                            δì prepend "but only " to each list entry
                                                                                            ¨¦ drop the first and last list entry
                                                                                            “€ƒ€Ÿ€‚€€“ push "and all of the"
                                                                                            “€³Šª€‚€€“ push "but none of the"
                                                                                            ‚ push the two strings into a list
                                                                                            ’ „ê Ðœs ’δJ append " little ducks " to each
                                                                                            ì prepend it to the sentence list ["and all of the little ducks ", "but none of the little ducks ", "but only one little duck " ...]
                                                                                            …‹é‚ƒ. push "came back."
                                                                                            δJ append that to each list entry
                                                                                            U save that list in X for later use

                                                                                            ### Determine which verse has to be answered ###
                                                                                            .•4Ôāl• push "eoruvt"
                                                                                            |н2è get the third letter of the input
                                                                                            k get the index of that letter in "eoruvt". Now we know which verse we must return
                                                                                            © save that index in ® for later use

                                                                                            ### Print the answer strings ###
                                                                                            è.ª? print that index of the first sentence list (first three words of answer)
                                                                                            I„ join the four input strings by <space><newline>
                                                                                            ý
                                                                                            # split that by spaces
                                                                                            3.$ cut off the first three words
                                                                                            17£ keep only the next 17 words
                                                                                            ðý join remaining words by spaces

                                                                                            ¶: replace <space><newline> by only <newline>
                                                                                            , print that ("went out ... Quack",")
                                                                                            X®è? print the last line of answer





                                                                                            share|improve this answer










                                                                                            $endgroup$
















                                                                                              2















                                                                                              2











                                                                                              2







                                                                                              $begingroup$


                                                                                              05AB1E, 134 bytes



                                                                                              “€µ‚•„í†ìˆÈ“#’ „ê Ðœs’δJ樅î¥Ðœº¶s‚ìðδJD…€³€É δ쨦“€ƒ€Ÿ€‚€€““€³Šª€‚€€“‚’ „ê Ðœs ’δJ셋邃.δJU.•4Ôāl•|н2èk©è.ª?I„ 
                                                                                              ý#3.$17£ðý„
                                                                                              ¶:,X®è?


                                                                                              Try it online!



                                                                                              Since i'm relatively new to 05AB1E, this can maybe be golfed a lot



                                                                                               ### Preparation of the output strings ###
                                                                                              “€µ‚•„í†ìˆÈ“ push "one two three four five"
                                                                                              # split that by spaces
                                                                                              ’ „ê Ðœs’ push " little ducks"
                                                                                              δJ join each number with " little ducks"
                                                                                              ć¨ separate "one little ducks" and drop the "s"
                                                                                              …î¥Ðœº¶ push "mother duck herself"
                                                                                              s swap it with "one little duck"
                                                                                              ‚ì prepend both strings to the list ["mother duck herself", "one little duck", "two little ducks" ... ]
                                                                                              ðδJ append a space to each list entry
                                                                                              D duplicate it
                                                                                              …€³€É push "but only "
                                                                                              δì prepend "but only " to each list entry
                                                                                              ¨¦ drop the first and last list entry
                                                                                              “€ƒ€Ÿ€‚€€“ push "and all of the"
                                                                                              “€³Šª€‚€€“ push "but none of the"
                                                                                              ‚ push the two strings into a list
                                                                                              ’ „ê Ðœs ’δJ append " little ducks " to each
                                                                                              ì prepend it to the sentence list ["and all of the little ducks ", "but none of the little ducks ", "but only one little duck " ...]
                                                                                              …‹é‚ƒ. push "came back."
                                                                                              δJ append that to each list entry
                                                                                              U save that list in X for later use

                                                                                              ### Determine which verse has to be answered ###
                                                                                              .•4Ôāl• push "eoruvt"
                                                                                              |н2è get the third letter of the input
                                                                                              k get the index of that letter in "eoruvt". Now we know which verse we must return
                                                                                              © save that index in ® for later use

                                                                                              ### Print the answer strings ###
                                                                                              è.ª? print that index of the first sentence list (first three words of answer)
                                                                                              I„ join the four input strings by <space><newline>
                                                                                              ý
                                                                                              # split that by spaces
                                                                                              3.$ cut off the first three words
                                                                                              17£ keep only the next 17 words
                                                                                              ðý join remaining words by spaces

                                                                                              ¶: replace <space><newline> by only <newline>
                                                                                              , print that ("went out ... Quack",")
                                                                                              X®è? print the last line of answer





                                                                                              share|improve this answer










                                                                                              $endgroup$




                                                                                              05AB1E, 134 bytes



                                                                                              “€µ‚•„í†ìˆÈ“#’ „ê Ðœs’δJ樅î¥Ðœº¶s‚ìðδJD…€³€É δ쨦“€ƒ€Ÿ€‚€€““€³Šª€‚€€“‚’ „ê Ðœs ’δJ셋邃.δJU.•4Ôāl•|н2èk©è.ª?I„ 
                                                                                              ý#3.$17£ðý„
                                                                                              ¶:,X®è?


                                                                                              Try it online!



                                                                                              Since i'm relatively new to 05AB1E, this can maybe be golfed a lot



                                                                                               ### Preparation of the output strings ###
                                                                                              “€µ‚•„í†ìˆÈ“ push "one two three four five"
                                                                                              # split that by spaces
                                                                                              ’ „ê Ðœs’ push " little ducks"
                                                                                              δJ join each number with " little ducks"
                                                                                              ć¨ separate "one little ducks" and drop the "s"
                                                                                              …î¥Ðœº¶ push "mother duck herself"
                                                                                              s swap it with "one little duck"
                                                                                              ‚ì prepend both strings to the list ["mother duck herself", "one little duck", "two little ducks" ... ]
                                                                                              ðδJ append a space to each list entry
                                                                                              D duplicate it
                                                                                              …€³€É push "but only "
                                                                                              δì prepend "but only " to each list entry
                                                                                              ¨¦ drop the first and last list entry
                                                                                              “€ƒ€Ÿ€‚€€“ push "and all of the"
                                                                                              “€³Šª€‚€€“ push "but none of the"
                                                                                              ‚ push the two strings into a list
                                                                                              ’ „ê Ðœs ’δJ append " little ducks " to each
                                                                                              ì prepend it to the sentence list ["and all of the little ducks ", "but none of the little ducks ", "but only one little duck " ...]
                                                                                              …‹é‚ƒ. push "came back."
                                                                                              δJ append that to each list entry
                                                                                              U save that list in X for later use

                                                                                              ### Determine which verse has to be answered ###
                                                                                              .•4Ôāl• push "eoruvt"
                                                                                              |н2è get the third letter of the input
                                                                                              k get the index of that letter in "eoruvt". Now we know which verse we must return
                                                                                              © save that index in ® for later use

                                                                                              ### Print the answer strings ###
                                                                                              è.ª? print that index of the first sentence list (first three words of answer)
                                                                                              I„ join the four input strings by <space><newline>
                                                                                              ý
                                                                                              # split that by spaces
                                                                                              3.$ cut off the first three words
                                                                                              17£ keep only the next 17 words
                                                                                              ðý join remaining words by spaces

                                                                                              ¶: replace <space><newline> by only <newline>
                                                                                              , print that ("went out ... Quack",")
                                                                                              X®è? print the last line of answer






                                                                                              share|improve this answer













                                                                                              share|improve this answer




                                                                                              share|improve this answer










                                                                                              answered Oct 2 at 10:19









                                                                                              DorianDorian

                                                                                              1,4216 silver badges8 bronze badges




                                                                                              1,4216 silver badges8 bronze badges
























                                                                                                  1

















                                                                                                  $begingroup$


                                                                                                  Perl 6, 247 bytes





                                                                                                  S:i/nesl.*?<(s//om/..(.)(S*)**3%s(.**92).*(.**11)/;[(my$l=" little ducks")~$3 XR~"Mother duck herself$2and all of the","One$l~=$2but none of the","Five$l~="but only "four","Four$lthree","Three$ltwo","Two$lone"]["eotvur".index($0)]


                                                                                                  Try it online!



                                                                                                  Definitely golfable, especially the last 5 elements in the list in the form "num $l num-1", or the starting regex that matches the right parts of the old input.






                                                                                                  share|improve this answer












                                                                                                  $endgroup$


















                                                                                                    1

















                                                                                                    $begingroup$


                                                                                                    Perl 6, 247 bytes





                                                                                                    S:i/nesl.*?<(s//om/..(.)(S*)**3%s(.**92).*(.**11)/;[(my$l=" little ducks")~$3 XR~"Mother duck herself$2and all of the","One$l~=$2but none of the","Five$l~="but only "four","Four$lthree","Three$ltwo","Two$lone"]["eotvur".index($0)]


                                                                                                    Try it online!



                                                                                                    Definitely golfable, especially the last 5 elements in the list in the form "num $l num-1", or the starting regex that matches the right parts of the old input.






                                                                                                    share|improve this answer












                                                                                                    $endgroup$
















                                                                                                      1















                                                                                                      1











                                                                                                      1







                                                                                                      $begingroup$


                                                                                                      Perl 6, 247 bytes





                                                                                                      S:i/nesl.*?<(s//om/..(.)(S*)**3%s(.**92).*(.**11)/;[(my$l=" little ducks")~$3 XR~"Mother duck herself$2and all of the","One$l~=$2but none of the","Five$l~="but only "four","Four$lthree","Three$ltwo","Two$lone"]["eotvur".index($0)]


                                                                                                      Try it online!



                                                                                                      Definitely golfable, especially the last 5 elements in the list in the form "num $l num-1", or the starting regex that matches the right parts of the old input.






                                                                                                      share|improve this answer












                                                                                                      $endgroup$




                                                                                                      Perl 6, 247 bytes





                                                                                                      S:i/nesl.*?<(s//om/..(.)(S*)**3%s(.**92).*(.**11)/;[(my$l=" little ducks")~$3 XR~"Mother duck herself$2and all of the","One$l~=$2but none of the","Five$l~="but only "four","Four$lthree","Three$ltwo","Two$lone"]["eotvur".index($0)]


                                                                                                      Try it online!



                                                                                                      Definitely golfable, especially the last 5 elements in the list in the form "num $l num-1", or the starting regex that matches the right parts of the old input.







                                                                                                      share|improve this answer















                                                                                                      share|improve this answer




                                                                                                      share|improve this answer








                                                                                                      edited Sep 26 at 8:31

























                                                                                                      answered Sep 26 at 8:12









                                                                                                      Jo KingJo King

                                                                                                      36.1k4 gold badges78 silver badges151 bronze badges




                                                                                                      36.1k4 gold badges78 silver badges151 bronze badges
























                                                                                                          1

















                                                                                                          $begingroup$


                                                                                                          Charcoal, 156 bytes



                                                                                                          ≔⌕tvuroe§θ²δ§⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸⸿η⸿ζ⸿§⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                          Try it online! Link is to verbose version of code. Explanation:



                                                                                                          ≔⌕tvuroe§θ²δ


                                                                                                          Look at the third character of the first line to work out which verse we want.



                                                                                                          §⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸


                                                                                                          Output the first part of the first line by indexing into the list of strings Five, Four, Three, Two, One, Mother duck herself. Then print little duck and s as appropriate, followed by the last 18 characters of the input line (which are always the same on each verse).



                                                                                                          ⸿η⸿ζ⸿


                                                                                                          The middle two lines are always the same on each verse.



                                                                                                          §⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                          For the last line it turns out to be golfier to include little ducks in the list of alternatives for some reason, but the last 11 characters are still copied from the input.






                                                                                                          share|improve this answer










                                                                                                          $endgroup$


















                                                                                                            1

















                                                                                                            $begingroup$


                                                                                                            Charcoal, 156 bytes



                                                                                                            ≔⌕tvuroe§θ²δ§⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸⸿η⸿ζ⸿§⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                            Try it online! Link is to verbose version of code. Explanation:



                                                                                                            ≔⌕tvuroe§θ²δ


                                                                                                            Look at the third character of the first line to work out which verse we want.



                                                                                                            §⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸


                                                                                                            Output the first part of the first line by indexing into the list of strings Five, Four, Three, Two, One, Mother duck herself. Then print little duck and s as appropriate, followed by the last 18 characters of the input line (which are always the same on each verse).



                                                                                                            ⸿η⸿ζ⸿


                                                                                                            The middle two lines are always the same on each verse.



                                                                                                            §⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                            For the last line it turns out to be golfier to include little ducks in the list of alternatives for some reason, but the last 11 characters are still copied from the input.






                                                                                                            share|improve this answer










                                                                                                            $endgroup$
















                                                                                                              1















                                                                                                              1











                                                                                                              1







                                                                                                              $begingroup$


                                                                                                              Charcoal, 156 bytes



                                                                                                              ≔⌕tvuroe§θ²δ§⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸⸿η⸿ζ⸿§⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                              Try it online! Link is to verbose version of code. Explanation:



                                                                                                              ≔⌕tvuroe§θ²δ


                                                                                                              Look at the third character of the first line to work out which verse we want.



                                                                                                              §⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸


                                                                                                              Output the first part of the first line by indexing into the list of strings Five, Four, Three, Two, One, Mother duck herself. Then print little duck and s as appropriate, followed by the last 18 characters of the input line (which are always the same on each verse).



                                                                                                              ⸿η⸿ζ⸿


                                                                                                              The middle two lines are always the same on each verse.



                                                                                                              §⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                              For the last line it turns out to be golfier to include little ducks in the list of alternatives for some reason, but the last 11 characters are still copied from the input.






                                                                                                              share|improve this answer










                                                                                                              $endgroup$




                                                                                                              Charcoal, 156 bytes



                                                                                                              ≔⌕tvuroe§θ²δ§⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸⸿η⸿ζ⸿§⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                              Try it online! Link is to verbose version of code. Explanation:



                                                                                                              ≔⌕tvuroe§θ²δ


                                                                                                              Look at the third character of the first line to work out which verse we want.



                                                                                                              §⪪”↶0∨↘»≔xj➙⌈´βXPNLA‽⟦O⧴&▷V'¦³≧ψZρ⊞t”¶δF‹δ⁵”↶↧V4ⅉH‴G%”F‹δ⁴s⮌…⮌θ¹⁸


                                                                                                              Output the first part of the first line by indexing into the list of strings Five, Four, Three, Two, One, Mother duck herself. Then print little duck and s as appropriate, followed by the last 18 characters of the input line (which are always the same on each verse).



                                                                                                              ⸿η⸿ζ⸿


                                                                                                              The middle two lines are always the same on each verse.



                                                                                                              §⪪”}∧h⁴NQ≕Q^⪫ΦG✂q'ⅉMG./_⸿s⁵6P⁴″⊟±NNpOfBz↷Fι‖TM→⁻γ?k⁴ς!d⁵º'E,θ}x§-υ”¶δ✂ε±¹¹


                                                                                                              For the last line it turns out to be golfier to include little ducks in the list of alternatives for some reason, but the last 11 characters are still copied from the input.







                                                                                                              share|improve this answer













                                                                                                              share|improve this answer




                                                                                                              share|improve this answer










                                                                                                              answered Sep 28 at 0:01









                                                                                                              NeilNeil

                                                                                                              92.2k8 gold badges47 silver badges192 bronze badges




                                                                                                              92.2k8 gold badges47 silver badges192 bronze badges
























                                                                                                                  1

















                                                                                                                  $begingroup$


                                                                                                                  ink, 353 bytes



                                                                                                                  =d(v)
                                                                                                                  ~temp n=(v?"Fi")+(v?"F")*4+(v?"Th")+(v?"T")*2+(v?"O")
                                                                                                                  n-1:n:n-5:n-4:n-3:One little duckn-2:s went out one day,
                                                                                                                  over the hills and up away,
                                                                                                                  Mother Duck said "Quack Quack Quack Quack",
                                                                                                                  and all of the little duckn-3:s came back.


                                                                                                                  Try it online!



                                                                                                                  First, uses substring checks to figure out what verse we're in - that's easy enough thanks to the capitalisation of the numbers at the start - F, T and O don't occur in any other places, and you can distinguish the second and fourth verse from the first and third by also checking for Fi and Th respectively.



                                                                                                                  Then we just do what ink does best and print plain text specked with conditionals. I tried using switch statements at first, but while that looked nicer, it actually ended up longer.

                                                                                                                  You'd think the Quacks would be a good place to use variables, what with a string being repeated a bunch, but variables come with enough overhead that every way I tried to do that made the code longer. Maybe that's a sign I'm not supposed to golf in ink.






                                                                                                                  share|improve this answer










                                                                                                                  $endgroup$


















                                                                                                                    1

















                                                                                                                    $begingroup$


                                                                                                                    ink, 353 bytes



                                                                                                                    =d(v)
                                                                                                                    ~temp n=(v?"Fi")+(v?"F")*4+(v?"Th")+(v?"T")*2+(v?"O")
                                                                                                                    n-1:n:n-5:n-4:n-3:One little duckn-2:s went out one day,
                                                                                                                    over the hills and up away,
                                                                                                                    Mother Duck said "Quack Quack Quack Quack",
                                                                                                                    and all of the little duckn-3:s came back.


                                                                                                                    Try it online!



                                                                                                                    First, uses substring checks to figure out what verse we're in - that's easy enough thanks to the capitalisation of the numbers at the start - F, T and O don't occur in any other places, and you can distinguish the second and fourth verse from the first and third by also checking for Fi and Th respectively.



                                                                                                                    Then we just do what ink does best and print plain text specked with conditionals. I tried using switch statements at first, but while that looked nicer, it actually ended up longer.

                                                                                                                    You'd think the Quacks would be a good place to use variables, what with a string being repeated a bunch, but variables come with enough overhead that every way I tried to do that made the code longer. Maybe that's a sign I'm not supposed to golf in ink.






                                                                                                                    share|improve this answer










                                                                                                                    $endgroup$
















                                                                                                                      1















                                                                                                                      1











                                                                                                                      1







                                                                                                                      $begingroup$


                                                                                                                      ink, 353 bytes



                                                                                                                      =d(v)
                                                                                                                      ~temp n=(v?"Fi")+(v?"F")*4+(v?"Th")+(v?"T")*2+(v?"O")
                                                                                                                      n-1:n:n-5:n-4:n-3:One little duckn-2:s went out one day,
                                                                                                                      over the hills and up away,
                                                                                                                      Mother Duck said "Quack Quack Quack Quack",
                                                                                                                      and all of the little duckn-3:s came back.


                                                                                                                      Try it online!



                                                                                                                      First, uses substring checks to figure out what verse we're in - that's easy enough thanks to the capitalisation of the numbers at the start - F, T and O don't occur in any other places, and you can distinguish the second and fourth verse from the first and third by also checking for Fi and Th respectively.



                                                                                                                      Then we just do what ink does best and print plain text specked with conditionals. I tried using switch statements at first, but while that looked nicer, it actually ended up longer.

                                                                                                                      You'd think the Quacks would be a good place to use variables, what with a string being repeated a bunch, but variables come with enough overhead that every way I tried to do that made the code longer. Maybe that's a sign I'm not supposed to golf in ink.






                                                                                                                      share|improve this answer










                                                                                                                      $endgroup$




                                                                                                                      ink, 353 bytes



                                                                                                                      =d(v)
                                                                                                                      ~temp n=(v?"Fi")+(v?"F")*4+(v?"Th")+(v?"T")*2+(v?"O")
                                                                                                                      n-1:n:n-5:n-4:n-3:One little duckn-2:s went out one day,
                                                                                                                      over the hills and up away,
                                                                                                                      Mother Duck said "Quack Quack Quack Quack",
                                                                                                                      and all of the little duckn-3:s came back.


                                                                                                                      Try it online!



                                                                                                                      First, uses substring checks to figure out what verse we're in - that's easy enough thanks to the capitalisation of the numbers at the start - F, T and O don't occur in any other places, and you can distinguish the second and fourth verse from the first and third by also checking for Fi and Th respectively.



                                                                                                                      Then we just do what ink does best and print plain text specked with conditionals. I tried using switch statements at first, but while that looked nicer, it actually ended up longer.

                                                                                                                      You'd think the Quacks would be a good place to use variables, what with a string being repeated a bunch, but variables come with enough overhead that every way I tried to do that made the code longer. Maybe that's a sign I'm not supposed to golf in ink.







                                                                                                                      share|improve this answer













                                                                                                                      share|improve this answer




                                                                                                                      share|improve this answer










                                                                                                                      answered Oct 21 at 1:22









                                                                                                                      Sara JSara J

                                                                                                                      2,4268 silver badges27 bronze badges




                                                                                                                      2,4268 silver badges27 bronze badges































                                                                                                                          draft saved

                                                                                                                          draft discarded















































                                                                                                                          If this is an answer to a challenge…



                                                                                                                          • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                          • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                            Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                          • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                                                                                          More generally…



                                                                                                                          • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                          • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                                                                                          draft saved


                                                                                                                          draft discarded














                                                                                                                          StackExchange.ready(
                                                                                                                          function ()
                                                                                                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f193467%2fduck-duck-gone%23new-answer', 'question_page');

                                                                                                                          );

                                                                                                                          Post as a guest















                                                                                                                          Required, but never shown





















































                                                                                                                          Required, but never shown














                                                                                                                          Required, but never shown












                                                                                                                          Required, but never shown







                                                                                                                          Required, but never shown

































                                                                                                                          Required, but never shown














                                                                                                                          Required, but never shown












                                                                                                                          Required, but never shown







                                                                                                                          Required, but never shown









                                                                                                                          Popular posts from this blog

                                                                                                                          Tamil (spriik) Luke uk diar | Nawigatjuun

                                                                                                                          Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                                                                                                                          Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?