From b2899676f2b3eabd0d4b0bf172efd857b17fa6a8 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 22:14:28 +0000 Subject: [PATCH 1/7] [Sync Iteration] python/bottle-song/1 --- solutions/python/bottle-song/1/bottle_song.py | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 solutions/python/bottle-song/1/bottle_song.py diff --git a/solutions/python/bottle-song/1/bottle_song.py b/solutions/python/bottle-song/1/bottle_song.py new file mode 100644 index 0000000..a4c3ff3 --- /dev/null +++ b/solutions/python/bottle-song/1/bottle_song.py @@ -0,0 +1,81 @@ +""" +Bottle Song +=========== + +Recite verses from the children's song "Ten Green Bottles". + +This module exposes the precomputed lyrics and a helper to +extract slices of the song by verse. +""" + +Ten_Green_Bottles: list[str] = [ + "Ten green bottles hanging on the wall,", + "Ten green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be nine green bottles hanging on the wall.", + "", + "Nine green bottles hanging on the wall,", + "Nine green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be eight green bottles hanging on the wall.", + "", + "Eight green bottles hanging on the wall,", + "Eight green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be seven green bottles hanging on the wall.", + "", + "Seven green bottles hanging on the wall,", + "Seven green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be six green bottles hanging on the wall.", + "", + "Six green bottles hanging on the wall,", + "Six green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be five green bottles hanging on the wall.", + "", + "Five green bottles hanging on the wall,", + "Five green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be four green bottles hanging on the wall.", + "", + "Four green bottles hanging on the wall,", + "Four green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be three green bottles hanging on the wall.", + "", + "Three green bottles hanging on the wall,", + "Three green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be two green bottles hanging on the wall.", + "", + "Two green bottles hanging on the wall,", + "Two green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be one green bottle hanging on the wall.", + "", + "One green bottle hanging on the wall,", + "One green bottle hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be no green bottles hanging on the wall.", +] + + +def recite(start: int, take: int = 1) -> list[str]: + """ + Return a slice of the song lyrics corresponding to ``take`` consecutive + verses starting from the verse that begins with ``start`` green bottles. + + The lyrics are stored as a flat list where each verse occupies five lines + (four lyric lines plus a trailing blank line). This function computes the + appropriate slice boundaries to return the requested verses in order. + + :param start: The number of green bottles to start from (e.g., 10 for + "Ten green bottles"). Must be between 1 and 10. + :param take: Number of consecutive verses to include starting at ``start``. + Defaults to 1. + :returns: A list of lyric lines forming the requested verses. + """ + start: int = -(start * 5) + end: int = len(Ten_Green_Bottles) + start + (take * 5) + return Ten_Green_Bottles[start + 1 : end] From 9e17d05dee763823babe758e776f16c5d7149a43 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 02:36:52 +0000 Subject: [PATCH 2/7] [Sync Iteration] python/bottle-song/2 --- solutions/python/bottle-song/2/bottle_song.py | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 solutions/python/bottle-song/2/bottle_song.py diff --git a/solutions/python/bottle-song/2/bottle_song.py b/solutions/python/bottle-song/2/bottle_song.py new file mode 100644 index 0000000..78cb842 --- /dev/null +++ b/solutions/python/bottle-song/2/bottle_song.py @@ -0,0 +1,67 @@ +""" +Bottle Song +=========== + +Recite verses from the children's song "Ten Green Bottles". + +This module exposes the precomputed lyrics and a helper to +extract slices of the song by verse. +""" + +NUMBERS: tuple = ( + "One", + "Two", + "Three", + "Four", + "Five", + "Six", + "Seven", + "Eight", + "Nine", + "Ten", +) + + +def recite(start: int, take: int = 1) -> list[str]: + """ + Return a slice of the song lyrics corresponding to ``take`` consecutive + verses starting from the verse that begins with ``start`` green bottles. + + The lyrics are stored as a flat list where each verse occupies five lines + (four lyric lines plus a trailing blank line). This function computes the + appropriate slice boundaries to return the requested verses in order. + + :param start: The number of green bottles to start from (e.g., 10 for + "Ten green bottles"). Must be between 1 and 10. + :param take: Number of consecutive verses to include starting at ``start``. + Defaults to 1. + :returns: A list of lyric lines forming the requested verses. + """ + result: list[str] = [] + for i in range(start, start - take, -1): + if i == 1: + verse = [ + f"{NUMBERS[i - 1]} green bottle hanging on the wall,", + f"{NUMBERS[i - 1]} green bottle hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be no green bottles hanging on the wall.", + ] + elif i != start - take + 1: + verse = [ + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower()} green {'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + "", + ] + else: + verse = [ + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower()} green {'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + ] + result += verse + return result From 6dc35b3832dcd59704b4e4d8eb1fd059b594b4af Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 02:39:37 +0000 Subject: [PATCH 3/7] [Sync Iteration] python/bottle-song/3 --- solutions/python/bottle-song/3/bottle_song.py | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 solutions/python/bottle-song/3/bottle_song.py diff --git a/solutions/python/bottle-song/3/bottle_song.py b/solutions/python/bottle-song/3/bottle_song.py new file mode 100644 index 0000000..d60f0bf --- /dev/null +++ b/solutions/python/bottle-song/3/bottle_song.py @@ -0,0 +1,68 @@ +""" +Bottle Song. + +Recite verses from the children's song "Ten Green Bottles". + +This module exposes the precomputed lyrics and a helper to +extract slices of the song by verse. +""" + +NUMBERS: tuple = ( + "One", + "Two", + "Three", + "Four", + "Five", + "Six", + "Seven", + "Eight", + "Nine", + "Ten", +) + + +def recite(start: int, take: int = 1) -> list[str]: + """ + Return a slice of the song lyrics corresponding to ``take`` consecutive + verses starting from the verse that begins with ``start`` green bottles. + + The lyrics are stored as a flat list where each verse occupies five lines + (four lyric lines plus a trailing blank line). This function computes the + appropriate slice boundaries to return the requested verses in order. + + :param start: The number of green bottles to start from (e.g., 10 for + "Ten green bottles"). Must be between 1 and 10. + :param take: Number of consecutive verses to include starting at ``start``. + Defaults to 1. + :returns: A list of lyric lines forming the requested verses. + """ + result: list[str] = [] + for i in range(start, start - take, -1): + if i == 1: + verse = [ + f"{NUMBERS[i - 1]} green bottle hanging on the wall,", + f"{NUMBERS[i - 1]} green bottle hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be no green bottles hanging on the wall.", + ] + elif i != start - take + 1: + verse = [ + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower()} green " + f"{'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + "", + ] + else: + verse = [ + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower()} green " + f"{'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + ] + result += verse + return result From 72c0d9bdda81c9ce27e17df975f3cde9c76bffa0 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 02:42:41 +0000 Subject: [PATCH 4/7] [Sync Iteration] python/bottle-song/4 --- solutions/python/bottle-song/4/bottle_song.py | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 solutions/python/bottle-song/4/bottle_song.py diff --git a/solutions/python/bottle-song/4/bottle_song.py b/solutions/python/bottle-song/4/bottle_song.py new file mode 100644 index 0000000..b4bd2ba --- /dev/null +++ b/solutions/python/bottle-song/4/bottle_song.py @@ -0,0 +1,68 @@ +""" +Bottle Song. + +Recite verses from the children's song "Ten Green Bottles". + +This module exposes the precomputed lyrics and a helper to +extract slices of the song by verse. +""" + +NUMBERS: tuple = ( + "One", + "Two", + "Three", + "Four", + "Five", + "Six", + "Seven", + "Eight", + "Nine", + "Ten", +) + + +def recite(start: int, take: int = 1) -> list[str]: + """ + Return a slice of the song lyrics corresponding to ``take`` consecutive + verses starting from the verse that begins with ``start`` green bottles. + + The lyrics are generated as a flat list where each verse occupies five lines + (four lyric lines plus a trailing blank line). This function generates the + requested verses dynamically based on the song's pattern. + + :param start: The number of green bottles to start from (e.g., 10 for + "Ten green bottles"). Must be between 1 and 10. + :param take: Number of consecutive verses to include starting at ``start``. + Defaults to 1. + :returns: A list of lyric lines forming the requested verses. + """ + result: list[str] = [] + for i in range(start, start - take, -1): + if i == 1: + verse = [ + f"{NUMBERS[i - 1]} green bottle hanging on the wall,", + f"{NUMBERS[i - 1]} green bottle hanging on the wall,", + "And if one green bottle should accidentally fall,", + "There'll be no green bottles hanging on the wall.", + ] + elif i != start - take + 1: + verse = [ + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower()} green " + f"{'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + "", + ] + else: + verse = [ + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + f"{NUMBERS[i - 1]} green bottles hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower()} green " + f"{'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + ] + result += verse + return result From 037ed3a4c71ea7f3f46c2a56a31b79f4d70f9b9e Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 02:51:21 +0000 Subject: [PATCH 5/7] [Sync Iteration] python/bottle-song/5 --- solutions/python/bottle-song/5/bottle_song.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 solutions/python/bottle-song/5/bottle_song.py diff --git a/solutions/python/bottle-song/5/bottle_song.py b/solutions/python/bottle-song/5/bottle_song.py new file mode 100644 index 0000000..224ecb2 --- /dev/null +++ b/solutions/python/bottle-song/5/bottle_song.py @@ -0,0 +1,53 @@ +""" +Bottle Song. + +Recite verses from the children's song "Ten Green Bottles". + +This module exposes the precomputed lyrics and a helper to +extract slices of the song by verse. +""" + +NUMBERS: tuple = ( + "One", + "Two", + "Three", + "Four", + "Five", + "Six", + "Seven", + "Eight", + "Nine", + "Ten", +) + + +def recite(start: int, take: int = 1) -> list[str]: + """ + Return a slice of the song lyrics corresponding to ``take`` consecutive + verses starting from the verse that begins with ``start`` green bottles. + + The lyrics are generated as a flat list where each verse occupies five lines + (four lyric lines plus a trailing blank line). This function generates the + requested verses dynamically based on the song's pattern. + + :param start: The number of green bottles to start from (e.g., 10 for + "Ten green bottles"). Must be between 1 and 10. + :param take: Number of consecutive verses to include starting at ``start``. + Defaults to 1. + :returns: A list of lyric lines forming the requested verses. + """ + result: list[str] = [] + for i in range(start, start - take, -1): + result += [ + f"{NUMBERS[i - 1]} green " + f"{'bottles' if NUMBERS[i - 1] != 'One' else 'bottle'} hanging on the wall,", + f"{NUMBERS[i - 1]} green " + f"{'bottles' if NUMBERS[i - 1] != 'One' else 'bottle'} hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower() if (i - 2) > -1 else 'no'} green " + f"{'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + ] + if i != start - take + 1: + result.append("") + return result From 3c62b1056ac03ed0176a06ef3ae0dbd9b7cc7420 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 02:53:45 +0000 Subject: [PATCH 6/7] [Sync Iteration] python/bottle-song/6 --- solutions/python/bottle-song/6/bottle_song.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 solutions/python/bottle-song/6/bottle_song.py diff --git a/solutions/python/bottle-song/6/bottle_song.py b/solutions/python/bottle-song/6/bottle_song.py new file mode 100644 index 0000000..ef96d37 --- /dev/null +++ b/solutions/python/bottle-song/6/bottle_song.py @@ -0,0 +1,52 @@ +""" +Bottle Song. + +Recite verses from the children's song "Ten Green Bottles". + +This module exposes the precomputed lyrics and a helper to +extract slices of the song by verse. +""" + +NUMBERS: tuple = ( + "One", + "Two", + "Three", + "Four", + "Five", + "Six", + "Seven", + "Eight", + "Nine", + "Ten", +) + + +def recite(start: int, take: int = 1) -> list[str]: + """ + Return a slice of the song lyrics. + + The lyrics are generated as a flat list where each verse occupies five lines + (four lyric lines plus a trailing blank line). This function generates the + requested verses dynamically based on the song's pattern. + + :param start: The number of green bottles to start from (e.g., 10 for + "Ten green bottles"). Must be between 1 and 10. + :param take: Number of consecutive verses to include starting at ``start``. + Defaults to 1. + :returns: A list of lyric lines forming the requested verses. + """ + result: list[str] = [] + for i in range(start, start - take, -1): + result += [ + f"{NUMBERS[i - 1]} green " + f"{'bottles' if NUMBERS[i - 1] != 'One' else 'bottle'} hanging on the wall,", + f"{NUMBERS[i - 1]} green " + f"{'bottles' if NUMBERS[i - 1] != 'One' else 'bottle'} hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower() if (i - 2) > -1 else 'no'} green " + f"{'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + ] + if i != start - take + 1: + result.append("") + return result From 1ade518d1a123d4774c76aa4207aba769193b3b8 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 02:57:31 +0000 Subject: [PATCH 7/7] [Sync Iteration] python/bottle-song/7 --- solutions/python/bottle-song/7/bottle_song.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 solutions/python/bottle-song/7/bottle_song.py diff --git a/solutions/python/bottle-song/7/bottle_song.py b/solutions/python/bottle-song/7/bottle_song.py new file mode 100644 index 0000000..fc6bb43 --- /dev/null +++ b/solutions/python/bottle-song/7/bottle_song.py @@ -0,0 +1,54 @@ +""" +Bottle Song. + +Recite verses from the children's song "Ten Green Bottles". + +This module exposes the precomputed lyrics and a helper to +extract slices of the song by verse. +""" + +NUMBERS: tuple = ( + "One", + "Two", + "Three", + "Four", + "Five", + "Six", + "Seven", + "Eight", + "Nine", + "Ten", +) + + +def recite(start: int, take: int = 1) -> list[str]: + """ + Return a slice of the song lyrics. + + The lyrics are generated as a flat list where each verse occupies five lines + (four lyric lines plus a trailing blank line). This function generates the + requested verses dynamically based on the song's pattern. + + :param start: The number of green bottles to start from (e.g., 10 for + "Ten green bottles"). Must be between 1 and 10. + :param take: Number of consecutive verses to include starting at ``start``. + Defaults to 1. + :returns: A list of lyric lines forming the requested verses. + """ + result: list[str] = [] + for i in range(start, start - take, -1): + result += [ + f"{NUMBERS[i - 1]} green " + f"{'bottles' if NUMBERS[i - 1] != 'One' else 'bottle'} " + f"hanging on the wall,", + f"{NUMBERS[i - 1]} green " + f"{'bottles' if NUMBERS[i - 1] != 'One' else 'bottle'} " + f"hanging on the wall,", + "And if one green bottle should accidentally fall,", + f"There'll be {NUMBERS[i - 2].lower() if (i - 2) > -1 else 'no'} green " + f"{'bottles' if NUMBERS[i - 2] != 'One' else 'bottle'} hanging on" + f" the wall.", + ] + if i != start - take + 1: + result.append("") + return result