diff --git a/src/test/kotlin/g0001_0100/s0008_string_to_integer_atoi/SolutionTest.kt b/src/test/kotlin/g0001_0100/s0008_string_to_integer_atoi/SolutionTest.kt index ec2900c2a..cf2153d2d 100644 --- a/src/test/kotlin/g0001_0100/s0008_string_to_integer_atoi/SolutionTest.kt +++ b/src/test/kotlin/g0001_0100/s0008_string_to_integer_atoi/SolutionTest.kt @@ -29,4 +29,64 @@ internal class SolutionTest { fun myAtoi5() { assertThat(Solution().myAtoi("-91283472332"), equalTo(-2147483648)) } + + @Test + fun myAtoi6() { + assertThat(Solution().myAtoi("123"), equalTo(123)) + } + + @Test + fun myAtoi7() { + assertThat(Solution().myAtoi("+456"), equalTo(456)) + } + + @Test + fun myAtoi8() { + assertThat(Solution().myAtoi("0000123"), equalTo(123)) + } + + @Test + fun myAtoi9() { + assertThat(Solution().myAtoi("2147483648"), equalTo(Int.MAX_VALUE)) + } + + @Test + fun myAtoi10() { + assertThat(Solution().myAtoi("-2147483649"), equalTo(Int.MIN_VALUE)) + } + + @Test + fun myAtoi11() { + assertThat(Solution().myAtoi(""), equalTo(0)) + } + + @Test + fun myAtoi12() { + assertThat(Solution().myAtoi(" "), equalTo(0)) + } + + @Test + fun myAtoi13() { + assertThat(Solution().myAtoi("+-2"), equalTo(0)) + } + + @Test + fun myAtoi14() { + assertThat(Solution().myAtoi("0"), equalTo(0)) + } + + @Test + fun myAtoi15() { + assertThat(Solution().myAtoi("-0"), equalTo(0)) + } + + @Test + fun myAtoi16() { + assertThat(Solution().myAtoi("words 123"), equalTo(0)) + } + + @Test + fun myAtoi17() { + assertThat(Solution().myAtoi(" 0000000000012345678abc"), equalTo(12345678)) + } } diff --git a/src/test/kotlin/g1101_1200/s1184_distance_between_bus_stops/SolutionTest.kt b/src/test/kotlin/g1101_1200/s1184_distance_between_bus_stops/SolutionTest.kt index 7ba7b071d..77ce07a34 100644 --- a/src/test/kotlin/g1101_1200/s1184_distance_between_bus_stops/SolutionTest.kt +++ b/src/test/kotlin/g1101_1200/s1184_distance_between_bus_stops/SolutionTest.kt @@ -28,4 +28,52 @@ internal class SolutionTest { equalTo(4), ) } + + @Test + fun distanceBetweenBusStops4() { + assertThat( + Solution().distanceBetweenBusStops(intArrayOf(1, 2, 3, 4), 3, 1), + equalTo(5), + ) + } + + @Test + fun distanceBetweenBusStops5() { + assertThat( + Solution().distanceBetweenBusStops(intArrayOf(7, 1, 2, 3), 1, 3), + equalTo(3), + ) + } + + @Test + fun distanceBetweenBusStops6() { + assertThat( + Solution().distanceBetweenBusStops(intArrayOf(2, 2, 2, 2), 1, 3), + equalTo(4), + ) + } + + @Test + fun distanceBetweenBusStops7() { + assertThat( + Solution().distanceBetweenBusStops(intArrayOf(5), 0, 0), + equalTo(0), + ) + } + + @Test + fun distanceBetweenBusStops8() { + assertThat( + Solution().distanceBetweenBusStops(intArrayOf(3, 8), 1, 0), + equalTo(3), + ) + } + + @Test + fun distanceBetweenBusStops9() { + assertThat( + Solution().distanceBetweenBusStops(intArrayOf(1, 4, 6, 3), 2, 1), + equalTo(4), + ) + } } diff --git a/src/test/kotlin/g1801_1900/s1882_process_tasks_using_servers/SolutionTest.kt b/src/test/kotlin/g1801_1900/s1882_process_tasks_using_servers/SolutionTest.kt index 400927c5a..88db933eb 100644 --- a/src/test/kotlin/g1801_1900/s1882_process_tasks_using_servers/SolutionTest.kt +++ b/src/test/kotlin/g1801_1900/s1882_process_tasks_using_servers/SolutionTest.kt @@ -21,4 +21,62 @@ internal class SolutionTest { equalTo(intArrayOf(1, 4, 1, 4, 1, 3, 2)), ) } + + @Test + fun assignTasks3() { + assertThat( + Solution().assignTasks(intArrayOf(1), intArrayOf(1, 2, 3)), + equalTo(intArrayOf(0, 0, 0)), + ) + } + + @Test + fun assignTasks4() { + assertThat( + Solution().assignTasks(intArrayOf(2, 2, 2), intArrayOf(1, 2, 1, 2)), + equalTo(intArrayOf(0, 0, 1, 0)), + ) + } + + @Test + fun assignTasks5() { + assertThat( + Solution().assignTasks(intArrayOf(1, 2), intArrayOf(1, 2, 3, 4)), + equalTo(intArrayOf(0, 0, 1, 0)), + ) + } + + @Test + fun assignTasks6() { + assertThat( + Solution().assignTasks(intArrayOf(1, 2, 3), intArrayOf()), + equalTo(intArrayOf()), + ) + } + + @Test + fun assignTasks7() { + assertThat( + Solution().assignTasks(intArrayOf(3, 1, 4), intArrayOf(5)), + equalTo(intArrayOf(1)), + ) + } + + @Test + fun assignTasks8() { + assertThat( + Solution().assignTasks(intArrayOf(1, 2), intArrayOf(2, 2, 2)), + equalTo(intArrayOf(0, 1, 0)), + ) + } + + @Test + fun assignTasks9() { + val servers = intArrayOf(5, 3, 1, 4, 2) + val tasks = intArrayOf(1, 3, 5, 7, 9, 11) + assertThat( + Solution().assignTasks(servers, tasks), + equalTo(intArrayOf(2, 2, 4, 1, 2, 3)), + ) + } } diff --git a/src/test/kotlin/g2501_2600/s2600_k_items_with_the_maximum_sum/SolutionTest.kt b/src/test/kotlin/g2501_2600/s2600_k_items_with_the_maximum_sum/SolutionTest.kt index 8b67dd3d1..ac54c7756 100644 --- a/src/test/kotlin/g2501_2600/s2600_k_items_with_the_maximum_sum/SolutionTest.kt +++ b/src/test/kotlin/g2501_2600/s2600_k_items_with_the_maximum_sum/SolutionTest.kt @@ -14,4 +14,44 @@ internal class SolutionTest { fun kItemsWithMaximumSum2() { assertThat(Solution().kItemsWithMaximumSum(3, 2, 0, 4), equalTo(3)) } + + @Test + fun kItemsWithMaximumSum3() { + assertThat(Solution().kItemsWithMaximumSum(5, 3, 2, 5), equalTo(5)) + } + + @Test + fun kItemsWithMaximumSum4() { + assertThat(Solution().kItemsWithMaximumSum(3, 4, 5, 7), equalTo(3)) + } + + @Test + fun kItemsWithMaximumSum5() { + assertThat(Solution().kItemsWithMaximumSum(3, 1, 5, 6), equalTo(1)) + } + + @Test + fun kItemsWithMaximumSum6() { + assertThat(Solution().kItemsWithMaximumSum(2, 1, 10, 13), equalTo(-8)) + } + + @Test + fun kItemsWithMaximumSum7() { + assertThat(Solution().kItemsWithMaximumSum(0, 5, 5, 3), equalTo(0)) + } + + @Test + fun kItemsWithMaximumSum8() { + assertThat(Solution().kItemsWithMaximumSum(2, 0, 5, 3), equalTo(1)) + } + + @Test + fun kItemsWithMaximumSum9() { + assertThat(Solution().kItemsWithMaximumSum(4, 3, 0, 6), equalTo(4)) + } + + @Test + fun kItemsWithMaximumSum10() { + assertThat(Solution().kItemsWithMaximumSum(5, 5, 5, 0), equalTo(0)) + } } diff --git a/src/test/kotlin/g3501_3600/s3548_equal_sum_grid_partition_ii/SolutionTest.kt b/src/test/kotlin/g3501_3600/s3548_equal_sum_grid_partition_ii/SolutionTest.kt index f3eac3174..c7b2243e1 100644 --- a/src/test/kotlin/g3501_3600/s3548_equal_sum_grid_partition_ii/SolutionTest.kt +++ b/src/test/kotlin/g3501_3600/s3548_equal_sum_grid_partition_ii/SolutionTest.kt @@ -131,4 +131,65 @@ internal class SolutionTest { equalTo(true), ) } + + @Test + fun canPartitionGrid12() { + val solution = Solution() + val grid = arrayOf( + intArrayOf(2, 1), + intArrayOf(1, 1), + ) + assertThat(solution.canPartitionGrid(grid), equalTo(true)) + } + + @Test + fun canPartitionGrid13() { + val solution = Solution() + val grid = arrayOf( + intArrayOf(1), + intArrayOf(2), + intArrayOf(1), + ) + assertThat(solution.canPartitionGrid(grid), equalTo(true)) + } + + @Test + fun canPartitionGrid14() { + val solution = Solution() + val grid = arrayOf( + intArrayOf(1, 2), + intArrayOf(1, 1), + ) + assertThat(solution.canPartitionGrid(grid), equalTo(true)) + } + + @Test + fun canPartitionGrid15() { + val solution = Solution() + val grid = arrayOf( + intArrayOf(1, 1, 2), + intArrayOf(1, 1, 1), + ) + assertThat(solution.canPartitionGrid(grid), equalTo(true)) + } + + @Test + fun canPartitionGrid16() { + val solution = Solution() + val grid = arrayOf( + intArrayOf(1, 1), + intArrayOf(1, 1), + ) + assertThat(solution.canPartitionGrid(grid), equalTo(true)) + } + + @Test + fun canPartitionGrid17() { + val solution = Solution() + val grid = arrayOf( + intArrayOf(1, 2), + intArrayOf(3, 4), + ) + assertThat(solution.canPartitionGrid(grid), equalTo(true)) + } }