DatasetRepo commited on
Commit
0912700
·
verified ·
1 Parent(s): 32c952c

ece040cec26d5826aa5bd6f2dee393fb1cbbc5499c3603466ca7aeec86debd37

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +6 -0
  2. minimum_operations_to_make_all_array_elements_equal/meta.json +26 -0
  3. minimum_operations_to_make_all_array_elements_equal/ocaml_tests/main.ml +26 -0
  4. minimum_operations_to_make_all_array_elements_equal/scala_tests/MySuite.scala +12 -0
  5. minimum_operations_to_make_array_elements_zero/haskell_tests/Main.hs +26 -0
  6. minimum_operations_to_make_array_elements_zero/java_tests/Main.java +20 -0
  7. minimum_operations_to_make_array_elements_zero/meta.json +26 -0
  8. minimum_operations_to_make_array_elements_zero/ocaml_tests/main.ml +27 -0
  9. minimum_operations_to_make_array_elements_zero/scala_tests/MySuite.scala +12 -0
  10. minimum_operations_to_make_array_equal_ii/.DS_Store +0 -0
  11. minimum_operations_to_make_array_equal_ii/haskell_tests/Main.hs +24 -0
  12. minimum_operations_to_make_array_equal_ii/java_tests/Main.java +21 -0
  13. minimum_operations_to_make_array_equal_ii/meta.json +3 -0
  14. minimum_operations_to_make_array_equal_ii/ocaml_tests/main.ml +26 -0
  15. minimum_operations_to_make_array_equal_ii/scala_tests/MySuite.scala +12 -0
  16. minimum_operations_to_make_array_equal_to_target/haskell_tests/Main.hs +3 -0
  17. minimum_operations_to_make_array_equal_to_target/java_tests/Main.java +21 -0
  18. minimum_operations_to_make_array_equal_to_target/meta.json +3 -0
  19. minimum_operations_to_make_array_equal_to_target/ocaml_tests/main.ml +0 -0
  20. minimum_operations_to_make_array_equal_to_target/scala_tests/MySuite.scala +0 -0
  21. minimum_operations_to_make_array_values_equal_to_k/haskell_tests/Main.hs +45 -0
  22. minimum_operations_to_make_array_values_equal_to_k/java_tests/Main.java +25 -0
  23. minimum_operations_to_make_array_values_equal_to_k/meta.json +565 -0
  24. minimum_operations_to_make_array_values_equal_to_k/ocaml_tests/main.ml +50 -0
  25. minimum_operations_to_make_array_values_equal_to_k/scala_tests/MySuite.scala +44 -0
  26. minimum_operations_to_make_binary_array_elements_equal_to_one_i/haskell_tests/Main.hs +0 -0
  27. minimum_operations_to_make_binary_array_elements_equal_to_one_i/java_tests/Main.java +20 -0
  28. minimum_operations_to_make_binary_array_elements_equal_to_one_i/meta.json +0 -0
  29. minimum_operations_to_make_binary_array_elements_equal_to_one_i/ocaml_tests/main.ml +0 -0
  30. minimum_operations_to_make_binary_array_elements_equal_to_one_i/scala_tests/MySuite.scala +0 -0
  31. minimum_operations_to_make_binary_array_elements_equal_to_one_ii/haskell_tests/Main.hs +0 -0
  32. minimum_operations_to_make_binary_array_elements_equal_to_one_ii/java_tests/Main.java +20 -0
  33. minimum_operations_to_make_binary_array_elements_equal_to_one_ii/meta.json +0 -0
  34. minimum_operations_to_make_binary_array_elements_equal_to_one_ii/ocaml_tests/main.ml +0 -0
  35. minimum_operations_to_make_binary_array_elements_equal_to_one_ii/scala_tests/MySuite.scala +0 -0
  36. minimum_operations_to_make_columns_strictly_increasing/haskell_tests/Main.hs +41 -0
  37. minimum_operations_to_make_columns_strictly_increasing/java_tests/Main.java +20 -0
  38. minimum_operations_to_make_columns_strictly_increasing/meta.json +1195 -0
  39. minimum_operations_to_make_columns_strictly_increasing/ocaml_tests/main.ml +42 -0
  40. minimum_operations_to_make_columns_strictly_increasing/scala_tests/MySuite.scala +32 -0
  41. minimum_operations_to_make_median_of_array_equal_to_k/haskell_tests/Main.hs +3 -0
  42. minimum_operations_to_make_median_of_array_equal_to_k/java_tests/Main.java +25 -0
  43. minimum_operations_to_make_median_of_array_equal_to_k/meta.json +3 -0
  44. minimum_operations_to_make_median_of_array_equal_to_k/ocaml_tests/main.ml +0 -0
  45. minimum_operations_to_make_median_of_array_equal_to_k/scala_tests/MySuite.scala +0 -0
  46. minimum_operations_to_make_the_array_alternating/.DS_Store +0 -0
  47. minimum_operations_to_make_the_array_alternating/haskell_tests/Main.hs +24 -0
  48. minimum_operations_to_make_the_array_alternating/java_tests/Main.java +21 -0
  49. minimum_operations_to_make_the_array_alternating/meta.json +3 -0
  50. minimum_operations_to_make_the_array_alternating/ocaml_tests/main.ml +26 -0
.gitattributes CHANGED
@@ -227,3 +227,9 @@ minimum_number_of_operations_to_satisfy_conditions/meta.json filter=lfs diff=lfs
227
  minimum_operations_to_exceed_threshold_value_ii/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
228
  minimum_operations_to_exceed_threshold_value_ii/meta.json filter=lfs diff=lfs merge=lfs -text
229
  minimum_operations_to_halve_array_sum/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
227
  minimum_operations_to_exceed_threshold_value_ii/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
228
  minimum_operations_to_exceed_threshold_value_ii/meta.json filter=lfs diff=lfs merge=lfs -text
229
  minimum_operations_to_halve_array_sum/meta.json filter=lfs diff=lfs merge=lfs -text
230
+ minimum_operations_to_make_array_equal_ii/meta.json filter=lfs diff=lfs merge=lfs -text
231
+ minimum_operations_to_make_array_equal_to_target/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
232
+ minimum_operations_to_make_array_equal_to_target/meta.json filter=lfs diff=lfs merge=lfs -text
233
+ minimum_operations_to_make_median_of_array_equal_to_k/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
234
+ minimum_operations_to_make_median_of_array_equal_to_k/meta.json filter=lfs diff=lfs merge=lfs -text
235
+ minimum_operations_to_make_the_array_alternating/meta.json filter=lfs diff=lfs merge=lfs -text
minimum_operations_to_make_all_array_elements_equal/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2718,
3
+ "name": "minimum_operations_to_make_all_array_elements_equal",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/minimum-operations-to-make-all-array-elements-equal/",
6
+ "date": "1679184000000",
7
+ "task_description": "You are given an array `nums` consisting of positive integers. You are also given an integer array `queries` of size `m`. For the `ith` query, you want to make all of the elements of `nums` equal to` queries[i]`. You can perform the following operation on the array **any** number of times: **Increase** or **decrease** an element of the array by `1`. Return _an array _`answer`_ of size _`m`_ where _`answer[i]`_ is the **minimum** number of operations to make all elements of _`nums`_ equal to _`queries[i]`. **Note** that after each query the array is reset to its original state. **Example 1:** ``` **Input:** nums = [3,1,6,8], queries = [1,5] **Output:** [14,10] **Explanation:** For the first query we can do the following operations: - Decrease nums[0] 2 times, so that nums = [1,1,6,8]. - Decrease nums[2] 5 times, so that nums = [1,1,1,8]. - Decrease nums[3] 7 times, so that nums = [1,1,1,1]. So the total number of operations for the first query is 2 + 5 + 7 = 14. For the second query we can do the following operations: - Increase nums[0] 2 times, so that nums = [5,1,6,8]. - Increase nums[1] 4 times, so that nums = [5,5,6,8]. - Decrease nums[2] 1 time, so that nums = [5,5,5,8]. - Decrease nums[3] 3 times, so that nums = [5,5,5,5]. So the total number of operations for the second query is 2 + 4 + 1 + 3 = 10. ``` **Example 2:** ``` **Input:** nums = [2,9,6,3], queries = [10] **Output:** [20] **Explanation:** We can increase each value in the array to 10. The total number of operations will be 8 + 1 + 4 + 7 = 20. ``` **Constraints:** `n == nums.length` `m == queries.length` `1 <= n, m <= 105` `1 <= nums[i], queries[i] <= 109`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [3,1,6,8], queries = [1,5]",
12
+ "output": "[14,10] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [2,9,6,3], queries = [10]",
17
+ "output": "[20] "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "minOperations :: [Int] -> [Int] -> [Int]\nminOperations nums queries ",
22
+ "ocaml_template": "let minOperations (nums: int list) (queries: int list) : int list = ",
23
+ "scala_template": "def minOperations(nums: List[Int],queries: List[Int]): List[Int] = { \n \n}",
24
+ "java_template": "public static List<Integer> minOperations(List<Integer> nums, List<Integer> queries) {\n\n}",
25
+ "python_template": "class Solution(object):\n def minOperations(self, nums, queries):\n \"\"\"\n :type nums: List[int]\n :type queries: List[int]\n :rtype: List[int]\n \"\"\"\n "
26
+ }
minimum_operations_to_make_all_array_elements_equal/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 [14;10] (minOperations [3;1;6;8] [1;5])
12
+
13
+ let test2 _ = assert_equal [20] (minOperations [2;9;6;3] [10])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minOperations" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
minimum_operations_to_make_all_array_elements_equal/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minOperations(List(3,1,6,8),List(1,5)), List(14,10))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minOperations(List(2,9,6,3),List(10)), List(20))
10
+ }
11
+
12
+ }
minimum_operations_to_make_array_elements_zero/haskell_tests/Main.hs ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minOperations :: [[Int]] -> Int
7
+ minOperations queries = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minOperations [[1,2],[2,4]])," 3 (minOperations [[1,2],[2,4]]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minOperations [[2,6]])," 4 (minOperations [[2,6]]))
18
+
19
+
20
+ -- Grouping test cases
21
+ tests :: Test
22
+ tests = TestList [TestLabel "Test1" test1]
23
+
24
+ -- Running the tests
25
+ main :: IO Counts
26
+ main = runTestTT tests
minimum_operations_to_make_array_elements_zero/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(3, minOperations(Arrays.asList(Arrays.asList(1,2),Arrays.asList(2,4))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(4, minOperations(Arrays.asList(Arrays.asList(2,6))));
18
+ }
19
+
20
+ }
minimum_operations_to_make_array_elements_zero/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3744,
3
+ "name": "minimum_operations_to_make_array_elements_zero",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/minimum-operations-to-make-array-elements-zero/",
6
+ "date": "2025-03-16 00:00:00",
7
+ "task_description": "You are given a 2D array `queries`, where `queries[i]` is of the form `[l, r]`. Each `queries[i]` defines an array of integers `nums` consisting of elements ranging from `l` to `r`, both **inclusive**. In one operation, you can: Select two integers `a` and `b` from the array. Replace them with `floor(a / 4)` and `floor(b / 4)`. Your task is to determine the **minimum** number of operations required to reduce all elements of the array to zero for each query. Return the sum of the results for all queries. **Example 1:** **Input:** queries = [[1,2],[2,4]] **Output:** 3 **Explanation:** For `queries[0]`: The initial array is `nums = [1, 2]`. In the first operation, select `nums[0]` and `nums[1]`. The array becomes `[0, 0]`. The minimum number of operations required is 1. For `queries[1]`: The initial array is `nums = [2, 3, 4]`. In the first operation, select `nums[0]` and `nums[2]`. The array becomes `[0, 3, 1]`. In the second operation, select `nums[1]` and `nums[2]`. The array becomes `[0, 0, 0]`. The minimum number of operations required is 2. The output is `1 + 2 = 3`. **Example 2:** **Input:** queries = [[2,6]] **Output:** 4 **Explanation:** For `queries[0]`: The initial array is `nums = [2, 3, 4, 5, 6]`. In the first operation, select `nums[0]` and `nums[3]`. The array becomes `[0, 3, 4, 1, 6]`. In the second operation, select `nums[2]` and `nums[4]`. The array becomes `[0, 3, 1, 1, 1]`. In the third operation, select `nums[1]` and `nums[2]`. The array becomes `[0, 0, 0, 1, 1]`. In the fourth operation, select `nums[3]` and `nums[4]`. The array becomes `[0, 0, 0, 0, 0]`. The minimum number of operations required is 4. The output is 4. **Constraints:** `1 <= queries.length <= 105` `queries[i].length == 2` `queries[i] == [l, r]` `1 <= l < r <= 109`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "queries = [[1,2],[2,4]]",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "queries = [[2,6]]",
17
+ "output": "4 "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "minOperations :: [[Int]] -> Int\nminOperations queries ",
22
+ "ocaml_template": "let minOperations (queries: int list list) : int = ",
23
+ "scala_template": "def minOperations(queries: List[List[Int]]): Int = { \n \n}",
24
+ "java_template": "class Solution {\n public long minOperations(int[][] queries) {\n \n }\n}",
25
+ "python_template": "class Solution(object):\n def minOperations(self, queries):\n \"\"\"\n :type queries: List[List[int]]\n :rtype: int\n \"\"\"\n "
26
+ }
minimum_operations_to_make_array_elements_zero/ocaml_tests/main.ml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minOperations (queries: int list list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 3 (minOperations [[1;2];[2;4]])
13
+
14
+ let test2 _ = assert_equal 4 (minOperations [[2;6]])
15
+
16
+
17
+ (* Grouping test cases *)
18
+ let suite = "Test Suite for minOperations" >::: [
19
+
20
+ "test1" >:: test1;
21
+ "test2" >:: test2;
22
+ ]
23
+
24
+
25
+ (* Running the tests *)
26
+ let () = run_test_tt_main suite
27
+ end
minimum_operations_to_make_array_elements_zero/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minOperations(List(List(1,2),List(2,4))), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minOperations(List(List(2,6))), 4)
10
+ }
11
+
12
+ }
minimum_operations_to_make_array_equal_ii/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimum_operations_to_make_array_equal_ii/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 (minOperations [4,3,1,4] [1,3,7,1] 3)," 2 (minOperations [4,3,1,4] [1,3,7,1] 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minOperations [3,8,5,2] [2,4,1,6] 1)," (-1) (minOperations [3,8,5,2] [2,4,1,6] 1))
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_operations_to_make_array_equal_ii/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, minOperations(new ArrayList<>(Arrays.asList(4,3,1,4)), new ArrayList<>(Arrays.asList(1,3,7,1)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, minOperations(new ArrayList<>(Arrays.asList(3,8,5,2)), new ArrayList<>(Arrays.asList(2,4,1,6)), 1));
19
+ }
20
+
21
+ }
minimum_operations_to_make_array_equal_ii/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44120829e884ad49a50965ce79c536597b613dfa452b8862cc52d4efbcc7cac6
3
+ size 26003395
minimum_operations_to_make_array_equal_ii/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 2 (minOperations [4;3;1;4] [1;3;7;1] 3)
12
+
13
+ let test2 _ = assert_equal (-1) (minOperations [3;8;5;2] [2;4;1;6] 1)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minOperations" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
minimum_operations_to_make_array_equal_ii/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minOperations(List(4,3,1,4),List(1,3,7,1),3), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minOperations(List(3,8,5,2),List(2,4,1,6),1), -1)
10
+ }
11
+
12
+ }
minimum_operations_to_make_array_equal_to_target/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:925ea5ffc5802e4c3b5a563e039139a284f835b5db7fd7e0951286b892544105
3
+ size 12206980
minimum_operations_to_make_array_equal_to_target/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, minimumOperations(new ArrayList<>(Arrays.asList(3,5,1,2)), new ArrayList<>(Arrays.asList(4,6,2,4))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(5, minimumOperations(new ArrayList<>(Arrays.asList(1,3,2)), new ArrayList<>(Arrays.asList(2,1,4))));
19
+ }
20
+
21
+ }
minimum_operations_to_make_array_equal_to_target/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5094cf70d2d8c38f08a4678063c41bf9f6ef2dd23645b54c6b2a05022e74609
3
+ size 28850001
minimum_operations_to_make_array_equal_to_target/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_array_equal_to_target/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_array_values_equal_to_k/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 (minOperations [5,2,5,4,5] 2)," 2 (minOperations [5,2,5,4,5] 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minOperations [2,1,2] 2)," (-1) (minOperations [2,1,2] 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minOperations [9,7,5,3] 1)," 4 (minOperations [9,7,5,3] 1))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (minOperations [40, 99, 29, 74, 59, 35, 87, 76, 92, 18, 23, 59, 37, 72, 59, 22, 100, 34, 34, 63, 84, 38, 96, 63, 65, 64, 15, 55, 54, 36, 6, 87, 48, 10, 61, 40, 62, 51, 64, 77, 61, 60, 90, 93, 41, 64, 39, 72, 27, 75, 71, 82, 15] 46)," (-1) (minOperations [40, 99, 29, 74, 59, 35, 87, 76, 92, 18, 23, 59, 37, 72, 59, 22, 100, 34, 34, 63, 84, 38, 96, 63, 65, 64, 15, 55, 54, 36, 6, 87, 48, 10, 61, 40, 62, 51, 64, 77, 61, 60, 90, 93, 41, 64, 39, 72, 27, 75, 71, 82, 15] 46))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (minOperations [73, 80, 65, 6, 85, 3, 67, 52, 37, 97, 24, 59, 34, 5, 95, 10, 52, 80, 99, 93, 42, 66, 19, 95, 74, 76, 71, 66, 77, 76, 30, 34, 83, 55, 81, 97, 38, 86, 65, 24, 48, 80, 17, 54, 29, 3, 63, 4, 38, 88, 30, 2, 30, 75, 81, 8, 5, 90, 31] 65)," (-1) (minOperations [73, 80, 65, 6, 85, 3, 67, 52, 37, 97, 24, 59, 34, 5, 95, 10, 52, 80, 99, 93, 42, 66, 19, 95, 74, 76, 71, 66, 77, 76, 30, 34, 83, 55, 81, 97, 38, 86, 65, 24, 48, 80, 17, 54, 29, 3, 63, 4, 38, 88, 30, 2, 30, 75, 81, 8, 5, 90, 31] 65))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (minOperations [63, 21, 26, 82, 95, 2, 100, 69, 52, 67, 67, 78, 36, 22, 17, 76, 2, 10, 65, 61, 20, 49, 27, 63, 74, 99, 56, 85, 30, 94, 56, 66, 78, 99, 10, 30, 68, 39, 34, 27, 83, 18, 23, 18, 27, 30, 26, 1, 78, 16, 16, 19, 31, 98, 30, 95, 10, 10, 20, 5, 80, 6, 39, 14, 98, 21, 9, 33, 82, 13, 33, 33, 42, 73, 29, 67, 17, 76, 19, 92, 55, 69, 56, 35, 71, 70, 39, 44, 38, 19, 100, 4, 54, 31] 68)," (-1) (minOperations [63, 21, 26, 82, 95, 2, 100, 69, 52, 67, 67, 78, 36, 22, 17, 76, 2, 10, 65, 61, 20, 49, 27, 63, 74, 99, 56, 85, 30, 94, 56, 66, 78, 99, 10, 30, 68, 39, 34, 27, 83, 18, 23, 18, 27, 30, 26, 1, 78, 16, 16, 19, 31, 98, 30, 95, 10, 10, 20, 5, 80, 6, 39, 14, 98, 21, 9, 33, 82, 13, 33, 33, 42, 73, 29, 67, 17, 76, 19, 92, 55, 69, 56, 35, 71, 70, 39, 44, 38, 19, 100, 4, 54, 31] 68))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (minOperations [82, 17, 35, 3, 93, 79, 33, 29, 77, 50, 47, 48, 8, 61, 78, 34, 63, 21, 82, 84, 85, 84, 58, 76, 48, 69, 55, 31, 55, 90, 28, 46, 4, 45, 71, 42, 40, 82, 37, 20] 31)," (-1) (minOperations [82, 17, 35, 3, 93, 79, 33, 29, 77, 50, 47, 48, 8, 61, 78, 34, 63, 21, 82, 84, 85, 84, 58, 76, 48, 69, 55, 31, 55, 90, 28, 46, 4, 45, 71, 42, 40, 82, 37, 20] 31))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (minOperations [89, 22, 3, 78, 1, 77, 18, 60, 12, 10, 61, 93, 14, 49, 23, 34, 92, 54, 92, 4, 68, 15, 39, 86, 16, 94, 26, 45, 8, 59, 28, 84, 75, 66, 32, 85, 11, 6, 55] 55)," (-1) (minOperations [89, 22, 3, 78, 1, 77, 18, 60, 12, 10, 61, 93, 14, 49, 23, 34, 92, 54, 92, 4, 68, 15, 39, 86, 16, 94, 26, 45, 8, 59, 28, 84, 75, 66, 32, 85, 11, 6, 55] 55))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (minOperations [60, 52, 92, 54, 70, 29, 16, 30, 10, 45, 3, 31, 48, 85, 2, 91, 75, 49] 49)," (-1) (minOperations [60, 52, 92, 54, 70, 29, 16, 30, 10, 45, 3, 31, 48, 85, 2, 91, 75, 49] 49))
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_operations_to_make_array_values_equal_to_k/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, minOperations(new ArrayList<>(Arrays.asList(5,2,5,4,5)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, minOperations(new ArrayList<>(Arrays.asList(2,1,2)), 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(4, minOperations(new ArrayList<>(Arrays.asList(9,7,5,3)), 1));
23
+ }
24
+
25
+ }
minimum_operations_to_make_array_values_equal_to_k/meta.json ADDED
@@ -0,0 +1,565 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3621,
3
+ "name": "minimum_operations_to_make_array_values_equal_to_k",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/",
6
+ "date": "2024-11-23 00:00:00",
7
+ "task_description": "You are given an integer array `nums` and an integer `k`. An integer `h` is called **valid** if all values in the array that are **strictly greater** than `h` are _identical_. For example, if `nums = [10, 8, 10, 8]`, a **valid** integer is `h = 9` because all `nums[i] > 9` are equal to 10, but 5 is not a **valid** integer. You are allowed to perform the following operation on `nums`: Select an integer `h` that is _valid_ for the **current** values in `nums`. For each index `i` where `nums[i] > h`, set `nums[i]` to `h`. Return the **minimum** number of operations required to make every element in `nums` **equal** to `k`. If it is impossible to make all elements equal to `k`, return -1. **Example 1:** **Input:** nums = [5,2,5,4,5], k = 2 **Output:** 2 **Explanation:** The operations can be performed in order using valid integers 4 and then 2. **Example 2:** **Input:** nums = [2,1,2], k = 2 **Output:** -1 **Explanation:** It is impossible to make all the values equal to 2. **Example 3:** **Input:** nums = [9,7,5,3], k = 1 **Output:** 4 **Explanation:** The operations can be performed using valid integers in the order 7, 5, 3, and 1. **Constraints:** `1 <= nums.length <= 100 ` `1 <= nums[i] <= 100` `1 <= k <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [5,2,5,4,5], k = 2",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [2,1,2], k = 2",
17
+ "output": "-1 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [9,7,5,3], k = 1",
22
+ "output": "4 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ [
29
+ 40,
30
+ 99,
31
+ 29,
32
+ 74,
33
+ 59,
34
+ 35,
35
+ 87,
36
+ 76,
37
+ 92,
38
+ 18,
39
+ 23,
40
+ 59,
41
+ 37,
42
+ 72,
43
+ 59,
44
+ 22,
45
+ 100,
46
+ 34,
47
+ 34,
48
+ 63,
49
+ 84,
50
+ 38,
51
+ 96,
52
+ 63,
53
+ 65,
54
+ 64,
55
+ 15,
56
+ 55,
57
+ 54,
58
+ 36,
59
+ 6,
60
+ 87,
61
+ 48,
62
+ 10,
63
+ 61,
64
+ 40,
65
+ 62,
66
+ 51,
67
+ 64,
68
+ 77,
69
+ 61,
70
+ 60,
71
+ 90,
72
+ 93,
73
+ 41,
74
+ 64,
75
+ 39,
76
+ 72,
77
+ 27,
78
+ 75,
79
+ 71,
80
+ 82,
81
+ 15
82
+ ],
83
+ 46
84
+ ],
85
+ "output": -1
86
+ },
87
+ {
88
+ "input": [
89
+ [
90
+ 73,
91
+ 80,
92
+ 65,
93
+ 6,
94
+ 85,
95
+ 3,
96
+ 67,
97
+ 52,
98
+ 37,
99
+ 97,
100
+ 24,
101
+ 59,
102
+ 34,
103
+ 5,
104
+ 95,
105
+ 10,
106
+ 52,
107
+ 80,
108
+ 99,
109
+ 93,
110
+ 42,
111
+ 66,
112
+ 19,
113
+ 95,
114
+ 74,
115
+ 76,
116
+ 71,
117
+ 66,
118
+ 77,
119
+ 76,
120
+ 30,
121
+ 34,
122
+ 83,
123
+ 55,
124
+ 81,
125
+ 97,
126
+ 38,
127
+ 86,
128
+ 65,
129
+ 24,
130
+ 48,
131
+ 80,
132
+ 17,
133
+ 54,
134
+ 29,
135
+ 3,
136
+ 63,
137
+ 4,
138
+ 38,
139
+ 88,
140
+ 30,
141
+ 2,
142
+ 30,
143
+ 75,
144
+ 81,
145
+ 8,
146
+ 5,
147
+ 90,
148
+ 31
149
+ ],
150
+ 65
151
+ ],
152
+ "output": -1
153
+ },
154
+ {
155
+ "input": [
156
+ [
157
+ 63,
158
+ 21,
159
+ 26,
160
+ 82,
161
+ 95,
162
+ 2,
163
+ 100,
164
+ 69,
165
+ 52,
166
+ 67,
167
+ 67,
168
+ 78,
169
+ 36,
170
+ 22,
171
+ 17,
172
+ 76,
173
+ 2,
174
+ 10,
175
+ 65,
176
+ 61,
177
+ 20,
178
+ 49,
179
+ 27,
180
+ 63,
181
+ 74,
182
+ 99,
183
+ 56,
184
+ 85,
185
+ 30,
186
+ 94,
187
+ 56,
188
+ 66,
189
+ 78,
190
+ 99,
191
+ 10,
192
+ 30,
193
+ 68,
194
+ 39,
195
+ 34,
196
+ 27,
197
+ 83,
198
+ 18,
199
+ 23,
200
+ 18,
201
+ 27,
202
+ 30,
203
+ 26,
204
+ 1,
205
+ 78,
206
+ 16,
207
+ 16,
208
+ 19,
209
+ 31,
210
+ 98,
211
+ 30,
212
+ 95,
213
+ 10,
214
+ 10,
215
+ 20,
216
+ 5,
217
+ 80,
218
+ 6,
219
+ 39,
220
+ 14,
221
+ 98,
222
+ 21,
223
+ 9,
224
+ 33,
225
+ 82,
226
+ 13,
227
+ 33,
228
+ 33,
229
+ 42,
230
+ 73,
231
+ 29,
232
+ 67,
233
+ 17,
234
+ 76,
235
+ 19,
236
+ 92,
237
+ 55,
238
+ 69,
239
+ 56,
240
+ 35,
241
+ 71,
242
+ 70,
243
+ 39,
244
+ 44,
245
+ 38,
246
+ 19,
247
+ 100,
248
+ 4,
249
+ 54,
250
+ 31
251
+ ],
252
+ 68
253
+ ],
254
+ "output": -1
255
+ },
256
+ {
257
+ "input": [
258
+ [
259
+ 82,
260
+ 17,
261
+ 35,
262
+ 3,
263
+ 93,
264
+ 79,
265
+ 33,
266
+ 29,
267
+ 77,
268
+ 50,
269
+ 47,
270
+ 48,
271
+ 8,
272
+ 61,
273
+ 78,
274
+ 34,
275
+ 63,
276
+ 21,
277
+ 82,
278
+ 84,
279
+ 85,
280
+ 84,
281
+ 58,
282
+ 76,
283
+ 48,
284
+ 69,
285
+ 55,
286
+ 31,
287
+ 55,
288
+ 90,
289
+ 28,
290
+ 46,
291
+ 4,
292
+ 45,
293
+ 71,
294
+ 42,
295
+ 40,
296
+ 82,
297
+ 37,
298
+ 20
299
+ ],
300
+ 31
301
+ ],
302
+ "output": -1
303
+ },
304
+ {
305
+ "input": [
306
+ [
307
+ 89,
308
+ 22,
309
+ 3,
310
+ 78,
311
+ 1,
312
+ 77,
313
+ 18,
314
+ 60,
315
+ 12,
316
+ 10,
317
+ 61,
318
+ 93,
319
+ 14,
320
+ 49,
321
+ 23,
322
+ 34,
323
+ 92,
324
+ 54,
325
+ 92,
326
+ 4,
327
+ 68,
328
+ 15,
329
+ 39,
330
+ 86,
331
+ 16,
332
+ 94,
333
+ 26,
334
+ 45,
335
+ 8,
336
+ 59,
337
+ 28,
338
+ 84,
339
+ 75,
340
+ 66,
341
+ 32,
342
+ 85,
343
+ 11,
344
+ 6,
345
+ 55
346
+ ],
347
+ 55
348
+ ],
349
+ "output": -1
350
+ },
351
+ {
352
+ "input": [
353
+ [
354
+ 60,
355
+ 52,
356
+ 92,
357
+ 54,
358
+ 70,
359
+ 29,
360
+ 16,
361
+ 30,
362
+ 10,
363
+ 45,
364
+ 3,
365
+ 31,
366
+ 48,
367
+ 85,
368
+ 2,
369
+ 91,
370
+ 75,
371
+ 49
372
+ ],
373
+ 49
374
+ ],
375
+ "output": -1
376
+ },
377
+ {
378
+ "input": [
379
+ [
380
+ 21,
381
+ 15,
382
+ 83,
383
+ 9,
384
+ 55,
385
+ 79,
386
+ 99,
387
+ 79,
388
+ 25,
389
+ 37,
390
+ 88,
391
+ 61,
392
+ 11,
393
+ 63,
394
+ 18,
395
+ 20,
396
+ 60,
397
+ 15,
398
+ 96,
399
+ 77,
400
+ 79,
401
+ 93,
402
+ 25,
403
+ 14,
404
+ 10,
405
+ 31,
406
+ 28,
407
+ 37,
408
+ 26,
409
+ 2,
410
+ 5,
411
+ 38,
412
+ 98,
413
+ 85,
414
+ 26,
415
+ 51,
416
+ 94,
417
+ 67,
418
+ 84,
419
+ 77,
420
+ 30,
421
+ 58,
422
+ 97,
423
+ 30,
424
+ 95,
425
+ 82,
426
+ 64
427
+ ],
428
+ 14
429
+ ],
430
+ "output": -1
431
+ },
432
+ {
433
+ "input": [
434
+ [
435
+ 68,
436
+ 3,
437
+ 91,
438
+ 58,
439
+ 85,
440
+ 75,
441
+ 42,
442
+ 7,
443
+ 13,
444
+ 12,
445
+ 51,
446
+ 12,
447
+ 43,
448
+ 46,
449
+ 16,
450
+ 10,
451
+ 28,
452
+ 73,
453
+ 73,
454
+ 65,
455
+ 31,
456
+ 17,
457
+ 54,
458
+ 9,
459
+ 39,
460
+ 86,
461
+ 85,
462
+ 24,
463
+ 19,
464
+ 66,
465
+ 36,
466
+ 50,
467
+ 75,
468
+ 55,
469
+ 50,
470
+ 25
471
+ ],
472
+ 88
473
+ ],
474
+ "output": -1
475
+ },
476
+ {
477
+ "input": [
478
+ [
479
+ 90,
480
+ 77,
481
+ 80,
482
+ 41,
483
+ 9,
484
+ 49,
485
+ 55,
486
+ 60,
487
+ 46,
488
+ 54,
489
+ 46,
490
+ 20,
491
+ 3,
492
+ 72,
493
+ 17,
494
+ 96,
495
+ 41,
496
+ 73
497
+ ],
498
+ 20
499
+ ],
500
+ "output": -1
501
+ },
502
+ {
503
+ "input": [
504
+ [
505
+ 34,
506
+ 99,
507
+ 20,
508
+ 50,
509
+ 29,
510
+ 80,
511
+ 87,
512
+ 46,
513
+ 38,
514
+ 64,
515
+ 95,
516
+ 18,
517
+ 14,
518
+ 9,
519
+ 72,
520
+ 42,
521
+ 7,
522
+ 76,
523
+ 62,
524
+ 17,
525
+ 28,
526
+ 76,
527
+ 70,
528
+ 60,
529
+ 95,
530
+ 61,
531
+ 85,
532
+ 70,
533
+ 21,
534
+ 11,
535
+ 56,
536
+ 93,
537
+ 34,
538
+ 32,
539
+ 87,
540
+ 73,
541
+ 28,
542
+ 56,
543
+ 77,
544
+ 84,
545
+ 53,
546
+ 58,
547
+ 78,
548
+ 1,
549
+ 95,
550
+ 39,
551
+ 83,
552
+ 44,
553
+ 93
554
+ ],
555
+ 8
556
+ ],
557
+ "output": -1
558
+ }
559
+ ],
560
+ "haskell_template": "minOperations :: [Int] -> Int -> Int\nminOperations nums k ",
561
+ "ocaml_template": "let minOperations (nums: int list) (k: int) : int = ",
562
+ "scala_template": "def minOperations(nums: List[Int],k: Int): Int = { \n \n}",
563
+ "java_template": "class Solution {\n public int minOperations(int[] nums, int k) {\n \n }\n}",
564
+ "python_template": "class Solution(object):\n def minOperations(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "
565
+ }
minimum_operations_to_make_array_values_equal_to_k/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 (minOperations [5;2;5;4;5] 2)
12
+
13
+ let test2 _ = assert_equal (-1) (minOperations [2;1;2] 2)
14
+
15
+ let test3 _ = assert_equal 4 (minOperations [9;7;5;3] 1)
16
+
17
+ let test4 _ = assert_equal (-1) (minOperations [40; 99; 29; 74; 59; 35; 87; 76; 92; 18; 23; 59; 37; 72; 59; 22; 100; 34; 34; 63; 84; 38; 96; 63; 65; 64; 15; 55; 54; 36; 6; 87; 48; 10; 61; 40; 62; 51; 64; 77; 61; 60; 90; 93; 41; 64; 39; 72; 27; 75; 71; 82; 15] 46)
18
+
19
+ let test5 _ = assert_equal (-1) (minOperations [73; 80; 65; 6; 85; 3; 67; 52; 37; 97; 24; 59; 34; 5; 95; 10; 52; 80; 99; 93; 42; 66; 19; 95; 74; 76; 71; 66; 77; 76; 30; 34; 83; 55; 81; 97; 38; 86; 65; 24; 48; 80; 17; 54; 29; 3; 63; 4; 38; 88; 30; 2; 30; 75; 81; 8; 5; 90; 31] 65)
20
+
21
+ let test6 _ = assert_equal (-1) (minOperations [63; 21; 26; 82; 95; 2; 100; 69; 52; 67; 67; 78; 36; 22; 17; 76; 2; 10; 65; 61; 20; 49; 27; 63; 74; 99; 56; 85; 30; 94; 56; 66; 78; 99; 10; 30; 68; 39; 34; 27; 83; 18; 23; 18; 27; 30; 26; 1; 78; 16; 16; 19; 31; 98; 30; 95; 10; 10; 20; 5; 80; 6; 39; 14; 98; 21; 9; 33; 82; 13; 33; 33; 42; 73; 29; 67; 17; 76; 19; 92; 55; 69; 56; 35; 71; 70; 39; 44; 38; 19; 100; 4; 54; 31] 68)
22
+
23
+ let test7 _ = assert_equal (-1) (minOperations [82; 17; 35; 3; 93; 79; 33; 29; 77; 50; 47; 48; 8; 61; 78; 34; 63; 21; 82; 84; 85; 84; 58; 76; 48; 69; 55; 31; 55; 90; 28; 46; 4; 45; 71; 42; 40; 82; 37; 20] 31)
24
+
25
+ let test8 _ = assert_equal (-1) (minOperations [89; 22; 3; 78; 1; 77; 18; 60; 12; 10; 61; 93; 14; 49; 23; 34; 92; 54; 92; 4; 68; 15; 39; 86; 16; 94; 26; 45; 8; 59; 28; 84; 75; 66; 32; 85; 11; 6; 55] 55)
26
+
27
+ let test9 _ = assert_equal (-1) (minOperations [60; 52; 92; 54; 70; 29; 16; 30; 10; 45; 3; 31; 48; 85; 2; 91; 75; 49] 49)
28
+
29
+ let test10 _ = assert_equal (-1) (minOperations [21; 15; 83; 9; 55; 79; 99; 79; 25; 37; 88; 61; 11; 63; 18; 20; 60; 15; 96; 77; 79; 93; 25; 14; 10; 31; 28; 37; 26; 2; 5; 38; 98; 85; 26; 51; 94; 67; 84; 77; 30; 58; 97; 30; 95; 82; 64] 14)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for minOperations" >::: [
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_operations_to_make_array_values_equal_to_k/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minOperations(List(5,2,5,4,5),2), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minOperations(List(2,1,2),2), -1)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minOperations(List(9,7,5,3),1), 4)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minOperations(List(40, 99, 29, 74, 59, 35, 87, 76, 92, 18, 23, 59, 37, 72, 59, 22, 100, 34, 34, 63, 84, 38, 96, 63, 65, 64, 15, 55, 54, 36, 6, 87, 48, 10, 61, 40, 62, 51, 64, 77, 61, 60, 90, 93, 41, 64, 39, 72, 27, 75, 71, 82, 15),46), -1)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minOperations(List(73, 80, 65, 6, 85, 3, 67, 52, 37, 97, 24, 59, 34, 5, 95, 10, 52, 80, 99, 93, 42, 66, 19, 95, 74, 76, 71, 66, 77, 76, 30, 34, 83, 55, 81, 97, 38, 86, 65, 24, 48, 80, 17, 54, 29, 3, 63, 4, 38, 88, 30, 2, 30, 75, 81, 8, 5, 90, 31),65), -1)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minOperations(List(63, 21, 26, 82, 95, 2, 100, 69, 52, 67, 67, 78, 36, 22, 17, 76, 2, 10, 65, 61, 20, 49, 27, 63, 74, 99, 56, 85, 30, 94, 56, 66, 78, 99, 10, 30, 68, 39, 34, 27, 83, 18, 23, 18, 27, 30, 26, 1, 78, 16, 16, 19, 31, 98, 30, 95, 10, 10, 20, 5, 80, 6, 39, 14, 98, 21, 9, 33, 82, 13, 33, 33, 42, 73, 29, 67, 17, 76, 19, 92, 55, 69, 56, 35, 71, 70, 39, 44, 38, 19, 100, 4, 54, 31),68), -1)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minOperations(List(82, 17, 35, 3, 93, 79, 33, 29, 77, 50, 47, 48, 8, 61, 78, 34, 63, 21, 82, 84, 85, 84, 58, 76, 48, 69, 55, 31, 55, 90, 28, 46, 4, 45, 71, 42, 40, 82, 37, 20),31), -1)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minOperations(List(89, 22, 3, 78, 1, 77, 18, 60, 12, 10, 61, 93, 14, 49, 23, 34, 92, 54, 92, 4, 68, 15, 39, 86, 16, 94, 26, 45, 8, 59, 28, 84, 75, 66, 32, 85, 11, 6, 55),55), -1)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minOperations(List(60, 52, 92, 54, 70, 29, 16, 30, 10, 45, 3, 31, 48, 85, 2, 91, 75, 49),49), -1)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minOperations(List(21, 15, 83, 9, 55, 79, 99, 79, 25, 37, 88, 61, 11, 63, 18, 20, 60, 15, 96, 77, 79, 93, 25, 14, 10, 31, 28, 37, 26, 2, 5, 38, 98, 85, 26, 51, 94, 67, 84, 77, 30, 58, 97, 30, 95, 82, 64),14), -1)
42
+ }
43
+
44
+ }
minimum_operations_to_make_binary_array_elements_equal_to_one_i/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_binary_array_elements_equal_to_one_i/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(3, minOperations(Arrays.asList(0,1,1,1,0,0)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(-1, minOperations(Arrays.asList(0,1,1,1)));
18
+ }
19
+
20
+ }
minimum_operations_to_make_binary_array_elements_equal_to_one_i/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_binary_array_elements_equal_to_one_i/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_binary_array_elements_equal_to_one_i/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_binary_array_elements_equal_to_one_ii/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_binary_array_elements_equal_to_one_ii/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(4, minOperations(Arrays.asList(0,1,1,0,1)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(1, minOperations(Arrays.asList(1,0,0,0)));
18
+ }
19
+
20
+ }
minimum_operations_to_make_binary_array_elements_equal_to_one_ii/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_binary_array_elements_equal_to_one_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_binary_array_elements_equal_to_one_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_columns_strictly_increasing/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minimumOperations :: [[Int]] -> Int
7
+ minimumOperations grid = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minimumOperations [[3,2],[1,3],[3,4],[0,1]])," 15 (minimumOperations [[3,2],[1,3],[3,4],[0,1]]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minimumOperations [[3,2,1],[2,1,0],[1,2,3]])," 12 (minimumOperations [[3,2,1],[2,1,0],[1,2,3]]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (minimumOperations [[127, 732, 2076, 1498, 1120, 1701, 48, 1574, 2349, 8, 1946, 1434, 2138, 1519], [2137, 1079, 2434, 1499, 1135, 1702, 66, 1575, 2350, 1980, 2137, 2467, 2139, 1520]])," 3718 (minimumOperations [[127, 732, 2076, 1498, 1120, 1701, 48, 1574, 2349, 8, 1946, 1434, 2138, 1519], [2137, 1079, 2434, 1499, 1135, 1702, 66, 1575, 2350, 1980, 2137, 2467, 2139, 1520]]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (minimumOperations [[1451, 1480, 2377, 391, 714, 220, 433, 2198, 559, 1443, 1286, 947, 1212, 805, 2450, 1661, 1072, 1652, 801, 316, 273, 761, 1189, 2445, 996, 151, 1875, 676, 103, 7, 1610, 1520, 2035, 439, 1284, 1935, 93, 1342, 774, 1971, 1923, 937, 1301, 2206, 985, 1301, 1509, 2022, 1803]])," 0 (minimumOperations [[1451, 1480, 2377, 391, 714, 220, 433, 2198, 559, 1443, 1286, 947, 1212, 805, 2450, 1661, 1072, 1652, 801, 316, 273, 761, 1189, 2445, 996, 151, 1875, 676, 103, 7, 1610, 1520, 2035, 439, 1284, 1935, 93, 1342, 774, 1971, 1923, 937, 1301, 2206, 985, 1301, 1509, 2022, 1803]]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (minimumOperations [[1238, 1786, 31], [2142, 1787, 1359], [2280, 1788, 1360], [2281, 1899, 1504], [2282, 1900, 1505], [2283, 1901, 2140], [2284, 1902, 2141], [2285, 1903, 2142], [2286, 1904, 2143], [2473, 1905, 2144], [2474, 1906, 2285], [2475, 1907, 2286], [2476, 1908, 2287], [2477, 1909, 2288], [2478, 1917, 2289], [2479, 1918, 2290], [2480, 1919, 2291], [2481, 2426, 2292], [2482, 2427, 2293], [2483, 2428, 2336], [2484, 2429, 2337], [2485, 2430, 2338], [2486, 2431, 2339], [2487, 2432, 2340], [2488, 2433, 2341], [2489, 2434, 2342], [2490, 2435, 2343], [2491, 2436, 2344], [2492, 2437, 2345], [2493, 2438, 2346], [2494, 2439, 2347], [2495, 2440, 2348], [2496, 2441, 2349], [2497, 2442, 2350], [2498, 2443, 2351], [2499, 2444, 2368]])," 114619 (minimumOperations [[1238, 1786, 31], [2142, 1787, 1359], [2280, 1788, 1360], [2281, 1899, 1504], [2282, 1900, 1505], [2283, 1901, 2140], [2284, 1902, 2141], [2285, 1903, 2142], [2286, 1904, 2143], [2473, 1905, 2144], [2474, 1906, 2285], [2475, 1907, 2286], [2476, 1908, 2287], [2477, 1909, 2288], [2478, 1917, 2289], [2479, 1918, 2290], [2480, 1919, 2291], [2481, 2426, 2292], [2482, 2427, 2293], [2483, 2428, 2336], [2484, 2429, 2337], [2485, 2430, 2338], [2486, 2431, 2339], [2487, 2432, 2340], [2488, 2433, 2341], [2489, 2434, 2342], [2490, 2435, 2343], [2491, 2436, 2344], [2492, 2437, 2345], [2493, 2438, 2346], [2494, 2439, 2347], [2495, 2440, 2348], [2496, 2441, 2349], [2497, 2442, 2350], [2498, 2443, 2351], [2499, 2444, 2368]]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (minimumOperations [[868, 1485, 2457, 395, 2382, 314, 1979, 528, 728, 1132, 1436, 1478, 1306, 963, 2033, 1976, 1427, 1549, 1320, 88, 134, 1125, 114, 2234, 1283, 1850, 1536, 2116, 2018, 1182, 903, 881, 1447, 19, 1224, 134, 47, 2091, 1467, 1340, 1450, 2472], [1091, 1486, 2458, 396, 2383, 1444, 1980, 529, 1511, 1133, 1437, 2101, 2141, 2339, 2034, 1977, 1428, 1550, 2161, 543, 1632, 2125, 2469, 2235, 1284, 1851, 1537, 2117, 2019, 2091, 1991, 1052, 2384, 455, 1640, 2081, 2366, 2092, 1468, 1341, 1595, 2473], [1120, 2266, 2459, 397, 2384, 1445, 1981, 808, 1512, 2174, 2439, 2102, 2142, 2340, 2035, 2002, 1429, 2122, 2162, 1055, 1718, 2126, 2470, 2236, 1285, 2020, 1538, 2221, 2456, 2092, 1992, 1053, 2385, 563, 1641, 2082, 2367, 2157, 1886, 1342, 1596, 2474], [2494, 2267, 2460, 398, 2385, 1446, 1982, 2296, 2075, 2175, 2440, 2103, 2143, 2341, 2036, 2003, 1430, 2128, 2163, 1056, 2465, 2127, 2471, 2237, 1286, 2021, 1539, 2400, 2457, 2093, 1993, 1802, 2386, 1120, 1642, 2083, 2368, 2158, 1887, 2046, 1597, 2475], [2495, 2313, 2461, 2131, 2386, 1674, 1983, 2297, 2076, 2176, 2441, 2104, 2144, 2342, 2037, 2004, 1899, 2304, 2164, 1569, 2466, 2128, 2472, 2238, 1456, 2022, 1680, 2401, 2458, 2094, 1994, 1803, 2387, 1121, 1643, 2084, 2369, 2159, 1888, 2224, 1598, 2476], [2496, 2314, 2462, 2132, 2387, 1675, 1984, 2298, 2077, 2177, 2450, 2105, 2145, 2343, 2038, 2005, 1900, 2305, 2277, 1570, 2467, 2129, 2473, 2239, 1457, 2023, 1681, 2402, 2459, 2095, 1995, 1804, 2388, 1122, 1661, 2085, 2370, 2483, 1889, 2225, 1599, 2477], [2497, 2315, 2463, 2449, 2388, 1676, 1985, 2299, 2417, 2178, 2451, 2106, 2146, 2344, 2039, 2006, 1901, 2306, 2278, 1571, 2468, 2417, 2474, 2240, 1703, 2024, 1682, 2403, 2460, 2143, 2381, 1993, 2389, 2314, 1662, 2086, 2371, 2484, 1890, 2401, 1600, 2478], [2498, 2316, 2464, 2450, 2389, 1677, 2090, 2300, 2418, 2179, 2452, 2107, 2147, 2345, 2040, 2007, 1902, 2307, 2279, 1572, 2469, 2418, 2475, 2241, 1704, 2204, 1683, 2404, 2461, 2144, 2382, 2020, 2390, 2315, 1663, 2087, 2372, 2485, 1891, 2402, 1601, 2479]])," 229471 (minimumOperations [[868, 1485, 2457, 395, 2382, 314, 1979, 528, 728, 1132, 1436, 1478, 1306, 963, 2033, 1976, 1427, 1549, 1320, 88, 134, 1125, 114, 2234, 1283, 1850, 1536, 2116, 2018, 1182, 903, 881, 1447, 19, 1224, 134, 47, 2091, 1467, 1340, 1450, 2472], [1091, 1486, 2458, 396, 2383, 1444, 1980, 529, 1511, 1133, 1437, 2101, 2141, 2339, 2034, 1977, 1428, 1550, 2161, 543, 1632, 2125, 2469, 2235, 1284, 1851, 1537, 2117, 2019, 2091, 1991, 1052, 2384, 455, 1640, 2081, 2366, 2092, 1468, 1341, 1595, 2473], [1120, 2266, 2459, 397, 2384, 1445, 1981, 808, 1512, 2174, 2439, 2102, 2142, 2340, 2035, 2002, 1429, 2122, 2162, 1055, 1718, 2126, 2470, 2236, 1285, 2020, 1538, 2221, 2456, 2092, 1992, 1053, 2385, 563, 1641, 2082, 2367, 2157, 1886, 1342, 1596, 2474], [2494, 2267, 2460, 398, 2385, 1446, 1982, 2296, 2075, 2175, 2440, 2103, 2143, 2341, 2036, 2003, 1430, 2128, 2163, 1056, 2465, 2127, 2471, 2237, 1286, 2021, 1539, 2400, 2457, 2093, 1993, 1802, 2386, 1120, 1642, 2083, 2368, 2158, 1887, 2046, 1597, 2475], [2495, 2313, 2461, 2131, 2386, 1674, 1983, 2297, 2076, 2176, 2441, 2104, 2144, 2342, 2037, 2004, 1899, 2304, 2164, 1569, 2466, 2128, 2472, 2238, 1456, 2022, 1680, 2401, 2458, 2094, 1994, 1803, 2387, 1121, 1643, 2084, 2369, 2159, 1888, 2224, 1598, 2476], [2496, 2314, 2462, 2132, 2387, 1675, 1984, 2298, 2077, 2177, 2450, 2105, 2145, 2343, 2038, 2005, 1900, 2305, 2277, 1570, 2467, 2129, 2473, 2239, 1457, 2023, 1681, 2402, 2459, 2095, 1995, 1804, 2388, 1122, 1661, 2085, 2370, 2483, 1889, 2225, 1599, 2477], [2497, 2315, 2463, 2449, 2388, 1676, 1985, 2299, 2417, 2178, 2451, 2106, 2146, 2344, 2039, 2006, 1901, 2306, 2278, 1571, 2468, 2417, 2474, 2240, 1703, 2024, 1682, 2403, 2460, 2143, 2381, 1993, 2389, 2314, 1662, 2086, 2371, 2484, 1890, 2401, 1600, 2478], [2498, 2316, 2464, 2450, 2389, 1677, 2090, 2300, 2418, 2179, 2452, 2107, 2147, 2345, 2040, 2007, 1902, 2307, 2279, 1572, 2469, 2418, 2475, 2241, 1704, 2204, 1683, 2404, 2461, 2144, 2382, 2020, 2390, 2315, 1663, 2087, 2372, 2485, 1891, 2402, 1601, 2479]]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (minimumOperations [[2091, 1538, 1215, 1122, 672, 1607, 504, 2056, 2351, 1723], [2092, 2317, 1361, 1283, 673, 1608, 2252, 2239, 2352, 1724], [2097, 2318, 1362, 2316, 854, 1609, 2456, 2428, 2353, 1725], [2098, 2319, 1363, 2317, 855, 2462, 2457, 2429, 2354, 1726], [2099, 2320, 2404, 2318, 2091, 2463, 2458, 2430, 2355, 1727], [2301, 2321, 2447, 2319, 2092, 2464, 2459, 2431, 2356, 1728], [2302, 2322, 2448, 2320, 2093, 2465, 2460, 2474, 2357, 1729], [2303, 2323, 2449, 2321, 2094, 2466, 2461, 2475, 2358, 1730], [2304, 2324, 2450, 2322, 2095, 2467, 2462, 2476, 2359, 2089], [2305, 2325, 2451, 2323, 2444, 2468, 2463, 2477, 2360, 2090], [2306, 2326, 2452, 2324, 2445, 2469, 2464, 2478, 2361, 2091], [2307, 2327, 2453, 2325, 2446, 2470, 2465, 2479, 2362, 2386], [2308, 2443, 2454, 2326, 2447, 2471, 2466, 2480, 2481, 2387], [2309, 2444, 2455, 2327, 2448, 2472, 2467, 2481, 2482, 2432], [2310, 2445, 2456, 2328, 2449, 2473, 2468, 2482, 2483, 2433], [2311, 2446, 2457, 2329, 2450, 2474, 2469, 2483, 2484, 2434], [2312, 2447, 2458, 2484, 2451, 2475, 2470, 2484, 2485, 2435], [2313, 2448, 2459, 2485, 2452, 2476, 2471, 2485, 2486, 2436], [2314, 2449, 2460, 2486, 2453, 2477, 2472, 2486, 2487, 2437], [2315, 2450, 2461, 2487, 2454, 2478, 2473, 2487, 2488, 2438], [2316, 2451, 2462, 2488, 2455, 2479, 2474, 2488, 2489, 2439], [2317, 2452, 2463, 2489, 2456, 2480, 2475, 2489, 2490, 2440], [2427, 2453, 2464, 2490, 2457, 2481, 2476, 2490, 2491, 2441], [2428, 2454, 2465, 2491, 2458, 2482, 2477, 2491, 2492, 2442], [2429, 2455, 2466, 2492, 2459, 2483, 2478, 2492, 2493, 2443], [2430, 2456, 2467, 2493, 2460, 2484, 2479, 2493, 2494, 2444], [2431, 2457, 2468, 2494, 2461, 2485, 2480, 2494, 2495, 2445], [2432, 2458, 2469, 2495, 2462, 2486, 2481, 2495, 2496, 2446], [2433, 2459, 2470, 2496, 2463, 2487, 2482, 2496, 2497, 2447], [2434, 2460, 2471, 2497, 2464, 2488, 2483, 2497, 2498, 2448], [2435, 2461, 2472, 2498, 2465, 2489, 2484, 2498, 2499, 2449], [2436, 2462, 2473, 2499, 2466, 2490, 2485, 2499, 2500, 2450], [2437, 2463, 2474, 2500, 2467, 2491, 2486, 2500, 2501, 2451], [2438, 2464, 2475, 2501, 2468, 2492, 2487, 2501, 2502, 2452], [2439, 2465, 2476, 2502, 2469, 2493, 2488, 2502, 2503, 2473], [2440, 2466, 2477, 2503, 2470, 2494, 2489, 2503, 2504, 2474], [2441, 2467, 2478, 2504, 2471, 2495, 2490, 2504, 2505, 2475], [2442, 2468, 2479, 2505, 2472, 2496, 2491, 2505, 2506, 2476], [2443, 2469, 2480, 2506, 2473, 2497, 2492, 2506, 2507, 2477], [2444, 2470, 2481, 2507, 2474, 2498, 2493, 2507, 2508, 2478], [2445, 2471, 2482, 2508, 2475, 2499, 2494, 2508, 2509, 2479], [2446, 2472, 2483, 2509, 2476, 2500, 2495, 2509, 2510, 2480], [2447, 2473, 2484, 2510, 2477, 2501, 2496, 2510, 2511, 2481], [2448, 2474, 2485, 2511, 2478, 2502, 2497, 2511, 2512, 2482]])," 504941 (minimumOperations [[2091, 1538, 1215, 1122, 672, 1607, 504, 2056, 2351, 1723], [2092, 2317, 1361, 1283, 673, 1608, 2252, 2239, 2352, 1724], [2097, 2318, 1362, 2316, 854, 1609, 2456, 2428, 2353, 1725], [2098, 2319, 1363, 2317, 855, 2462, 2457, 2429, 2354, 1726], [2099, 2320, 2404, 2318, 2091, 2463, 2458, 2430, 2355, 1727], [2301, 2321, 2447, 2319, 2092, 2464, 2459, 2431, 2356, 1728], [2302, 2322, 2448, 2320, 2093, 2465, 2460, 2474, 2357, 1729], [2303, 2323, 2449, 2321, 2094, 2466, 2461, 2475, 2358, 1730], [2304, 2324, 2450, 2322, 2095, 2467, 2462, 2476, 2359, 2089], [2305, 2325, 2451, 2323, 2444, 2468, 2463, 2477, 2360, 2090], [2306, 2326, 2452, 2324, 2445, 2469, 2464, 2478, 2361, 2091], [2307, 2327, 2453, 2325, 2446, 2470, 2465, 2479, 2362, 2386], [2308, 2443, 2454, 2326, 2447, 2471, 2466, 2480, 2481, 2387], [2309, 2444, 2455, 2327, 2448, 2472, 2467, 2481, 2482, 2432], [2310, 2445, 2456, 2328, 2449, 2473, 2468, 2482, 2483, 2433], [2311, 2446, 2457, 2329, 2450, 2474, 2469, 2483, 2484, 2434], [2312, 2447, 2458, 2484, 2451, 2475, 2470, 2484, 2485, 2435], [2313, 2448, 2459, 2485, 2452, 2476, 2471, 2485, 2486, 2436], [2314, 2449, 2460, 2486, 2453, 2477, 2472, 2486, 2487, 2437], [2315, 2450, 2461, 2487, 2454, 2478, 2473, 2487, 2488, 2438], [2316, 2451, 2462, 2488, 2455, 2479, 2474, 2488, 2489, 2439], [2317, 2452, 2463, 2489, 2456, 2480, 2475, 2489, 2490, 2440], [2427, 2453, 2464, 2490, 2457, 2481, 2476, 2490, 2491, 2441], [2428, 2454, 2465, 2491, 2458, 2482, 2477, 2491, 2492, 2442], [2429, 2455, 2466, 2492, 2459, 2483, 2478, 2492, 2493, 2443], [2430, 2456, 2467, 2493, 2460, 2484, 2479, 2493, 2494, 2444], [2431, 2457, 2468, 2494, 2461, 2485, 2480, 2494, 2495, 2445], [2432, 2458, 2469, 2495, 2462, 2486, 2481, 2495, 2496, 2446], [2433, 2459, 2470, 2496, 2463, 2487, 2482, 2496, 2497, 2447], [2434, 2460, 2471, 2497, 2464, 2488, 2483, 2497, 2498, 2448], [2435, 2461, 2472, 2498, 2465, 2489, 2484, 2498, 2499, 2449], [2436, 2462, 2473, 2499, 2466, 2490, 2485, 2499, 2500, 2450], [2437, 2463, 2474, 2500, 2467, 2491, 2486, 2500, 2501, 2451], [2438, 2464, 2475, 2501, 2468, 2492, 2487, 2501, 2502, 2452], [2439, 2465, 2476, 2502, 2469, 2493, 2488, 2502, 2503, 2473], [2440, 2466, 2477, 2503, 2470, 2494, 2489, 2503, 2504, 2474], [2441, 2467, 2478, 2504, 2471, 2495, 2490, 2504, 2505, 2475], [2442, 2468, 2479, 2505, 2472, 2496, 2491, 2505, 2506, 2476], [2443, 2469, 2480, 2506, 2473, 2497, 2492, 2506, 2507, 2477], [2444, 2470, 2481, 2507, 2474, 2498, 2493, 2507, 2508, 2478], [2445, 2471, 2482, 2508, 2475, 2499, 2494, 2508, 2509, 2479], [2446, 2472, 2483, 2509, 2476, 2500, 2495, 2509, 2510, 2480], [2447, 2473, 2484, 2510, 2477, 2501, 2496, 2510, 2511, 2481], [2448, 2474, 2485, 2511, 2478, 2502, 2497, 2511, 2512, 2482]]))
33
+
34
+
35
+ -- Grouping test cases
36
+ tests :: Test
37
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6]
38
+
39
+ -- Running the tests
40
+ main :: IO Counts
41
+ main = runTestTT tests
minimum_operations_to_make_columns_strictly_increasing/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(15, minimumOperations(Arrays.asList(Arrays.asList(3,2),Arrays.asList(1,3),Arrays.asList(3,4),Arrays.asList(0,1))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(12, minimumOperations(Arrays.asList(Arrays.asList(3,2,1),Arrays.asList(2,1,0),Arrays.asList(1,2,3))));
18
+ }
19
+
20
+ }
minimum_operations_to_make_columns_strictly_increasing/meta.json ADDED
@@ -0,0 +1,1195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3691,
3
+ "name": "minimum_operations_to_make_columns_strictly_increasing",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimum-operations-to-make-columns-strictly-increasing/",
6
+ "date": "2024-12-22 00:00:00",
7
+ "task_description": "You are given a `m x n` matrix `grid` consisting of non-negative integers. In one operation, you can increment the value of any `grid[i][j]` by 1. Return the **minimum** number of operations needed to make all columns of `grid` **strictly increasing**. **Example 1:** **Input:** grid = [[3,2],[1,3],[3,4],[0,1]] **Output:** 15 **Explanation:** To make the `0th` column strictly increasing, we can apply 3 operations on `grid[1][0]`, 2 operations on `grid[2][0]`, and 6 operations on `grid[3][0]`. To make the `1st` column strictly increasing, we can apply 4 operations on `grid[3][1]`. **Example 2:** **Input:** grid = [[3,2,1],[2,1,0],[1,2,3]] **Output:** 12 **Explanation:** To make the `0th` column strictly increasing, we can apply 2 operations on `grid[1][0]`, and 4 operations on `grid[2][0]`. To make the `1st` column strictly increasing, we can apply 2 operations on `grid[1][1]`, and 2 operations on `grid[2][1]`. To make the `2nd` column strictly increasing, we can apply 2 operations on `grid[1][2]`. **Constraints:** `m == grid.length` `n == grid[i].length` `1 <= m, n <= 50` `0 <= grid[i][j] < 2500` ``` ```",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "grid = [[3,2],[1,3],[3,4],[0,1]]",
12
+ "output": "15 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "grid = [[3,2,1],[2,1,0],[1,2,3]]",
17
+ "output": "12 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 127,
25
+ 732,
26
+ 2076,
27
+ 1498,
28
+ 1120,
29
+ 1701,
30
+ 48,
31
+ 1574,
32
+ 2349,
33
+ 8,
34
+ 1946,
35
+ 1434,
36
+ 2138,
37
+ 1519
38
+ ],
39
+ [
40
+ 2137,
41
+ 1079,
42
+ 2434,
43
+ 1499,
44
+ 1135,
45
+ 1702,
46
+ 66,
47
+ 1575,
48
+ 2350,
49
+ 1980,
50
+ 2137,
51
+ 2467,
52
+ 2139,
53
+ 1520
54
+ ]
55
+ ],
56
+ "output": 3718
57
+ },
58
+ {
59
+ "input": [
60
+ [
61
+ 1451,
62
+ 1480,
63
+ 2377,
64
+ 391,
65
+ 714,
66
+ 220,
67
+ 433,
68
+ 2198,
69
+ 559,
70
+ 1443,
71
+ 1286,
72
+ 947,
73
+ 1212,
74
+ 805,
75
+ 2450,
76
+ 1661,
77
+ 1072,
78
+ 1652,
79
+ 801,
80
+ 316,
81
+ 273,
82
+ 761,
83
+ 1189,
84
+ 2445,
85
+ 996,
86
+ 151,
87
+ 1875,
88
+ 676,
89
+ 103,
90
+ 7,
91
+ 1610,
92
+ 1520,
93
+ 2035,
94
+ 439,
95
+ 1284,
96
+ 1935,
97
+ 93,
98
+ 1342,
99
+ 774,
100
+ 1971,
101
+ 1923,
102
+ 937,
103
+ 1301,
104
+ 2206,
105
+ 985,
106
+ 1301,
107
+ 1509,
108
+ 2022,
109
+ 1803
110
+ ]
111
+ ],
112
+ "output": 0
113
+ },
114
+ {
115
+ "input": [
116
+ [
117
+ 1238,
118
+ 1786,
119
+ 31
120
+ ],
121
+ [
122
+ 2142,
123
+ 1787,
124
+ 1359
125
+ ],
126
+ [
127
+ 2280,
128
+ 1788,
129
+ 1360
130
+ ],
131
+ [
132
+ 2281,
133
+ 1899,
134
+ 1504
135
+ ],
136
+ [
137
+ 2282,
138
+ 1900,
139
+ 1505
140
+ ],
141
+ [
142
+ 2283,
143
+ 1901,
144
+ 2140
145
+ ],
146
+ [
147
+ 2284,
148
+ 1902,
149
+ 2141
150
+ ],
151
+ [
152
+ 2285,
153
+ 1903,
154
+ 2142
155
+ ],
156
+ [
157
+ 2286,
158
+ 1904,
159
+ 2143
160
+ ],
161
+ [
162
+ 2473,
163
+ 1905,
164
+ 2144
165
+ ],
166
+ [
167
+ 2474,
168
+ 1906,
169
+ 2285
170
+ ],
171
+ [
172
+ 2475,
173
+ 1907,
174
+ 2286
175
+ ],
176
+ [
177
+ 2476,
178
+ 1908,
179
+ 2287
180
+ ],
181
+ [
182
+ 2477,
183
+ 1909,
184
+ 2288
185
+ ],
186
+ [
187
+ 2478,
188
+ 1917,
189
+ 2289
190
+ ],
191
+ [
192
+ 2479,
193
+ 1918,
194
+ 2290
195
+ ],
196
+ [
197
+ 2480,
198
+ 1919,
199
+ 2291
200
+ ],
201
+ [
202
+ 2481,
203
+ 2426,
204
+ 2292
205
+ ],
206
+ [
207
+ 2482,
208
+ 2427,
209
+ 2293
210
+ ],
211
+ [
212
+ 2483,
213
+ 2428,
214
+ 2336
215
+ ],
216
+ [
217
+ 2484,
218
+ 2429,
219
+ 2337
220
+ ],
221
+ [
222
+ 2485,
223
+ 2430,
224
+ 2338
225
+ ],
226
+ [
227
+ 2486,
228
+ 2431,
229
+ 2339
230
+ ],
231
+ [
232
+ 2487,
233
+ 2432,
234
+ 2340
235
+ ],
236
+ [
237
+ 2488,
238
+ 2433,
239
+ 2341
240
+ ],
241
+ [
242
+ 2489,
243
+ 2434,
244
+ 2342
245
+ ],
246
+ [
247
+ 2490,
248
+ 2435,
249
+ 2343
250
+ ],
251
+ [
252
+ 2491,
253
+ 2436,
254
+ 2344
255
+ ],
256
+ [
257
+ 2492,
258
+ 2437,
259
+ 2345
260
+ ],
261
+ [
262
+ 2493,
263
+ 2438,
264
+ 2346
265
+ ],
266
+ [
267
+ 2494,
268
+ 2439,
269
+ 2347
270
+ ],
271
+ [
272
+ 2495,
273
+ 2440,
274
+ 2348
275
+ ],
276
+ [
277
+ 2496,
278
+ 2441,
279
+ 2349
280
+ ],
281
+ [
282
+ 2497,
283
+ 2442,
284
+ 2350
285
+ ],
286
+ [
287
+ 2498,
288
+ 2443,
289
+ 2351
290
+ ],
291
+ [
292
+ 2499,
293
+ 2444,
294
+ 2368
295
+ ]
296
+ ],
297
+ "output": 114619
298
+ },
299
+ {
300
+ "input": [
301
+ [
302
+ 868,
303
+ 1485,
304
+ 2457,
305
+ 395,
306
+ 2382,
307
+ 314,
308
+ 1979,
309
+ 528,
310
+ 728,
311
+ 1132,
312
+ 1436,
313
+ 1478,
314
+ 1306,
315
+ 963,
316
+ 2033,
317
+ 1976,
318
+ 1427,
319
+ 1549,
320
+ 1320,
321
+ 88,
322
+ 134,
323
+ 1125,
324
+ 114,
325
+ 2234,
326
+ 1283,
327
+ 1850,
328
+ 1536,
329
+ 2116,
330
+ 2018,
331
+ 1182,
332
+ 903,
333
+ 881,
334
+ 1447,
335
+ 19,
336
+ 1224,
337
+ 134,
338
+ 47,
339
+ 2091,
340
+ 1467,
341
+ 1340,
342
+ 1450,
343
+ 2472
344
+ ],
345
+ [
346
+ 1091,
347
+ 1486,
348
+ 2458,
349
+ 396,
350
+ 2383,
351
+ 1444,
352
+ 1980,
353
+ 529,
354
+ 1511,
355
+ 1133,
356
+ 1437,
357
+ 2101,
358
+ 2141,
359
+ 2339,
360
+ 2034,
361
+ 1977,
362
+ 1428,
363
+ 1550,
364
+ 2161,
365
+ 543,
366
+ 1632,
367
+ 2125,
368
+ 2469,
369
+ 2235,
370
+ 1284,
371
+ 1851,
372
+ 1537,
373
+ 2117,
374
+ 2019,
375
+ 2091,
376
+ 1991,
377
+ 1052,
378
+ 2384,
379
+ 455,
380
+ 1640,
381
+ 2081,
382
+ 2366,
383
+ 2092,
384
+ 1468,
385
+ 1341,
386
+ 1595,
387
+ 2473
388
+ ],
389
+ [
390
+ 1120,
391
+ 2266,
392
+ 2459,
393
+ 397,
394
+ 2384,
395
+ 1445,
396
+ 1981,
397
+ 808,
398
+ 1512,
399
+ 2174,
400
+ 2439,
401
+ 2102,
402
+ 2142,
403
+ 2340,
404
+ 2035,
405
+ 2002,
406
+ 1429,
407
+ 2122,
408
+ 2162,
409
+ 1055,
410
+ 1718,
411
+ 2126,
412
+ 2470,
413
+ 2236,
414
+ 1285,
415
+ 2020,
416
+ 1538,
417
+ 2221,
418
+ 2456,
419
+ 2092,
420
+ 1992,
421
+ 1053,
422
+ 2385,
423
+ 563,
424
+ 1641,
425
+ 2082,
426
+ 2367,
427
+ 2157,
428
+ 1886,
429
+ 1342,
430
+ 1596,
431
+ 2474
432
+ ],
433
+ [
434
+ 2494,
435
+ 2267,
436
+ 2460,
437
+ 398,
438
+ 2385,
439
+ 1446,
440
+ 1982,
441
+ 2296,
442
+ 2075,
443
+ 2175,
444
+ 2440,
445
+ 2103,
446
+ 2143,
447
+ 2341,
448
+ 2036,
449
+ 2003,
450
+ 1430,
451
+ 2128,
452
+ 2163,
453
+ 1056,
454
+ 2465,
455
+ 2127,
456
+ 2471,
457
+ 2237,
458
+ 1286,
459
+ 2021,
460
+ 1539,
461
+ 2400,
462
+ 2457,
463
+ 2093,
464
+ 1993,
465
+ 1802,
466
+ 2386,
467
+ 1120,
468
+ 1642,
469
+ 2083,
470
+ 2368,
471
+ 2158,
472
+ 1887,
473
+ 2046,
474
+ 1597,
475
+ 2475
476
+ ],
477
+ [
478
+ 2495,
479
+ 2313,
480
+ 2461,
481
+ 2131,
482
+ 2386,
483
+ 1674,
484
+ 1983,
485
+ 2297,
486
+ 2076,
487
+ 2176,
488
+ 2441,
489
+ 2104,
490
+ 2144,
491
+ 2342,
492
+ 2037,
493
+ 2004,
494
+ 1899,
495
+ 2304,
496
+ 2164,
497
+ 1569,
498
+ 2466,
499
+ 2128,
500
+ 2472,
501
+ 2238,
502
+ 1456,
503
+ 2022,
504
+ 1680,
505
+ 2401,
506
+ 2458,
507
+ 2094,
508
+ 1994,
509
+ 1803,
510
+ 2387,
511
+ 1121,
512
+ 1643,
513
+ 2084,
514
+ 2369,
515
+ 2159,
516
+ 1888,
517
+ 2224,
518
+ 1598,
519
+ 2476
520
+ ],
521
+ [
522
+ 2496,
523
+ 2314,
524
+ 2462,
525
+ 2132,
526
+ 2387,
527
+ 1675,
528
+ 1984,
529
+ 2298,
530
+ 2077,
531
+ 2177,
532
+ 2450,
533
+ 2105,
534
+ 2145,
535
+ 2343,
536
+ 2038,
537
+ 2005,
538
+ 1900,
539
+ 2305,
540
+ 2277,
541
+ 1570,
542
+ 2467,
543
+ 2129,
544
+ 2473,
545
+ 2239,
546
+ 1457,
547
+ 2023,
548
+ 1681,
549
+ 2402,
550
+ 2459,
551
+ 2095,
552
+ 1995,
553
+ 1804,
554
+ 2388,
555
+ 1122,
556
+ 1661,
557
+ 2085,
558
+ 2370,
559
+ 2483,
560
+ 1889,
561
+ 2225,
562
+ 1599,
563
+ 2477
564
+ ],
565
+ [
566
+ 2497,
567
+ 2315,
568
+ 2463,
569
+ 2449,
570
+ 2388,
571
+ 1676,
572
+ 1985,
573
+ 2299,
574
+ 2417,
575
+ 2178,
576
+ 2451,
577
+ 2106,
578
+ 2146,
579
+ 2344,
580
+ 2039,
581
+ 2006,
582
+ 1901,
583
+ 2306,
584
+ 2278,
585
+ 1571,
586
+ 2468,
587
+ 2417,
588
+ 2474,
589
+ 2240,
590
+ 1703,
591
+ 2024,
592
+ 1682,
593
+ 2403,
594
+ 2460,
595
+ 2143,
596
+ 2381,
597
+ 1993,
598
+ 2389,
599
+ 2314,
600
+ 1662,
601
+ 2086,
602
+ 2371,
603
+ 2484,
604
+ 1890,
605
+ 2401,
606
+ 1600,
607
+ 2478
608
+ ],
609
+ [
610
+ 2498,
611
+ 2316,
612
+ 2464,
613
+ 2450,
614
+ 2389,
615
+ 1677,
616
+ 2090,
617
+ 2300,
618
+ 2418,
619
+ 2179,
620
+ 2452,
621
+ 2107,
622
+ 2147,
623
+ 2345,
624
+ 2040,
625
+ 2007,
626
+ 1902,
627
+ 2307,
628
+ 2279,
629
+ 1572,
630
+ 2469,
631
+ 2418,
632
+ 2475,
633
+ 2241,
634
+ 1704,
635
+ 2204,
636
+ 1683,
637
+ 2404,
638
+ 2461,
639
+ 2144,
640
+ 2382,
641
+ 2020,
642
+ 2390,
643
+ 2315,
644
+ 1663,
645
+ 2087,
646
+ 2372,
647
+ 2485,
648
+ 1891,
649
+ 2402,
650
+ 1601,
651
+ 2479
652
+ ]
653
+ ],
654
+ "output": 229471
655
+ },
656
+ {
657
+ "input": [
658
+ [
659
+ 2091,
660
+ 1538,
661
+ 1215,
662
+ 1122,
663
+ 672,
664
+ 1607,
665
+ 504,
666
+ 2056,
667
+ 2351,
668
+ 1723
669
+ ],
670
+ [
671
+ 2092,
672
+ 2317,
673
+ 1361,
674
+ 1283,
675
+ 673,
676
+ 1608,
677
+ 2252,
678
+ 2239,
679
+ 2352,
680
+ 1724
681
+ ],
682
+ [
683
+ 2097,
684
+ 2318,
685
+ 1362,
686
+ 2316,
687
+ 854,
688
+ 1609,
689
+ 2456,
690
+ 2428,
691
+ 2353,
692
+ 1725
693
+ ],
694
+ [
695
+ 2098,
696
+ 2319,
697
+ 1363,
698
+ 2317,
699
+ 855,
700
+ 2462,
701
+ 2457,
702
+ 2429,
703
+ 2354,
704
+ 1726
705
+ ],
706
+ [
707
+ 2099,
708
+ 2320,
709
+ 2404,
710
+ 2318,
711
+ 2091,
712
+ 2463,
713
+ 2458,
714
+ 2430,
715
+ 2355,
716
+ 1727
717
+ ],
718
+ [
719
+ 2301,
720
+ 2321,
721
+ 2447,
722
+ 2319,
723
+ 2092,
724
+ 2464,
725
+ 2459,
726
+ 2431,
727
+ 2356,
728
+ 1728
729
+ ],
730
+ [
731
+ 2302,
732
+ 2322,
733
+ 2448,
734
+ 2320,
735
+ 2093,
736
+ 2465,
737
+ 2460,
738
+ 2474,
739
+ 2357,
740
+ 1729
741
+ ],
742
+ [
743
+ 2303,
744
+ 2323,
745
+ 2449,
746
+ 2321,
747
+ 2094,
748
+ 2466,
749
+ 2461,
750
+ 2475,
751
+ 2358,
752
+ 1730
753
+ ],
754
+ [
755
+ 2304,
756
+ 2324,
757
+ 2450,
758
+ 2322,
759
+ 2095,
760
+ 2467,
761
+ 2462,
762
+ 2476,
763
+ 2359,
764
+ 2089
765
+ ],
766
+ [
767
+ 2305,
768
+ 2325,
769
+ 2451,
770
+ 2323,
771
+ 2444,
772
+ 2468,
773
+ 2463,
774
+ 2477,
775
+ 2360,
776
+ 2090
777
+ ],
778
+ [
779
+ 2306,
780
+ 2326,
781
+ 2452,
782
+ 2324,
783
+ 2445,
784
+ 2469,
785
+ 2464,
786
+ 2478,
787
+ 2361,
788
+ 2091
789
+ ],
790
+ [
791
+ 2307,
792
+ 2327,
793
+ 2453,
794
+ 2325,
795
+ 2446,
796
+ 2470,
797
+ 2465,
798
+ 2479,
799
+ 2362,
800
+ 2386
801
+ ],
802
+ [
803
+ 2308,
804
+ 2443,
805
+ 2454,
806
+ 2326,
807
+ 2447,
808
+ 2471,
809
+ 2466,
810
+ 2480,
811
+ 2481,
812
+ 2387
813
+ ],
814
+ [
815
+ 2309,
816
+ 2444,
817
+ 2455,
818
+ 2327,
819
+ 2448,
820
+ 2472,
821
+ 2467,
822
+ 2481,
823
+ 2482,
824
+ 2432
825
+ ],
826
+ [
827
+ 2310,
828
+ 2445,
829
+ 2456,
830
+ 2328,
831
+ 2449,
832
+ 2473,
833
+ 2468,
834
+ 2482,
835
+ 2483,
836
+ 2433
837
+ ],
838
+ [
839
+ 2311,
840
+ 2446,
841
+ 2457,
842
+ 2329,
843
+ 2450,
844
+ 2474,
845
+ 2469,
846
+ 2483,
847
+ 2484,
848
+ 2434
849
+ ],
850
+ [
851
+ 2312,
852
+ 2447,
853
+ 2458,
854
+ 2484,
855
+ 2451,
856
+ 2475,
857
+ 2470,
858
+ 2484,
859
+ 2485,
860
+ 2435
861
+ ],
862
+ [
863
+ 2313,
864
+ 2448,
865
+ 2459,
866
+ 2485,
867
+ 2452,
868
+ 2476,
869
+ 2471,
870
+ 2485,
871
+ 2486,
872
+ 2436
873
+ ],
874
+ [
875
+ 2314,
876
+ 2449,
877
+ 2460,
878
+ 2486,
879
+ 2453,
880
+ 2477,
881
+ 2472,
882
+ 2486,
883
+ 2487,
884
+ 2437
885
+ ],
886
+ [
887
+ 2315,
888
+ 2450,
889
+ 2461,
890
+ 2487,
891
+ 2454,
892
+ 2478,
893
+ 2473,
894
+ 2487,
895
+ 2488,
896
+ 2438
897
+ ],
898
+ [
899
+ 2316,
900
+ 2451,
901
+ 2462,
902
+ 2488,
903
+ 2455,
904
+ 2479,
905
+ 2474,
906
+ 2488,
907
+ 2489,
908
+ 2439
909
+ ],
910
+ [
911
+ 2317,
912
+ 2452,
913
+ 2463,
914
+ 2489,
915
+ 2456,
916
+ 2480,
917
+ 2475,
918
+ 2489,
919
+ 2490,
920
+ 2440
921
+ ],
922
+ [
923
+ 2427,
924
+ 2453,
925
+ 2464,
926
+ 2490,
927
+ 2457,
928
+ 2481,
929
+ 2476,
930
+ 2490,
931
+ 2491,
932
+ 2441
933
+ ],
934
+ [
935
+ 2428,
936
+ 2454,
937
+ 2465,
938
+ 2491,
939
+ 2458,
940
+ 2482,
941
+ 2477,
942
+ 2491,
943
+ 2492,
944
+ 2442
945
+ ],
946
+ [
947
+ 2429,
948
+ 2455,
949
+ 2466,
950
+ 2492,
951
+ 2459,
952
+ 2483,
953
+ 2478,
954
+ 2492,
955
+ 2493,
956
+ 2443
957
+ ],
958
+ [
959
+ 2430,
960
+ 2456,
961
+ 2467,
962
+ 2493,
963
+ 2460,
964
+ 2484,
965
+ 2479,
966
+ 2493,
967
+ 2494,
968
+ 2444
969
+ ],
970
+ [
971
+ 2431,
972
+ 2457,
973
+ 2468,
974
+ 2494,
975
+ 2461,
976
+ 2485,
977
+ 2480,
978
+ 2494,
979
+ 2495,
980
+ 2445
981
+ ],
982
+ [
983
+ 2432,
984
+ 2458,
985
+ 2469,
986
+ 2495,
987
+ 2462,
988
+ 2486,
989
+ 2481,
990
+ 2495,
991
+ 2496,
992
+ 2446
993
+ ],
994
+ [
995
+ 2433,
996
+ 2459,
997
+ 2470,
998
+ 2496,
999
+ 2463,
1000
+ 2487,
1001
+ 2482,
1002
+ 2496,
1003
+ 2497,
1004
+ 2447
1005
+ ],
1006
+ [
1007
+ 2434,
1008
+ 2460,
1009
+ 2471,
1010
+ 2497,
1011
+ 2464,
1012
+ 2488,
1013
+ 2483,
1014
+ 2497,
1015
+ 2498,
1016
+ 2448
1017
+ ],
1018
+ [
1019
+ 2435,
1020
+ 2461,
1021
+ 2472,
1022
+ 2498,
1023
+ 2465,
1024
+ 2489,
1025
+ 2484,
1026
+ 2498,
1027
+ 2499,
1028
+ 2449
1029
+ ],
1030
+ [
1031
+ 2436,
1032
+ 2462,
1033
+ 2473,
1034
+ 2499,
1035
+ 2466,
1036
+ 2490,
1037
+ 2485,
1038
+ 2499,
1039
+ 2500,
1040
+ 2450
1041
+ ],
1042
+ [
1043
+ 2437,
1044
+ 2463,
1045
+ 2474,
1046
+ 2500,
1047
+ 2467,
1048
+ 2491,
1049
+ 2486,
1050
+ 2500,
1051
+ 2501,
1052
+ 2451
1053
+ ],
1054
+ [
1055
+ 2438,
1056
+ 2464,
1057
+ 2475,
1058
+ 2501,
1059
+ 2468,
1060
+ 2492,
1061
+ 2487,
1062
+ 2501,
1063
+ 2502,
1064
+ 2452
1065
+ ],
1066
+ [
1067
+ 2439,
1068
+ 2465,
1069
+ 2476,
1070
+ 2502,
1071
+ 2469,
1072
+ 2493,
1073
+ 2488,
1074
+ 2502,
1075
+ 2503,
1076
+ 2473
1077
+ ],
1078
+ [
1079
+ 2440,
1080
+ 2466,
1081
+ 2477,
1082
+ 2503,
1083
+ 2470,
1084
+ 2494,
1085
+ 2489,
1086
+ 2503,
1087
+ 2504,
1088
+ 2474
1089
+ ],
1090
+ [
1091
+ 2441,
1092
+ 2467,
1093
+ 2478,
1094
+ 2504,
1095
+ 2471,
1096
+ 2495,
1097
+ 2490,
1098
+ 2504,
1099
+ 2505,
1100
+ 2475
1101
+ ],
1102
+ [
1103
+ 2442,
1104
+ 2468,
1105
+ 2479,
1106
+ 2505,
1107
+ 2472,
1108
+ 2496,
1109
+ 2491,
1110
+ 2505,
1111
+ 2506,
1112
+ 2476
1113
+ ],
1114
+ [
1115
+ 2443,
1116
+ 2469,
1117
+ 2480,
1118
+ 2506,
1119
+ 2473,
1120
+ 2497,
1121
+ 2492,
1122
+ 2506,
1123
+ 2507,
1124
+ 2477
1125
+ ],
1126
+ [
1127
+ 2444,
1128
+ 2470,
1129
+ 2481,
1130
+ 2507,
1131
+ 2474,
1132
+ 2498,
1133
+ 2493,
1134
+ 2507,
1135
+ 2508,
1136
+ 2478
1137
+ ],
1138
+ [
1139
+ 2445,
1140
+ 2471,
1141
+ 2482,
1142
+ 2508,
1143
+ 2475,
1144
+ 2499,
1145
+ 2494,
1146
+ 2508,
1147
+ 2509,
1148
+ 2479
1149
+ ],
1150
+ [
1151
+ 2446,
1152
+ 2472,
1153
+ 2483,
1154
+ 2509,
1155
+ 2476,
1156
+ 2500,
1157
+ 2495,
1158
+ 2509,
1159
+ 2510,
1160
+ 2480
1161
+ ],
1162
+ [
1163
+ 2447,
1164
+ 2473,
1165
+ 2484,
1166
+ 2510,
1167
+ 2477,
1168
+ 2501,
1169
+ 2496,
1170
+ 2510,
1171
+ 2511,
1172
+ 2481
1173
+ ],
1174
+ [
1175
+ 2448,
1176
+ 2474,
1177
+ 2485,
1178
+ 2511,
1179
+ 2478,
1180
+ 2502,
1181
+ 2497,
1182
+ 2511,
1183
+ 2512,
1184
+ 2482
1185
+ ]
1186
+ ],
1187
+ "output": 504941
1188
+ }
1189
+ ],
1190
+ "haskell_template": "minimumOperations :: [[Int]] -> Int\nminimumOperations grid ",
1191
+ "ocaml_template": "let minimumOperations (grid: int list list) : int = ",
1192
+ "scala_template": "def minimumOperations(grid: List[List[Int]]): Int = { \n \n}",
1193
+ "java_template": "class Solution {\n public int minimumOperations(int[][] grid) {\n \n }\n}",
1194
+ "python_template": "class Solution(object):\n def minimumOperations(self, grid):\n \"\"\"\n :type grid: List[List[int]]\n :rtype: int\n \"\"\"\n "
1195
+ }
minimum_operations_to_make_columns_strictly_increasing/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minimumOperations (grid: int list list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 15 (minimumOperations [[3;2];[1;3];[3;4];[0;1]])
13
+
14
+ let test2 _ = assert_equal 12 (minimumOperations [[3;2;1];[2;1;0];[1;2;3]])
15
+
16
+ let test3 _ = assert_equal 12 (minimumOperations [[127; 732; 2076; 1498; 1120; 1701; 48; 1574; 2349; 8; 1946; 1434; 2138; 1519]; [2137; 1079; 2434; 1499; 1135; 1702; 66; 1575; 2350; 1980; 2137; 2467; 2139; 1520]])
17
+
18
+ let test4 _ = assert_equal 12 (minimumOperations [[1451; 1480; 2377; 391; 714; 220; 433; 2198; 559; 1443; 1286; 947; 1212; 805; 2450; 1661; 1072; 1652; 801; 316; 273; 761; 1189; 2445; 996; 151; 1875; 676; 103; 7; 1610; 1520; 2035; 439; 1284; 1935; 93; 1342; 774; 1971; 1923; 937; 1301; 2206; 985; 1301; 1509; 2022; 1803]])
19
+
20
+ let test5 _ = assert_equal 12 (minimumOperations [[1238; 1786; 31]; [2142; 1787; 1359]; [2280; 1788; 1360]; [2281; 1899; 1504]; [2282; 1900; 1505]; [2283; 1901; 2140]; [2284; 1902; 2141]; [2285; 1903; 2142]; [2286; 1904; 2143]; [2473; 1905; 2144]; [2474; 1906; 2285]; [2475; 1907; 2286]; [2476; 1908; 2287]; [2477; 1909; 2288]; [2478; 1917; 2289]; [2479; 1918; 2290]; [2480; 1919; 2291]; [2481; 2426; 2292]; [2482; 2427; 2293]; [2483; 2428; 2336]; [2484; 2429; 2337]; [2485; 2430; 2338]; [2486; 2431; 2339]; [2487; 2432; 2340]; [2488; 2433; 2341]; [2489; 2434; 2342]; [2490; 2435; 2343]; [2491; 2436; 2344]; [2492; 2437; 2345]; [2493; 2438; 2346]; [2494; 2439; 2347]; [2495; 2440; 2348]; [2496; 2441; 2349]; [2497; 2442; 2350]; [2498; 2443; 2351]; [2499; 2444; 2368]])
21
+
22
+ let test6 _ = assert_equal 12 (minimumOperations [[868; 1485; 2457; 395; 2382; 314; 1979; 528; 728; 1132; 1436; 1478; 1306; 963; 2033; 1976; 1427; 1549; 1320; 88; 134; 1125; 114; 2234; 1283; 1850; 1536; 2116; 2018; 1182; 903; 881; 1447; 19; 1224; 134; 47; 2091; 1467; 1340; 1450; 2472]; [1091; 1486; 2458; 396; 2383; 1444; 1980; 529; 1511; 1133; 1437; 2101; 2141; 2339; 2034; 1977; 1428; 1550; 2161; 543; 1632; 2125; 2469; 2235; 1284; 1851; 1537; 2117; 2019; 2091; 1991; 1052; 2384; 455; 1640; 2081; 2366; 2092; 1468; 1341; 1595; 2473]; [1120; 2266; 2459; 397; 2384; 1445; 1981; 808; 1512; 2174; 2439; 2102; 2142; 2340; 2035; 2002; 1429; 2122; 2162; 1055; 1718; 2126; 2470; 2236; 1285; 2020; 1538; 2221; 2456; 2092; 1992; 1053; 2385; 563; 1641; 2082; 2367; 2157; 1886; 1342; 1596; 2474]; [2494; 2267; 2460; 398; 2385; 1446; 1982; 2296; 2075; 2175; 2440; 2103; 2143; 2341; 2036; 2003; 1430; 2128; 2163; 1056; 2465; 2127; 2471; 2237; 1286; 2021; 1539; 2400; 2457; 2093; 1993; 1802; 2386; 1120; 1642; 2083; 2368; 2158; 1887; 2046; 1597; 2475]; [2495; 2313; 2461; 2131; 2386; 1674; 1983; 2297; 2076; 2176; 2441; 2104; 2144; 2342; 2037; 2004; 1899; 2304; 2164; 1569; 2466; 2128; 2472; 2238; 1456; 2022; 1680; 2401; 2458; 2094; 1994; 1803; 2387; 1121; 1643; 2084; 2369; 2159; 1888; 2224; 1598; 2476]; [2496; 2314; 2462; 2132; 2387; 1675; 1984; 2298; 2077; 2177; 2450; 2105; 2145; 2343; 2038; 2005; 1900; 2305; 2277; 1570; 2467; 2129; 2473; 2239; 1457; 2023; 1681; 2402; 2459; 2095; 1995; 1804; 2388; 1122; 1661; 2085; 2370; 2483; 1889; 2225; 1599; 2477]; [2497; 2315; 2463; 2449; 2388; 1676; 1985; 2299; 2417; 2178; 2451; 2106; 2146; 2344; 2039; 2006; 1901; 2306; 2278; 1571; 2468; 2417; 2474; 2240; 1703; 2024; 1682; 2403; 2460; 2143; 2381; 1993; 2389; 2314; 1662; 2086; 2371; 2484; 1890; 2401; 1600; 2478]; [2498; 2316; 2464; 2450; 2389; 1677; 2090; 2300; 2418; 2179; 2452; 2107; 2147; 2345; 2040; 2007; 1902; 2307; 2279; 1572; 2469; 2418; 2475; 2241; 1704; 2204; 1683; 2404; 2461; 2144; 2382; 2020; 2390; 2315; 1663; 2087; 2372; 2485; 1891; 2402; 1601; 2479]])
23
+
24
+ let test7 _ = assert_equal 12 (minimumOperations [[2091; 1538; 1215; 1122; 672; 1607; 504; 2056; 2351; 1723]; [2092; 2317; 1361; 1283; 673; 1608; 2252; 2239; 2352; 1724]; [2097; 2318; 1362; 2316; 854; 1609; 2456; 2428; 2353; 1725]; [2098; 2319; 1363; 2317; 855; 2462; 2457; 2429; 2354; 1726]; [2099; 2320; 2404; 2318; 2091; 2463; 2458; 2430; 2355; 1727]; [2301; 2321; 2447; 2319; 2092; 2464; 2459; 2431; 2356; 1728]; [2302; 2322; 2448; 2320; 2093; 2465; 2460; 2474; 2357; 1729]; [2303; 2323; 2449; 2321; 2094; 2466; 2461; 2475; 2358; 1730]; [2304; 2324; 2450; 2322; 2095; 2467; 2462; 2476; 2359; 2089]; [2305; 2325; 2451; 2323; 2444; 2468; 2463; 2477; 2360; 2090]; [2306; 2326; 2452; 2324; 2445; 2469; 2464; 2478; 2361; 2091]; [2307; 2327; 2453; 2325; 2446; 2470; 2465; 2479; 2362; 2386]; [2308; 2443; 2454; 2326; 2447; 2471; 2466; 2480; 2481; 2387]; [2309; 2444; 2455; 2327; 2448; 2472; 2467; 2481; 2482; 2432]; [2310; 2445; 2456; 2328; 2449; 2473; 2468; 2482; 2483; 2433]; [2311; 2446; 2457; 2329; 2450; 2474; 2469; 2483; 2484; 2434]; [2312; 2447; 2458; 2484; 2451; 2475; 2470; 2484; 2485; 2435]; [2313; 2448; 2459; 2485; 2452; 2476; 2471; 2485; 2486; 2436]; [2314; 2449; 2460; 2486; 2453; 2477; 2472; 2486; 2487; 2437]; [2315; 2450; 2461; 2487; 2454; 2478; 2473; 2487; 2488; 2438]; [2316; 2451; 2462; 2488; 2455; 2479; 2474; 2488; 2489; 2439]; [2317; 2452; 2463; 2489; 2456; 2480; 2475; 2489; 2490; 2440]; [2427; 2453; 2464; 2490; 2457; 2481; 2476; 2490; 2491; 2441]; [2428; 2454; 2465; 2491; 2458; 2482; 2477; 2491; 2492; 2442]; [2429; 2455; 2466; 2492; 2459; 2483; 2478; 2492; 2493; 2443]; [2430; 2456; 2467; 2493; 2460; 2484; 2479; 2493; 2494; 2444]; [2431; 2457; 2468; 2494; 2461; 2485; 2480; 2494; 2495; 2445]; [2432; 2458; 2469; 2495; 2462; 2486; 2481; 2495; 2496; 2446]; [2433; 2459; 2470; 2496; 2463; 2487; 2482; 2496; 2497; 2447]; [2434; 2460; 2471; 2497; 2464; 2488; 2483; 2497; 2498; 2448]; [2435; 2461; 2472; 2498; 2465; 2489; 2484; 2498; 2499; 2449]; [2436; 2462; 2473; 2499; 2466; 2490; 2485; 2499; 2500; 2450]; [2437; 2463; 2474; 2500; 2467; 2491; 2486; 2500; 2501; 2451]; [2438; 2464; 2475; 2501; 2468; 2492; 2487; 2501; 2502; 2452]; [2439; 2465; 2476; 2502; 2469; 2493; 2488; 2502; 2503; 2473]; [2440; 2466; 2477; 2503; 2470; 2494; 2489; 2503; 2504; 2474]; [2441; 2467; 2478; 2504; 2471; 2495; 2490; 2504; 2505; 2475]; [2442; 2468; 2479; 2505; 2472; 2496; 2491; 2505; 2506; 2476]; [2443; 2469; 2480; 2506; 2473; 2497; 2492; 2506; 2507; 2477]; [2444; 2470; 2481; 2507; 2474; 2498; 2493; 2507; 2508; 2478]; [2445; 2471; 2482; 2508; 2475; 2499; 2494; 2508; 2509; 2479]; [2446; 2472; 2483; 2509; 2476; 2500; 2495; 2509; 2510; 2480]; [2447; 2473; 2484; 2510; 2477; 2501; 2496; 2510; 2511; 2481]; [2448; 2474; 2485; 2511; 2478; 2502; 2497; 2511; 2512; 2482]])
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for minimumOperations" >::: [
29
+
30
+ "test1" >:: test1;
31
+ "test2" >:: test2;
32
+ "test3" >:: test3;
33
+ "test4" >:: test4;
34
+ "test5" >:: test5;
35
+ "test6" >:: test6;
36
+ "test7" >:: test7;
37
+ ]
38
+
39
+
40
+ (* Running the tests *)
41
+ let () = run_test_tt_main suite
42
+ end
minimum_operations_to_make_columns_strictly_increasing/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumOperations(List(List(3,2),List(1,3),List(3,4),List(0,1))), 15)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumOperations(List(List(3,2,1),List(2,1,0),List(1,2,3))), 12)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumOperations(List(127, 732, 2076, 1498, 1120, 1701, 48, 1574, 2349, 8, 1946, 1434, 2138, 1519),List(2137, 1079, 2434, 1499, 1135, 1702, 66, 1575, 2350, 1980, 2137, 2467, 2139, 1520)), 3718)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumOperations(List(1451, 1480, 2377, 391, 714, 220, 433, 2198, 559, 1443, 1286, 947, 1212, 805, 2450, 1661, 1072, 1652, 801, 316, 273, 761, 1189, 2445, 996, 151, 1875, 676, 103, 7, 1610, 1520, 2035, 439, 1284, 1935, 93, 1342, 774, 1971, 1923, 937, 1301, 2206, 985, 1301, 1509, 2022, 1803)), 0)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumOperations(List(1238, 1786, 31),List(2142, 1787, 1359),List(2280, 1788, 1360),List(2281, 1899, 1504),List(2282, 1900, 1505),List(2283, 1901, 2140),List(2284, 1902, 2141),List(2285, 1903, 2142),List(2286, 1904, 2143),List(2473, 1905, 2144),List(2474, 1906, 2285),List(2475, 1907, 2286),List(2476, 1908, 2287),List(2477, 1909, 2288),List(2478, 1917, 2289),List(2479, 1918, 2290),List(2480, 1919, 2291),List(2481, 2426, 2292),List(2482, 2427, 2293),List(2483, 2428, 2336),List(2484, 2429, 2337),List(2485, 2430, 2338),List(2486, 2431, 2339),List(2487, 2432, 2340),List(2488, 2433, 2341),List(2489, 2434, 2342),List(2490, 2435, 2343),List(2491, 2436, 2344),List(2492, 2437, 2345),List(2493, 2438, 2346),List(2494, 2439, 2347),List(2495, 2440, 2348),List(2496, 2441, 2349),List(2497, 2442, 2350),List(2498, 2443, 2351),List(2499, 2444, 2368)), 114619)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumOperations(List(868, 1485, 2457, 395, 2382, 314, 1979, 528, 728, 1132, 1436, 1478, 1306, 963, 2033, 1976, 1427, 1549, 1320, 88, 134, 1125, 114, 2234, 1283, 1850, 1536, 2116, 2018, 1182, 903, 881, 1447, 19, 1224, 134, 47, 2091, 1467, 1340, 1450, 2472),List(1091, 1486, 2458, 396, 2383, 1444, 1980, 529, 1511, 1133, 1437, 2101, 2141, 2339, 2034, 1977, 1428, 1550, 2161, 543, 1632, 2125, 2469, 2235, 1284, 1851, 1537, 2117, 2019, 2091, 1991, 1052, 2384, 455, 1640, 2081, 2366, 2092, 1468, 1341, 1595, 2473),List(1120, 2266, 2459, 397, 2384, 1445, 1981, 808, 1512, 2174, 2439, 2102, 2142, 2340, 2035, 2002, 1429, 2122, 2162, 1055, 1718, 2126, 2470, 2236, 1285, 2020, 1538, 2221, 2456, 2092, 1992, 1053, 2385, 563, 1641, 2082, 2367, 2157, 1886, 1342, 1596, 2474),List(2494, 2267, 2460, 398, 2385, 1446, 1982, 2296, 2075, 2175, 2440, 2103, 2143, 2341, 2036, 2003, 1430, 2128, 2163, 1056, 2465, 2127, 2471, 2237, 1286, 2021, 1539, 2400, 2457, 2093, 1993, 1802, 2386, 1120, 1642, 2083, 2368, 2158, 1887, 2046, 1597, 2475),List(2495, 2313, 2461, 2131, 2386, 1674, 1983, 2297, 2076, 2176, 2441, 2104, 2144, 2342, 2037, 2004, 1899, 2304, 2164, 1569, 2466, 2128, 2472, 2238, 1456, 2022, 1680, 2401, 2458, 2094, 1994, 1803, 2387, 1121, 1643, 2084, 2369, 2159, 1888, 2224, 1598, 2476),List(2496, 2314, 2462, 2132, 2387, 1675, 1984, 2298, 2077, 2177, 2450, 2105, 2145, 2343, 2038, 2005, 1900, 2305, 2277, 1570, 2467, 2129, 2473, 2239, 1457, 2023, 1681, 2402, 2459, 2095, 1995, 1804, 2388, 1122, 1661, 2085, 2370, 2483, 1889, 2225, 1599, 2477),List(2497, 2315, 2463, 2449, 2388, 1676, 1985, 2299, 2417, 2178, 2451, 2106, 2146, 2344, 2039, 2006, 1901, 2306, 2278, 1571, 2468, 2417, 2474, 2240, 1703, 2024, 1682, 2403, 2460, 2143, 2381, 1993, 2389, 2314, 1662, 2086, 2371, 2484, 1890, 2401, 1600, 2478),List(2498, 2316, 2464, 2450, 2389, 1677, 2090, 2300, 2418, 2179, 2452, 2107, 2147, 2345, 2040, 2007, 1902, 2307, 2279, 1572, 2469, 2418, 2475, 2241, 1704, 2204, 1683, 2404, 2461, 2144, 2382, 2020, 2390, 2315, 1663, 2087, 2372, 2485, 1891, 2402, 1601, 2479)), 229471)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumOperations(List(2091, 1538, 1215, 1122, 672, 1607, 504, 2056, 2351, 1723),List(2092, 2317, 1361, 1283, 673, 1608, 2252, 2239, 2352, 1724),List(2097, 2318, 1362, 2316, 854, 1609, 2456, 2428, 2353, 1725),List(2098, 2319, 1363, 2317, 855, 2462, 2457, 2429, 2354, 1726),List(2099, 2320, 2404, 2318, 2091, 2463, 2458, 2430, 2355, 1727),List(2301, 2321, 2447, 2319, 2092, 2464, 2459, 2431, 2356, 1728),List(2302, 2322, 2448, 2320, 2093, 2465, 2460, 2474, 2357, 1729),List(2303, 2323, 2449, 2321, 2094, 2466, 2461, 2475, 2358, 1730),List(2304, 2324, 2450, 2322, 2095, 2467, 2462, 2476, 2359, 2089),List(2305, 2325, 2451, 2323, 2444, 2468, 2463, 2477, 2360, 2090),List(2306, 2326, 2452, 2324, 2445, 2469, 2464, 2478, 2361, 2091),List(2307, 2327, 2453, 2325, 2446, 2470, 2465, 2479, 2362, 2386),List(2308, 2443, 2454, 2326, 2447, 2471, 2466, 2480, 2481, 2387),List(2309, 2444, 2455, 2327, 2448, 2472, 2467, 2481, 2482, 2432),List(2310, 2445, 2456, 2328, 2449, 2473, 2468, 2482, 2483, 2433),List(2311, 2446, 2457, 2329, 2450, 2474, 2469, 2483, 2484, 2434),List(2312, 2447, 2458, 2484, 2451, 2475, 2470, 2484, 2485, 2435),List(2313, 2448, 2459, 2485, 2452, 2476, 2471, 2485, 2486, 2436),List(2314, 2449, 2460, 2486, 2453, 2477, 2472, 2486, 2487, 2437),List(2315, 2450, 2461, 2487, 2454, 2478, 2473, 2487, 2488, 2438),List(2316, 2451, 2462, 2488, 2455, 2479, 2474, 2488, 2489, 2439),List(2317, 2452, 2463, 2489, 2456, 2480, 2475, 2489, 2490, 2440),List(2427, 2453, 2464, 2490, 2457, 2481, 2476, 2490, 2491, 2441),List(2428, 2454, 2465, 2491, 2458, 2482, 2477, 2491, 2492, 2442),List(2429, 2455, 2466, 2492, 2459, 2483, 2478, 2492, 2493, 2443),List(2430, 2456, 2467, 2493, 2460, 2484, 2479, 2493, 2494, 2444),List(2431, 2457, 2468, 2494, 2461, 2485, 2480, 2494, 2495, 2445),List(2432, 2458, 2469, 2495, 2462, 2486, 2481, 2495, 2496, 2446),List(2433, 2459, 2470, 2496, 2463, 2487, 2482, 2496, 2497, 2447),List(2434, 2460, 2471, 2497, 2464, 2488, 2483, 2497, 2498, 2448),List(2435, 2461, 2472, 2498, 2465, 2489, 2484, 2498, 2499, 2449),List(2436, 2462, 2473, 2499, 2466, 2490, 2485, 2499, 2500, 2450),List(2437, 2463, 2474, 2500, 2467, 2491, 2486, 2500, 2501, 2451),List(2438, 2464, 2475, 2501, 2468, 2492, 2487, 2501, 2502, 2452),List(2439, 2465, 2476, 2502, 2469, 2493, 2488, 2502, 2503, 2473),List(2440, 2466, 2477, 2503, 2470, 2494, 2489, 2503, 2504, 2474),List(2441, 2467, 2478, 2504, 2471, 2495, 2490, 2504, 2505, 2475),List(2442, 2468, 2479, 2505, 2472, 2496, 2491, 2505, 2506, 2476),List(2443, 2469, 2480, 2506, 2473, 2497, 2492, 2506, 2507, 2477),List(2444, 2470, 2481, 2507, 2474, 2498, 2493, 2507, 2508, 2478),List(2445, 2471, 2482, 2508, 2475, 2499, 2494, 2508, 2509, 2479),List(2446, 2472, 2483, 2509, 2476, 2500, 2495, 2509, 2510, 2480),List(2447, 2473, 2484, 2510, 2477, 2501, 2496, 2510, 2511, 2481),List(2448, 2474, 2485, 2511, 2478, 2502, 2497, 2511, 2512, 2482)), 504941)
30
+ }
31
+
32
+ }
minimum_operations_to_make_median_of_array_equal_to_k/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb7838213dde684a0a50316366c589bf37a972d0d34449e117901d22d4d859b9
3
+ size 11225610
minimum_operations_to_make_median_of_array_equal_to_k/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, minOperationsToMakeMedianK(new ArrayList<>(Arrays.asList(2,5,6,8,5)), 4));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(3, minOperationsToMakeMedianK(new ArrayList<>(Arrays.asList(2,5,6,8,5)), 7));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(0, minOperationsToMakeMedianK(new ArrayList<>(Arrays.asList(1,2,3,4,5,6)), 4));
23
+ }
24
+
25
+ }
minimum_operations_to_make_median_of_array_equal_to_k/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e8fa2e532197d07f99d33244fdf23177c0980877fd6a2b6c93290557190bfc0a
3
+ size 24638756
minimum_operations_to_make_median_of_array_equal_to_k/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_median_of_array_equal_to_k/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_operations_to_make_the_array_alternating/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimum_operations_to_make_the_array_alternating/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 (minimumOperations [3,1,3,2,4,3])," 3 (minimumOperations [3,1,3,2,4,3]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumOperations [1,2,2,2,2])," 2 (minimumOperations [1,2,2,2,2]))
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_operations_to_make_the_array_alternating/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, minimumOperations(new ArrayList<>(Arrays.asList(3,1,3,2,4,3))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, minimumOperations(new ArrayList<>(Arrays.asList(1,2,2,2,2))));
19
+ }
20
+
21
+ }
minimum_operations_to_make_the_array_alternating/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83751e0c51346bb147af244496d63164c9b0c984d3b256461aa5251fefd1bb16
3
+ size 12988062
minimum_operations_to_make_the_array_alternating/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 (minimumOperations [3;1;3;2;4;3])
12
+
13
+ let test2 _ = assert_equal 2 (minimumOperations [1;2;2;2;2])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minimumOperations" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end