Skip to content

Commit e331d2b

Browse files
authored
Added tests for tasks 556-3142
1 parent 433d0bb commit e331d2b

File tree

5 files changed

+351
-0
lines changed

5 files changed

+351
-0
lines changed

src/test/kotlin/g0501_0600/s0556_next_greater_element_iii/SolutionTest.kt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,69 @@ internal class SolutionTest {
1414
fun nextGreaterElement2() {
1515
assertThat(Solution().nextGreaterElement(21), equalTo(-1))
1616
}
17+
18+
@Test
19+
fun nextGreaterElement3() {
20+
assertThat(Solution().nextGreaterElement(1234), equalTo(1243))
21+
}
22+
23+
@Test
24+
fun nextGreaterElement4() {
25+
assertThat(Solution().nextGreaterElement(4321), equalTo(-1))
26+
}
27+
28+
@Test
29+
fun nextGreaterElement5() {
30+
assertThat(Solution().nextGreaterElement(115), equalTo(151))
31+
}
32+
33+
@Test
34+
fun nextGreaterElement6() {
35+
assertThat(Solution().nextGreaterElement(111), equalTo(-1))
36+
}
37+
38+
@Test
39+
fun nextGreaterElement7() {
40+
assertThat(Solution().nextGreaterElement(12443322), equalTo(13222344))
41+
}
42+
43+
@Test
44+
fun nextGreaterElement8() {
45+
assertThat(Solution().nextGreaterElement(230241), equalTo(230412))
46+
}
47+
48+
@Test
49+
fun nextGreaterElement9() {
50+
assertThat(Solution().nextGreaterElement(1999999999), equalTo(-1))
51+
}
52+
53+
@Test
54+
fun nextGreaterElement10() {
55+
assertThat(Solution().nextGreaterElement(218765), equalTo(251678))
56+
}
57+
58+
@Test
59+
fun nextGreaterElement11() {
60+
assertThat(Solution().nextGreaterElement(7), equalTo(-1))
61+
}
62+
63+
@Test
64+
fun nextGreaterElement12() {
65+
assertThat(Solution().nextGreaterElement(132), equalTo(213))
66+
}
67+
68+
@Test
69+
fun nextGreaterElement13() {
70+
assertThat(Solution().nextGreaterElement(534976), equalTo(536479))
71+
}
72+
73+
@Test
74+
fun nextGreaterElement14() {
75+
assertThat(Solution().nextGreaterElement(1998), equalTo(8199))
76+
}
77+
78+
@Test
79+
fun nextGreaterElement15() {
80+
assertThat(Solution().nextGreaterElement(2147483647), equalTo(-1))
81+
}
1782
}

src/test/kotlin/g0801_0900/s0840_magic_squares_in_grid/SolutionTest.kt

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,116 @@ internal class SolutionTest {
1818
fun numMagicSquaresInside2() {
1919
assertThat(Solution().numMagicSquaresInside(arrayOf(intArrayOf(8))), equalTo(0))
2020
}
21+
22+
@Test
23+
fun numMagicSquaresInside3() {
24+
val grid = arrayOf(
25+
intArrayOf(8, 1, 6),
26+
intArrayOf(3, 5, 7),
27+
intArrayOf(4, 9, 2),
28+
)
29+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(1))
30+
}
31+
32+
@Test
33+
fun numMagicSquaresInside4() {
34+
val grid = arrayOf(
35+
intArrayOf(8, 1, 6, 8, 1, 6),
36+
intArrayOf(3, 5, 7, 3, 5, 7),
37+
intArrayOf(4, 9, 2, 4, 9, 2),
38+
)
39+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(2))
40+
}
41+
42+
@Test
43+
fun numMagicSquaresInside5() {
44+
val grid = arrayOf(
45+
intArrayOf(8, 1, 6, 1),
46+
intArrayOf(3, 5, 7, 5),
47+
intArrayOf(4, 9, 2, 9),
48+
intArrayOf(8, 1, 6, 1),
49+
)
50+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(1))
51+
}
52+
53+
@Test
54+
fun numMagicSquaresInside6() {
55+
val grid = arrayOf(
56+
intArrayOf(8, 1, 6),
57+
intArrayOf(3, 5, 7),
58+
intArrayOf(4, 9, 8),
59+
)
60+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(0))
61+
}
62+
63+
@Test
64+
fun numMagicSquaresInside7() {
65+
val grid = arrayOf(
66+
intArrayOf(8, 1, 6),
67+
intArrayOf(3, 5, 20),
68+
intArrayOf(4, 9, 2),
69+
)
70+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(0))
71+
}
72+
73+
@Test
74+
fun numMagicSquaresInside8() {
75+
val grid = arrayOf(
76+
intArrayOf(8, 1, 6),
77+
intArrayOf(3, 5, 7),
78+
intArrayOf(4, 2, 9),
79+
)
80+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(0))
81+
}
82+
83+
@Test
84+
fun numMagicSquaresInside9() {
85+
val grid = arrayOf(
86+
intArrayOf(8, 1, 6),
87+
intArrayOf(3, 5, 7),
88+
intArrayOf(4, 9, 3),
89+
)
90+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(0))
91+
}
92+
93+
@Test
94+
fun numMagicSquaresInside10() {
95+
val grid = arrayOf(
96+
intArrayOf(1, 2),
97+
intArrayOf(3, 4),
98+
intArrayOf(5, 6),
99+
)
100+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(0))
101+
}
102+
103+
@Test
104+
fun numMagicSquaresInside11() {
105+
val grid = arrayOf(
106+
intArrayOf(1, 2, 3),
107+
intArrayOf(4, 5, 6),
108+
)
109+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(0))
110+
}
111+
112+
@Test
113+
fun numMagicSquaresInside12() {
114+
val grid = arrayOf(
115+
intArrayOf(1, 2, 3, 8),
116+
intArrayOf(4, 5, 6, 1),
117+
intArrayOf(7, 8, 9, 6),
118+
intArrayOf(3, 5, 7, 7),
119+
)
120+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(0))
121+
}
122+
123+
@Test
124+
fun numMagicSquaresInside13() {
125+
val grid = arrayOf(
126+
intArrayOf(8, 1, 6, 8),
127+
intArrayOf(3, 5, 7, 3),
128+
intArrayOf(4, 9, 2, 4),
129+
intArrayOf(8, 1, 6, 99),
130+
)
131+
assertThat(Solution().numMagicSquaresInside(grid), equalTo(1))
132+
}
21133
}

src/test/kotlin/g1101_1200/s1185_day_of_the_week/SolutionTest.kt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,69 @@ internal class SolutionTest {
1919
fun dayOfTheWeek3() {
2020
assertThat(Solution().dayOfTheWeek(15, 8, 1993), equalTo("Sunday"))
2121
}
22+
23+
@Test
24+
fun dayOfTheWeek4() {
25+
assertThat(Solution().dayOfTheWeek(1, 1, 1971), equalTo("Friday"))
26+
}
27+
28+
@Test
29+
fun dayOfTheWeek5() {
30+
assertThat(Solution().dayOfTheWeek(29, 2, 2020), equalTo("Saturday"))
31+
}
32+
33+
@Test
34+
fun dayOfTheWeek6() {
35+
assertThat(Solution().dayOfTheWeek(1, 3, 2020), equalTo("Sunday"))
36+
}
37+
38+
@Test
39+
fun dayOfTheWeek7() {
40+
assertThat(Solution().dayOfTheWeek(28, 2, 2019), equalTo("Thursday"))
41+
}
42+
43+
@Test
44+
fun dayOfTheWeek8() {
45+
assertThat(Solution().dayOfTheWeek(31, 12, 1999), equalTo("Friday"))
46+
}
47+
48+
@Test
49+
fun dayOfTheWeek9() {
50+
assertThat(Solution().dayOfTheWeek(1, 1, 2001), equalTo("Monday"))
51+
}
52+
53+
@Test
54+
fun dayOfTheWeek10() {
55+
assertThat(Solution().dayOfTheWeek(1, 1, 2000), equalTo("Saturday"))
56+
}
57+
58+
@Test
59+
fun dayOfTheWeek11() {
60+
assertThat(Solution().dayOfTheWeek(1, 3, 1900), equalTo("Monday"))
61+
}
62+
63+
@Test
64+
fun dayOfTheWeek12() {
65+
assertThat(Solution().dayOfTheWeek(15, 6, 2024), equalTo("Saturday"))
66+
}
67+
68+
@Test
69+
fun dayOfTheWeek13() {
70+
assertThat(Solution().dayOfTheWeek(30, 11, 1985), equalTo("Saturday"))
71+
}
72+
73+
@Test
74+
fun dayOfTheWeek14() {
75+
assertThat(Solution().dayOfTheWeek(20, 4, 1975), equalTo("Sunday"))
76+
}
77+
78+
@Test
79+
fun dayOfTheWeek15() {
80+
assertThat(Solution().dayOfTheWeek(5, 1, 1971), equalTo("Tuesday"))
81+
}
82+
83+
@Test
84+
fun dayOfTheWeek16() {
85+
assertThat(Solution().dayOfTheWeek(6, 1, 1971), equalTo("Wednesday"))
86+
}
2287
}

src/test/kotlin/g2401_2500/s2481_minimum_cuts_to_divide_a_circle/SolutionTest.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,39 @@ internal class SolutionTest {
1414
fun numberOfCuts2() {
1515
assertThat(Solution().numberOfCuts(3), equalTo(3))
1616
}
17+
18+
@Test
19+
fun numberOfCuts3() {
20+
assertThat(Solution().numberOfCuts(1), equalTo(0))
21+
}
22+
23+
@Test
24+
fun numberOfCuts4() {
25+
assertThat(Solution().numberOfCuts(6), equalTo(3))
26+
}
27+
28+
@Test
29+
fun numberOfCuts5() {
30+
assertThat(Solution().numberOfCuts(5), equalTo(5))
31+
}
32+
33+
@Test
34+
fun numberOfCuts6() {
35+
assertThat(Solution().numberOfCuts(100), equalTo(50))
36+
}
37+
38+
@Test
39+
fun numberOfCuts7() {
40+
assertThat(Solution().numberOfCuts(101), equalTo(101))
41+
}
42+
43+
@Test
44+
fun numberOfCuts8() {
45+
assertThat(Solution().numberOfCuts(2), equalTo(1))
46+
}
47+
48+
@Test
49+
fun numberOfCuts9() {
50+
assertThat(Solution().numberOfCuts(3), equalTo(3))
51+
}
1752
}

src/test/kotlin/g3101_3200/s3142_check_if_grid_satisfies_conditions/SolutionTest.kt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,78 @@ internal class SolutionTest {
2020
equalTo(false),
2121
)
2222
}
23+
24+
@Test
25+
fun satisfiesConditions3() {
26+
assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1), intArrayOf(2), intArrayOf(3))), equalTo(false))
27+
}
28+
29+
@Test
30+
fun satisfiesConditions4() {
31+
assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1), intArrayOf(1))), equalTo(true))
32+
}
33+
34+
@Test
35+
fun satisfiesConditions5() {
36+
assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1, 2, 3))), equalTo(true))
37+
}
38+
39+
@Test
40+
fun satisfiesConditions6() {
41+
assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1, 1))), equalTo(false))
42+
}
43+
44+
@Test
45+
fun satisfiesConditions7() {
46+
assertThat(
47+
Solution().satisfiesConditions(arrayOf(intArrayOf(1, 2, 2), intArrayOf(3, 4, 5))),
48+
equalTo(false),
49+
)
50+
}
51+
52+
@Test
53+
fun satisfiesConditions8() {
54+
val grid = arrayOf(
55+
intArrayOf(1, 0, 1),
56+
intArrayOf(0, 1, 0),
57+
intArrayOf(1, 0, 1),
58+
)
59+
assertThat(Solution().satisfiesConditions(grid), equalTo(false))
60+
}
61+
62+
@Test
63+
fun satisfiesConditions9() {
64+
assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(5, 1), intArrayOf(5, 0))), equalTo(true))
65+
}
66+
67+
@Test
68+
fun satisfiesConditions10() {
69+
assertThat(
70+
Solution().satisfiesConditions(arrayOf(intArrayOf(1, 0), intArrayOf(2, 2))),
71+
equalTo(false),
72+
)
73+
}
74+
75+
@Test
76+
fun satisfiesConditions11() {
77+
assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(7))), equalTo(true))
78+
}
79+
80+
@Test
81+
fun satisfiesConditions12() {
82+
val grid = arrayOf(
83+
intArrayOf(4, 1, 5, 2),
84+
intArrayOf(3, 0, 4, 1),
85+
)
86+
assertThat(Solution().satisfiesConditions(grid), equalTo(false))
87+
}
88+
89+
@Test
90+
fun satisfiesConditions13() {
91+
val grid = arrayOf(
92+
intArrayOf(2, 3, 3, 1),
93+
intArrayOf(1, 0, 4, 2),
94+
)
95+
assertThat(Solution().satisfiesConditions(grid), equalTo(false))
96+
}
2397
}

0 commit comments

Comments
 (0)