DatasetRepo commited on
Commit
f9ab7cd
·
verified ·
1 Parent(s): 5f2b388

39a8ae557bafed1b5e5736c10b5897d38635ffc981d13fa842f1ce72e4046229

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 +3 -0
  2. append_k_integers_with_minimal_sum/haskell_tests/Main.hs +24 -0
  3. append_k_integers_with_minimal_sum/java_tests/Main.java +21 -0
  4. append_k_integers_with_minimal_sum/meta.json +3 -0
  5. append_k_integers_with_minimal_sum/ocaml_tests/main.ml +26 -0
  6. append_k_integers_with_minimal_sum/scala_tests/MySuite.scala +12 -0
  7. apple_redistribution_into_boxes/haskell_tests/Main.hs +45 -0
  8. apple_redistribution_into_boxes/java_tests/Main.java +21 -0
  9. apple_redistribution_into_boxes/meta.json +482 -0
  10. apple_redistribution_into_boxes/ocaml_tests/main.ml +50 -0
  11. apple_redistribution_into_boxes/scala_tests/MySuite.scala +44 -0
  12. apply_bitwise_operations_to_make_strings_equal/haskell_tests/Main.hs +0 -0
  13. apply_bitwise_operations_to_make_strings_equal/java_tests/Main.java +21 -0
  14. apply_bitwise_operations_to_make_strings_equal/meta.json +0 -0
  15. apply_bitwise_operations_to_make_strings_equal/ocaml_tests/main.ml +0 -0
  16. apply_bitwise_operations_to_make_strings_equal/scala_tests/MySuite.scala +0 -0
  17. apply_discount_to_prices/haskell_tests/Main.hs +0 -0
  18. apply_discount_to_prices/java_tests/Main.java +21 -0
  19. apply_discount_to_prices/meta.json +0 -0
  20. apply_discount_to_prices/ocaml_tests/main.ml +0 -0
  21. apply_discount_to_prices/scala_tests/MySuite.scala +0 -0
  22. apply_operations_on_array_to_maximize_sum_of_squares/haskell_tests/Main.hs +0 -0
  23. apply_operations_on_array_to_maximize_sum_of_squares/java_tests/Main.java +21 -0
  24. apply_operations_on_array_to_maximize_sum_of_squares/meta.json +3 -0
  25. apply_operations_on_array_to_maximize_sum_of_squares/ocaml_tests/main.ml +0 -0
  26. apply_operations_on_array_to_maximize_sum_of_squares/scala_tests/MySuite.scala +0 -0
  27. apply_operations_to_an_array/.DS_Store +0 -0
  28. apply_operations_to_an_array/haskell_tests/Main.hs +24 -0
  29. apply_operations_to_an_array/java_tests/Main.java +21 -0
  30. apply_operations_to_an_array/meta.json +0 -0
  31. apply_operations_to_an_array/ocaml_tests/main.ml +26 -0
  32. apply_operations_to_an_array/scala_tests/MySuite.scala +12 -0
  33. apply_operations_to_make_all_array_elements_equal_to_zero/.DS_Store +0 -0
  34. apply_operations_to_make_all_array_elements_equal_to_zero/haskell_tests/Main.hs +24 -0
  35. apply_operations_to_make_all_array_elements_equal_to_zero/java_tests/Main.java +21 -0
  36. apply_operations_to_make_all_array_elements_equal_to_zero/meta.json +0 -0
  37. apply_operations_to_make_all_array_elements_equal_to_zero/ocaml_tests/main.ml +26 -0
  38. apply_operations_to_make_all_array_elements_equal_to_zero/scala_tests/MySuite.scala +12 -0
  39. apply_operations_to_make_string_empty/haskell_tests/Main.hs +0 -0
  40. apply_operations_to_make_string_empty/java_tests/Main.java +20 -0
  41. apply_operations_to_make_string_empty/meta.json +0 -0
  42. apply_operations_to_make_string_empty/ocaml_tests/main.ml +0 -0
  43. apply_operations_to_make_string_empty/scala_tests/MySuite.scala +0 -0
  44. apply_operations_to_make_two_strings_equal/haskell_tests/Main.hs +45 -0
  45. apply_operations_to_make_two_strings_equal/java_tests/Main.java +21 -0
  46. apply_operations_to_make_two_strings_equal/meta.json +107 -0
  47. apply_operations_to_make_two_strings_equal/ocaml_tests/main.ml +50 -0
  48. apply_operations_to_make_two_strings_equal/scala_tests/MySuite.scala +44 -0
  49. apply_operations_to_maximize_frequency_score/haskell_tests/Main.hs +0 -0
  50. apply_operations_to_maximize_frequency_score/java_tests/Main.java +21 -0
.gitattributes CHANGED
@@ -61,3 +61,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
61
  add_edges_to_make_degrees_of_all_nodes_even/meta.json filter=lfs diff=lfs merge=lfs -text
62
  all_divisions_with_the_highest_score_of_a_binary_array/meta.json filter=lfs diff=lfs merge=lfs -text
63
  alternating_groups_iii/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
61
  add_edges_to_make_degrees_of_all_nodes_even/meta.json filter=lfs diff=lfs merge=lfs -text
62
  all_divisions_with_the_highest_score_of_a_binary_array/meta.json filter=lfs diff=lfs merge=lfs -text
63
  alternating_groups_iii/meta.json filter=lfs diff=lfs merge=lfs -text
64
+ append_k_integers_with_minimal_sum/meta.json filter=lfs diff=lfs merge=lfs -text
65
+ apply_operations_on_array_to_maximize_sum_of_squares/meta.json filter=lfs diff=lfs merge=lfs -text
66
+ apply_operations_to_maximize_frequency_score/meta.json filter=lfs diff=lfs merge=lfs -text
append_k_integers_with_minimal_sum/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 (minimalKSum [1,4,25,10,25] 2)," 5 (minimalKSum [1,4,25,10,25] 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimalKSum [5,6] 6)," 25 (minimalKSum [5,6] 6))
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
append_k_integers_with_minimal_sum/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(5, minimalKSum(new ArrayList<>(Arrays.asList(1,4,25,10,25)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(25, minimalKSum(new ArrayList<>(Arrays.asList(5,6)), 6));
19
+ }
20
+
21
+ }
append_k_integers_with_minimal_sum/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:faa2aff4de05f80cc4c646f60941cccd98ac3c6d8d473556da1aa9d464171c4c
3
+ size 18911165
append_k_integers_with_minimal_sum/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 5 (minimalKSum [1;4;25;10;25] 2)
12
+
13
+ let test2 _ = assert_equal 25 (minimalKSum [5;6] 6)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minimalKSum" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
append_k_integers_with_minimal_sum/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimalKSum(List(1,4,25,10,25),2), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimalKSum(List(5,6),6), 25)
10
+ }
11
+
12
+ }
apple_redistribution_into_boxes/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 (minimumBoxes [1,3,2] [4,3,1,5,2])," 2 (minimumBoxes [1,3,2] [4,3,1,5,2]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumBoxes [5,5,5] [2,4,2,7])," 4 (minimumBoxes [5,5,5] [2,4,2,7]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimumBoxes [12, 39, 47, 10, 21, 26, 7, 50] [49, 43, 35, 30, 29, 28, 24, 7])," 6 (minimumBoxes [12, 39, 47, 10, 21, 26, 7, 50] [49, 43, 35, 30, 29, 28, 24, 7]))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (minimumBoxes [35, 48, 40, 16, 43, 36, 41, 4] [46, 45, 45, 44, 43, 40, 38, 38, 36, 34, 34, 33, 30, 29, 28, 26, 25, 24, 22, 22, 19, 18, 17, 7, 2, 2, 2, 1])," 6 (minimumBoxes [35, 48, 40, 16, 43, 36, 41, 4] [46, 45, 45, 44, 43, 40, 38, 38, 36, 34, 34, 33, 30, 29, 28, 26, 25, 24, 22, 22, 19, 18, 17, 7, 2, 2, 2, 1]))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (minimumBoxes [18, 45, 11, 47, 26, 2, 39, 48, 43, 16, 4, 17, 48, 44, 2, 21, 41, 40, 17, 29, 35, 23, 45, 30, 31, 34, 39] [205, 50, 45, 45, 45, 42, 39, 37, 35, 35, 31, 27, 26, 24, 24, 21, 21, 15, 14, 8, 6])," 21 (minimumBoxes [18, 45, 11, 47, 26, 2, 39, 48, 43, 16, 4, 17, 48, 44, 2, 21, 41, 40, 17, 29, 35, 23, 45, 30, 31, 34, 39] [205, 50, 45, 45, 45, 42, 39, 37, 35, 35, 31, 27, 26, 24, 24, 21, 21, 15, 14, 8, 6]))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (minimumBoxes [46, 5, 6, 15, 47, 20, 16, 19, 42, 44, 44, 28, 28, 19, 16, 26, 47, 12, 39, 40, 25, 25, 48, 3, 17, 6, 21, 22, 20, 2, 50, 50, 26, 26, 41, 5, 9, 31, 19, 40, 26] [719, 50, 49, 41, 31, 28, 28, 23, 22, 20, 15, 11, 11, 10, 8, 5])," 16 (minimumBoxes [46, 5, 6, 15, 47, 20, 16, 19, 42, 44, 44, 28, 28, 19, 16, 26, 47, 12, 39, 40, 25, 25, 48, 3, 17, 6, 21, 22, 20, 2, 50, 50, 26, 26, 41, 5, 9, 31, 19, 40, 26] [719, 50, 49, 41, 31, 28, 28, 23, 22, 20, 15, 11, 11, 10, 8, 5]))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (minimumBoxes [14, 12, 1, 27, 27, 29, 14, 12, 7, 6, 8, 42, 34, 42, 44, 46, 27, 49, 36, 24] [163, 46, 44, 44, 40, 37, 35, 34, 25, 12, 9, 8, 4])," 13 (minimumBoxes [14, 12, 1, 27, 27, 29, 14, 12, 7, 6, 8, 42, 34, 42, 44, 46, 27, 49, 36, 24] [163, 46, 44, 44, 40, 37, 35, 34, 25, 12, 9, 8, 4]))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (minimumBoxes [28, 3, 15, 44, 49, 25, 11, 50, 32, 2] [43, 39, 37, 36, 35, 35, 33, 32, 28, 25, 20, 16, 16, 6, 3, 2])," 8 (minimumBoxes [28, 3, 15, 44, 49, 25, 11, 50, 32, 2] [43, 39, 37, 36, 35, 35, 33, 32, 28, 25, 20, 16, 16, 6, 3, 2]))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (minimumBoxes [38, 42, 47, 16, 36] [50, 49, 48, 47, 47, 47, 44, 44, 42, 38, 36, 35, 35, 34, 34, 33, 31, 29, 29, 26, 26, 23, 19, 19, 18, 15, 14, 14, 13, 12, 12, 11, 8, 7, 7, 5, 4, 1, 1])," 4 (minimumBoxes [38, 42, 47, 16, 36] [50, 49, 48, 47, 47, 47, 44, 44, 42, 38, 36, 35, 35, 34, 34, 33, 31, 29, 29, 26, 26, 23, 19, 19, 18, 15, 14, 14, 13, 12, 12, 11, 8, 7, 7, 5, 4, 1, 1]))
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
apple_redistribution_into_boxes/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, minimumBoxes(new ArrayList<>(Arrays.asList(1,3,2)), new ArrayList<>(Arrays.asList(4,3,1,5,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, minimumBoxes(new ArrayList<>(Arrays.asList(5,5,5)), new ArrayList<>(Arrays.asList(2,4,2,7))));
19
+ }
20
+
21
+ }
apple_redistribution_into_boxes/meta.json ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3334,
3
+ "name": "apple_redistribution_into_boxes",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/apple-redistribution-into-boxes/",
6
+ "date": "2024-03-03 00:00:00",
7
+ "task_description": "You are given an array `apple` of size `n` and an array `capacity` of size `m`. There are `n` packs where the `ith` pack contains `apple[i]` apples. There are `m` boxes as well, and the `ith` box has a capacity of `capacity[i]` apples. Return _the **minimum** number of boxes you need to select to redistribute these _`n`_ packs of apples into boxes_. **Note** that, apples from the same pack can be distributed into different boxes. **Example 1:** ``` **Input:** apple = [1,3,2], capacity = [4,3,1,5,2] **Output:** 2 **Explanation:** We will use boxes with capacities 4 and 5. It is possible to distribute the apples as the total capacity is greater than or equal to the total number of apples. ``` **Example 2:** ``` **Input:** apple = [5,5,5], capacity = [2,4,2,7] **Output:** 4 **Explanation:** We will need to use all the boxes. ``` **Constraints:** `1 <= n == apple.length <= 50` `1 <= m == capacity.length <= 50` `1 <= apple[i], capacity[i] <= 50` The input is generated such that it's possible to redistribute packs of apples into boxes.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "apple = [1,3,2], capacity = [4,3,1,5,2]",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "apple = [5,5,5], capacity = [2,4,2,7]",
17
+ "output": "4 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 12,
25
+ 39,
26
+ 47,
27
+ 10,
28
+ 21,
29
+ 26,
30
+ 7,
31
+ 50
32
+ ],
33
+ [
34
+ 49,
35
+ 43,
36
+ 35,
37
+ 30,
38
+ 29,
39
+ 28,
40
+ 24,
41
+ 7
42
+ ]
43
+ ],
44
+ "output": 6
45
+ },
46
+ {
47
+ "input": [
48
+ [
49
+ 35,
50
+ 48,
51
+ 40,
52
+ 16,
53
+ 43,
54
+ 36,
55
+ 41,
56
+ 4
57
+ ],
58
+ [
59
+ 46,
60
+ 45,
61
+ 45,
62
+ 44,
63
+ 43,
64
+ 40,
65
+ 38,
66
+ 38,
67
+ 36,
68
+ 34,
69
+ 34,
70
+ 33,
71
+ 30,
72
+ 29,
73
+ 28,
74
+ 26,
75
+ 25,
76
+ 24,
77
+ 22,
78
+ 22,
79
+ 19,
80
+ 18,
81
+ 17,
82
+ 7,
83
+ 2,
84
+ 2,
85
+ 2,
86
+ 1
87
+ ]
88
+ ],
89
+ "output": 6
90
+ },
91
+ {
92
+ "input": [
93
+ [
94
+ 18,
95
+ 45,
96
+ 11,
97
+ 47,
98
+ 26,
99
+ 2,
100
+ 39,
101
+ 48,
102
+ 43,
103
+ 16,
104
+ 4,
105
+ 17,
106
+ 48,
107
+ 44,
108
+ 2,
109
+ 21,
110
+ 41,
111
+ 40,
112
+ 17,
113
+ 29,
114
+ 35,
115
+ 23,
116
+ 45,
117
+ 30,
118
+ 31,
119
+ 34,
120
+ 39
121
+ ],
122
+ [
123
+ 205,
124
+ 50,
125
+ 45,
126
+ 45,
127
+ 45,
128
+ 42,
129
+ 39,
130
+ 37,
131
+ 35,
132
+ 35,
133
+ 31,
134
+ 27,
135
+ 26,
136
+ 24,
137
+ 24,
138
+ 21,
139
+ 21,
140
+ 15,
141
+ 14,
142
+ 8,
143
+ 6
144
+ ]
145
+ ],
146
+ "output": 21
147
+ },
148
+ {
149
+ "input": [
150
+ [
151
+ 46,
152
+ 5,
153
+ 6,
154
+ 15,
155
+ 47,
156
+ 20,
157
+ 16,
158
+ 19,
159
+ 42,
160
+ 44,
161
+ 44,
162
+ 28,
163
+ 28,
164
+ 19,
165
+ 16,
166
+ 26,
167
+ 47,
168
+ 12,
169
+ 39,
170
+ 40,
171
+ 25,
172
+ 25,
173
+ 48,
174
+ 3,
175
+ 17,
176
+ 6,
177
+ 21,
178
+ 22,
179
+ 20,
180
+ 2,
181
+ 50,
182
+ 50,
183
+ 26,
184
+ 26,
185
+ 41,
186
+ 5,
187
+ 9,
188
+ 31,
189
+ 19,
190
+ 40,
191
+ 26
192
+ ],
193
+ [
194
+ 719,
195
+ 50,
196
+ 49,
197
+ 41,
198
+ 31,
199
+ 28,
200
+ 28,
201
+ 23,
202
+ 22,
203
+ 20,
204
+ 15,
205
+ 11,
206
+ 11,
207
+ 10,
208
+ 8,
209
+ 5
210
+ ]
211
+ ],
212
+ "output": 16
213
+ },
214
+ {
215
+ "input": [
216
+ [
217
+ 14,
218
+ 12,
219
+ 1,
220
+ 27,
221
+ 27,
222
+ 29,
223
+ 14,
224
+ 12,
225
+ 7,
226
+ 6,
227
+ 8,
228
+ 42,
229
+ 34,
230
+ 42,
231
+ 44,
232
+ 46,
233
+ 27,
234
+ 49,
235
+ 36,
236
+ 24
237
+ ],
238
+ [
239
+ 163,
240
+ 46,
241
+ 44,
242
+ 44,
243
+ 40,
244
+ 37,
245
+ 35,
246
+ 34,
247
+ 25,
248
+ 12,
249
+ 9,
250
+ 8,
251
+ 4
252
+ ]
253
+ ],
254
+ "output": 13
255
+ },
256
+ {
257
+ "input": [
258
+ [
259
+ 28,
260
+ 3,
261
+ 15,
262
+ 44,
263
+ 49,
264
+ 25,
265
+ 11,
266
+ 50,
267
+ 32,
268
+ 2
269
+ ],
270
+ [
271
+ 43,
272
+ 39,
273
+ 37,
274
+ 36,
275
+ 35,
276
+ 35,
277
+ 33,
278
+ 32,
279
+ 28,
280
+ 25,
281
+ 20,
282
+ 16,
283
+ 16,
284
+ 6,
285
+ 3,
286
+ 2
287
+ ]
288
+ ],
289
+ "output": 8
290
+ },
291
+ {
292
+ "input": [
293
+ [
294
+ 38,
295
+ 42,
296
+ 47,
297
+ 16,
298
+ 36
299
+ ],
300
+ [
301
+ 50,
302
+ 49,
303
+ 48,
304
+ 47,
305
+ 47,
306
+ 47,
307
+ 44,
308
+ 44,
309
+ 42,
310
+ 38,
311
+ 36,
312
+ 35,
313
+ 35,
314
+ 34,
315
+ 34,
316
+ 33,
317
+ 31,
318
+ 29,
319
+ 29,
320
+ 26,
321
+ 26,
322
+ 23,
323
+ 19,
324
+ 19,
325
+ 18,
326
+ 15,
327
+ 14,
328
+ 14,
329
+ 13,
330
+ 12,
331
+ 12,
332
+ 11,
333
+ 8,
334
+ 7,
335
+ 7,
336
+ 5,
337
+ 4,
338
+ 1,
339
+ 1
340
+ ]
341
+ ],
342
+ "output": 4
343
+ },
344
+ {
345
+ "input": [
346
+ [
347
+ 44,
348
+ 26,
349
+ 43,
350
+ 38,
351
+ 50,
352
+ 35,
353
+ 36,
354
+ 44,
355
+ 25,
356
+ 39,
357
+ 16,
358
+ 14,
359
+ 26,
360
+ 12,
361
+ 3,
362
+ 45,
363
+ 21,
364
+ 1,
365
+ 4,
366
+ 8,
367
+ 35,
368
+ 2,
369
+ 33,
370
+ 30,
371
+ 9,
372
+ 26,
373
+ 20,
374
+ 16,
375
+ 14,
376
+ 24,
377
+ 43,
378
+ 7
379
+ ],
380
+ [
381
+ 271,
382
+ 46,
383
+ 42,
384
+ 40,
385
+ 40,
386
+ 40,
387
+ 39,
388
+ 38,
389
+ 36,
390
+ 34,
391
+ 28,
392
+ 28,
393
+ 27,
394
+ 23,
395
+ 19,
396
+ 13,
397
+ 11,
398
+ 8,
399
+ 6
400
+ ]
401
+ ],
402
+ "output": 19
403
+ },
404
+ {
405
+ "input": [
406
+ [
407
+ 49,
408
+ 46,
409
+ 14,
410
+ 38,
411
+ 24,
412
+ 32,
413
+ 16,
414
+ 36,
415
+ 22,
416
+ 19,
417
+ 48,
418
+ 17,
419
+ 43,
420
+ 15,
421
+ 9,
422
+ 3,
423
+ 18,
424
+ 42,
425
+ 4,
426
+ 49,
427
+ 12,
428
+ 20,
429
+ 16,
430
+ 22,
431
+ 11,
432
+ 28,
433
+ 36,
434
+ 1,
435
+ 7,
436
+ 18,
437
+ 49,
438
+ 17,
439
+ 3,
440
+ 4,
441
+ 36,
442
+ 7,
443
+ 37,
444
+ 18,
445
+ 7,
446
+ 41,
447
+ 18,
448
+ 13,
449
+ 5
450
+ ],
451
+ [
452
+ 919,
453
+ 30,
454
+ 16,
455
+ 5
456
+ ]
457
+ ],
458
+ "output": 4
459
+ },
460
+ {
461
+ "input": [
462
+ [
463
+ 41,
464
+ 30,
465
+ 18,
466
+ 6
467
+ ],
468
+ [
469
+ 41,
470
+ 34,
471
+ 20
472
+ ]
473
+ ],
474
+ "output": 3
475
+ }
476
+ ],
477
+ "haskell_template": "minimumBoxes :: [Int] -> [Int] -> Int\nminimumBoxes apple capacity ",
478
+ "ocaml_template": "let minimumBoxes (apple: int list) (capacity: int list) : int = ",
479
+ "scala_template": "def minimumBoxes(apple: List[Int],capacity: List[Int]): Int = { \n \n}",
480
+ "java_template": "class Solution {\n public int minimumBoxes(int[] apple, int[] capacity) {\n \n }\n}",
481
+ "python_template": "class Solution(object):\n def minimumBoxes(self, apple, capacity):\n \"\"\"\n :type apple: List[int]\n :type capacity: List[int]\n :rtype: int\n \"\"\"\n "
482
+ }
apple_redistribution_into_boxes/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 (minimumBoxes [1;3;2] [4;3;1;5;2])
12
+
13
+ let test2 _ = assert_equal 4 (minimumBoxes [5;5;5] [2;4;2;7])
14
+
15
+ let test3 _ = assert_equal 6 (minimumBoxes [12; 39; 47; 10; 21; 26; 7; 50] [49; 43; 35; 30; 29; 28; 24; 7])
16
+
17
+ let test4 _ = assert_equal 6 (minimumBoxes [35; 48; 40; 16; 43; 36; 41; 4] [46; 45; 45; 44; 43; 40; 38; 38; 36; 34; 34; 33; 30; 29; 28; 26; 25; 24; 22; 22; 19; 18; 17; 7; 2; 2; 2; 1])
18
+
19
+ let test5 _ = assert_equal 21 (minimumBoxes [18; 45; 11; 47; 26; 2; 39; 48; 43; 16; 4; 17; 48; 44; 2; 21; 41; 40; 17; 29; 35; 23; 45; 30; 31; 34; 39] [205; 50; 45; 45; 45; 42; 39; 37; 35; 35; 31; 27; 26; 24; 24; 21; 21; 15; 14; 8; 6])
20
+
21
+ let test6 _ = assert_equal 16 (minimumBoxes [46; 5; 6; 15; 47; 20; 16; 19; 42; 44; 44; 28; 28; 19; 16; 26; 47; 12; 39; 40; 25; 25; 48; 3; 17; 6; 21; 22; 20; 2; 50; 50; 26; 26; 41; 5; 9; 31; 19; 40; 26] [719; 50; 49; 41; 31; 28; 28; 23; 22; 20; 15; 11; 11; 10; 8; 5])
22
+
23
+ let test7 _ = assert_equal 13 (minimumBoxes [14; 12; 1; 27; 27; 29; 14; 12; 7; 6; 8; 42; 34; 42; 44; 46; 27; 49; 36; 24] [163; 46; 44; 44; 40; 37; 35; 34; 25; 12; 9; 8; 4])
24
+
25
+ let test8 _ = assert_equal 8 (minimumBoxes [28; 3; 15; 44; 49; 25; 11; 50; 32; 2] [43; 39; 37; 36; 35; 35; 33; 32; 28; 25; 20; 16; 16; 6; 3; 2])
26
+
27
+ let test9 _ = assert_equal 4 (minimumBoxes [38; 42; 47; 16; 36] [50; 49; 48; 47; 47; 47; 44; 44; 42; 38; 36; 35; 35; 34; 34; 33; 31; 29; 29; 26; 26; 23; 19; 19; 18; 15; 14; 14; 13; 12; 12; 11; 8; 7; 7; 5; 4; 1; 1])
28
+
29
+ let test10 _ = assert_equal 19 (minimumBoxes [44; 26; 43; 38; 50; 35; 36; 44; 25; 39; 16; 14; 26; 12; 3; 45; 21; 1; 4; 8; 35; 2; 33; 30; 9; 26; 20; 16; 14; 24; 43; 7] [271; 46; 42; 40; 40; 40; 39; 38; 36; 34; 28; 28; 27; 23; 19; 13; 11; 8; 6])
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for minimumBoxes" >::: [
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
apple_redistribution_into_boxes/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumBoxes(List(1,3,2),List(4,3,1,5,2)), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumBoxes(List(5,5,5),List(2,4,2,7)), 4)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumBoxes(List(12, 39, 47, 10, 21, 26, 7, 50),List(49, 43, 35, 30, 29, 28, 24, 7)), 6)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumBoxes(List(35, 48, 40, 16, 43, 36, 41, 4),List(46, 45, 45, 44, 43, 40, 38, 38, 36, 34, 34, 33, 30, 29, 28, 26, 25, 24, 22, 22, 19, 18, 17, 7, 2, 2, 2, 1)), 6)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumBoxes(List(18, 45, 11, 47, 26, 2, 39, 48, 43, 16, 4, 17, 48, 44, 2, 21, 41, 40, 17, 29, 35, 23, 45, 30, 31, 34, 39),List(205, 50, 45, 45, 45, 42, 39, 37, 35, 35, 31, 27, 26, 24, 24, 21, 21, 15, 14, 8, 6)), 21)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumBoxes(List(46, 5, 6, 15, 47, 20, 16, 19, 42, 44, 44, 28, 28, 19, 16, 26, 47, 12, 39, 40, 25, 25, 48, 3, 17, 6, 21, 22, 20, 2, 50, 50, 26, 26, 41, 5, 9, 31, 19, 40, 26),List(719, 50, 49, 41, 31, 28, 28, 23, 22, 20, 15, 11, 11, 10, 8, 5)), 16)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumBoxes(List(14, 12, 1, 27, 27, 29, 14, 12, 7, 6, 8, 42, 34, 42, 44, 46, 27, 49, 36, 24),List(163, 46, 44, 44, 40, 37, 35, 34, 25, 12, 9, 8, 4)), 13)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumBoxes(List(28, 3, 15, 44, 49, 25, 11, 50, 32, 2),List(43, 39, 37, 36, 35, 35, 33, 32, 28, 25, 20, 16, 16, 6, 3, 2)), 8)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minimumBoxes(List(38, 42, 47, 16, 36),List(50, 49, 48, 47, 47, 47, 44, 44, 42, 38, 36, 35, 35, 34, 34, 33, 31, 29, 29, 26, 26, 23, 19, 19, 18, 15, 14, 14, 13, 12, 12, 11, 8, 7, 7, 5, 4, 1, 1)), 4)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minimumBoxes(List(44, 26, 43, 38, 50, 35, 36, 44, 25, 39, 16, 14, 26, 12, 3, 45, 21, 1, 4, 8, 35, 2, 33, 30, 9, 26, 20, 16, 14, 24, 43, 7),List(271, 46, 42, 40, 40, 40, 39, 38, 36, 34, 28, 28, 27, 23, 19, 13, 11, 8, 6)), 19)
42
+ }
43
+
44
+ }
apply_bitwise_operations_to_make_strings_equal/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
apply_bitwise_operations_to_make_strings_equal/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(true, makeStringsEqual("1010", "0110"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, makeStringsEqual("11", "00"));
19
+ }
20
+
21
+ }
apply_bitwise_operations_to_make_strings_equal/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
apply_bitwise_operations_to_make_strings_equal/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
apply_bitwise_operations_to_make_strings_equal/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
apply_discount_to_prices/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
apply_discount_to_prices/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("50", discountPrices("there are $1 $2 and 5$ candies in the shop", 50));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals("100", discountPrices("1 2 $3 4 $5 $6 7 8$ $9 $10$", 100));
19
+ }
20
+
21
+ }
apply_discount_to_prices/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
apply_discount_to_prices/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
apply_discount_to_prices/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_on_array_to_maximize_sum_of_squares/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_on_array_to_maximize_sum_of_squares/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(261, maxSum(new ArrayList<>(Arrays.asList(2,6,5,8)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(90, maxSum(new ArrayList<>(Arrays.asList(4,5,4,7)), 3));
19
+ }
20
+
21
+ }
apply_operations_on_array_to_maximize_sum_of_squares/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:257c8ae38093774da7de03e769aea9c0f894e2889bdc884008a92f5abf16a2e9
3
+ size 16515818
apply_operations_on_array_to_maximize_sum_of_squares/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_on_array_to_maximize_sum_of_squares/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
apply_operations_to_an_array/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 (applyOperations [1,2,2,1,1,0])," [1,4,2,0,0,0] (applyOperations [1,2,2,1,1,0]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (applyOperations [0,1])," [1,0] (applyOperations [0,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
apply_operations_to_an_array/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(new ArrayList<>(Arrays.asList(1,4,2,0,0,0)), applyOperations(new ArrayList<>(Arrays.asList(1,2,2,1,1,0))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(1,0)), applyOperations(new ArrayList<>(Arrays.asList(0,1))));
19
+ }
20
+
21
+ }
apply_operations_to_an_array/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_an_array/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 [1;4;2;0;0;0] (applyOperations [1;2;2;1;1;0])
12
+
13
+ let test2 _ = assert_equal [1;0] (applyOperations [0;1])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for applyOperations" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
apply_operations_to_an_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.applyOperations(List(1,2,2,1,1,0)), List(1,4,2,0,0,0))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.applyOperations(List(0,1)), List(1,0))
10
+ }
11
+
12
+ }
apply_operations_to_make_all_array_elements_equal_to_zero/.DS_Store ADDED
Binary file (6.15 kB). View file
 
apply_operations_to_make_all_array_elements_equal_to_zero/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 (checkArray [2,2,3,1,1,0] 3)," True (checkArray [2,2,3,1,1,0] 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (checkArray [1,3,1,1] 2)," False (checkArray [1,3,1,1] 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
apply_operations_to_make_all_array_elements_equal_to_zero/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(true, checkArray(new ArrayList<>(Arrays.asList(2,2,3,1,1,0)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, checkArray(new ArrayList<>(Arrays.asList(1,3,1,1)), 2));
19
+ }
20
+
21
+ }
apply_operations_to_make_all_array_elements_equal_to_zero/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_make_all_array_elements_equal_to_zero/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 true (checkArray [2;2;3;1;1;0] 3)
12
+
13
+ let test2 _ = assert_equal false (checkArray [1;3;1;1] 2)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for checkArray" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
apply_operations_to_make_all_array_elements_equal_to_zero/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.checkArray(List(2,2,3,1,1,0),3), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.checkArray(List(1,3,1,1),2), false)
10
+ }
11
+
12
+ }
apply_operations_to_make_string_empty/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_make_string_empty/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("aabcbbca", lastNonEmptyString("aabcbbca"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("abcd", lastNonEmptyString("abcd"));
18
+ }
19
+
20
+ }
apply_operations_to_make_string_empty/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_make_string_empty/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_make_string_empty/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_make_two_strings_equal/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 \"1100011000 \" \"0101001010 \" 2)," 4 (minOperations "1100011000" "0101001010" 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minOperations \"10110 \" \"00011 \" 4)," (-1) (minOperations "10110" "00011" 4))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minOperations \"1111111001101010111111101010001110001100101110111011100001001000001001010010010100100101000010010011110011101010100000001011101110011010110111111000101000000100001000000110000010001010111010010100000101010011101100 \" \"0001000110101011011001100110111000101111010101011000011101000001110110010011100111010101110110001010010001101100000010100110101001101101101110001110100111010100101110100101000001001110101011100111001101111111001111 \" 25)," (-1) (minOperations "1111111001101010111111101010001110001100101110111011100001001000001001010010010100100101000010010011110011101010100000001011101110011010110111111000101000000100001000000110000010001010111010010100000101010011101100" "0001000110101011011001100110111000101111010101011000011101000001110110010011100111010101110110001010010001101100000010100110101001101101101110001110100111010100101110100101000001001110101011100111001101111111001111" 25))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (minOperations \"110 \" \"010 \" 421)," (-1) (minOperations "110" "010" 421))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (minOperations \"01101000000000011111100010000111110100010010100110101100101101111111110110110101111011101110101110111111111010101001101001000100001010001010111100011101100011011010010011000000101100001000111000111010000100010110010110010011011101110011110110110100111110011100000001011110111111011110001001001110010010011101100010101000001100001000011111101110101110101011110101111011110111010000110100101110001000010110000110110011110100101111000011111010001101 \" \"10000110001010101010111101110110101011111110010001001111111111011111001011001010011000001010101100010100011110011111010100011000101110101111011000100011110111101111000011001101101100001111100110001110011010111101001101101110011011001101010101010110101010001100011111101011111001111101011100111100111001100001000001100100100000110001101100100000111111100100000001010001110101001111000001110000111010111000111010011011011000001111101100011110011000 \" 282)," (-1) (minOperations "01101000000000011111100010000111110100010010100110101100101101111111110110110101111011101110101110111111111010101001101001000100001010001010111100011101100011011010010011000000101100001000111000111010000100010110010110010011011101110011110110110100111110011100000001011110111111011110001001001110010010011101100010101000001100001000011111101110101110101011110101111011110111010000110100101110001000010110000110110011110100101111000011111010001101" "10000110001010101010111101110110101011111110010001001111111111011111001011001010011000001010101100010100011110011111010100011000101110101111011000100011110111101111000011001101101100001111100110001110011010111101001101101110011011001101010101010110101010001100011111101011111001111101011100111100111001100001000001100100100000110001101100100000111111100100000001010001110101001111000001110000111010111000111010011011011000001111101100011110011000" 282))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (minOperations \"1101001000101001101100000100111111000100011001011111100010100010011101011111000001000011101010010110110000111000000010111101110000100101011101000010001101100000000000010011100100001100100111101001010100000001110100011100010010110100111110010010110001101111110011001101100011000101111010111101101101101001100110110110100011110000100010101110101001011001011111110011101000111111011110101000110010101001001011100001001000011010110001001 \" \"1001101110111100010000000110100011011011000010110101011111010011111001111000101000001100010001111110010000001101101100000101110111001101010010111100010111000111110001101001010001011100101001010010101000111111000100000011101010111111111000010010101010001011101111110111110001011001111011011000001010011101110001001001100001111011110011010000011011101000010000010000100000101111101010101110011101111101101100111101010001001000010010000 \" 327)," (-1) (minOperations "1101001000101001101100000100111111000100011001011111100010100010011101011111000001000011101010010110110000111000000010111101110000100101011101000010001101100000000000010011100100001100100111101001010100000001110100011100010010110100111110010010110001101111110011001101100011000101111010111101101101101001100110110110100011110000100010101110101001011001011111110011101000111111011110101000110010101001001011100001001000011010110001001" "1001101110111100010000000110100011011011000010110101011111010011111001111000101000001100010001111110010000001101101100000101110111001101010010111100010111000111110001101001010001011100101001010010101000111111000100000011101010111111111000010010101010001011101111110111110001011001111011011000001010011101110001001001100001111011110011010000011011101000010000010000100000101111101010101110011101111101101100111101010001001000010010000" 327))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (minOperations \"01110110111110101110000110101011010110010010111101101001011101110001110101010111010110000101110100101100001100010111111011110100011010100101010110111010011110001000 \" \"10011100110101000110011101000111000110001111011000100011110001111001110000101011101000011011001001111000010111101111001011111111101100001110000111001011111101010001 \" 336)," 84 (minOperations "01110110111110101110000110101011010110010010111101101001011101110001110101010111010110000101110100101100001100010111111011110100011010100101010110111010011110001000" "10011100110101000110011101000111000110001111011000100011110001111001110000101011101000011011001001111000010111101111001011111111101100001110000111001011111101010001" 336))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (minOperations \"010110000101011010111001010100100010100001110101111111011101001101010011001101100111011000000100101010001010100100110110101000111010001011010001001101000011100001110011011110011001111011010100110000011101101001010011011010110101011011101011100001100011010111100011101011001001100111101011 \" \"110101010101001001011000111111111101101000110001001101111110010001100100100111101001010000001001110011111001100111011101011111111101101001110101111001111111010010100111110101100100101100010000011101000010110000010111011110001100000110110100111110011111010101101110111010001110110110101011 \" 410)," 141 (minOperations "010110000101011010111001010100100010100001110101111111011101001101010011001101100111011000000100101010001010100100110110101000111010001011010001001101000011100001110011011110011001111011010100110000011101101001010011011010110101011011101011100001100011010111100011101011001001100111101011" "110101010101001001011000111111111101101000110001001101111110010001100100100111101001010000001001110011111001100111011101011111111101101001110101111001111111010010100111110101100100101100010000011101000010110000010111011110001100000110110100111110011111010101101110111010001110110110101011" 410))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (minOperations \"11001001000110011111100001001110111101110011101001110110001011000001010000100011110111001001010100011101000000111111000011110000011001010010111000011100010001111010001000101100100111000001011110010101010010100000011111111110010001101011000111000011010000000110011101010101001000010101100011110010000010111000111011001100100101100110111011000100000010000110100010001011111000011011010001000001110100111001011010010110101101000000000 \" \"10011000100001001110001111101110100001000111000000101010100000110101110001000011010010111111001001111100010000011011101111001001110000010111111100111000100111000110100111100011110110001101101010100101001011000000100010000000011000100011110111110110010100111000101010000001100001111100010101101111111110110001110001101010100011100111010101110101101011000111011010001110111011110010101011000111101101101101111000100110010110110110001 \" 408)," (-1) (minOperations "11001001000110011111100001001110111101110011101001110110001011000001010000100011110111001001010100011101000000111111000011110000011001010010111000011100010001111010001000101100100111000001011110010101010010100000011111111110010001101011000111000011010000000110011101010101001000010101100011110010000010111000111011001100100101100110111011000100000010000110100010001011111000011011010001000001110100111001011010010110101101000000000" "10011000100001001110001111101110100001000111000000101010100000110101110001000011010010111111001001111100010000011011101111001001110000010111111100111000100111000110100111100011110110001101101010100101001011000000100010000000011000100011110111110110010100111000101010000001100001111100010101101111111110110001110001101010100011100111010101110101101011000111011010001110111011110010101011000111101101101101111000100110010110110110001" 408))
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
apply_operations_to_make_two_strings_equal/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(4, minOperations("1100011000", "0101001010", 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, minOperations("10110", "00011", 4));
19
+ }
20
+
21
+ }
apply_operations_to_make_two_strings_equal/meta.json ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3033,
3
+ "name": "apply_operations_to_make_two_strings_equal",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/apply-operations-to-make-two-strings-equal/",
6
+ "date": "2023-10-01 00:00:00",
7
+ "task_description": "You are given two **0-indexed** binary strings `s1` and `s2`, both of length `n`, and a positive integer `x`. You can perform any of the following operations on the string `s1` **any** number of times: Choose two indices `i` and `j`, and flip both `s1[i]` and `s1[j]`. The cost of this operation is `x`. Choose an index `i` such that `i < n - 1` and flip both `s1[i]` and `s1[i + 1]`. The cost of this operation is `1`. Return _the **minimum** cost needed to make the strings _`s1`_ and _`s2`_ equal, or return _`-1`_ if it is impossible._ **Note** that flipping a character means changing it from `0` to `1` or vice-versa. **Example 1:** ``` **Input:** s1 = \"1100011000\", s2 = \"0101001010\", x = 2 **Output:** 4 **Explanation:** We can do the following operations: - Choose i = 3 and apply the second operation. The resulting string is s1 = \"110**11**11000\". - Choose i = 4 and apply the second operation. The resulting string is s1 = \"1101**00**1000\". - Choose i = 0 and j = 8 and apply the first operation. The resulting string is s1 = \"**0**1010010**1**0\" = s2. The total cost is 1 + 1 + 2 = 4. It can be shown that it is the minimum cost possible. ``` **Example 2:** ``` **Input:** s1 = \"10110\", s2 = \"00011\", x = 4 **Output:** -1 **Explanation:** It is not possible to make the two strings equal. ``` **Constraints:** `n == s1.length == s2.length` `1 <= n, x <= 500` `s1` and `s2` consist only of the characters `'0'` and `'1'`.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s1 = \"1100011000\", s2 = \"0101001010\", x = 2",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s1 = \"10110\", s2 = \"00011\", x = 4",
17
+ "output": "-1 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"1111111001101010111111101010001110001100101110111011100001001000001001010010010100100101000010010011110011101010100000001011101110011010110111111000101000000100001000000110000010001010111010010100000101010011101100\"",
24
+ "\"0001000110101011011001100110111000101111010101011000011101000001110110010011100111010101110110001010010001101100000010100110101001101101101110001110100111010100101110100101000001001110101011100111001101111111001111\"",
25
+ 25
26
+ ],
27
+ "output": -1
28
+ },
29
+ {
30
+ "input": [
31
+ "\"110\"",
32
+ "\"010\"",
33
+ 421
34
+ ],
35
+ "output": -1
36
+ },
37
+ {
38
+ "input": [
39
+ "\"01101000000000011111100010000111110100010010100110101100101101111111110110110101111011101110101110111111111010101001101001000100001010001010111100011101100011011010010011000000101100001000111000111010000100010110010110010011011101110011110110110100111110011100000001011110111111011110001001001110010010011101100010101000001100001000011111101110101110101011110101111011110111010000110100101110001000010110000110110011110100101111000011111010001101\"",
40
+ "\"10000110001010101010111101110110101011111110010001001111111111011111001011001010011000001010101100010100011110011111010100011000101110101111011000100011110111101111000011001101101100001111100110001110011010111101001101101110011011001101010101010110101010001100011111101011111001111101011100111100111001100001000001100100100000110001101100100000111111100100000001010001110101001111000001110000111010111000111010011011011000001111101100011110011000\"",
41
+ 282
42
+ ],
43
+ "output": -1
44
+ },
45
+ {
46
+ "input": [
47
+ "\"1101001000101001101100000100111111000100011001011111100010100010011101011111000001000011101010010110110000111000000010111101110000100101011101000010001101100000000000010011100100001100100111101001010100000001110100011100010010110100111110010010110001101111110011001101100011000101111010111101101101101001100110110110100011110000100010101110101001011001011111110011101000111111011110101000110010101001001011100001001000011010110001001\"",
48
+ "\"1001101110111100010000000110100011011011000010110101011111010011111001111000101000001100010001111110010000001101101100000101110111001101010010111100010111000111110001101001010001011100101001010010101000111111000100000011101010111111111000010010101010001011101111110111110001011001111011011000001010011101110001001001100001111011110011010000011011101000010000010000100000101111101010101110011101111101101100111101010001001000010010000\"",
49
+ 327
50
+ ],
51
+ "output": -1
52
+ },
53
+ {
54
+ "input": [
55
+ "\"01110110111110101110000110101011010110010010111101101001011101110001110101010111010110000101110100101100001100010111111011110100011010100101010110111010011110001000\"",
56
+ "\"10011100110101000110011101000111000110001111011000100011110001111001110000101011101000011011001001111000010111101111001011111111101100001110000111001011111101010001\"",
57
+ 336
58
+ ],
59
+ "output": 84
60
+ },
61
+ {
62
+ "input": [
63
+ "\"010110000101011010111001010100100010100001110101111111011101001101010011001101100111011000000100101010001010100100110110101000111010001011010001001101000011100001110011011110011001111011010100110000011101101001010011011010110101011011101011100001100011010111100011101011001001100111101011\"",
64
+ "\"110101010101001001011000111111111101101000110001001101111110010001100100100111101001010000001001110011111001100111011101011111111101101001110101111001111111010010100111110101100100101100010000011101000010110000010111011110001100000110110100111110011111010101101110111010001110110110101011\"",
65
+ 410
66
+ ],
67
+ "output": 141
68
+ },
69
+ {
70
+ "input": [
71
+ "\"11001001000110011111100001001110111101110011101001110110001011000001010000100011110111001001010100011101000000111111000011110000011001010010111000011100010001111010001000101100100111000001011110010101010010100000011111111110010001101011000111000011010000000110011101010101001000010101100011110010000010111000111011001100100101100110111011000100000010000110100010001011111000011011010001000001110100111001011010010110101101000000000\"",
72
+ "\"10011000100001001110001111101110100001000111000000101010100000110101110001000011010010111111001001111100010000011011101111001001110000010111111100111000100111000110100111100011110110001101101010100101001011000000100010000000011000100011110111110110010100111000101010000001100001111100010101101111111110110001110001101010100011100111010101110101101011000111011010001110111011110010101011000111101101101101111000100110010110110110001\"",
73
+ 408
74
+ ],
75
+ "output": -1
76
+ },
77
+ {
78
+ "input": [
79
+ "\"0000100011100101101101100\"",
80
+ "\"1110111100001010010111111\"",
81
+ 94
82
+ ],
83
+ "output": -1
84
+ },
85
+ {
86
+ "input": [
87
+ "01001110110111001110111100001111110101101111000111111000101101111111100100010001010001011100011101101110000100101001111011011000011000110000000000001000000001010001100001100011000111110100100111000000111101010000001100110110011011000110100101",
88
+ "00011011000011000100010111010101110000101001000011110111010000111001010101001110010010110110100001010000010011111010000011000110111111101101011011111010110010111000011010000111101100010101101010001111100110001100001010111011001010001000111100",
89
+ 422
90
+ ],
91
+ "output": 120
92
+ },
93
+ {
94
+ "input": [
95
+ "010101011110111010000010100100100000100001010011110101001000011101011010000001100010001001110110110011101001001111111011111010101001110100001110011010100011011101000000010000010000110",
96
+ "001111101001000100111000011100101011101100000010010010111000111001101111110011011111000111000111100000000010011000010010000101110110010110100000000011001011111011000010010000001111010",
97
+ 1
98
+ ],
99
+ "output": 50
100
+ }
101
+ ],
102
+ "haskell_template": "minOperations :: String -> String -> Int -> Int\nminOperations s1 s2 x ",
103
+ "ocaml_template": "let minOperations (s1: string) (s2: string) (x: int) : int = ",
104
+ "scala_template": "def minOperations(s1: String,s2: String,x: Int): Int = { \n \n}",
105
+ "java_template": "class Solution {\n public int minOperations(String s1, String s2, int x) {\n \n }\n}",
106
+ "python_template": "class Solution(object):\n def minOperations(self, s1, s2, x):\n \"\"\"\n :type s1: str\n :type s2: str\n :type x: int\n :rtype: int\n \"\"\"\n "
107
+ }
apply_operations_to_make_two_strings_equal/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 4 (minOperations "1100011000" "0101001010" 2)
12
+
13
+ let test2 _ = assert_equal (-1) (minOperations "10110" "00011" 4)
14
+
15
+ let test3 _ = assert_equal (-1) (minOperations "1111111001101010111111101010001110001100101110111011100001001000001001010010010100100101000010010011110011101010100000001011101110011010110111111000101000000100001000000110000010001010111010010100000101010011101100" "0001000110101011011001100110111000101111010101011000011101000001110110010011100111010101110110001010010001101100000010100110101001101101101110001110100111010100101110100101000001001110101011100111001101111111001111" 25)
16
+
17
+ let test4 _ = assert_equal (-1) (minOperations "110" "010" 421)
18
+
19
+ let test5 _ = assert_equal (-1) (minOperations "01101000000000011111100010000111110100010010100110101100101101111111110110110101111011101110101110111111111010101001101001000100001010001010111100011101100011011010010011000000101100001000111000111010000100010110010110010011011101110011110110110100111110011100000001011110111111011110001001001110010010011101100010101000001100001000011111101110101110101011110101111011110111010000110100101110001000010110000110110011110100101111000011111010001101" "10000110001010101010111101110110101011111110010001001111111111011111001011001010011000001010101100010100011110011111010100011000101110101111011000100011110111101111000011001101101100001111100110001110011010111101001101101110011011001101010101010110101010001100011111101011111001111101011100111100111001100001000001100100100000110001101100100000111111100100000001010001110101001111000001110000111010111000111010011011011000001111101100011110011000" 282)
20
+
21
+ let test6 _ = assert_equal (-1) (minOperations "1101001000101001101100000100111111000100011001011111100010100010011101011111000001000011101010010110110000111000000010111101110000100101011101000010001101100000000000010011100100001100100111101001010100000001110100011100010010110100111110010010110001101111110011001101100011000101111010111101101101101001100110110110100011110000100010101110101001011001011111110011101000111111011110101000110010101001001011100001001000011010110001001" "1001101110111100010000000110100011011011000010110101011111010011111001111000101000001100010001111110010000001101101100000101110111001101010010111100010111000111110001101001010001011100101001010010101000111111000100000011101010111111111000010010101010001011101111110111110001011001111011011000001010011101110001001001100001111011110011010000011011101000010000010000100000101111101010101110011101111101101100111101010001001000010010000" 327)
22
+
23
+ let test7 _ = assert_equal 84 (minOperations "01110110111110101110000110101011010110010010111101101001011101110001110101010111010110000101110100101100001100010111111011110100011010100101010110111010011110001000" "10011100110101000110011101000111000110001111011000100011110001111001110000101011101000011011001001111000010111101111001011111111101100001110000111001011111101010001" 336)
24
+
25
+ let test8 _ = assert_equal 141 (minOperations "010110000101011010111001010100100010100001110101111111011101001101010011001101100111011000000100101010001010100100110110101000111010001011010001001101000011100001110011011110011001111011010100110000011101101001010011011010110101011011101011100001100011010111100011101011001001100111101011" "110101010101001001011000111111111101101000110001001101111110010001100100100111101001010000001001110011111001100111011101011111111101101001110101111001111111010010100111110101100100101100010000011101000010110000010111011110001100000110110100111110011111010101101110111010001110110110101011" 410)
26
+
27
+ let test9 _ = assert_equal (-1) (minOperations "11001001000110011111100001001110111101110011101001110110001011000001010000100011110111001001010100011101000000111111000011110000011001010010111000011100010001111010001000101100100111000001011110010101010010100000011111111110010001101011000111000011010000000110011101010101001000010101100011110010000010111000111011001100100101100110111011000100000010000110100010001011111000011011010001000001110100111001011010010110101101000000000" "10011000100001001110001111101110100001000111000000101010100000110101110001000011010010111111001001111100010000011011101111001001110000010111111100111000100111000110100111100011110110001101101010100101001011000000100010000000011000100011110111110110010100111000101010000001100001111100010101101111111110110001110001101010100011100111010101110101101011000111011010001110111011110010101011000111101101101101111000100110010110110110001" 408)
28
+
29
+ let test10 _ = assert_equal (-1) (minOperations "0000100011100101101101100" "1110111100001010010111111" 94)
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
apply_operations_to_make_two_strings_equal/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minOperations("1100011000","0101001010",2), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minOperations("10110","00011",4), -1)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minOperations("1111111001101010111111101010001110001100101110111011100001001000001001010010010100100101000010010011110011101010100000001011101110011010110111111000101000000100001000000110000010001010111010010100000101010011101100","0001000110101011011001100110111000101111010101011000011101000001110110010011100111010101110110001010010001101100000010100110101001101101101110001110100111010100101110100101000001001110101011100111001101111111001111",25), -1)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minOperations("110","010",421), -1)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minOperations("01101000000000011111100010000111110100010010100110101100101101111111110110110101111011101110101110111111111010101001101001000100001010001010111100011101100011011010010011000000101100001000111000111010000100010110010110010011011101110011110110110100111110011100000001011110111111011110001001001110010010011101100010101000001100001000011111101110101110101011110101111011110111010000110100101110001000010110000110110011110100101111000011111010001101","10000110001010101010111101110110101011111110010001001111111111011111001011001010011000001010101100010100011110011111010100011000101110101111011000100011110111101111000011001101101100001111100110001110011010111101001101101110011011001101010101010110101010001100011111101011111001111101011100111100111001100001000001100100100000110001101100100000111111100100000001010001110101001111000001110000111010111000111010011011011000001111101100011110011000",282), -1)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minOperations("1101001000101001101100000100111111000100011001011111100010100010011101011111000001000011101010010110110000111000000010111101110000100101011101000010001101100000000000010011100100001100100111101001010100000001110100011100010010110100111110010010110001101111110011001101100011000101111010111101101101101001100110110110100011110000100010101110101001011001011111110011101000111111011110101000110010101001001011100001001000011010110001001","1001101110111100010000000110100011011011000010110101011111010011111001111000101000001100010001111110010000001101101100000101110111001101010010111100010111000111110001101001010001011100101001010010101000111111000100000011101010111111111000010010101010001011101111110111110001011001111011011000001010011101110001001001100001111011110011010000011011101000010000010000100000101111101010101110011101111101101100111101010001001000010010000",327), -1)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minOperations("01110110111110101110000110101011010110010010111101101001011101110001110101010111010110000101110100101100001100010111111011110100011010100101010110111010011110001000","10011100110101000110011101000111000110001111011000100011110001111001110000101011101000011011001001111000010111101111001011111111101100001110000111001011111101010001",336), 84)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minOperations("010110000101011010111001010100100010100001110101111111011101001101010011001101100111011000000100101010001010100100110110101000111010001011010001001101000011100001110011011110011001111011010100110000011101101001010011011010110101011011101011100001100011010111100011101011001001100111101011","110101010101001001011000111111111101101000110001001101111110010001100100100111101001010000001001110011111001100111011101011111111101101001110101111001111111010010100111110101100100101100010000011101000010110000010111011110001100000110110100111110011111010101101110111010001110110110101011",410), 141)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minOperations("11001001000110011111100001001110111101110011101001110110001011000001010000100011110111001001010100011101000000111111000011110000011001010010111000011100010001111010001000101100100111000001011110010101010010100000011111111110010001101011000111000011010000000110011101010101001000010101100011110010000010111000111011001100100101100110111011000100000010000110100010001011111000011011010001000001110100111001011010010110101101000000000","10011000100001001110001111101110100001000111000000101010100000110101110001000011010010111111001001111100010000011011101111001001110000010111111100111000100111000110100111100011110110001101101010100101001011000000100010000000011000100011110111110110010100111000101010000001100001111100010101101111111110110001110001101010100011100111010101110101101011000111011010001110111011110010101011000111101101101101111000100110010110110110001",408), -1)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minOperations("0000100011100101101101100","1110111100001010010111111",94), -1)
42
+ }
43
+
44
+ }
apply_operations_to_maximize_frequency_score/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
apply_operations_to_maximize_frequency_score/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, maxFrequencyScore(new ArrayList<>(Arrays.asList(1,2,6,4)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(3, maxFrequencyScore(new ArrayList<>(Arrays.asList(1,4,4,2,4)), 0));
19
+ }
20
+
21
+ }