Skip to content

Commit

Permalink
Sync raindrops with problem-specifications (#547)
Browse files Browse the repository at this point in the history
* Rectify tests.toml for raindrops

This removes several entries for unimplemented tests.
See #370

* Delete extraneous test from raindrops

The 'big prime' test does not exist in the canonical-data
for this exercise.

* Normalize test descriptions in raindrops

This updates the raindrops tests to use the same test
descriptions as the canonical-data in problem-specifications.

* Sync raindrops with problem-specifications

This brings in updates to the instructions, normalizes the exercise's
config.json, and adds several new tests.
  • Loading branch information
kytrinyx authored Nov 15, 2022
1 parent 81425f0 commit 1929d49
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
6 changes: 5 additions & 1 deletion exercises/practice/raindrops/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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
2 changes: 1 addition & 1 deletion exercises/practice/raindrops/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"blurb": "Convert a number to a string, the content of which depends on the number's factors.",
"authors": [
"LegalizeAdulthood"
],
Expand All @@ -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"
}
13 changes: 10 additions & 3 deletions exercises/practice/raindrops/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
57 changes: 25 additions & 32 deletions exercises/practice/raindrops/raindrops_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1929d49

Please sign in to comment.