forked from igorwojda/kotlin-coding-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Challenge.kt
executable file
·37 lines (32 loc) · 1.17 KB
/
Challenge.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.igorwojda.matrix.spiralmatrixgenerator
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.Test
private fun generateSpiralMatrix(n: Int): List<MutableList<Int?>> {
TODO("Add your solution here")
}
private class Test {
@Test
fun `generateSpiralMatrix generates a 2x2 matrix`() {
val matrix = generateSpiralMatrix(2)
matrix.size shouldBeEqualTo 2
matrix[0] shouldBeEqualTo listOf(1, 2)
matrix[1] shouldBeEqualTo listOf(4, 3)
}
@Test
fun `generateSpiralMatrix generates a 3x3 matrix`() {
val matrix = generateSpiralMatrix(3)
matrix.size shouldBeEqualTo 3
matrix[0] shouldBeEqualTo listOf(1, 2, 3)
matrix[1] shouldBeEqualTo listOf(8, 9, 4)
matrix[2] shouldBeEqualTo listOf(7, 6, 5)
}
@Test
fun `generateSpiralMatrix generates a 4x4 matrix`() {
val matrix = generateSpiralMatrix(4)
matrix.size shouldBeEqualTo 4
matrix[0] shouldBeEqualTo listOf(1, 2, 3, 4)
matrix[1] shouldBeEqualTo listOf(12, 13, 14, 5)
matrix[2] shouldBeEqualTo listOf(11, 16, 15, 6)
matrix[3] shouldBeEqualTo listOf(10, 9, 8, 7)
}
}