Skip to content

Commit b53a879

Browse files
Ten Green Bottles (#2097)
1 parent 2901afc commit b53a879

File tree

4 files changed

+267
-0
lines changed

4 files changed

+267
-0
lines changed

exercises/beer-song/.deprecated

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**NOTE: This exercise has been deprecated**
2+
Your track should implement "bottle-song" instead.
3+
https://github.com/exercism/problem-specifications/issues/2066
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
{
2+
"exercise": "bottle-song",
3+
"cases": [
4+
{
5+
"description": "verse",
6+
"cases": [
7+
{
8+
"description": "single verse",
9+
"cases": [
10+
{
11+
"uuid": "d4ccf8fc-01dc-48c0-a201-4fbeb30f2d03",
12+
"description": "first generic verse",
13+
"property": "recite",
14+
"input": {
15+
"startBottles": 10,
16+
"takeDown": 1
17+
},
18+
"expected": [
19+
"Ten green bottles hanging on the wall,",
20+
"Ten green bottles hanging on the wall,",
21+
"And if one green bottle should accidentally fall,",
22+
"There'll be nine green bottles hanging on the wall."
23+
]
24+
},
25+
{
26+
"uuid": "0f0aded3-472a-4c64-b842-18d4f1f5f030",
27+
"description": "last generic verse",
28+
"property": "recite",
29+
"input": {
30+
"startBottles": 3,
31+
"takeDown": 1
32+
},
33+
"expected": [
34+
"Three green bottles hanging on the wall,",
35+
"Three green bottles hanging on the wall,",
36+
"And if one green bottle should accidentally fall,",
37+
"There'll be two green bottles hanging on the wall."
38+
]
39+
},
40+
{
41+
"uuid": "f61f3c97-131f-459e-b40a-7428f3ed99d9",
42+
"description": "verse with 2 bottles",
43+
"property": "recite",
44+
"input": {
45+
"startBottles": 2,
46+
"takeDown": 1
47+
},
48+
"expected": [
49+
"Two green bottles hanging on the wall,",
50+
"Two green bottles hanging on the wall,",
51+
"And if one green bottle should accidentally fall,",
52+
"There'll be one green bottle hanging on the wall."
53+
]
54+
},
55+
{
56+
"uuid": "05eadba9-5dbd-401e-a7e8-d17cc9baa8e0",
57+
"description": "verse with 1 bottle",
58+
"property": "recite",
59+
"input": {
60+
"startBottles": 1,
61+
"takeDown": 1
62+
},
63+
"expected": [
64+
"One green bottles hanging on the wall,",
65+
"One green bottles hanging on the wall,",
66+
"And if one green bottle should accidentally fall,",
67+
"There'll be no green bottles hanging on the wall."
68+
]
69+
}
70+
]
71+
}
72+
]
73+
},
74+
{
75+
"description": "lyrics",
76+
"cases": [
77+
{
78+
"description": "multiple verses",
79+
"cases": [
80+
{
81+
"uuid": "a4a28170-83d6-4dc1-bd8b-319b6abb6a80",
82+
"description": "first two verses",
83+
"property": "recite",
84+
"input": {
85+
"startBottles": 10,
86+
"takeDown": 2
87+
},
88+
"expected": [
89+
"Ten green bottles hanging on the wall,",
90+
"Ten green bottles hanging on the wall,",
91+
"And if one green bottle should accidentally fall,",
92+
"There'll be nine green bottles hanging on the wall.",
93+
"",
94+
"Nine green bottles hanging on the wall,",
95+
"Nine green bottles hanging on the wall,",
96+
"And if one green bottle should accidentally fall,",
97+
"There'll be eight green bottles hanging on the wall."
98+
]
99+
},
100+
{
101+
"uuid": "3185d438-c5ac-4ce6-bcd3-02c9ff1ed8db",
102+
"description": "last three verses",
103+
"property": "recite",
104+
"input": {
105+
"startBottles": 3,
106+
"takeDown": 3
107+
},
108+
"expected": [
109+
"Three green bottles hanging on the wall,",
110+
"Three green bottles hanging on the wall,",
111+
"And if one green bottle should accidentally fall,",
112+
"There'll be two green bottles hanging on the wall.",
113+
"",
114+
"Two green bottles hanging on the wall,",
115+
"Two green bottles hanging on the wall,",
116+
"And if one green bottle should accidentally fall,",
117+
"There'll be one green bottle hanging on the wall.",
118+
"",
119+
"One green bottles hanging on the wall,",
120+
"One green bottles hanging on the wall,",
121+
"And if one green bottle should accidentally fall,",
122+
"There'll be no green bottles hanging on the wall."
123+
]
124+
},
125+
{
126+
"uuid": "28c1584a-0e51-4b65-9ae2-fbc0bf4bbb28",
127+
"description": "all verses",
128+
"property": "recite",
129+
"input": {
130+
"startBottles": 10,
131+
"takeDown": 10
132+
},
133+
"expected": [
134+
"Ten green bottles hanging on the wall,",
135+
"Ten green bottles hanging on the wall,",
136+
"And if one green bottle should accidentally fall,",
137+
"There'll be nine green bottles hanging on the wall.",
138+
"",
139+
"Nine green bottles hanging on the wall,",
140+
"Nine green bottles hanging on the wall,",
141+
"And if one green bottle should accidentally fall,",
142+
"There'll be eight green bottles hanging on the wall.",
143+
"",
144+
"Eight green bottles hanging on the wall,",
145+
"Eight green bottles hanging on the wall,",
146+
"And if one green bottle should accidentally fall,",
147+
"There'll be seven green bottles hanging on the wall.",
148+
"",
149+
"Seven green bottles hanging on the wall,",
150+
"Seven green bottles hanging on the wall,",
151+
"And if one green bottle should accidentally fall,",
152+
"There'll be six green bottles hanging on the wall.",
153+
"",
154+
"Six green bottles hanging on the wall,",
155+
"Six green bottles hanging on the wall,",
156+
"And if one green bottle should accidentally fall,",
157+
"There'll be five green bottles hanging on the wall.",
158+
"",
159+
"Five green bottles hanging on the wall,",
160+
"Five green bottles hanging on the wall,",
161+
"And if one green bottle should accidentally fall,",
162+
"There'll be four green bottles hanging on the wall.",
163+
"",
164+
"Four green bottles hanging on the wall,",
165+
"Four green bottles hanging on the wall,",
166+
"And if one green bottle should accidentally fall,",
167+
"There'll be three green bottles hanging on the wall.",
168+
"",
169+
"Three green bottles hanging on the wall,",
170+
"Three green bottles hanging on the wall,",
171+
"And if one green bottle should accidentally fall,",
172+
"There'll be two green bottles hanging on the wall.",
173+
"",
174+
"Two green bottles hanging on the wall,",
175+
"Two green bottles hanging on the wall,",
176+
"And if one green bottle should accidentally fall,",
177+
"There'll be one green bottle hanging on the wall.",
178+
"",
179+
"One green bottles hanging on the wall,",
180+
"One green bottles hanging on the wall,",
181+
"And if one green bottle should accidentally fall,",
182+
"There'll be no green bottles hanging on the wall."
183+
]
184+
}
185+
]
186+
}
187+
]
188+
}
189+
]
190+
}

exercises/bottle-song/description.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Description
2+
3+
Recite the lyrics to that popular children's repetitive song: Ten Green Bottles.
4+
5+
Note that not all verses are identical.
6+
7+
```text
8+
Ten green bottles hanging on the wall,
9+
Ten green bottles hanging on the wall,
10+
And if one green bottle should accidentally fall,
11+
There'll be nine green bottles hanging on the wall.
12+
13+
Nine green bottles hanging on the wall,
14+
Nine green bottles hanging on the wall,
15+
And if one green bottle should accidentally fall,
16+
There'll be eight green bottles hanging on the wall.
17+
18+
Eight green bottles hanging on the wall,
19+
Eight green bottles hanging on the wall,
20+
And if one green bottle should accidentally fall,
21+
There'll be seven green bottles hanging on the wall.
22+
23+
Seven green bottles hanging on the wall,
24+
Seven green bottles hanging on the wall,
25+
And if one green bottle should accidentally fall,
26+
There'll be six green bottles hanging on the wall.
27+
28+
Six green bottles hanging on the wall,
29+
Six green bottles hanging on the wall,
30+
And if one green bottle should accidentally fall,
31+
There'll be five green bottles hanging on the wall.
32+
33+
Five green bottles hanging on the wall,
34+
Five green bottles hanging on the wall,
35+
And if one green bottle should accidentally fall,
36+
There'll be four green bottles hanging on the wall.
37+
38+
Four green bottles hanging on the wall,
39+
Four green bottles hanging on the wall,
40+
And if one green bottle should accidentally fall,
41+
There'll be three green bottles hanging on the wall.
42+
43+
Three green bottles hanging on the wall,
44+
Three green bottles hanging on the wall,
45+
And if one green bottle should accidentally fall,
46+
There'll be two green bottles hanging on the wall.
47+
48+
Two green bottles hanging on the wall,
49+
Two green bottles hanging on the wall,
50+
And if one green bottle should accidentally fall,
51+
There'll be one green bottle hanging on the wall.
52+
53+
One green bottles hanging on the wall,
54+
One green bottles hanging on the wall,
55+
And if one green bottle should accidentally fall,
56+
There'll be no green bottles hanging on the wall.
57+
```
58+
59+
## For bonus points
60+
61+
Did you get the tests passing and the code clean?
62+
If you want to, these are some additional things you could try:
63+
64+
* Remove as much duplication as you possibly can.
65+
* Optimize for readability, even if it means introducing duplication.
66+
* If you've removed all the duplication, do you have a lot of conditionals?
67+
Try replacing the conditionals with polymorphism, if it applies in this language.
68+
How readable is it?
69+
70+
Then please share your thoughts in a comment on the submission.
71+
Did this experiment make the code better? Worse? Did you learn anything from it?

exercises/bottle-song/metadata.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
blurb = "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles."
2+
source = "Wikipedia"
3+
source_url = "https://en.wikipedia.org/wiki/Ten_Green_Bottles"

0 commit comments

Comments
 (0)