-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Bottle Song" exercise and test suite (#252)
* Add "Bottle Song" exercise and test suite A new exercise called "Bottle Song" has been introduced. This includes corresponding test suite for the exercise. Modification was also made to update the average run time value in the config file. Overall, this commit provides a new practice exercise for users to solve. * Update config file with reordering and run time adjustment Repositioned the "Bottle Song" exercise in the configuration file for better flow. The average run time value for the test runner was also corrected from 2.0 to 2. These modifications should enhance the setup for users working through exercises. * Add skip functionality to bottle-song tests A condition to skip individual tests has been added to the test-bottle-song.bats file. This will allow us to selectively run or skip certain tests, providing a more flexible testing approach.
- Loading branch information
Jegors Čemisovs
authored
Apr 11, 2024
1 parent
5a90993
commit c62627c
Showing
8 changed files
with
947 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Instructions | ||
|
||
Recite the lyrics to that popular children's repetitive song: Ten Green Bottles. | ||
|
||
Note that not all verses are identical. | ||
|
||
```text | ||
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. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"authors": [ | ||
"rabestro" | ||
], | ||
"files": { | ||
"solution": [ | ||
"bottle-song.awk" | ||
], | ||
"test": [ | ||
"test-bottle-song.bats" | ||
], | ||
"example": [ | ||
".meta/example.awk" | ||
] | ||
}, | ||
"blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.", | ||
"source": "Wikipedia", | ||
"source_url": "https://en.wikipedia.org/wiki/Ten_Green_Bottles" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# These variables are initialized on the command line (using '-v'): | ||
# - startBottles | ||
# - takeDown | ||
|
||
BEGIN { | ||
split("One Two Three Four Five Six Seven Eight Nine Ten", Numbers) | ||
|
||
while (takeDown--) { | ||
print_verse(startBottles--) | ||
if (takeDown) print "" | ||
} | ||
} | ||
|
||
function print_verse(bottles) { | ||
print first_line(bottles) | ||
print first_line(bottles) | ||
print "And if one green bottle should accidentally fall," | ||
print last_line(bottles - 1) | ||
} | ||
|
||
function first_line(bottles) { | ||
return Numbers[bottles] hanging(bottles) "," | ||
} | ||
|
||
function last_line(bottles) { | ||
return "There'll be " tolower(bottles == 0 ? "no" : Numbers[bottles]) hanging(bottles) "." | ||
} | ||
|
||
function hanging(bottles) { | ||
return " green bottle" (bottles == 1 ? "" : "s") " hanging on the wall" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[5a02fd08-d336-4607-8006-246fe6fa9fb0] | ||
description = "verse -> single verse -> first generic verse" | ||
|
||
[77299ca6-545e-4217-a9cc-606b342e0187] | ||
description = "verse -> single verse -> last generic verse" | ||
|
||
[102cbca0-b197-40fd-b548-e99609b06428] | ||
description = "verse -> single verse -> verse with 2 bottles" | ||
|
||
[b8ef9fce-960e-4d85-a0c9-980a04ec1972] | ||
description = "verse -> single verse -> verse with 1 bottle" | ||
|
||
[c59d4076-f671-4ee3-baaa-d4966801f90d] | ||
description = "verse -> single verse -> verse with 0 bottles" | ||
|
||
[7e17c794-402d-4ca6-8f96-4d8f6ee1ec7e] | ||
description = "lyrics -> multiple verses -> first two verses" | ||
|
||
[949868e7-67e8-43d3-9bb4-69277fe020fb] | ||
description = "lyrics -> multiple verses -> last three verses" | ||
|
||
[bc220626-126c-4e72-8df4-fddfc0c3e458] | ||
description = "lyrics -> multiple verses -> all verses" |
Oops, something went wrong.