File tree Expand file tree Collapse file tree 4 files changed +31
-0
lines changed Expand file tree Collapse file tree 4 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 387
387
- [ Password maker] ( password-maker " 5637b03c6be7e01d99000046 ")
388
388
- [ Password System] ( password-system " 57a23e3753ba332b8e0008da ")
389
389
- [ Paul's Misery] ( pauls-misery " 57ee31c5e77282c24d000024 ")
390
+ - [ Perimeter sequence] ( perimeter-sequence " 589519d1f0902e01af000054 ")
390
391
- [ Perpendicular lines] ( perpendicular-lines-1 " 6391fe3f322221003db3bad6 ")
391
392
- [ Pizza Payments] ( pizza-payments " 5b043e3886d0752685000009 ")
392
393
- [ Plan Your Dream Wedding] ( plan-your-dream-wedding " 66314d6b7cb7030393dddf8a ")
Original file line number Diff line number Diff line change
1
+ # [ Perimeter sequence] ( https://www.codewars.com/kata/perimeter-sequence " https://www.codewars.com/kata/589519d1f0902e01af000054 ")
2
+
3
+ The first three stages of a sequence are shown.
4
+
5
+ ![ blocks] ( https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTVw-YEuGbD31EB47C7PSi_RpBxr5EJSydV9dj5lOmzsDWFsoAs )
6
+
7
+ The block size is ` a ` by ` a ` and ` a ≥ 1 ` .
8
+
9
+ What is the perimeter of the ` n ` th shape in the sequence (` n ≥ 1 ` ) ?
Original file line number Diff line number Diff line change
1
+ interface Kata {
2
+ static int perimeterSequence (int a , int n ){
3
+ return 4 * a * n ;
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 PerimeterSequenceTest {
7
+ @ ParameterizedTest
8
+ @ CsvSource (textBlock = """
9
+ 1, 1, 4
10
+ 1, 2, 8
11
+ 1, 3, 12
12
+ """ )
13
+ void sample (int a , int n , int p ) {
14
+ assertEquals (p , Kata .perimeterSequence (a , n ));
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments