DatasetRepo commited on
Commit
c71cf02
·
verified ·
1 Parent(s): 0314a9b

2169f9355af969aa9bbb73abd14c2c6a2e7408e243761b28fccb0ad8ea84a12f

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 +1 -0
  2. time_needed_to_rearrange_a_binary_string/haskell_tests/Main.hs +24 -0
  3. time_needed_to_rearrange_a_binary_string/java_tests/Main.java +21 -0
  4. time_needed_to_rearrange_a_binary_string/meta.json +67 -0
  5. time_needed_to_rearrange_a_binary_string/ocaml_tests/main.ml +26 -0
  6. time_needed_to_rearrange_a_binary_string/scala_tests/MySuite.scala +12 -0
  7. time_to_cross_a_bridge/haskell_tests/Main.hs +0 -0
  8. time_to_cross_a_bridge/java_tests/Main.java +21 -0
  9. time_to_cross_a_bridge/meta.json +0 -0
  10. time_to_cross_a_bridge/ocaml_tests/main.ml +0 -0
  11. time_to_cross_a_bridge/scala_tests/MySuite.scala +0 -0
  12. total_appeal_of_a_string/.DS_Store +0 -0
  13. total_appeal_of_a_string/haskell_tests/Main.hs +24 -0
  14. total_appeal_of_a_string/java_tests/Main.java +21 -0
  15. total_appeal_of_a_string/meta.json +0 -0
  16. total_appeal_of_a_string/ocaml_tests/main.ml +26 -0
  17. total_appeal_of_a_string/scala_tests/MySuite.scala +12 -0
  18. total_characters_in_string_after_transformations_i/haskell_tests/Main.hs +0 -0
  19. total_characters_in_string_after_transformations_i/java_tests/Main.java +21 -0
  20. total_characters_in_string_after_transformations_i/meta.json +0 -0
  21. total_characters_in_string_after_transformations_i/ocaml_tests/main.ml +0 -0
  22. total_characters_in_string_after_transformations_i/scala_tests/MySuite.scala +0 -0
  23. total_characters_in_string_after_transformations_ii/haskell_tests/Main.hs +0 -0
  24. total_characters_in_string_after_transformations_ii/java_tests/Main.java +21 -0
  25. total_characters_in_string_after_transformations_ii/meta.json +0 -0
  26. total_characters_in_string_after_transformations_ii/ocaml_tests/main.ml +0 -0
  27. total_characters_in_string_after_transformations_ii/scala_tests/MySuite.scala +0 -0
  28. total_cost_to_hire_k_workers/.DS_Store +0 -0
  29. total_cost_to_hire_k_workers/haskell_tests/Main.hs +24 -0
  30. total_cost_to_hire_k_workers/java_tests/Main.java +21 -0
  31. total_cost_to_hire_k_workers/meta.json +3 -0
  32. total_cost_to_hire_k_workers/ocaml_tests/main.ml +26 -0
  33. total_cost_to_hire_k_workers/scala_tests/MySuite.scala +12 -0
  34. total_distance_traveled/haskell_tests/Main.hs +45 -0
  35. total_distance_traveled/java_tests/Main.java +21 -0
  36. total_distance_traveled/meta.json +97 -0
  37. total_distance_traveled/ocaml_tests/main.ml +50 -0
  38. total_distance_traveled/scala_tests/MySuite.scala +44 -0
  39. transform_array_by_parity/haskell_tests/Main.hs +41 -0
  40. transform_array_by_parity/java_tests/Main.java +20 -0
  41. transform_array_by_parity/meta.json +657 -0
  42. transform_array_by_parity/ocaml_tests/main.ml +42 -0
  43. transform_array_by_parity/scala_tests/MySuite.scala +32 -0
  44. transformed_array/haskell_tests/Main.hs +41 -0
  45. transformed_array/java_tests/Main.java +20 -0
  46. transformed_array/meta.json +563 -0
  47. transformed_array/ocaml_tests/main.ml +42 -0
  48. transformed_array/scala_tests/MySuite.scala +32 -0
  49. unique_3_digit_even_numbers/haskell_tests/Main.hs +47 -0
  50. unique_3_digit_even_numbers/java_tests/Main.java +28 -0
.gitattributes CHANGED
@@ -287,3 +287,4 @@ successful_pairs_of_spells_and_potions/meta.json filter=lfs diff=lfs merge=lfs -
287
  sum_of_distances/meta.json filter=lfs diff=lfs merge=lfs -text
288
  sum_of_matrix_after_queries/meta.json filter=lfs diff=lfs merge=lfs -text
289
  task_scheduler_ii/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
287
  sum_of_distances/meta.json filter=lfs diff=lfs merge=lfs -text
288
  sum_of_matrix_after_queries/meta.json filter=lfs diff=lfs merge=lfs -text
289
  task_scheduler_ii/meta.json filter=lfs diff=lfs merge=lfs -text
290
+ total_cost_to_hire_k_workers/meta.json filter=lfs diff=lfs merge=lfs -text
time_needed_to_rearrange_a_binary_string/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 (secondsToRemoveOccurrences \"0110101 \")," 4 (secondsToRemoveOccurrences "0110101"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (secondsToRemoveOccurrences \"11100 \")," 0 (secondsToRemoveOccurrences "11100"))
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
time_needed_to_rearrange_a_binary_string/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, secondsToRemoveOccurrences("0110101"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, secondsToRemoveOccurrences("11100"));
19
+ }
20
+
21
+ }
time_needed_to_rearrange_a_binary_string/meta.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2464,
3
+ "name": "time_needed_to_rearrange_a_binary_string",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/",
6
+ "date": "1659744000000",
7
+ "task_description": "You are given a binary string `s`. In one second, **all** occurrences of `\"01\"` are **simultaneously** replaced with `\"10\"`. This process **repeats** until no occurrences of `\"01\"` exist. Return_ the number of seconds needed to complete this process._ **Example 1:** ``` **Input:** s = \"0110101\" **Output:** 4 **Explanation:** After one second, s becomes \"1011010\". After another second, s becomes \"1101100\". After the third second, s becomes \"1110100\". After the fourth second, s becomes \"1111000\". No occurrence of \"01\" exists any longer, and the process needed 4 seconds to complete, so we return 4. ``` **Example 2:** ``` **Input:** s = \"11100\" **Output:** 0 **Explanation:** No occurrence of \"01\" exists in s, and the processes needed 0 seconds to complete, so we return 0. ``` **Constraints:** `1 <= s.length <= 1000` `s[i]` is either `'0'` or `'1'`. **Follow up:** Can you solve this problem in O(n) time complexity?",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"0110101\"",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"11100\"",
17
+ "output": "0 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "00000000001100100110010110001010010100011101110100111010111100000011000111111101011100000011110101001001001111001011001110001010001010000010110110111011010111001111111011100000010111110010100111110001110100010101010101001100010011100101000011111011011001001111001000100100100000111111000100001101000111010100101111010011111101001100111110111101000110100111011000101001010011100",
23
+ "output": 204
24
+ },
25
+ {
26
+ "input": "101101110011100110111111000000111100111110000011111100100011110110111110000000100011000101001000000101101100001010001011011011100110010100110101111101001000100101010011110100100000111101000100111000000111100011010000100011000001011011011100001000011110100000011000010111100110001111101001101000011101110101010110010011001011111001001010111110101011101111010101111010101111000000011010011110100110110110010001011010010100110110000001110101111011000010001001000101010100010011000100001111000001011110100001111111101111011000111100100000100010110001101101000010110011111110110101101110111100010011110101111101011001110101000111011111110001001100110001110011001011001000011100001111000001000110110011010011111011100000110001101100010010100011001011001100011010010001010100001111000001110110011110001100101100010000101110111111011010010111001010000010111101010111111100101011100001110001010110000101110100010010111001001101110101111101001111001101010011101100101000110011100100001000000010000",
27
+ "output": 510
28
+ },
29
+ {
30
+ "input": "10010011111101010110111111001111011110101100100100100011101011001011001001110001101111100",
31
+ "output": 53
32
+ },
33
+ {
34
+ "input": "1100101110101001010101010001101100001000011001000101011111000100111010101101011001001110011011010100101111101001011011010010101001110111011001111101001010110010010001001110101110111010110111101101010010100001111011101001110000110111110110110110110101010100001111011100101111110001100011111101100001100110",
35
+ "output": 173
36
+ },
37
+ {
38
+ "input": "10100000000110111000001000100100011011000011101100001100111010011001010110110011110010001110100010000110111011101100101101001011001010010101100011011101000000011101011101111010111111101010111111010011000000100011011011100111000",
39
+ "output": 127
40
+ },
41
+ {
42
+ "input": "101011101110001001010100100100010101011010101001100101011000100101110000110000010101001001001010111011100101110101000000000001000011011110111110100001110000010001101111110110111000001011111011100010010110010100111110111000001101100110010101000000100100111000100010111111001110111000101110110100111001010100010001000000100010101001001000000110010111110011000011111001101110110100110100010111000000000001111111010011010111111001011011100",
43
+ "output": 237
44
+ },
45
+ {
46
+ "input": "01011110000110010110000001100100010011100100010001111000010110010101101100101100101010010110000010100111100100100001011101110111101101010000100010110111000100010001011010000010110001000011001011100000000010011001001110100100110010110111001110001101111100010010110010100000100011101010100111011001110001111101111111110001010100011000010101010001011100001100000101100101111010000011000001100110001010110110101100001001011110101010111010011011000000001011010000001011101111001011001111001101011101011100100111111000000111010101000111110000111011000001010001100011",
47
+ "output": 304
48
+ },
49
+ {
50
+ "input": "010001001001011111000101110010001010000101000110100001110010000110010101000010001010001111011001011101010100001010110001101001001111010000001110001010000101011010011110110011001001001000011101110011101100001110010001111000011100100111100101001010111100011100110011100111110000111110110100000111111001110010100000001001101110101010101100001001100100000101101100111011010111100111100101100011000110110100010100001001010000010100111011110111001101110111101001110000010011000110110011010001111100101101011100100001011000111001100010101011110101101110100010011100011010101011100110100010110100010011001110111011000011011111001011001000001100001010011000000000100010000101001100010110010100100001000100000100100001000011010100100000111010110110101101001001101111100000100001111100010110010010111000000010001101011100100000110001101111111000000111011001001101001001001000101100101001101000011100100111111011000010010111100111100011100100011010101100001011101000000001000101110010101",
51
+ "output": 522
52
+ },
53
+ {
54
+ "input": "0100100001111010100100001011100001110110010101010100110001011110011000010000110111001000110000000010111001011111101111111000111100101101101",
55
+ "output": 84
56
+ },
57
+ {
58
+ "input": "0101011000011000100111101011110100000101000000111100100111001010011001011010100100001100010101100011101001101100001001101101000110011000100111110010101101110001001100010000110000010001110010111101100001001011010110011100111111101001100001101101111111010000011001000001011111110101111110111100101111111000101100101100101001010001111001010001111000000110010100110010100011110111011100100001111011010010101000011101111110100101110001111100111110001",
59
+ "output": 247
60
+ }
61
+ ],
62
+ "haskell_template": "secondsToRemoveOccurrences :: String -> Int\nsecondsToRemoveOccurrences s ",
63
+ "ocaml_template": "let secondsToRemoveOccurrences (s: string) : int = ",
64
+ "scala_template": "def secondsToRemoveOccurrences(s: String): Int = { \n \n}",
65
+ "java_template": "public static int secondsToRemoveOccurrences(String s) {\n\n}",
66
+ "python_template": "class Solution(object):\n def secondsToRemoveOccurrences(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n "
67
+ }
time_needed_to_rearrange_a_binary_string/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 4 (secondsToRemoveOccurrences "0110101")
12
+
13
+ let test2 _ = assert_equal 0 (secondsToRemoveOccurrences "11100")
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for secondsToRemoveOccurrences" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
time_needed_to_rearrange_a_binary_string/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.secondsToRemoveOccurrences("0110101"), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.secondsToRemoveOccurrences("11100"), 0)
10
+ }
11
+
12
+ }
time_to_cross_a_bridge/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
time_to_cross_a_bridge/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(6, findCrossingTime(1, 3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,1,2,1)),new ArrayList<>(Arrays.asList(1,1,3,1)),new ArrayList<>(Arrays.asList(1,1,4,1))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(37, findCrossingTime(3, 2, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,5,1,8)),new ArrayList<>(Arrays.asList(10,10,10,10))))));
19
+ }
20
+
21
+ }
time_to_cross_a_bridge/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
time_to_cross_a_bridge/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
time_to_cross_a_bridge/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
total_appeal_of_a_string/.DS_Store ADDED
Binary file (6.15 kB). View file
 
total_appeal_of_a_string/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 (appealSum \"abbca \")," 28 (appealSum "abbca"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (appealSum \"code \")," 20 (appealSum "code"))
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
total_appeal_of_a_string/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(28, appealSum("abbca"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(20, appealSum("code"));
19
+ }
20
+
21
+ }
total_appeal_of_a_string/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
total_appeal_of_a_string/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 28 (appealSum "abbca")
12
+
13
+ let test2 _ = assert_equal 20 (appealSum "code")
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for appealSum" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
total_appeal_of_a_string/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.appealSum("abbca"), 28)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.appealSum("code"), 20)
10
+ }
11
+
12
+ }
total_characters_in_string_after_transformations_i/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
total_characters_in_string_after_transformations_i/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(7, lengthAfterTransformations("abcyy", 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(5, lengthAfterTransformations("azbk", 1));
19
+ }
20
+
21
+ }
total_characters_in_string_after_transformations_i/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
total_characters_in_string_after_transformations_i/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
total_characters_in_string_after_transformations_i/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
total_characters_in_string_after_transformations_ii/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
total_characters_in_string_after_transformations_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(7, lengthAfterTransformations("abcyy", 2, new ArrayList<>(Arrays.asList(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(8, lengthAfterTransformations("azbk", 1, new ArrayList<>(Arrays.asList(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2))));
19
+ }
20
+
21
+ }
total_characters_in_string_after_transformations_ii/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
total_characters_in_string_after_transformations_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
total_characters_in_string_after_transformations_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
total_cost_to_hire_k_workers/.DS_Store ADDED
Binary file (6.15 kB). View file
 
total_cost_to_hire_k_workers/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 (totalCost [17,12,10,2,7,2,11,20,8] 3 4)," 11 (totalCost [17,12,10,2,7,2,11,20,8] 3 4))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (totalCost [1,2,4,1] 3 3)," 4 (totalCost [1,2,4,1] 3 3))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
total_cost_to_hire_k_workers/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(11, totalCost(new ArrayList<>(Arrays.asList(17,12,10,2,7,2,11,20,8)), 3, 4));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, totalCost(new ArrayList<>(Arrays.asList(1,2,4,1)), 3, 3));
19
+ }
20
+
21
+ }
total_cost_to_hire_k_workers/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab23392935b1d0e05518c4acbb9ccab0b86200dae0b68853fdb7811ef4393a82
3
+ size 11002409
total_cost_to_hire_k_workers/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 11 (totalCost [17;12;10;2;7;2;11;20;8] 3 4)
12
+
13
+ let test2 _ = assert_equal 4 (totalCost [1;2;4;1] 3 3)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for totalCost" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
total_cost_to_hire_k_workers/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.totalCost(List(17,12,10,2,7,2,11,20,8),3,4), 11)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.totalCost(List(1,2,4,1),3,3), 4)
10
+ }
11
+
12
+ }
total_distance_traveled/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 (distanceTraveled 5 10)," 60 (distanceTraveled 5 10))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (distanceTraveled 1 2)," 10 (distanceTraveled 1 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (distanceTraveled 98 21)," 1190 (distanceTraveled 98 21))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (distanceTraveled 36 37)," 440 (distanceTraveled 36 37))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (distanceTraveled 70 42)," 870 (distanceTraveled 70 42))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (distanceTraveled 75 78)," 930 (distanceTraveled 75 78))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (distanceTraveled 62 58)," 770 (distanceTraveled 62 58))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (distanceTraveled 70 95)," 870 (distanceTraveled 70 95))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (distanceTraveled 6 35)," 70 (distanceTraveled 6 35))
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
total_distance_traveled/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(60, distanceTraveled(5, 10));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(10, distanceTraveled(1, 2));
19
+ }
20
+
21
+ }
total_distance_traveled/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2857,
3
+ "name": "total_distance_traveled",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/total-distance-traveled/",
6
+ "date": "2023-06-11 00:00:00",
7
+ "task_description": "A truck has two fuel tanks. You are given two integers, `mainTank` representing the fuel present in the main tank in liters and `additionalTank` representing the fuel present in the additional tank in liters. The truck has a mileage of `10` km per liter. Whenever `5` liters of fuel get used up in the main tank, if the additional tank has at least `1` liters of fuel, `1` liters of fuel will be transferred from the additional tank to the main tank. Return _the maximum distance which can be traveled._ **Note: **Injection from the additional tank is not continuous. It happens suddenly and immediately for every 5 liters consumed. **Example 1:** ``` **Input:** mainTank = 5, additionalTank = 10 **Output:** 60 **Explanation:** After spending 5 litre of fuel, fuel remaining is (5 - 5 + 1) = 1 litre and distance traveled is 50km. After spending another 1 litre of fuel, no fuel gets injected in the main tank and the main tank becomes empty. Total distance traveled is 60km. ``` **Example 2:** ``` **Input:** mainTank = 1, additionalTank = 2 **Output:** 10 **Explanation:** After spending 1 litre of fuel, the main tank becomes empty. Total distance traveled is 10km. ``` **Constraints:** `1 <= mainTank, additionalTank <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "mainTank = 5, additionalTank = 10",
12
+ "output": "60 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "mainTank = 1, additionalTank = 2",
17
+ "output": "10 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 98,
24
+ 21
25
+ ],
26
+ "output": 1190
27
+ },
28
+ {
29
+ "input": [
30
+ 36,
31
+ 37
32
+ ],
33
+ "output": 440
34
+ },
35
+ {
36
+ "input": [
37
+ 70,
38
+ 42
39
+ ],
40
+ "output": 870
41
+ },
42
+ {
43
+ "input": [
44
+ 75,
45
+ 78
46
+ ],
47
+ "output": 930
48
+ },
49
+ {
50
+ "input": [
51
+ 62,
52
+ 58
53
+ ],
54
+ "output": 770
55
+ },
56
+ {
57
+ "input": [
58
+ 70,
59
+ 95
60
+ ],
61
+ "output": 870
62
+ },
63
+ {
64
+ "input": [
65
+ 6,
66
+ 35
67
+ ],
68
+ "output": 70
69
+ },
70
+ {
71
+ "input": [
72
+ 57,
73
+ 55
74
+ ],
75
+ "output": 710
76
+ },
77
+ {
78
+ "input": [
79
+ 70,
80
+ 89
81
+ ],
82
+ "output": 870
83
+ },
84
+ {
85
+ "input": [
86
+ 89,
87
+ 23
88
+ ],
89
+ "output": 1110
90
+ }
91
+ ],
92
+ "haskell_template": "distanceTraveled :: Int -> Int -> Int\ndistanceTraveled mainTank additionalTank ",
93
+ "ocaml_template": "let distanceTraveled (mainTank: int) (additionalTank: int) : int = ",
94
+ "scala_template": "def distanceTraveled(mainTank: Int,additionalTank: Int): Int = { \n \n}",
95
+ "java_template": "class Solution {\n public int distanceTraveled(int mainTank, int additionalTank) {\n \n }\n}",
96
+ "python_template": "class Solution(object):\n def distanceTraveled(self, mainTank, additionalTank):\n \"\"\"\n :type mainTank: int\n :type additionalTank: int\n :rtype: int\n \"\"\"\n "
97
+ }
total_distance_traveled/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 60 (distanceTraveled 5 10)
12
+
13
+ let test2 _ = assert_equal 10 (distanceTraveled 1 2)
14
+
15
+ let test3 _ = assert_equal 1190 (distanceTraveled 98 21)
16
+
17
+ let test4 _ = assert_equal 440 (distanceTraveled 36 37)
18
+
19
+ let test5 _ = assert_equal 870 (distanceTraveled 70 42)
20
+
21
+ let test6 _ = assert_equal 930 (distanceTraveled 75 78)
22
+
23
+ let test7 _ = assert_equal 770 (distanceTraveled 62 58)
24
+
25
+ let test8 _ = assert_equal 870 (distanceTraveled 70 95)
26
+
27
+ let test9 _ = assert_equal 70 (distanceTraveled 6 35)
28
+
29
+ let test10 _ = assert_equal 710 (distanceTraveled 57 55)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for distanceTraveled" >::: [
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
total_distance_traveled/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.distanceTraveled(5,10), 60)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.distanceTraveled(1,2), 10)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.distanceTraveled(98,21), 1190)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.distanceTraveled(36,37), 440)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.distanceTraveled(70,42), 870)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.distanceTraveled(75,78), 930)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.distanceTraveled(62,58), 770)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.distanceTraveled(70,95), 870)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.distanceTraveled(6,35), 70)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.distanceTraveled(57,55), 710)
42
+ }
43
+
44
+ }
transform_array_by_parity/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ transformArray :: [Int] -> [Int]
7
+ transformArray nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (transformArray [4,3,2,1])," [0,0,1,1] (transformArray [4,3,2,1]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (transformArray [1,5,1,4,2])," [0,0,1,1,1] (transformArray [1,5,1,4,2]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])," [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])," [0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])," [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1])," [0,0,0,0,0,0,0,0,1,1,1,1] (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])," [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] (transformArray [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))
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
transform_array_by_parity/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(Arrays.asList(0,0,1,1), transformArray(Arrays.asList(4,3,2,1)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(0,0,1,1,1), transformArray(Arrays.asList(1,5,1,4,2)));
18
+ }
19
+
20
+ }
transform_array_by_parity/meta.json ADDED
@@ -0,0 +1,657 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3778,
3
+ "name": "transform_array_by_parity",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/transform-array-by-parity/",
6
+ "date": "2025-02-15 00:00:00",
7
+ "task_description": "You are given an integer array `nums`. Transform `nums` by performing the following operations in the **exact** order specified: Replace each even number with 0. Replace each odd numbers with 1. Sort the modified array in **non-decreasing** order. Return the resulting array after performing these operations. **Example 1:** **Input:** nums = [4,3,2,1] **Output:** [0,0,1,1] **Explanation:** Replace the even numbers (4 and 2) with 0 and the odd numbers (3 and 1) with 1. Now, `nums = [0, 1, 0, 1]`. After sorting `nums` in non-descending order, `nums = [0, 0, 1, 1]`. **Example 2:** **Input:** nums = [1,5,1,4,2] **Output:** [0,0,1,1,1] **Explanation:** Replace the even numbers (4 and 2) with 0 and the odd numbers (1, 5 and 1) with 1. Now, `nums = [1, 1, 1, 0, 0]`. After sorting `nums` in non-descending order, `nums = [0, 0, 1, 1, 1]`. **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 1000`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [4,3,2,1]",
12
+ "output": "[0,0,1,1] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,5,1,4,2]",
17
+ "output": "[0,0,1,1,1] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 0,
24
+ 0,
25
+ 0,
26
+ 0,
27
+ 0,
28
+ 0,
29
+ 0,
30
+ 0,
31
+ 0,
32
+ 0,
33
+ 0,
34
+ 0,
35
+ 0,
36
+ 0,
37
+ 0,
38
+ 0,
39
+ 0,
40
+ 0,
41
+ 0,
42
+ 0,
43
+ 0,
44
+ 0,
45
+ 0,
46
+ 0,
47
+ 0,
48
+ 0,
49
+ 0,
50
+ 0,
51
+ 0,
52
+ 0,
53
+ 0,
54
+ 0,
55
+ 0,
56
+ 0,
57
+ 0,
58
+ 0,
59
+ 0,
60
+ 0,
61
+ 0,
62
+ 0,
63
+ 0,
64
+ 0,
65
+ 0,
66
+ 0,
67
+ 0,
68
+ 0,
69
+ 0,
70
+ 0,
71
+ 0,
72
+ 0,
73
+ 1,
74
+ 1,
75
+ 1,
76
+ 1,
77
+ 1,
78
+ 1,
79
+ 1,
80
+ 1,
81
+ 1,
82
+ 1,
83
+ 1,
84
+ 1,
85
+ 1,
86
+ 1,
87
+ 1,
88
+ 1,
89
+ 1,
90
+ 1,
91
+ 1,
92
+ 1,
93
+ 1,
94
+ 1,
95
+ 1,
96
+ 1,
97
+ 1,
98
+ 1,
99
+ 1,
100
+ 1,
101
+ 1,
102
+ 1,
103
+ 1,
104
+ 1,
105
+ 1,
106
+ 1,
107
+ 1,
108
+ 1,
109
+ 1,
110
+ 1,
111
+ 1,
112
+ 1,
113
+ 1,
114
+ 1,
115
+ 1,
116
+ 1,
117
+ 1,
118
+ 1,
119
+ 1
120
+ ],
121
+ "output": [
122
+ 0,
123
+ 0,
124
+ 0,
125
+ 0,
126
+ 0,
127
+ 0,
128
+ 0,
129
+ 0,
130
+ 0,
131
+ 0,
132
+ 0,
133
+ 0,
134
+ 0,
135
+ 0,
136
+ 0,
137
+ 0,
138
+ 0,
139
+ 0,
140
+ 0,
141
+ 0,
142
+ 0,
143
+ 0,
144
+ 0,
145
+ 0,
146
+ 0,
147
+ 0,
148
+ 0,
149
+ 0,
150
+ 0,
151
+ 0,
152
+ 0,
153
+ 0,
154
+ 0,
155
+ 0,
156
+ 0,
157
+ 0,
158
+ 0,
159
+ 0,
160
+ 0,
161
+ 0,
162
+ 0,
163
+ 0,
164
+ 0,
165
+ 0,
166
+ 0,
167
+ 0,
168
+ 0,
169
+ 0,
170
+ 0,
171
+ 0,
172
+ 1,
173
+ 1,
174
+ 1,
175
+ 1,
176
+ 1,
177
+ 1,
178
+ 1,
179
+ 1,
180
+ 1,
181
+ 1,
182
+ 1,
183
+ 1,
184
+ 1,
185
+ 1,
186
+ 1,
187
+ 1,
188
+ 1,
189
+ 1,
190
+ 1,
191
+ 1,
192
+ 1,
193
+ 1,
194
+ 1,
195
+ 1,
196
+ 1,
197
+ 1,
198
+ 1,
199
+ 1,
200
+ 1,
201
+ 1,
202
+ 1,
203
+ 1,
204
+ 1,
205
+ 1,
206
+ 1,
207
+ 1,
208
+ 1,
209
+ 1,
210
+ 1,
211
+ 1,
212
+ 1,
213
+ 1,
214
+ 1,
215
+ 1,
216
+ 1,
217
+ 1,
218
+ 1
219
+ ]
220
+ },
221
+ {
222
+ "input": [
223
+ 0,
224
+ 0,
225
+ 0,
226
+ 0,
227
+ 0,
228
+ 0,
229
+ 0,
230
+ 0,
231
+ 0,
232
+ 0,
233
+ 0,
234
+ 0,
235
+ 0,
236
+ 1,
237
+ 1,
238
+ 1,
239
+ 1,
240
+ 1,
241
+ 1,
242
+ 1,
243
+ 1,
244
+ 1,
245
+ 1,
246
+ 1,
247
+ 1,
248
+ 1,
249
+ 1,
250
+ 1,
251
+ 1,
252
+ 1,
253
+ 1,
254
+ 1,
255
+ 1,
256
+ 1,
257
+ 1,
258
+ 1
259
+ ],
260
+ "output": [
261
+ 0,
262
+ 0,
263
+ 0,
264
+ 0,
265
+ 0,
266
+ 0,
267
+ 0,
268
+ 0,
269
+ 0,
270
+ 0,
271
+ 0,
272
+ 0,
273
+ 0,
274
+ 1,
275
+ 1,
276
+ 1,
277
+ 1,
278
+ 1,
279
+ 1,
280
+ 1,
281
+ 1,
282
+ 1,
283
+ 1,
284
+ 1,
285
+ 1,
286
+ 1,
287
+ 1,
288
+ 1,
289
+ 1,
290
+ 1,
291
+ 1,
292
+ 1,
293
+ 1,
294
+ 1,
295
+ 1,
296
+ 1
297
+ ]
298
+ },
299
+ {
300
+ "input": [
301
+ 0,
302
+ 0,
303
+ 0,
304
+ 0,
305
+ 0,
306
+ 0,
307
+ 0,
308
+ 0,
309
+ 0,
310
+ 0,
311
+ 0,
312
+ 0,
313
+ 0,
314
+ 0,
315
+ 0,
316
+ 0,
317
+ 0,
318
+ 0,
319
+ 0,
320
+ 0,
321
+ 0,
322
+ 0,
323
+ 0,
324
+ 0,
325
+ 0,
326
+ 0,
327
+ 0,
328
+ 0,
329
+ 0,
330
+ 0,
331
+ 0,
332
+ 0,
333
+ 0,
334
+ 0,
335
+ 0,
336
+ 0,
337
+ 0,
338
+ 0,
339
+ 0,
340
+ 0,
341
+ 0,
342
+ 0,
343
+ 0,
344
+ 1,
345
+ 1,
346
+ 1,
347
+ 1,
348
+ 1,
349
+ 1,
350
+ 1,
351
+ 1,
352
+ 1,
353
+ 1,
354
+ 1,
355
+ 1,
356
+ 1,
357
+ 1,
358
+ 1,
359
+ 1,
360
+ 1,
361
+ 1,
362
+ 1,
363
+ 1,
364
+ 1,
365
+ 1,
366
+ 1,
367
+ 1,
368
+ 1,
369
+ 1,
370
+ 1,
371
+ 1,
372
+ 1,
373
+ 1,
374
+ 1,
375
+ 1,
376
+ 1,
377
+ 1,
378
+ 1,
379
+ 1,
380
+ 1,
381
+ 1,
382
+ 1,
383
+ 1,
384
+ 1,
385
+ 1,
386
+ 1,
387
+ 1,
388
+ 1,
389
+ 1
390
+ ],
391
+ "output": [
392
+ 0,
393
+ 0,
394
+ 0,
395
+ 0,
396
+ 0,
397
+ 0,
398
+ 0,
399
+ 0,
400
+ 0,
401
+ 0,
402
+ 0,
403
+ 0,
404
+ 0,
405
+ 0,
406
+ 0,
407
+ 0,
408
+ 0,
409
+ 0,
410
+ 0,
411
+ 0,
412
+ 0,
413
+ 0,
414
+ 0,
415
+ 0,
416
+ 0,
417
+ 0,
418
+ 0,
419
+ 0,
420
+ 0,
421
+ 0,
422
+ 0,
423
+ 0,
424
+ 0,
425
+ 0,
426
+ 0,
427
+ 0,
428
+ 0,
429
+ 0,
430
+ 0,
431
+ 0,
432
+ 0,
433
+ 0,
434
+ 0,
435
+ 1,
436
+ 1,
437
+ 1,
438
+ 1,
439
+ 1,
440
+ 1,
441
+ 1,
442
+ 1,
443
+ 1,
444
+ 1,
445
+ 1,
446
+ 1,
447
+ 1,
448
+ 1,
449
+ 1,
450
+ 1,
451
+ 1,
452
+ 1,
453
+ 1,
454
+ 1,
455
+ 1,
456
+ 1,
457
+ 1,
458
+ 1,
459
+ 1,
460
+ 1,
461
+ 1,
462
+ 1,
463
+ 1,
464
+ 1,
465
+ 1,
466
+ 1,
467
+ 1,
468
+ 1,
469
+ 1,
470
+ 1,
471
+ 1,
472
+ 1,
473
+ 1,
474
+ 1,
475
+ 1,
476
+ 1,
477
+ 1,
478
+ 1,
479
+ 1,
480
+ 1
481
+ ]
482
+ },
483
+ {
484
+ "input": [
485
+ 0,
486
+ 0,
487
+ 0,
488
+ 0,
489
+ 0,
490
+ 0,
491
+ 0,
492
+ 0,
493
+ 1,
494
+ 1,
495
+ 1,
496
+ 1
497
+ ],
498
+ "output": [
499
+ 0,
500
+ 0,
501
+ 0,
502
+ 0,
503
+ 0,
504
+ 0,
505
+ 0,
506
+ 0,
507
+ 1,
508
+ 1,
509
+ 1,
510
+ 1
511
+ ]
512
+ },
513
+ {
514
+ "input": [
515
+ 0,
516
+ 0,
517
+ 0,
518
+ 0,
519
+ 0,
520
+ 0,
521
+ 0,
522
+ 0,
523
+ 0,
524
+ 0,
525
+ 0,
526
+ 0,
527
+ 0,
528
+ 0,
529
+ 0,
530
+ 0,
531
+ 0,
532
+ 0,
533
+ 0,
534
+ 0,
535
+ 0,
536
+ 0,
537
+ 0,
538
+ 0,
539
+ 0,
540
+ 0,
541
+ 0,
542
+ 0,
543
+ 0,
544
+ 0,
545
+ 0,
546
+ 0,
547
+ 0,
548
+ 0,
549
+ 0,
550
+ 0,
551
+ 1,
552
+ 1,
553
+ 1,
554
+ 1,
555
+ 1,
556
+ 1,
557
+ 1,
558
+ 1,
559
+ 1,
560
+ 1,
561
+ 1,
562
+ 1,
563
+ 1,
564
+ 1,
565
+ 1,
566
+ 1,
567
+ 1,
568
+ 1,
569
+ 1,
570
+ 1,
571
+ 1,
572
+ 1,
573
+ 1,
574
+ 1,
575
+ 1,
576
+ 1,
577
+ 1,
578
+ 1,
579
+ 1,
580
+ 1
581
+ ],
582
+ "output": [
583
+ 0,
584
+ 0,
585
+ 0,
586
+ 0,
587
+ 0,
588
+ 0,
589
+ 0,
590
+ 0,
591
+ 0,
592
+ 0,
593
+ 0,
594
+ 0,
595
+ 0,
596
+ 0,
597
+ 0,
598
+ 0,
599
+ 0,
600
+ 0,
601
+ 0,
602
+ 0,
603
+ 0,
604
+ 0,
605
+ 0,
606
+ 0,
607
+ 0,
608
+ 0,
609
+ 0,
610
+ 0,
611
+ 0,
612
+ 0,
613
+ 0,
614
+ 0,
615
+ 0,
616
+ 0,
617
+ 0,
618
+ 0,
619
+ 1,
620
+ 1,
621
+ 1,
622
+ 1,
623
+ 1,
624
+ 1,
625
+ 1,
626
+ 1,
627
+ 1,
628
+ 1,
629
+ 1,
630
+ 1,
631
+ 1,
632
+ 1,
633
+ 1,
634
+ 1,
635
+ 1,
636
+ 1,
637
+ 1,
638
+ 1,
639
+ 1,
640
+ 1,
641
+ 1,
642
+ 1,
643
+ 1,
644
+ 1,
645
+ 1,
646
+ 1,
647
+ 1,
648
+ 1
649
+ ]
650
+ }
651
+ ],
652
+ "haskell_template": "transformArray :: [Int] -> [Int]\ntransformArray nums ",
653
+ "ocaml_template": "let transformArray (nums: int list) : int list = ",
654
+ "scala_template": "def transformArray(nums: List[Int]): List[Int] = { \n \n}",
655
+ "java_template": "class Solution {\n public int[] transformArray(int[] nums) {\n \n }\n}",
656
+ "python_template": "class Solution(object):\n def transformArray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n "
657
+ }
transform_array_by_parity/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let transformArray (nums: int list) : int list = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal [0;0;1;1] (transformArray [4;3;2;1])
13
+
14
+ let test2 _ = assert_equal [0;0;1;1;1] (transformArray [1;5;1;4;2])
15
+
16
+ let test3 _ = assert_equal [0;0;1;1;1] (transformArray [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1])
17
+
18
+ let test4 _ = assert_equal [0;0;1;1;1] (transformArray [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1])
19
+
20
+ let test5 _ = assert_equal [0;0;1;1;1] (transformArray [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1])
21
+
22
+ let test6 _ = assert_equal [0;0;1;1;1] (transformArray [0; 0; 0; 0; 0; 0; 0; 0; 1; 1; 1; 1])
23
+
24
+ let test7 _ = assert_equal [0;0;1;1;1] (transformArray [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1])
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for transformArray" >::: [
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
transform_array_by_parity/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.transformArray(List(4,3,2,1)), List(0,0,1,1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.transformArray(List(1,5,1,4,2)), List(0,0,1,1,1))
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.transformArray(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), List(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.transformArray(0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), List(0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.transformArray(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), List(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.transformArray(0,0,0,0,0,0,0,0,1,1,1,1), List(0,0,0,0,0,0,0,0,1,1,1,1))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.transformArray(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), List(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1))
30
+ }
31
+
32
+ }
transformed_array/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ constructTransformedArray :: [Int] -> [Int]
7
+ constructTransformedArray nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (constructTransformedArray [3,-2,1,1])," [1,1,1,3] (constructTransformedArray [3,-2,1,1]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (constructTransformedArray [-1,4,-1])," [-1,-1,4] (constructTransformedArray [-1,4,-1]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (constructTransformedArray [20, ( -26), 14, ( -18), ( -48), 74, 0, ( -26), ( -55), ( -82), 19, ( -55), 1, ( -93), ( -62), ( -31), ( -49), ( -20), 25, 84, ( -33), ( -75), 59, 64, ( -7), 5, ( -20), ( -89), 3, 27, 4, ( -57), 25, ( -38), ( -94), ( -15), ( -92), 75, ( -43), 60, ( -74), ( -33), ( -35), ( -22), ( -5), ( -10), 24, 80, ( -73), 67, ( -92), 58, 9, ( -31), 30, ( -56), ( -78)])," [-33,25,(-49),(-35),(-93),59,0,(-43),19,(-33),27,(-93),(-93),(-94),(-82),(-33),(-7),30,(-22),24,(-5),(-18),(-7),4,(-20),4,0,9,(-57),(-78),(-94),(-57),20,9,30,(-33),(-26),(-56),9,(-35),64,(-55),(-26),(-75),60,(-15),(-93),(-93),25,14,(-31),9,(-48),59,(-89),(-78),(-15)] (constructTransformedArray [20, -26, 14, -18, -48, 74, 0, -26, -55, -82, 19, -55, 1, -93, -62, -31, -49, -20, 25, 84, -33, -75, 59, 64, -7, 5, -20, -89, 3, 27, 4, -57, 25, -38, -94, -15, -92, 75, -43, 60, -74, -33, -35, -22, -5, -10, 24, 80, -73, 67, -92, 58, 9, -31, 30, -56, -78]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (constructTransformedArray [-23, 42, 69, ( -97), ( -58), 97, ( -47), 65, 45, ( -93), 31, ( -44), ( -78), ( -49), 81, 60, 51, ( -80), ( -74), 87, 20, 1, 86, ( -32), ( -80), 58, ( -23), 6, ( -92), 9, ( -99), ( -11), 44, 71, 56, 50, 6, ( -64), ( -61)])," [51,(-58),44,(-32),(-80),(-80),(-64),71,81,71,69,(-47),(-78),(-97),(-80),6,(-92),60,86,(-92),42,86,(-99),(-99),86,97,(-97),71,81,(-61),(-93),20,(-64),(-23),(-78),65,(-97),(-78),51] (constructTransformedArray [-23, 42, 69, -97, -58, 97, -47, 65, 45, -93, 31, -44, -78, -49, 81, 60, 51, -80, -74, 87, 20, 1, 86, -32, -80, 58, -23, 6, -92, 9, -99, -11, 44, 71, 56, 50, 6, -64, -61]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (constructTransformedArray [61, ( -63), ( -16), 10, ( -39), ( -16), ( -95), ( -44), ( -16), 21, 4, 18, ( -56), 53, 39, 69, 29, ( -87), 43, ( -75), ( -81), ( -3), ( -66), ( -18), ( -73), 38, 9, 75, ( -98), 43, 67, ( -49), 100, ( -9), 62, 32, ( -13), ( -2), ( -81), 79, 88, ( -1), 16, 27, 81, ( -90), ( -88), 15, 60, 33, ( -20), ( -12), 86, 20, 83, 10, ( -55), 88, 82, 32, 98, 7, ( -66), 60, 54, 50, ( -42), ( -99), 69, ( -29), ( -98), ( -51), ( -54), 65, ( -63), ( -16), 11, ( -82)])," [7,29,54,53,27,(-99),(-99),(-1),(-98),67,39,43,62,(-42),20,(-95),(-90),(-16),7,(-66),(-87),43,62,(-16),43,60,32,(-73),(-16),(-54),(-75),98,83,(-73),43,(-99),(-18),32,32,88,(-20),88,82,(-98),15,(-9),(-13),(-66),67,(-39),67,79,98,65,32,50,(-63),(-99),(-66),53,(-16),69,(-63),(-90),88,(-2),(-73),(-88),32,88,(-20),(-81),43,98,18,32,21,65] (constructTransformedArray [61, -63, -16, 10, -39, -16, -95, -44, -16, 21, 4, 18, -56, 53, 39, 69, 29, -87, 43, -75, -81, -3, -66, -18, -73, 38, 9, 75, -98, 43, 67, -49, 100, -9, 62, 32, -13, -2, -81, 79, 88, -1, 16, 27, 81, -90, -88, 15, 60, 33, -20, -12, 86, 20, 83, 10, -55, 88, 82, 32, 98, 7, -66, 60, 54, 50, -42, -99, 69, -29, -98, -51, -54, 65, -63, -16, 11, -82]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (constructTransformedArray [55, ( -64), ( -7), ( -6), ( -30), ( -37), 16, 58, 57, 33, 62, 82, ( -6), 94, 65, 0, ( -74), ( -32), 50, 70, ( -85), 55, 43, ( -70), 38, 75, 98, 86, ( -79), 41, ( -80), 65, 68, ( -17), ( -15), ( -92), 84, 5, ( -93), ( -8), ( -10), 32, 46, 40])," [82,75,(-8),32,50,(-6),43,55,55,46,(-79),(-37),16,70,(-92),0,(-80),41,38,(-64),(-70),68,55,32,50,(-6),84,75,5,98,(-93),57,(-6),(-74),70,65,68,46,(-17),65,(-80),41,55,(-8)] (constructTransformedArray [55, -64, -7, -6, -30, -37, 16, 58, 57, 33, 62, 82, -6, 94, 65, 0, -74, -32, 50, 70, -85, 55, 43, -70, 38, 75, 98, 86, -79, 41, -80, 65, 68, -17, -15, -92, 84, 5, -93, -8, -10, 32, 46, 40]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (constructTransformedArray [1, ( -93), 55, ( -75), 27, 83, 4, 93, ( -63), 60, 89, 46, 7, 5, ( -67), ( -62), ( -49), ( -18), 77, 2, 44, 48, 76, ( -58), 99, 92, ( -2), ( -99), ( -35), ( -32), ( -61), ( -26), 49, 95, ( -69)])," [-93,5,76,95,(-26),77,89,(-61),(-62),(-69),(-32),76,2,77,(-18),(-58),55,(-69),92,48,(-32),(-69),(-35),1,77,7,99,95,(-35),49,27,83,46,(-58),1] (constructTransformedArray [1, -93, 55, -75, 27, 83, 4, 93, -63, 60, 89, 46, 7, 5, -67, -62, -49, -18, 77, 2, 44, 48, 76, -58, 99, 92, -2, -99, -35, -32, -61, -26, 49, 95, -69]))
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
transformed_array/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(Arrays.asList(1,1,1,3), constructTransformedArray(Arrays.asList(3,-2,1,1)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(-1,-1,4), constructTransformedArray(Arrays.asList(-1,4,-1)));
18
+ }
19
+
20
+ }
transformed_array/meta.json ADDED
@@ -0,0 +1,563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3651,
3
+ "name": "transformed_array",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/transformed-array/",
6
+ "date": "2024-12-01 00:00:00",
7
+ "task_description": "You are given an integer array `nums` that represents a circular array. Your task is to create a new array `result` of the **same** size, following these rules: For each index `i` (where `0 <= i < nums.length`), perform the following **independent** actions: If `nums[i] > 0`: Start at index `i` and move `nums[i]` steps to the **right** in the circular array. Set `result[i]` to the value of the index where you land. If `nums[i] < 0`: Start at index `i` and move `abs(nums[i])` steps to the **left** in the circular array. Set `result[i]` to the value of the index where you land. If `nums[i] == 0`: Set `result[i]` to `nums[i]`. Return the new array `result`. **Note:** Since `nums` is circular, moving past the last element wraps around to the beginning, and moving before the first element wraps back to the end. **Example 1:** **Input:** nums = [3,-2,1,1] **Output:** [1,1,1,3] **Explanation:** For `nums[0]` that is equal to 3, If we move 3 steps to right, we reach `nums[3]`. So `result[0]` should be 1. For `nums[1]` that is equal to -2, If we move 2 steps to left, we reach `nums[3]`. So `result[1]` should be 1. For `nums[2]` that is equal to 1, If we move 1 step to right, we reach `nums[3]`. So `result[2]` should be 1. For `nums[3]` that is equal to 1, If we move 1 step to right, we reach `nums[0]`. So `result[3]` should be 3. **Example 2:** **Input:** nums = [-1,4,-1] **Output:** [-1,-1,4] **Explanation:** For `nums[0]` that is equal to -1, If we move 1 step to left, we reach `nums[2]`. So `result[0]` should be -1. For `nums[1]` that is equal to 4, If we move 4 steps to right, we reach `nums[2]`. So `result[1]` should be -1. For `nums[2]` that is equal to -1, If we move 1 step to left, we reach `nums[1]`. So `result[2]` should be 4. **Constraints:** `1 <= nums.length <= 100` `-100 <= nums[i] <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [3,-2,1,1]",
12
+ "output": "[1,1,1,3] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [-1,4,-1]",
17
+ "output": "[-1,-1,4] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 20,
24
+ -26,
25
+ 14,
26
+ -18,
27
+ -48,
28
+ 74,
29
+ 0,
30
+ -26,
31
+ -55,
32
+ -82,
33
+ 19,
34
+ -55,
35
+ 1,
36
+ -93,
37
+ -62,
38
+ -31,
39
+ -49,
40
+ -20,
41
+ 25,
42
+ 84,
43
+ -33,
44
+ -75,
45
+ 59,
46
+ 64,
47
+ -7,
48
+ 5,
49
+ -20,
50
+ -89,
51
+ 3,
52
+ 27,
53
+ 4,
54
+ -57,
55
+ 25,
56
+ -38,
57
+ -94,
58
+ -15,
59
+ -92,
60
+ 75,
61
+ -43,
62
+ 60,
63
+ -74,
64
+ -33,
65
+ -35,
66
+ -22,
67
+ -5,
68
+ -10,
69
+ 24,
70
+ 80,
71
+ -73,
72
+ 67,
73
+ -92,
74
+ 58,
75
+ 9,
76
+ -31,
77
+ 30,
78
+ -56,
79
+ -78
80
+ ],
81
+ "output": [
82
+ -33,
83
+ 25,
84
+ -49,
85
+ -35,
86
+ -93,
87
+ 59,
88
+ 0,
89
+ -43,
90
+ 19,
91
+ -33,
92
+ 27,
93
+ -93,
94
+ -93,
95
+ -94,
96
+ -82,
97
+ -33,
98
+ -7,
99
+ 30,
100
+ -22,
101
+ 24,
102
+ -5,
103
+ -18,
104
+ -7,
105
+ 4,
106
+ -20,
107
+ 4,
108
+ 0,
109
+ 9,
110
+ -57,
111
+ -78,
112
+ -94,
113
+ -57,
114
+ 20,
115
+ 9,
116
+ 30,
117
+ -33,
118
+ -26,
119
+ -56,
120
+ 9,
121
+ -35,
122
+ 64,
123
+ -55,
124
+ -26,
125
+ -75,
126
+ 60,
127
+ -15,
128
+ -93,
129
+ -93,
130
+ 25,
131
+ 14,
132
+ -31,
133
+ 9,
134
+ -48,
135
+ 59,
136
+ -89,
137
+ -78,
138
+ -15
139
+ ]
140
+ },
141
+ {
142
+ "input": [
143
+ -23,
144
+ 42,
145
+ 69,
146
+ -97,
147
+ -58,
148
+ 97,
149
+ -47,
150
+ 65,
151
+ 45,
152
+ -93,
153
+ 31,
154
+ -44,
155
+ -78,
156
+ -49,
157
+ 81,
158
+ 60,
159
+ 51,
160
+ -80,
161
+ -74,
162
+ 87,
163
+ 20,
164
+ 1,
165
+ 86,
166
+ -32,
167
+ -80,
168
+ 58,
169
+ -23,
170
+ 6,
171
+ -92,
172
+ 9,
173
+ -99,
174
+ -11,
175
+ 44,
176
+ 71,
177
+ 56,
178
+ 50,
179
+ 6,
180
+ -64,
181
+ -61
182
+ ],
183
+ "output": [
184
+ 51,
185
+ -58,
186
+ 44,
187
+ -32,
188
+ -80,
189
+ -80,
190
+ -64,
191
+ 71,
192
+ 81,
193
+ 71,
194
+ 69,
195
+ -47,
196
+ -78,
197
+ -97,
198
+ -80,
199
+ 6,
200
+ -92,
201
+ 60,
202
+ 86,
203
+ -92,
204
+ 42,
205
+ 86,
206
+ -99,
207
+ -99,
208
+ 86,
209
+ 97,
210
+ -97,
211
+ 71,
212
+ 81,
213
+ -61,
214
+ -93,
215
+ 20,
216
+ -64,
217
+ -23,
218
+ -78,
219
+ 65,
220
+ -97,
221
+ -78,
222
+ 51
223
+ ]
224
+ },
225
+ {
226
+ "input": [
227
+ 61,
228
+ -63,
229
+ -16,
230
+ 10,
231
+ -39,
232
+ -16,
233
+ -95,
234
+ -44,
235
+ -16,
236
+ 21,
237
+ 4,
238
+ 18,
239
+ -56,
240
+ 53,
241
+ 39,
242
+ 69,
243
+ 29,
244
+ -87,
245
+ 43,
246
+ -75,
247
+ -81,
248
+ -3,
249
+ -66,
250
+ -18,
251
+ -73,
252
+ 38,
253
+ 9,
254
+ 75,
255
+ -98,
256
+ 43,
257
+ 67,
258
+ -49,
259
+ 100,
260
+ -9,
261
+ 62,
262
+ 32,
263
+ -13,
264
+ -2,
265
+ -81,
266
+ 79,
267
+ 88,
268
+ -1,
269
+ 16,
270
+ 27,
271
+ 81,
272
+ -90,
273
+ -88,
274
+ 15,
275
+ 60,
276
+ 33,
277
+ -20,
278
+ -12,
279
+ 86,
280
+ 20,
281
+ 83,
282
+ 10,
283
+ -55,
284
+ 88,
285
+ 82,
286
+ 32,
287
+ 98,
288
+ 7,
289
+ -66,
290
+ 60,
291
+ 54,
292
+ 50,
293
+ -42,
294
+ -99,
295
+ 69,
296
+ -29,
297
+ -98,
298
+ -51,
299
+ -54,
300
+ 65,
301
+ -63,
302
+ -16,
303
+ 11,
304
+ -82
305
+ ],
306
+ "output": [
307
+ 7,
308
+ 29,
309
+ 54,
310
+ 53,
311
+ 27,
312
+ -99,
313
+ -99,
314
+ -1,
315
+ -98,
316
+ 67,
317
+ 39,
318
+ 43,
319
+ 62,
320
+ -42,
321
+ 20,
322
+ -95,
323
+ -90,
324
+ -16,
325
+ 7,
326
+ -66,
327
+ -87,
328
+ 43,
329
+ 62,
330
+ -16,
331
+ 43,
332
+ 60,
333
+ 32,
334
+ -73,
335
+ -16,
336
+ -54,
337
+ -75,
338
+ 98,
339
+ 83,
340
+ -73,
341
+ 43,
342
+ -99,
343
+ -18,
344
+ 32,
345
+ 32,
346
+ 88,
347
+ -20,
348
+ 88,
349
+ 82,
350
+ -98,
351
+ 15,
352
+ -9,
353
+ -13,
354
+ -66,
355
+ 67,
356
+ -39,
357
+ 67,
358
+ 79,
359
+ 98,
360
+ 65,
361
+ 32,
362
+ 50,
363
+ -63,
364
+ -99,
365
+ -66,
366
+ 53,
367
+ -16,
368
+ 69,
369
+ -63,
370
+ -90,
371
+ 88,
372
+ -2,
373
+ -73,
374
+ -88,
375
+ 32,
376
+ 88,
377
+ -20,
378
+ -81,
379
+ 43,
380
+ 98,
381
+ 18,
382
+ 32,
383
+ 21,
384
+ 65
385
+ ]
386
+ },
387
+ {
388
+ "input": [
389
+ 55,
390
+ -64,
391
+ -7,
392
+ -6,
393
+ -30,
394
+ -37,
395
+ 16,
396
+ 58,
397
+ 57,
398
+ 33,
399
+ 62,
400
+ 82,
401
+ -6,
402
+ 94,
403
+ 65,
404
+ 0,
405
+ -74,
406
+ -32,
407
+ 50,
408
+ 70,
409
+ -85,
410
+ 55,
411
+ 43,
412
+ -70,
413
+ 38,
414
+ 75,
415
+ 98,
416
+ 86,
417
+ -79,
418
+ 41,
419
+ -80,
420
+ 65,
421
+ 68,
422
+ -17,
423
+ -15,
424
+ -92,
425
+ 84,
426
+ 5,
427
+ -93,
428
+ -8,
429
+ -10,
430
+ 32,
431
+ 46,
432
+ 40
433
+ ],
434
+ "output": [
435
+ 82,
436
+ 75,
437
+ -8,
438
+ 32,
439
+ 50,
440
+ -6,
441
+ 43,
442
+ 55,
443
+ 55,
444
+ 46,
445
+ -79,
446
+ -37,
447
+ 16,
448
+ 70,
449
+ -92,
450
+ 0,
451
+ -80,
452
+ 41,
453
+ 38,
454
+ -64,
455
+ -70,
456
+ 68,
457
+ 55,
458
+ 32,
459
+ 50,
460
+ -6,
461
+ 84,
462
+ 75,
463
+ 5,
464
+ 98,
465
+ -93,
466
+ 57,
467
+ -6,
468
+ -74,
469
+ 70,
470
+ 65,
471
+ 68,
472
+ 46,
473
+ -17,
474
+ 65,
475
+ -80,
476
+ 41,
477
+ 55,
478
+ -8
479
+ ]
480
+ },
481
+ {
482
+ "input": [
483
+ 1,
484
+ -93,
485
+ 55,
486
+ -75,
487
+ 27,
488
+ 83,
489
+ 4,
490
+ 93,
491
+ -63,
492
+ 60,
493
+ 89,
494
+ 46,
495
+ 7,
496
+ 5,
497
+ -67,
498
+ -62,
499
+ -49,
500
+ -18,
501
+ 77,
502
+ 2,
503
+ 44,
504
+ 48,
505
+ 76,
506
+ -58,
507
+ 99,
508
+ 92,
509
+ -2,
510
+ -99,
511
+ -35,
512
+ -32,
513
+ -61,
514
+ -26,
515
+ 49,
516
+ 95,
517
+ -69
518
+ ],
519
+ "output": [
520
+ -93,
521
+ 5,
522
+ 76,
523
+ 95,
524
+ -26,
525
+ 77,
526
+ 89,
527
+ -61,
528
+ -62,
529
+ -69,
530
+ -32,
531
+ 76,
532
+ 2,
533
+ 77,
534
+ -18,
535
+ -58,
536
+ 55,
537
+ -69,
538
+ 92,
539
+ 48,
540
+ -32,
541
+ -69,
542
+ -35,
543
+ 1,
544
+ 77,
545
+ 7,
546
+ 99,
547
+ 95,
548
+ -35,
549
+ 49,
550
+ 27,
551
+ 83,
552
+ 46,
553
+ -58,
554
+ 1
555
+ ]
556
+ }
557
+ ],
558
+ "haskell_template": "constructTransformedArray :: [Int] -> [Int]\nconstructTransformedArray nums ",
559
+ "ocaml_template": "let constructTransformedArray (nums: int list) : int list = ",
560
+ "scala_template": "def constructTransformedArray(nums: List[Int]): List[Int] = { \n \n}",
561
+ "java_template": "class Solution {\n public int[] constructTransformedArray(int[] nums) {\n \n }\n}",
562
+ "python_template": "class Solution(object):\n def constructTransformedArray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n "
563
+ }
transformed_array/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let constructTransformedArray (nums: int list) : int list = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal [1;1;1;3] (constructTransformedArray [3;-2;1;1])
13
+
14
+ let test2 _ = assert_equal [-1;-1;4] (constructTransformedArray [-1;4;-1])
15
+
16
+ let test3 _ = assert_equal [-1;-1;4] (constructTransformedArray [20; -26; 14; -18; -48; 74; 0; -26; -55; -82; 19; -55; 1; -93; -62; -31; -49; -20; 25; 84; -33; -75; 59; 64; -7; 5; -20; -89; 3; 27; 4; -57; 25; -38; -94; -15; -92; 75; -43; 60; -74; -33; -35; -22; -5; -10; 24; 80; -73; 67; -92; 58; 9; -31; 30; -56; -78])
17
+
18
+ let test4 _ = assert_equal [-1;-1;4] (constructTransformedArray [-23; 42; 69; -97; -58; 97; -47; 65; 45; -93; 31; -44; -78; -49; 81; 60; 51; -80; -74; 87; 20; 1; 86; -32; -80; 58; -23; 6; -92; 9; -99; -11; 44; 71; 56; 50; 6; -64; -61])
19
+
20
+ let test5 _ = assert_equal [-1;-1;4] (constructTransformedArray [61; -63; -16; 10; -39; -16; -95; -44; -16; 21; 4; 18; -56; 53; 39; 69; 29; -87; 43; -75; -81; -3; -66; -18; -73; 38; 9; 75; -98; 43; 67; -49; 100; -9; 62; 32; -13; -2; -81; 79; 88; -1; 16; 27; 81; -90; -88; 15; 60; 33; -20; -12; 86; 20; 83; 10; -55; 88; 82; 32; 98; 7; -66; 60; 54; 50; -42; -99; 69; -29; -98; -51; -54; 65; -63; -16; 11; -82])
21
+
22
+ let test6 _ = assert_equal [-1;-1;4] (constructTransformedArray [55; -64; -7; -6; -30; -37; 16; 58; 57; 33; 62; 82; -6; 94; 65; 0; -74; -32; 50; 70; -85; 55; 43; -70; 38; 75; 98; 86; -79; 41; -80; 65; 68; -17; -15; -92; 84; 5; -93; -8; -10; 32; 46; 40])
23
+
24
+ let test7 _ = assert_equal [-1;-1;4] (constructTransformedArray [1; -93; 55; -75; 27; 83; 4; 93; -63; 60; 89; 46; 7; 5; -67; -62; -49; -18; 77; 2; 44; 48; 76; -58; 99; 92; -2; -99; -35; -32; -61; -26; 49; 95; -69])
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for constructTransformedArray" >::: [
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
transformed_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.constructTransformedArray(List(3,-2,1,1)), List(1,1,1,3))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.constructTransformedArray(List(-1,4,-1)), List(-1,-1,4))
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.constructTransformedArray(20,-26,14,-18,-48,74,0,-26,-55,-82,19,-55,1,-93,-62,-31,-49,-20,25,84,-33,-75,59,64,-7,5,-20,-89,3,27,4,-57,25,-38,-94,-15,-92,75,-43,60,-74,-33,-35,-22,-5,-10,24,80,-73,67,-92,58,9,-31,30,-56,-78), List(-33,25,-49,-35,-93,59,0,-43,19,-33,27,-93,-93,-94,-82,-33,-7,30,-22,24,-5,-18,-7,4,-20,4,0,9,-57,-78,-94,-57,20,9,30,-33,-26,-56,9,-35,64,-55,-26,-75,60,-15,-93,-93,25,14,-31,9,-48,59,-89,-78,-15))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.constructTransformedArray(-23,42,69,-97,-58,97,-47,65,45,-93,31,-44,-78,-49,81,60,51,-80,-74,87,20,1,86,-32,-80,58,-23,6,-92,9,-99,-11,44,71,56,50,6,-64,-61), List(51,-58,44,-32,-80,-80,-64,71,81,71,69,-47,-78,-97,-80,6,-92,60,86,-92,42,86,-99,-99,86,97,-97,71,81,-61,-93,20,-64,-23,-78,65,-97,-78,51))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.constructTransformedArray(61,-63,-16,10,-39,-16,-95,-44,-16,21,4,18,-56,53,39,69,29,-87,43,-75,-81,-3,-66,-18,-73,38,9,75,-98,43,67,-49,100,-9,62,32,-13,-2,-81,79,88,-1,16,27,81,-90,-88,15,60,33,-20,-12,86,20,83,10,-55,88,82,32,98,7,-66,60,54,50,-42,-99,69,-29,-98,-51,-54,65,-63,-16,11,-82), List(7,29,54,53,27,-99,-99,-1,-98,67,39,43,62,-42,20,-95,-90,-16,7,-66,-87,43,62,-16,43,60,32,-73,-16,-54,-75,98,83,-73,43,-99,-18,32,32,88,-20,88,82,-98,15,-9,-13,-66,67,-39,67,79,98,65,32,50,-63,-99,-66,53,-16,69,-63,-90,88,-2,-73,-88,32,88,-20,-81,43,98,18,32,21,65))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.constructTransformedArray(55,-64,-7,-6,-30,-37,16,58,57,33,62,82,-6,94,65,0,-74,-32,50,70,-85,55,43,-70,38,75,98,86,-79,41,-80,65,68,-17,-15,-92,84,5,-93,-8,-10,32,46,40), List(82,75,-8,32,50,-6,43,55,55,46,-79,-37,16,70,-92,0,-80,41,38,-64,-70,68,55,32,50,-6,84,75,5,98,-93,57,-6,-74,70,65,68,46,-17,65,-80,41,55,-8))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.constructTransformedArray(1,-93,55,-75,27,83,4,93,-63,60,89,46,7,5,-67,-62,-49,-18,77,2,44,48,76,-58,99,92,-2,-99,-35,-32,-61,-26,49,95,-69), List(-93,5,76,95,-26,77,89,-61,-62,-69,-32,76,2,77,-18,-58,55,-69,92,48,-32,-69,-35,1,77,7,99,95,-35,49,27,83,46,-58,1))
30
+ }
31
+
32
+ }
unique_3_digit_even_numbers/haskell_tests/Main.hs ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ totalNumbers :: [Int] -> Int
7
+ totalNumbers digits = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (totalNumbers [1,2,3,4])," 12 (totalNumbers [1,2,3,4]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (totalNumbers [0,2,2])," 2 (totalNumbers [0,2,2]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (totalNumbers [6,6,6])," 1 (totalNumbers [6,6,6]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (totalNumbers [1,3,5])," 0 (totalNumbers [1,3,5]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (totalNumbers [7, 9, 2, 1])," 6 (totalNumbers [7, 9, 2, 1]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (totalNumbers [1, 7, 4, 7, 8, 4, 7, 2, 2])," 59 (totalNumbers [1, 7, 4, 7, 8, 4, 7, 2, 2]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (totalNumbers [1, 3, 1])," 0 (totalNumbers [1, 3, 1]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (totalNumbers [4, 8, 0, 3, 0, 1, 7])," 57 (totalNumbers [4, 8, 0, 3, 0, 1, 7]))
36
+
37
+ test9 :: Test
38
+ test9 = TestCase (assertEqual "for (totalNumbers [3, 3, 1, 8, 8, 5, 4, 5])," 37 (totalNumbers [3, 3, 1, 8, 8, 5, 4, 5]))
39
+
40
+
41
+ -- Grouping test cases
42
+ tests :: Test
43
+ 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]
44
+
45
+ -- Running the tests
46
+ main :: IO Counts
47
+ main = runTestTT tests
unique_3_digit_even_numbers/java_tests/Main.java ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(12, totalNumbers(Arrays.asList(1,2,3,4)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(2, totalNumbers(Arrays.asList(0,2,2)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(1, totalNumbers(Arrays.asList(6,6,6)));
22
+ }
23
+ @Test
24
+ public void test4() {
25
+ assertEquals(0, totalNumbers(Arrays.asList(1,3,5)));
26
+ }
27
+
28
+ }