-
-
Notifications
You must be signed in to change notification settings - Fork 3
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` * Skip subsequent tests
- Loading branch information
Showing
8 changed files
with
294 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": [ | ||
"BNAndras" | ||
], | ||
"files": { | ||
"solution": [ | ||
"src/bottle-song.art" | ||
], | ||
"test": [ | ||
"tests/test-bottle-song.art" | ||
], | ||
"example": [ | ||
".meta/src/example.art" | ||
] | ||
}, | ||
"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,28 @@ | ||
decimalOrdinal: ["no" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten"] | ||
|
||
recite: function [startBottles takeDown][ | ||
verses: fold.seed:[] 1..takeDown [acc i] [ | ||
currentBottle: startBottles - dec i | ||
nextBottle: dec currentBottle | ||
bottles: case currentBottle [ | ||
2 -> "bottle" | ||
any -> "bottles" | ||
] | ||
case currentBottle [ | ||
1 -> acc ++ [{ | ||
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. | ||
}] | ||
any -> acc ++ join.with:"\n" @[ | ||
~"|capitalize decimalOrdinal\[currentBottle]| green bottles hanging on the wall," | ||
~"|capitalize decimalOrdinal\[currentBottle]| green bottles hanging on the wall," | ||
"And if one green bottle should accidentally fall," | ||
~"There'll be |decimalOrdinal\[nextBottle]| green |bottles| hanging on the wall." | ||
] | ||
] | ||
] | ||
|
||
join.with:"\n\n" verses | ||
] |
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 @@ | ||
# 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. | ||
|
||
[d4ccf8fc-01dc-48c0-a201-4fbeb30f2d03] | ||
description = "verse -> single verse -> first generic verse" | ||
|
||
[0f0aded3-472a-4c64-b842-18d4f1f5f030] | ||
description = "verse -> single verse -> last generic verse" | ||
|
||
[f61f3c97-131f-459e-b40a-7428f3ed99d9] | ||
description = "verse -> single verse -> verse with 2 bottles" | ||
|
||
[05eadba9-5dbd-401e-a7e8-d17cc9baa8e0] | ||
description = "verse -> single verse -> verse with 1 bottle" | ||
|
||
[a4a28170-83d6-4dc1-bd8b-319b6abb6a80] | ||
description = "lyrics -> multiple verses -> first two verses" | ||
|
||
[3185d438-c5ac-4ce6-bcd3-02c9ff1ed8db] | ||
description = "lyrics -> multiple verses -> last three verses" | ||
|
||
[28c1584a-0e51-4b65-9ae2-fbc0bf4bbb28] | ||
description = "lyrics -> multiple verses -> all verses" |
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,3 @@ | ||
recite: function [startBottles takeDown][ | ||
panic "please implement the recite function" | ||
] |
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,3 @@ | ||
import {unitt}! | ||
|
||
runTests.failFast findTests "tests" |
145 changes: 145 additions & 0 deletions
145
exercises/practice/bottle-song/tests/test-bottle-song.art
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,145 @@ | ||
import {unitt}! | ||
import {src/bottle-song}! | ||
|
||
suite "Bottle Song" [ | ||
suite "single verse" [ | ||
test "first generic verse" [ | ||
result: recite 10 1 | ||
expected: { | ||
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. | ||
} | ||
assert -> expected = result | ||
] | ||
|
||
test.skip "last generic verse" [ | ||
result: recite 3 1 | ||
expected: { | ||
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. | ||
} | ||
assert -> expected = result | ||
] | ||
|
||
test.skip "verse with 2 bottles" [ | ||
result: recite 2 1 | ||
expected: { | ||
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. | ||
} | ||
assert -> expected = result | ||
] | ||
|
||
test.skip "verse with 1 bottle" [ | ||
result: recite 1 1 | ||
expected: { | ||
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. | ||
} | ||
assert -> expected = result | ||
] | ||
] | ||
|
||
suite "multiple verses" [ | ||
test.skip "first two verses" [ | ||
result: recite 10 2 | ||
expected: { | ||
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. | ||
} | ||
assert -> expected = result | ||
] | ||
|
||
test.skip "last three verses" [ | ||
result: recite 3 3 | ||
expected: { | ||
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. | ||
} | ||
assert -> expected = result | ||
] | ||
|
||
test.skip "all verses" [ | ||
result: recite 10 10 | ||
expected: { | ||
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. | ||
} | ||
assert -> expected = result | ||
] | ||
] | ||
] |