forked from igorwojda/kotlin-coding-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
challenge.kt
60 lines (52 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.igorwojda.integer.countupanddown
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.Test
private fun countUpAndDown(n: Int): List<Int> {
TODO("not implemented")
}
private class Test {
@Test
fun `count up and down 0`() {
countUpAndDown(0) shouldBeEqualTo listOf(0)
}
@Test
fun `count up and down 1`() {
countUpAndDown(1) shouldBeEqualTo listOf(0, 1, 0)
}
@Test
fun `count up and down 2`() {
countUpAndDown(2) shouldBeEqualTo listOf(0, 1, 2, 1, 0)
}
@Test
fun `count up and down 3`() {
countUpAndDown(3) shouldBeEqualTo listOf(0, 1, 2, 3, 2, 1, 0)
}
@Test
fun `count up and down 4`() {
countUpAndDown(4) shouldBeEqualTo listOf(0, 1, 2, 3, 4, 3, 2, 1, 0)
}
@Test
fun `count up and down 9`() {
countUpAndDown(9) shouldBeEqualTo listOf(
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
8,
7,
6,
5,
4,
3,
2,
1,
0
)
}
}