File tree Expand file tree Collapse file tree 4 files changed +44
-0
lines changed
Expand file tree Collapse file tree 4 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff line change 1+ interface Kata {
2+ static int sixToast (int num ){
3+ return Math .abs (6 - num );
4+ }
5+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 ")
You can’t perform that action at this time.
0 commit comments