-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
2 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
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
"Remove this line and implement your solution" | halt_error | ||
def is_pling: . % 3 == 0; | ||
def is_plang: . % 5 == 0; | ||
def is_plong: . % 7 == 0; | ||
|
||
def not_sound: (is_pling | not) and (is_plang | not ) and (is_plong | not); | ||
|
||
.number | if not_sound then (. | tostring) | ||
else ( | ||
(if is_pling then "Pling" else "" end )+ | ||
(if is_plang then "Plang" else "" end )+ | ||
(if is_plong then "Plong" else "" end) | ||
) end |
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 @@ | ||
|
||
[./test-raindrops.bats] | ||
|
||
bats ./test-raindrops.bats | ||
|
||
1..18 | ||
ok 1 the sound for 1 is 1 | ||
ok 2 the sound for 3 is Pling | ||
ok 3 the sound for 5 is Plang | ||
ok 4 the sound for 7 is Plong | ||
ok 5 the sound for 6 is Pling as it has a factor 3 | ||
ok 6 2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base | ||
ok 7 the sound for 9 is Pling as it has a factor 3 | ||
ok 8 the sound for 10 is Plang as it has a factor 5 | ||
ok 9 the sound for 14 is Plong as it has a factor of 7 | ||
ok 10 the sound for 15 is PlingPlang as it has factors 3 and 5 | ||
ok 11 the sound for 21 is PlingPlong as it has factors 3 and 7 | ||
ok 12 the sound for 25 is Plang as it has a factor 5 | ||
ok 13 the sound for 27 is Pling as it has a factor 3 | ||
ok 14 the sound for 35 is PlangPlong as it has factors 5 and 7 | ||
ok 15 the sound for 49 is Plong as it has a factor 7 | ||
ok 16 the sound for 52 is 52 | ||
ok 17 the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7 | ||
ok 18 the sound for 3125 is Plang as it has a factor 5 | ||
|
||
real 0m2.435s | ||
user 0m1.320s | ||
sys 0m1.185s |