| 1 | 1 | def recite(start: int, take: int = 1) -> list[str]: |
| 2 | | pass |
| 2 | verses = [] |
| 3 | |
| 4 | # Edge Case: Handle when take is 0 or negative |
| 5 | if take <= 0: |
| 6 | return [] |
| 7 | |
| 8 | # Edge Case: Handle when start is negative |
| 9 | if start < 0: |
| 10 | start = 0 |
| 11 | |
| 12 | for i in range(take): |
| 13 | current_bottles = start - i |
| 14 | |
| 15 | # Edge Case: Handle when current_bottles is less than 0 |
| 16 | if current_bottles < 0: |
| 17 | break |
| 18 | |
| 19 | # Handle the case for 0 bottles |
| 20 | if current_bottles == 0: |
| 21 | line1 = "No more bottles of beer on the wall, no more bottles of beer." |
| 22 | line2 = "Go to the store and buy some more, 99 bottles of beer on the wall." |
| 23 | # Handle the case for 1 bottle |
| 24 | elif current_bottles == 1: |
| 25 | line1 = "1 bottle of beer on the wall, 1 bottle of beer." |
| 26 | line2 = "Take it down and pass it around, no more bottles of beer on the wall." |
| 27 | # Handle the case for 2 bottles |
| 28 | elif current_bottles == 2: |
| 29 | line1 = "2 bottles of beer on the wall, 2 bottles of beer." |
| 30 | line2 = "Take one down and pass it around, 1 bottle of beer on the wall." |
| 31 | # Handle all other cases |
| 32 | else: |
| 33 | line1 = f"{current_bottles} bottles of beer on the wall, {current_bottles} bottles of beer." |
| 34 | line2 = f"Take one down and pass it around, {current_bottles - 1} bottles of beer on the wall." |
| 35 | |
| 36 | verses.append(line1) |
| 37 | verses.append(line2) |
| 38 | |
| 39 | # Add empty line between verses, but not after the last verse |
| 40 | if i < take - 1: |
| 41 | verses.append("") |
| 42 | |
| 43 | return verses |
| 44 | |
| 45 | # Handled Edge Cases: take is 0 or negative, start is negative, current_bottles is less than 0 |