Skip to content

Commit a60c3be

Browse files
* docs: kata description * feat: kata/perimeter-sequence --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent ab3e764 commit a60c3be

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

kata/7-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@
387387
- [Password maker](password-maker "5637b03c6be7e01d99000046")
388388
- [Password System](password-system "57a23e3753ba332b8e0008da")
389389
- [Paul's Misery](pauls-misery "57ee31c5e77282c24d000024")
390+
- [Perimeter sequence](perimeter-sequence "589519d1f0902e01af000054")
390391
- [Perpendicular lines](perpendicular-lines-1 "6391fe3f322221003db3bad6")
391392
- [Pizza Payments](pizza-payments "5b043e3886d0752685000009")
392393
- [Plan Your Dream Wedding](plan-your-dream-wedding "66314d6b7cb7030393dddf8a")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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`) ?
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata{
2+
static int perimeterSequence(int a, int n){
3+
return 4 * a * n;
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 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+
}

0 commit comments

Comments
 (0)