Skip to content

Commit 28244ed

Browse files
committed
1 parent 61b54a1 commit 28244ed

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
# [BASIC: Making Six Toast.](https://www.codewars.com/kata/basic-making-six-toast "https://www.codewars.com/kata/5834fec22fb0ba7d080000e8")
22

3-
# Story:
4-
5-
You are going to make toast fast, you think that you should make multiple pieces of toasts and once. So, you try to make 6 pieces of toast.
6-
7-
___
8-
9-
# Problem:
3+
## Problem:
104

115
You forgot to count the number of toast you put into there, you don't know if you put exactly six pieces of toast into the toasters.
126

13-
Define a function that counts how many more (or less) pieces of toast you need in the toasters. Even though you need more or less, the number will still be positive, not negative.
7+
Define a function that counts how many more (or less) pieces of toast you need in the toasters. Even though you need more or less, the
8+
number will still be positive, not negative.
149

1510
## Examples:
1611

17-
You must return the number of toast the you need to put in (or to take out). In case of `5` you can still put `1` toast in:
12+
You must return the number of toast you need to put in (or to take out). In case of `5` you can still put `1` toast in:
1813

1914
```
2015
5 --> 1
@@ -24,8 +19,4 @@ And in case of `12` you need `6` toasts less (but not `-6`):
2419

2520
```
2621
12 --> 6
27-
```
28-
29-
___
30-
31-
Good luck!
22+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata{
2+
static int sixToast(int num){
3+
return Math.abs(6 - num);
4+
}
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class SixToastTest {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
15, 9
10+
6 ,0
11+
3, 3
12+
""")
13+
void sample(int num, int expected) {
14+
assertEquals(expected, Kata.sixToast(num));
15+
}
16+
}

0 commit comments

Comments
 (0)