b187339e7ae2f691d78aa1c6debf0346a26e463712ff7c1b589c6473ca9fdbc3
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- minimum_impossible_or/scala_tests/MySuite.scala +12 -0
- minimum_increment_operations_to_make_array_beautiful/haskell_tests/Main.hs +45 -0
- minimum_increment_operations_to_make_array_beautiful/java_tests/Main.java +25 -0
- minimum_increment_operations_to_make_array_beautiful/meta.json +184 -0
- minimum_increment_operations_to_make_array_beautiful/ocaml_tests/main.ml +50 -0
- minimum_increment_operations_to_make_array_beautiful/scala_tests/MySuite.scala +44 -0
- minimum_increments_for_target_multiples_in_an_array/haskell_tests/Main.hs +0 -0
- minimum_increments_for_target_multiples_in_an_array/java_tests/Main.java +25 -0
- minimum_increments_for_target_multiples_in_an_array/meta.json +0 -0
- minimum_increments_for_target_multiples_in_an_array/ocaml_tests/main.ml +0 -0
- minimum_increments_for_target_multiples_in_an_array/scala_tests/MySuite.scala +0 -0
- minimum_index_of_a_valid_split/.DS_Store +0 -0
- minimum_index_of_a_valid_split/haskell_tests/Main.hs +27 -0
- minimum_index_of_a_valid_split/java_tests/Main.java +25 -0
- minimum_index_of_a_valid_split/meta.json +0 -0
- minimum_index_of_a_valid_split/ocaml_tests/main.ml +29 -0
- minimum_index_of_a_valid_split/scala_tests/MySuite.scala +16 -0
- minimum_length_of_anagram_concatenation/haskell_tests/Main.hs +0 -0
- minimum_length_of_anagram_concatenation/java_tests/Main.java +20 -0
- minimum_length_of_anagram_concatenation/meta.json +0 -0
- minimum_length_of_anagram_concatenation/ocaml_tests/main.ml +0 -0
- minimum_length_of_anagram_concatenation/scala_tests/MySuite.scala +0 -0
- minimum_length_of_string_after_operations/haskell_tests/Main.hs +0 -0
- minimum_length_of_string_after_operations/java_tests/Main.java +20 -0
- minimum_length_of_string_after_operations/meta.json +0 -0
- minimum_length_of_string_after_operations/ocaml_tests/main.ml +0 -0
- minimum_length_of_string_after_operations/scala_tests/MySuite.scala +0 -0
- minimum_levels_to_gain_more_points/haskell_tests/Main.hs +0 -0
- minimum_levels_to_gain_more_points/java_tests/Main.java +24 -0
- minimum_levels_to_gain_more_points/meta.json +0 -0
- minimum_levels_to_gain_more_points/ocaml_tests/main.ml +0 -0
- minimum_levels_to_gain_more_points/scala_tests/MySuite.scala +0 -0
- minimum_lines_to_represent_a_line_chart/.DS_Store +0 -0
- minimum_lines_to_represent_a_line_chart/haskell_tests/Main.hs +24 -0
- minimum_lines_to_represent_a_line_chart/java_tests/Main.java +21 -0
- minimum_lines_to_represent_a_line_chart/meta.json +3 -0
- minimum_lines_to_represent_a_line_chart/ocaml_tests/main.ml +26 -0
- minimum_lines_to_represent_a_line_chart/scala_tests/MySuite.scala +12 -0
- minimum_money_required_before_transactions/.DS_Store +0 -0
- minimum_money_required_before_transactions/haskell_tests/Main.hs +24 -0
- minimum_money_required_before_transactions/java_tests/Main.java +21 -0
- minimum_money_required_before_transactions/meta.json +3 -0
- minimum_money_required_before_transactions/ocaml_tests/main.ml +26 -0
- minimum_money_required_before_transactions/scala_tests/MySuite.scala +12 -0
- minimum_moves_to_capture_the_queen/haskell_tests/Main.hs +45 -0
- minimum_moves_to_capture_the_queen/java_tests/Main.java +21 -0
- minimum_moves_to_capture_the_queen/meta.json +137 -0
- minimum_moves_to_capture_the_queen/ocaml_tests/main.ml +50 -0
- minimum_moves_to_capture_the_queen/scala_tests/MySuite.scala +44 -0
.gitattributes
CHANGED
|
@@ -218,3 +218,5 @@ minimum_cost_to_make_arrays_identical/meta.json filter=lfs diff=lfs merge=lfs -t
|
|
| 218 |
minimum_difference_in_sums_after_removal_of_elements/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 219 |
minimum_fuel_cost_to_report_to_the_capital/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 220 |
minimum_impossible_or/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 218 |
minimum_difference_in_sums_after_removal_of_elements/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 219 |
minimum_fuel_cost_to_report_to_the_capital/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 220 |
minimum_impossible_or/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 221 |
+
minimum_lines_to_represent_a_line_chart/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 222 |
+
minimum_money_required_before_transactions/meta.json filter=lfs diff=lfs merge=lfs -text
|
minimum_impossible_or/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minImpossibleOR(List(2,1)), 4)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minImpossibleOR(List(5,3,2)), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
minimum_increment_operations_to_make_array_beautiful/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
|
| 7 |
+
--Program end
|
| 8 |
+
|
| 9 |
+
-- Test cases
|
| 10 |
+
|
| 11 |
+
test1 :: Test
|
| 12 |
+
test1 = TestCase (assertEqual "for (minIncrementOperations [2,3,0,0,2] 4)," 3 (minIncrementOperations [2,3,0,0,2] 4))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minIncrementOperations [0,1,3,3] 5)," 2 (minIncrementOperations [0,1,3,3] 5))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (minIncrementOperations [1,1,2] 1)," 0 (minIncrementOperations [1,1,2] 1))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (minIncrementOperations [462325066, 206420187, 521315460, 318264093, 66475813, 619438353, 499937120, 9685155, 2855537, 913944240] 373173460)," 0 (minIncrementOperations [462325066, 206420187, 521315460, 318264093, 66475813, 619438353, 499937120, 9685155, 2855537, 913944240] 373173460))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (minIncrementOperations [317576829, 230943442, 194377313, 217961295, 179889103, 421788827, 346731151, 31378563, 457215528] 663944532)," 918451928 (minIncrementOperations [317576829, 230943442, 194377313, 217961295, 179889103, 421788827, 346731151, 31378563, 457215528] 663944532))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (minIncrementOperations [554240499, 168910099, 370475323, 72793279, 181768111, 415255001] 179842580)," 0 (minIncrementOperations [554240499, 168910099, 370475323, 72793279, 181768111, 415255001] 179842580))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (minIncrementOperations [168413874, 337615557, 757898546, 697884066, 97110609, 987627695, 755555424, 530718081, 976002691] 944893763)," 186995217 (minIncrementOperations [168413874, 337615557, 757898546, 697884066, 97110609, 987627695, 755555424, 530718081, 976002691] 944893763))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (minIncrementOperations [484598604, 491482864, 339460418, 940057113, 528767250, 102185549] 189117733)," 0 (minIncrementOperations [484598604, 491482864, 339460418, 940057113, 528767250, 102185549] 189117733))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (minIncrementOperations [719164977, 892326581, 957540324, 991726451, 280307765, 41099724, 871482641] 740459607)," 0 (minIncrementOperations [719164977, 892326581, 957540324, 991726451, 280307765, 41099724, 871482641] 740459607))
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
-- Grouping test cases
|
| 40 |
+
tests :: Test
|
| 41 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
|
| 42 |
+
|
| 43 |
+
-- Running the tests
|
| 44 |
+
main :: IO Counts
|
| 45 |
+
main = runTestTT tests
|
minimum_increment_operations_to_make_array_beautiful/java_tests/Main.java
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(3, minIncrementOperations(new ArrayList<>(Arrays.asList(2,3,0,0,2)), 4));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, minIncrementOperations(new ArrayList<>(Arrays.asList(0,1,3,3)), 5));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(0, minIncrementOperations(new ArrayList<>(Arrays.asList(1,1,2)), 1));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
minimum_increment_operations_to_make_array_beautiful/meta.json
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3178,
|
| 3 |
+
"name": "minimum_increment_operations_to_make_array_beautiful",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/minimum-increment-operations-to-make-array-beautiful/",
|
| 6 |
+
"date": "2023-10-22 00:00:00",
|
| 7 |
+
"task_description": "You are given a **0-indexed** integer array `nums` having length `n`, and an integer `k`. You can perform the following **increment** operation **any** number of times (**including zero**): Choose an index `i` in the range `[0, n - 1]`, and increase `nums[i]` by `1`. An array is considered **beautiful** if, for any **subarray** with a size of `3` or **more**, its **maximum** element is **greater than or equal** to `k`. Return _an integer denoting the **minimum** number of increment operations needed to make _`nums`_ **beautiful**._ A subarray is a contiguous **non-empty** sequence of elements within an array. **Example 1:** ``` **Input:** nums = [2,3,0,0,2], k = 4 **Output:** 3 **Explanation:** We can perform the following increment operations to make nums beautiful: Choose index i = 1 and increase nums[1] by 1 -> [2,4,0,0,2]. Choose index i = 4 and increase nums[4] by 1 -> [2,4,0,0,3]. Choose index i = 4 and increase nums[4] by 1 -> [2,4,0,0,4]. The subarrays with a size of 3 or more are: [2,4,0], [4,0,0], [0,0,4], [2,4,0,0], [4,0,0,4], [2,4,0,0,4]. In all the subarrays, the maximum element is equal to k = 4, so nums is now beautiful. It can be shown that nums cannot be made beautiful with fewer than 3 increment operations. Hence, the answer is 3. ``` **Example 2:** ``` **Input:** nums = [0,1,3,3], k = 5 **Output:** 2 **Explanation:** We can perform the following increment operations to make nums beautiful: Choose index i = 2 and increase nums[2] by 1 -> [0,1,4,3]. Choose index i = 2 and increase nums[2] by 1 -> [0,1,5,3]. The subarrays with a size of 3 or more are: [0,1,5], [1,5,3], [0,1,5,3]. In all the subarrays, the maximum element is equal to k = 5, so nums is now beautiful. It can be shown that nums cannot be made beautiful with fewer than 2 increment operations. Hence, the answer is 2. ``` **Example 3:** ``` **Input:** nums = [1,1,2], k = 1 **Output:** 0 **Explanation:** The only subarray with a size of 3 or more in this example is [1,1,2]. The maximum element, 2, is already greater than k = 1, so we don't need any increment operation. Hence, the answer is 0. ``` **Constraints:** `3 <= n == nums.length <= 105` `0 <= nums[i] <= 109` `0 <= k <= 109`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [2,3,0,0,2], k = 4",
|
| 12 |
+
"output": "3 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [0,1,3,3], k = 5",
|
| 17 |
+
"output": "2 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "nums = [1,1,2], k = 1",
|
| 22 |
+
"output": "0 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
[
|
| 29 |
+
462325066,
|
| 30 |
+
206420187,
|
| 31 |
+
521315460,
|
| 32 |
+
318264093,
|
| 33 |
+
66475813,
|
| 34 |
+
619438353,
|
| 35 |
+
499937120,
|
| 36 |
+
9685155,
|
| 37 |
+
2855537,
|
| 38 |
+
913944240
|
| 39 |
+
],
|
| 40 |
+
373173460
|
| 41 |
+
],
|
| 42 |
+
"output": 0
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"input": [
|
| 46 |
+
[
|
| 47 |
+
317576829,
|
| 48 |
+
230943442,
|
| 49 |
+
194377313,
|
| 50 |
+
217961295,
|
| 51 |
+
179889103,
|
| 52 |
+
421788827,
|
| 53 |
+
346731151,
|
| 54 |
+
31378563,
|
| 55 |
+
457215528
|
| 56 |
+
],
|
| 57 |
+
663944532
|
| 58 |
+
],
|
| 59 |
+
"output": 918451928
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"input": [
|
| 63 |
+
[
|
| 64 |
+
554240499,
|
| 65 |
+
168910099,
|
| 66 |
+
370475323,
|
| 67 |
+
72793279,
|
| 68 |
+
181768111,
|
| 69 |
+
415255001
|
| 70 |
+
],
|
| 71 |
+
179842580
|
| 72 |
+
],
|
| 73 |
+
"output": 0
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"input": [
|
| 77 |
+
[
|
| 78 |
+
168413874,
|
| 79 |
+
337615557,
|
| 80 |
+
757898546,
|
| 81 |
+
697884066,
|
| 82 |
+
97110609,
|
| 83 |
+
987627695,
|
| 84 |
+
755555424,
|
| 85 |
+
530718081,
|
| 86 |
+
976002691
|
| 87 |
+
],
|
| 88 |
+
944893763
|
| 89 |
+
],
|
| 90 |
+
"output": 186995217
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"input": [
|
| 94 |
+
[
|
| 95 |
+
484598604,
|
| 96 |
+
491482864,
|
| 97 |
+
339460418,
|
| 98 |
+
940057113,
|
| 99 |
+
528767250,
|
| 100 |
+
102185549
|
| 101 |
+
],
|
| 102 |
+
189117733
|
| 103 |
+
],
|
| 104 |
+
"output": 0
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"input": [
|
| 108 |
+
[
|
| 109 |
+
719164977,
|
| 110 |
+
892326581,
|
| 111 |
+
957540324,
|
| 112 |
+
991726451,
|
| 113 |
+
280307765,
|
| 114 |
+
41099724,
|
| 115 |
+
871482641
|
| 116 |
+
],
|
| 117 |
+
740459607
|
| 118 |
+
],
|
| 119 |
+
"output": 0
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"input": [
|
| 123 |
+
[
|
| 124 |
+
49010645,
|
| 125 |
+
338826954,
|
| 126 |
+
801318173,
|
| 127 |
+
348190584,
|
| 128 |
+
354157732,
|
| 129 |
+
232141023
|
| 130 |
+
],
|
| 131 |
+
94104474
|
| 132 |
+
],
|
| 133 |
+
"output": 0
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"input": [
|
| 137 |
+
[
|
| 138 |
+
305762391,
|
| 139 |
+
417436427,
|
| 140 |
+
338549371,
|
| 141 |
+
153703212
|
| 142 |
+
],
|
| 143 |
+
649513426
|
| 144 |
+
],
|
| 145 |
+
"output": 232076999
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"input": [
|
| 149 |
+
[
|
| 150 |
+
220369410,
|
| 151 |
+
282934213,
|
| 152 |
+
198247569,
|
| 153 |
+
726195262,
|
| 154 |
+
41979645,
|
| 155 |
+
117267716,
|
| 156 |
+
555256808,
|
| 157 |
+
683741535,
|
| 158 |
+
880011605,
|
| 159 |
+
218580428
|
| 160 |
+
],
|
| 161 |
+
493276257
|
| 162 |
+
],
|
| 163 |
+
"output": 210342044
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"input": [
|
| 167 |
+
[
|
| 168 |
+
902477971,
|
| 169 |
+
881152273,
|
| 170 |
+
639491946,
|
| 171 |
+
510273653,
|
| 172 |
+
365179409
|
| 173 |
+
],
|
| 174 |
+
422822051
|
| 175 |
+
],
|
| 176 |
+
"output": 0
|
| 177 |
+
}
|
| 178 |
+
],
|
| 179 |
+
"haskell_template": "minIncrementOperations :: [Int] -> Int -> Int\nminIncrementOperations nums k ",
|
| 180 |
+
"ocaml_template": "let minIncrementOperations (nums: int list) (k: int) : int = ",
|
| 181 |
+
"scala_template": "def minIncrementOperations(nums: List[Int],k: Int): Int = { \n \n}",
|
| 182 |
+
"java_template": "class Solution {\n public long minIncrementOperations(int[] nums, int k) {\n \n }\n}",
|
| 183 |
+
"python_template": "class Solution(object):\n def minIncrementOperations(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "
|
| 184 |
+
}
|
minimum_increment_operations_to_make_array_beautiful/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 3 (minIncrementOperations [2;3;0;0;2] 4)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (minIncrementOperations [0;1;3;3] 5)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 0 (minIncrementOperations [1;1;2] 1)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 0 (minIncrementOperations [462325066; 206420187; 521315460; 318264093; 66475813; 619438353; 499937120; 9685155; 2855537; 913944240] 373173460)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 918451928 (minIncrementOperations [317576829; 230943442; 194377313; 217961295; 179889103; 421788827; 346731151; 31378563; 457215528] 663944532)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 0 (minIncrementOperations [554240499; 168910099; 370475323; 72793279; 181768111; 415255001] 179842580)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 186995217 (minIncrementOperations [168413874; 337615557; 757898546; 697884066; 97110609; 987627695; 755555424; 530718081; 976002691] 944893763)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 0 (minIncrementOperations [484598604; 491482864; 339460418; 940057113; 528767250; 102185549] 189117733)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 0 (minIncrementOperations [719164977; 892326581; 957540324; 991726451; 280307765; 41099724; 871482641] 740459607)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 0 (minIncrementOperations [49010645; 338826954; 801318173; 348190584; 354157732; 232141023] 94104474)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for minIncrementOperations" >::: [
|
| 34 |
+
|
| 35 |
+
"test1" >:: test1;
|
| 36 |
+
"test2" >:: test2;
|
| 37 |
+
"test3" >:: test3;
|
| 38 |
+
"test4" >:: test4;
|
| 39 |
+
"test5" >:: test5;
|
| 40 |
+
"test6" >:: test6;
|
| 41 |
+
"test7" >:: test7;
|
| 42 |
+
"test8" >:: test8;
|
| 43 |
+
"test9" >:: test9;
|
| 44 |
+
"test10" >:: test10;
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
(* Running the tests *)
|
| 49 |
+
let () = run_test_tt_main suite
|
| 50 |
+
end
|
minimum_increment_operations_to_make_array_beautiful/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minIncrementOperations(List(2,3,0,0,2),4), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minIncrementOperations(List(0,1,3,3),5), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.minIncrementOperations(List(1,1,2),1), 0)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.minIncrementOperations(List(462325066, 206420187, 521315460, 318264093, 66475813, 619438353, 499937120, 9685155, 2855537, 913944240),373173460), 0)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.minIncrementOperations(List(317576829, 230943442, 194377313, 217961295, 179889103, 421788827, 346731151, 31378563, 457215528),663944532), 918451928)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.minIncrementOperations(List(554240499, 168910099, 370475323, 72793279, 181768111, 415255001),179842580), 0)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.minIncrementOperations(List(168413874, 337615557, 757898546, 697884066, 97110609, 987627695, 755555424, 530718081, 976002691),944893763), 186995217)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.minIncrementOperations(List(484598604, 491482864, 339460418, 940057113, 528767250, 102185549),189117733), 0)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.minIncrementOperations(List(719164977, 892326581, 957540324, 991726451, 280307765, 41099724, 871482641),740459607), 0)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.minIncrementOperations(List(49010645, 338826954, 801318173, 348190584, 354157732, 232141023),94104474), 0)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
minimum_increments_for_target_multiples_in_an_array/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_increments_for_target_multiples_in_an_array/java_tests/Main.java
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(1, minimumIncrements(new ArrayList<>(Arrays.asList(1,2,3)), new ArrayList<>(Arrays.asList(4))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, minimumIncrements(new ArrayList<>(Arrays.asList(8,4)), new ArrayList<>(Arrays.asList(10,5))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(0, minimumIncrements(new ArrayList<>(Arrays.asList(7,9,10)), new ArrayList<>(Arrays.asList(7))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
minimum_increments_for_target_multiples_in_an_array/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_increments_for_target_multiples_in_an_array/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_increments_for_target_multiples_in_an_array/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_index_of_a_valid_split/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_index_of_a_valid_split/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
|
| 7 |
+
--Program end
|
| 8 |
+
|
| 9 |
+
-- Test cases
|
| 10 |
+
|
| 11 |
+
test1 :: Test
|
| 12 |
+
test1 = TestCase (assertEqual "for (minimumIndex [1,2,2,2])," 2 (minimumIndex [1,2,2,2]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minimumIndex [2,1,3,1,1,1,7,1,2,1])," 4 (minimumIndex [2,1,3,1,1,1,7,1,2,1]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (minimumIndex [3,3,3,3,7,2,2])," (-1) (minimumIndex [3,3,3,3,7,2,2]))
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
-- Grouping test cases
|
| 22 |
+
tests :: Test
|
| 23 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
|
| 24 |
+
|
| 25 |
+
-- Running the tests
|
| 26 |
+
main :: IO Counts
|
| 27 |
+
main = runTestTT tests
|
minimum_index_of_a_valid_split/java_tests/Main.java
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(2, minimumIndex(new ArrayList<>(Arrays.asList(1,2,2,2))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(4, minimumIndex(new ArrayList<>(Arrays.asList(2,1,3,1,1,1,7,1,2,1))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(-1, minimumIndex(new ArrayList<>(Arrays.asList(3,3,3,3,7,2,2))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
minimum_index_of_a_valid_split/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_index_of_a_valid_split/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 2 (minimumIndex [1;2;2;2])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 4 (minimumIndex [2;1;3;1;1;1;7;1;2;1])
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal (-1) (minimumIndex [3;3;3;3;7;2;2])
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for minimumIndex" >::: [
|
| 20 |
+
|
| 21 |
+
"test1" >:: test1;
|
| 22 |
+
"test2" >:: test2;
|
| 23 |
+
"test3" >:: test3;
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
(* Running the tests *)
|
| 28 |
+
let () = run_test_tt_main suite
|
| 29 |
+
end
|
minimum_index_of_a_valid_split/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minimumIndex(List(1,2,2,2)), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minimumIndex(List(2,1,3,1,1,1,7,1,2,1)), 4)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.minimumIndex(List(3,3,3,3,7,2,2)), -1)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
minimum_length_of_anagram_concatenation/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_length_of_anagram_concatenation/java_tests/Main.java
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(2, minAnagramLength("abba"));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(4, minAnagramLength("cdef"));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
minimum_length_of_anagram_concatenation/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_length_of_anagram_concatenation/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_length_of_anagram_concatenation/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_length_of_string_after_operations/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_length_of_string_after_operations/java_tests/Main.java
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(5, minimumLength("abaacbcbb"));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(2, minimumLength("aa"));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
minimum_length_of_string_after_operations/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_length_of_string_after_operations/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_length_of_string_after_operations/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_levels_to_gain_more_points/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_levels_to_gain_more_points/java_tests/Main.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(1, minimumLevels(Arrays.asList(1,0,1,0)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(3, minimumLevels(Arrays.asList(1,1,1,1,1)));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(-1, minimumLevels(Arrays.asList(0,0)));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
minimum_levels_to_gain_more_points/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_levels_to_gain_more_points/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_levels_to_gain_more_points/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_lines_to_represent_a_line_chart/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_lines_to_represent_a_line_chart/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
|
| 7 |
+
--Program end
|
| 8 |
+
|
| 9 |
+
-- Test cases
|
| 10 |
+
|
| 11 |
+
test1 :: Test
|
| 12 |
+
test1 = TestCase (assertEqual "for (minimumLines [[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]])," 3 (minimumLines [[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minimumLines [[3,4],[1,2],[7,8],[2,3]])," 1 (minimumLines [[3,4],[1,2],[7,8],[2,3]]))
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
-- Grouping test cases
|
| 19 |
+
tests :: Test
|
| 20 |
+
tests = TestList [TestLabel "Test1" test1]
|
| 21 |
+
|
| 22 |
+
-- Running the tests
|
| 23 |
+
main :: IO Counts
|
| 24 |
+
main = runTestTT tests
|
minimum_lines_to_represent_a_line_chart/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(3, minimumLines(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,7)),new ArrayList<>(Arrays.asList(2,6)),new ArrayList<>(Arrays.asList(3,5)),new ArrayList<>(Arrays.asList(4,4)),new ArrayList<>(Arrays.asList(5,4)),new ArrayList<>(Arrays.asList(6,3)),new ArrayList<>(Arrays.asList(7,2)),new ArrayList<>(Arrays.asList(8,1))))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, minimumLines(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,4)),new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(7,8)),new ArrayList<>(Arrays.asList(2,3))))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_lines_to_represent_a_line_chart/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bfa1c6f6db3c53eb107c77e61132db68f322256ba267a3fa40dbfe55035dadec
|
| 3 |
+
size 23241781
|
minimum_lines_to_represent_a_line_chart/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 3 (minimumLines [[1;7];[2;6];[3;5];[4;4];[5;4];[6;3];[7;2];[8;1]])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 1 (minimumLines [[3;4];[1;2];[7;8];[2;3]])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for minimumLines" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
minimum_lines_to_represent_a_line_chart/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minimumLines(List(List(1,7),List(2,6),List(3,5),List(4,4),List(5,4),List(6,3),List(7,2),List(8,1))), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minimumLines(List(List(3,4),List(1,2),List(7,8),List(2,3))), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
minimum_money_required_before_transactions/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_money_required_before_transactions/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
|
| 7 |
+
--Program end
|
| 8 |
+
|
| 9 |
+
-- Test cases
|
| 10 |
+
|
| 11 |
+
test1 :: Test
|
| 12 |
+
test1 = TestCase (assertEqual "for (minimumMoney [[2,1],[5,0],[4,2]])," 10 (minimumMoney [[2,1],[5,0],[4,2]]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minimumMoney [[3,0],[0,3]])," 3 (minimumMoney [[3,0],[0,3]]))
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
-- Grouping test cases
|
| 19 |
+
tests :: Test
|
| 20 |
+
tests = TestList [TestLabel "Test1" test1]
|
| 21 |
+
|
| 22 |
+
-- Running the tests
|
| 23 |
+
main :: IO Counts
|
| 24 |
+
main = runTestTT tests
|
minimum_money_required_before_transactions/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(10, minimumMoney(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,1)),new ArrayList<>(Arrays.asList(5,0)),new ArrayList<>(Arrays.asList(4,2))))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(3, minimumMoney(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,0)),new ArrayList<>(Arrays.asList(0,3))))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_money_required_before_transactions/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42fb9fef44fe519bfe4b3af0e5dc09e38b0b810ecb71ad7b94ad7bd9ac3cf83a
|
| 3 |
+
size 40362911
|
minimum_money_required_before_transactions/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 10 (minimumMoney [[2;1];[5;0];[4;2]])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 3 (minimumMoney [[3;0];[0;3]])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for minimumMoney" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
minimum_money_required_before_transactions/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minimumMoney(List(List(2,1),List(5,0),List(4,2))), 10)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minimumMoney(List(List(3,0),List(0,3))), 3)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
minimum_moves_to_capture_the_queen/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
|
| 7 |
+
--Program end
|
| 8 |
+
|
| 9 |
+
-- Test cases
|
| 10 |
+
|
| 11 |
+
test1 :: Test
|
| 12 |
+
test1 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 1 1 8 8 2 3)," 2 (minMovesToCaptureTheQueen 1 1 8 8 2 3))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 5 3 3 4 5 2)," 1 (minMovesToCaptureTheQueen 5 3 3 4 5 2))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 8 4 6 7 2 1)," 2 (minMovesToCaptureTheQueen 8 4 6 7 2 1))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 4 7 1 4 4 1)," 1 (minMovesToCaptureTheQueen 4 7 1 4 4 1))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 3 7 3 5 5 8)," 2 (minMovesToCaptureTheQueen 3 7 3 5 5 8))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 6 2 4 4 4 6)," 2 (minMovesToCaptureTheQueen 6 2 4 4 4 6))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 7 3 3 4 5 3)," 1 (minMovesToCaptureTheQueen 7 3 3 4 5 3))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 8 6 2 1 1 3)," 2 (minMovesToCaptureTheQueen 8 6 2 1 1 3))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (minMovesToCaptureTheQueen 6 8 1 1 6 3)," 1 (minMovesToCaptureTheQueen 6 8 1 1 6 3))
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
-- Grouping test cases
|
| 40 |
+
tests :: Test
|
| 41 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
|
| 42 |
+
|
| 43 |
+
-- Running the tests
|
| 44 |
+
main :: IO Counts
|
| 45 |
+
main = runTestTT tests
|
minimum_moves_to_capture_the_queen/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(2, minMovesToCaptureTheQueen(1, 1, 8, 8, 2, 3));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, minMovesToCaptureTheQueen(5, 3, 3, 4, 5, 2));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_moves_to_capture_the_queen/meta.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3270,
|
| 3 |
+
"name": "minimum_moves_to_capture_the_queen",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/minimum-moves-to-capture-the-queen/",
|
| 6 |
+
"date": "2023-12-31 00:00:00",
|
| 7 |
+
"task_description": "There is a **1-indexed** `8 x 8` chessboard containing `3` pieces. You are given `6` integers `a`, `b`, `c`, `d`, `e`, and `f` where: `(a, b)` denotes the position of the white rook. `(c, d)` denotes the position of the white bishop. `(e, f)` denotes the position of the black queen. Given that you can only move the white pieces, return _the **minimum** number of moves required to capture the black queen_. **Note** that: Rooks can move any number of squares either vertically or horizontally, but cannot jump over other pieces. Bishops can move any number of squares diagonally, but cannot jump over other pieces. A rook or a bishop can capture the queen if it is located in a square that they can move to. The queen does not move. **Example 1:** ``` **Input:** a = 1, b = 1, c = 8, d = 8, e = 2, f = 3 **Output:** 2 **Explanation:** We can capture the black queen in two moves by moving the white rook to (1, 3) then to (2, 3). It is impossible to capture the black queen in less than two moves since it is not being attacked by any of the pieces at the beginning. ``` **Example 2:** ``` **Input:** a = 5, b = 3, c = 3, d = 4, e = 5, f = 2 **Output:** 1 **Explanation:** We can capture the black queen in a single move by doing one of the following: - Move the white rook to (5, 2). - Move the white bishop to (5, 2). ``` **Constraints:** `1 <= a, b, c, d, e, f <= 8` No two pieces are on the same square.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "a = 1, b = 1, c = 8, d = 8, e = 2, f = 3",
|
| 12 |
+
"output": "2 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "a = 5, b = 3, c = 3, d = 4, e = 5, f = 2",
|
| 17 |
+
"output": "1 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
8,
|
| 24 |
+
4,
|
| 25 |
+
6,
|
| 26 |
+
7,
|
| 27 |
+
2,
|
| 28 |
+
1
|
| 29 |
+
],
|
| 30 |
+
"output": 2
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"input": [
|
| 34 |
+
4,
|
| 35 |
+
7,
|
| 36 |
+
1,
|
| 37 |
+
4,
|
| 38 |
+
4,
|
| 39 |
+
1
|
| 40 |
+
],
|
| 41 |
+
"output": 1
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"input": [
|
| 45 |
+
3,
|
| 46 |
+
7,
|
| 47 |
+
3,
|
| 48 |
+
5,
|
| 49 |
+
5,
|
| 50 |
+
8
|
| 51 |
+
],
|
| 52 |
+
"output": 2
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"input": [
|
| 56 |
+
6,
|
| 57 |
+
2,
|
| 58 |
+
4,
|
| 59 |
+
4,
|
| 60 |
+
4,
|
| 61 |
+
6
|
| 62 |
+
],
|
| 63 |
+
"output": 2
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"input": [
|
| 67 |
+
7,
|
| 68 |
+
3,
|
| 69 |
+
3,
|
| 70 |
+
4,
|
| 71 |
+
5,
|
| 72 |
+
3
|
| 73 |
+
],
|
| 74 |
+
"output": 1
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"input": [
|
| 78 |
+
8,
|
| 79 |
+
6,
|
| 80 |
+
2,
|
| 81 |
+
1,
|
| 82 |
+
1,
|
| 83 |
+
3
|
| 84 |
+
],
|
| 85 |
+
"output": 2
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"input": [
|
| 89 |
+
6,
|
| 90 |
+
8,
|
| 91 |
+
1,
|
| 92 |
+
1,
|
| 93 |
+
6,
|
| 94 |
+
3
|
| 95 |
+
],
|
| 96 |
+
"output": 1
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"input": [
|
| 100 |
+
2,
|
| 101 |
+
4,
|
| 102 |
+
6,
|
| 103 |
+
7,
|
| 104 |
+
1,
|
| 105 |
+
3
|
| 106 |
+
],
|
| 107 |
+
"output": 2
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"input": [
|
| 111 |
+
7,
|
| 112 |
+
1,
|
| 113 |
+
4,
|
| 114 |
+
7,
|
| 115 |
+
7,
|
| 116 |
+
5
|
| 117 |
+
],
|
| 118 |
+
"output": 1
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"input": [
|
| 122 |
+
3,
|
| 123 |
+
4,
|
| 124 |
+
1,
|
| 125 |
+
5,
|
| 126 |
+
6,
|
| 127 |
+
2
|
| 128 |
+
],
|
| 129 |
+
"output": 2
|
| 130 |
+
}
|
| 131 |
+
],
|
| 132 |
+
"haskell_template": "minMovesToCaptureTheQueen :: Int -> Int -> Int -> Int -> Int -> Int -> Int\nminMovesToCaptureTheQueen a b c d e f ",
|
| 133 |
+
"ocaml_template": "let minMovesToCaptureTheQueen (a: int) (b: int) (c: int) (d: int) (e: int) (f: int) : int = ",
|
| 134 |
+
"scala_template": "def minMovesToCaptureTheQueen(a: Int,b: Int,c: Int,d: Int,e: Int,f: Int): Int = { \n \n}",
|
| 135 |
+
"java_template": "class Solution {\n public int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {\n \n }\n}",
|
| 136 |
+
"python_template": "class Solution(object):\n def minMovesToCaptureTheQueen(self, a, b, c, d, e, f):\n \"\"\"\n :type a: int\n :type b: int\n :type c: int\n :type d: int\n :type e: int\n :type f: int\n :rtype: int\n \"\"\"\n "
|
| 137 |
+
}
|
minimum_moves_to_capture_the_queen/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 2 (minMovesToCaptureTheQueen 1 1 8 8 2 3)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 1 (minMovesToCaptureTheQueen 5 3 3 4 5 2)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 2 (minMovesToCaptureTheQueen 8 4 6 7 2 1)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 1 (minMovesToCaptureTheQueen 4 7 1 4 4 1)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 2 (minMovesToCaptureTheQueen 3 7 3 5 5 8)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 2 (minMovesToCaptureTheQueen 6 2 4 4 4 6)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 1 (minMovesToCaptureTheQueen 7 3 3 4 5 3)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 2 (minMovesToCaptureTheQueen 8 6 2 1 1 3)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 1 (minMovesToCaptureTheQueen 6 8 1 1 6 3)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 2 (minMovesToCaptureTheQueen 2 4 6 7 1 3)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for minMovesToCaptureTheQueen" >::: [
|
| 34 |
+
|
| 35 |
+
"test1" >:: test1;
|
| 36 |
+
"test2" >:: test2;
|
| 37 |
+
"test3" >:: test3;
|
| 38 |
+
"test4" >:: test4;
|
| 39 |
+
"test5" >:: test5;
|
| 40 |
+
"test6" >:: test6;
|
| 41 |
+
"test7" >:: test7;
|
| 42 |
+
"test8" >:: test8;
|
| 43 |
+
"test9" >:: test9;
|
| 44 |
+
"test10" >:: test10;
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
(* Running the tests *)
|
| 49 |
+
let () = run_test_tt_main suite
|
| 50 |
+
end
|
minimum_moves_to_capture_the_queen/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minMovesToCaptureTheQueen(1,1,8,8,2,3), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minMovesToCaptureTheQueen(5,3,3,4,5,2), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.minMovesToCaptureTheQueen(8,4,6,7,2,1), 2)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.minMovesToCaptureTheQueen(4,7,1,4,4,1), 1)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.minMovesToCaptureTheQueen(3,7,3,5,5,8), 2)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.minMovesToCaptureTheQueen(6,2,4,4,4,6), 2)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.minMovesToCaptureTheQueen(7,3,3,4,5,3), 1)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.minMovesToCaptureTheQueen(8,6,2,1,1,3), 2)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.minMovesToCaptureTheQueen(6,8,1,1,6,3), 1)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.minMovesToCaptureTheQueen(2,4,6,7,1,3), 2)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|