trust

Finished
11def recite(start: int, take: int = 1) -> list[str]:
2 pass
2 result = []
3
4 # Edge Case: take is 0, return empty list
5 if take == 0:
6 return []
7
8 # Edge Case: start is negative, treat as 0
9 if start < 0:
10 start = 0
11
12 for i in range(take):
13 current = start - i
14
15 # Edge Case: current is less than 0, treat as 0
16 if current < 0:
17 break
18
19 # Handle the special case for 0 bottles
20 if current == 0:
21 result.append("No more bottles of beer on the wall, no more bottles of beer.")
22 result.append("Go to the store and buy some more, 99 bottles of beer on the wall.")
23 else:
24 # Determine bottle/bottles text
25 bottle_text = "bottle" if current == 1 else "bottles"
26 next_bottle_text = "bottle" if current - 1 == 1 else "bottles"
27
28 # First line
29 result.append(f"{current} {bottle_text} of beer on the wall, {current} {bottle_text} of beer.")
30
31 # Second line
32 if current == 1:
33 result.append("Take it down and pass it around, no more bottles of beer on the wall.")
34 else:
35 next_num = current - 1
36 if next_num == 0:
37 result.append("Take one down and pass it around, no more bottles of beer on the wall.")
38 else:
39 result.append(f"Take one down and pass it around, {next_num} {next_bottle_text} of beer on the wall.")
40
41 # Add empty line except after the last verse
42 if i < take - 1:
43 result.append("")
44
45 return result
46
47# Handled Edge Cases: take is 0, start is negative, current is less than 0
Test NameStatus
test_all_verses
Pass
test_first_generic_verse
Pass
test_first_two_verses
Pass
test_last_generic_verse
Pass
test_last_three_verses
Pass
test_verse_with_0_bottles
Pass
test_verse_with_1_bottle
Pass
test_verse_with_2_bottles
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.