Skip to content

Commit 563d35f

Browse files
* docs: kata description * feat: kata/basic-making-six-toast --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent f32846b commit 563d35f

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# [BASIC: Making Six Toast.](https://www.codewars.com/kata/basic-making-six-toast "https://www.codewars.com/kata/5834fec22fb0ba7d080000e8")
2+
3+
## Problem:
4+
5+
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.
6+
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.
9+
10+
## Examples:
11+
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:
13+
14+
```
15+
5 --> 1
16+
```
17+
18+
And in case of `12` you need `6` toasts less (but not `-6`):
19+
20+
```
21+
12 --> 6
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+
}

kata/8-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Area of a Square](area-of-a-square "5748838ce2fab90b86001b1a")
1414
- [Area or Perimeter](area-or-perimeter "5ab6538b379d20ad880000ab")
1515
- [Array plus array](array-plus-array "5a2be17aee1aaefe2a000151")
16+
- [BASIC: Making Six Toast.](basic-making-six-toast "5834fec22fb0ba7d080000e8")
1617
- [Basic Mathematical Operations](basic-mathematical-operations "57356c55867b9b7a60000bd7")
1718
- [Basic subclasses - Adam and Eve](basic-subclasses-adam-and-eve "547274e24481cfc469000416")
1819
- [Basic variable assignment](basic-variable-assignment "50ee6b0bdeab583673000025")

0 commit comments

Comments
 (0)