diff --git a/kata/7-kyu/boiled-eggs/README.md b/kata/7-kyu/boiled-eggs/README.md new file mode 100644 index 00000000..e2689c79 --- /dev/null +++ b/kata/7-kyu/boiled-eggs/README.md @@ -0,0 +1,24 @@ +# [Boiled Eggs](https://www.codewars.com/kata/boiled-eggs "https://www.codewars.com/kata/52b5247074ea613a09000164") + +You are the greatest chef on earth. No one boils eggs like you! Your restaurant is always full of guests, who love your boiled eggs. But +when there is a greater order of boiled eggs, you need some time, because you have only one pot for your job. How much time do you need? + +## Your Task + +Implement a function, which takes a non-negative integer, representing the number of eggs to boil. It must return the time in minutes ( +integer), which it takes to have all the eggs boiled. + +## Rules + +* you can put at most 8 eggs into the pot at once +* it takes 5 minutes to boil an egg +* we assume, that the water is boiling all the time (no time to heat up) +* for simplicity, we also don't consider the time it takes to put eggs into the pot or get them out of it + +## Example (Input --> Output) + +``` +0 --> 0 +5 --> 5 +10 --> 10 +``` \ No newline at end of file diff --git a/kata/7-kyu/boiled-eggs/main/BoilingWater.java b/kata/7-kyu/boiled-eggs/main/BoilingWater.java new file mode 100644 index 00000000..32093684 --- /dev/null +++ b/kata/7-kyu/boiled-eggs/main/BoilingWater.java @@ -0,0 +1,5 @@ +interface BoilingWater{ + static int cookingTime(int eggs) { + return (eggs + 7) / 8 * 5; + } +} \ No newline at end of file diff --git a/kata/7-kyu/boiled-eggs/test/SolutionTest.java b/kata/7-kyu/boiled-eggs/test/SolutionTest.java new file mode 100644 index 00000000..e5eaf8e6 --- /dev/null +++ b/kata/7-kyu/boiled-eggs/test/SolutionTest.java @@ -0,0 +1,17 @@ +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +class SolutionTest { + @ParameterizedTest + @CsvSource(textBlock = """ + 0, 0 + 5, 5 + 10, 10 + 90072355, 56295225 + """) + void sample(int eggs, int time) { + assertEquals(time, BoilingWater.cookingTime(eggs)); + } +} \ No newline at end of file diff --git a/kata/7-kyu/index.md b/kata/7-kyu/index.md index 249eee7e..fb3e281f 100644 --- a/kata/7-kyu/index.md +++ b/kata/7-kyu/index.md @@ -57,6 +57,7 @@ - [Bits Battle](bits-battle "58856a06760b85c4e6000055") - [Blood Moon](blood-moon "5cba04533e6dce000eaf6126") - [Blowing Birthday Candles](blowing-birthday-candles "6630da20f925eb3007c5a498") +- [Boiled Eggs](boiled-eggs "52b5247074ea613a09000164") - [Breaking chocolate problem](breaking-chocolate-problem "534ea96ebb17181947000ada") - [Broken sequence](broken-sequence "5512e5662b34d88e44000060") - [Bubblesort Once](bubblesort-once "56b97b776ffcea598a0006f2")