diff --git a/exercises/practice/raindrops/.docs/instructions.md b/exercises/practice/raindrops/.docs/instructions.md index a78585df2..fc61d36e9 100644 --- a/exercises/practice/raindrops/.docs/instructions.md +++ b/exercises/practice/raindrops/.docs/instructions.md @@ -1,6 +1,8 @@ # Instructions -Your task is to convert a number into a string that contains raindrop sounds corresponding to certain potential factors. A factor is a number that evenly divides into another number, leaving no remainder. The simplest way to test if a one number is a factor of another is to use the [modulo operation](https://en.wikipedia.org/wiki/Modulo_operation). +Your task is to convert a number into a string that contains raindrop sounds corresponding to certain potential factors. +A factor is a number that evenly divides into another number, leaving no remainder. +The simplest way to test if one number is a factor of another is to use the [modulo operation][modulo]. The rules of `raindrops` are that if a given number: @@ -14,3 +16,5 @@ The rules of `raindrops` are that if a given number: - 28 has 7 as a factor, but not 3 or 5, so the result would be "Plong". - 30 has both 3 and 5 as factors, but not 7, so the result would be "PlingPlang". - 34 is not factored by 3, 5, or 7, so the result would be "34". + +[modulo]: https://en.wikipedia.org/wiki/Modulo_operation diff --git a/exercises/practice/raindrops/.meta/config.json b/exercises/practice/raindrops/.meta/config.json index 46a264e3c..8c5e3986e 100644 --- a/exercises/practice/raindrops/.meta/config.json +++ b/exercises/practice/raindrops/.meta/config.json @@ -1,5 +1,4 @@ { - "blurb": "Convert a number to a string, the content of which depends on the number's factors.", "authors": [ "LegalizeAdulthood" ], @@ -24,6 +23,7 @@ ".meta/example.h" ] }, + "blurb": "Convert a number to a string, the content of which depends on the number's factors.", "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" } diff --git a/exercises/practice/raindrops/.meta/tests.toml b/exercises/practice/raindrops/.meta/tests.toml index a97c6e1ab..756d16ca1 100644 --- a/exercises/practice/raindrops/.meta/tests.toml +++ b/exercises/practice/raindrops/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# 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. [1575d549-e502-46d4-a8e1-6b7bec6123d8] description = "the sound for 1 is 1" diff --git a/exercises/practice/raindrops/raindrops_test.cpp b/exercises/practice/raindrops/raindrops_test.cpp index bb8646717..92db5d307 100644 --- a/exercises/practice/raindrops/raindrops_test.cpp +++ b/exercises/practice/raindrops/raindrops_test.cpp @@ -5,84 +5,77 @@ #include "test/catch.hpp" #endif -TEST_CASE("one_yields_itself") +TEST_CASE("the_sound_for_1_is_1") { REQUIRE("1" == raindrops::convert(1)); } - #if defined(EXERCISM_RUN_ALL_TESTS) -TEST_CASE("three_yields_pling") +TEST_CASE("the_sound_for_3_is_pling") { REQUIRE("Pling" == raindrops::convert(3)); } - -TEST_CASE("five_yields_plang") +TEST_CASE("the_sound_for_5_is_plang") { REQUIRE("Plang" == raindrops::convert(5)); } - -TEST_CASE("seven_yields_plong") +TEST_CASE("the_sound_for_7_is_plong") { REQUIRE("Plong" == raindrops::convert(7)); } - -TEST_CASE("six_yields_pling") +TEST_CASE("the_sound_for_6_is_pling_as_it_has_a_factor_3") { REQUIRE("Pling" == raindrops::convert(6)); } - -TEST_CASE("nine_yields_pling") +TEST_CASE("2_to_the_power_3_does_not_make_a_raindrop_sound_as_3_is_the_exponent_not_the_base") +{ + REQUIRE("8" == raindrops::convert(8)); +} +TEST_CASE("the_sound_for_9_is_pling_as_it_has_a_factor_3") { REQUIRE("Pling" == raindrops::convert(9)); } - -TEST_CASE("ten_yields_plang") +TEST_CASE("the_sound_for_10_is_plang_as_it_has_a_factor_5") { REQUIRE("Plang" == raindrops::convert(10)); } - -TEST_CASE("fourteen_yields_plong") +TEST_CASE("the_sound_for_14_is_plong_as_it_has_a_factor_of_7") { REQUIRE("Plong" == raindrops::convert(14)); } - -TEST_CASE("fifteen_yields_plingplang") +TEST_CASE("the_sound_for_15_is_plingplang_as_it_has_factors_3_and_5") { REQUIRE("PlingPlang" == raindrops::convert(15)); } - -TEST_CASE("twenty_one_yields_plingplong") +TEST_CASE("the_sound_for_21_is_plingplong_as_it_has_factors_3_and_7") { REQUIRE("PlingPlong" == raindrops::convert(21)); } - -TEST_CASE("twenty_five_yields_plang") +TEST_CASE("the_sound_for_25_is_plang_as_it_has_a_factor_5") { REQUIRE("Plang" == raindrops::convert(25)); } - -TEST_CASE("thirty_five_yields_plangplong") +TEST_CASE("the_sound_for_27_is_pling_as_it_has_a_factor_3") +{ + REQUIRE("Pling" == raindrops::convert(27)); +} +TEST_CASE("the_sound_for_35_is_plangplong_as_it_has_factors_5_and_7") { REQUIRE("PlangPlong" == raindrops::convert(35)); } - -TEST_CASE("forty_nine_yields_plong") +TEST_CASE("the_sound_for_49_is_plong_as_it_has_a_factor_7") { REQUIRE("Plong" == raindrops::convert(49)); } - -TEST_CASE("fifty_two_yields_itself") +TEST_CASE("the_sound_for_52_is_52") { REQUIRE("52" == raindrops::convert(52)); } - -TEST_CASE("one_hundred_five_yields_plingplangplong") +TEST_CASE("the_sound_for_105_is_plingplangplong_as_it_has_factors_3_5_and_7") { REQUIRE("PlingPlangPlong" == raindrops::convert(105)); } - -TEST_CASE("big_prime_yields_itself") +TEST_CASE("the_sound_for_3125_is_plang_as_it_has_a_factor_5") { - REQUIRE("12121" == raindrops::convert(12121)); + REQUIRE("Plang" == raindrops::convert(3125)); } #endif