DatasetRepo commited on
Commit
6c3b977
·
verified ·
1 Parent(s): 1746633

d2d40aab49b4a8ad1e98133439810184eac51541cac4032761d3ca8a595a5464

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 +2 -0
  2. removing_minimum_number_of_magic_beans/scala_tests/MySuite.scala +12 -0
  3. removing_stars_from_a_string/.DS_Store +0 -0
  4. removing_stars_from_a_string/haskell_tests/Main.hs +24 -0
  5. removing_stars_from_a_string/java_tests/Main.java +21 -0
  6. removing_stars_from_a_string/meta.json +26 -0
  7. removing_stars_from_a_string/ocaml_tests/main.ml +26 -0
  8. removing_stars_from_a_string/scala_tests/MySuite.scala +12 -0
  9. replace_elements_in_an_array/.DS_Store +0 -0
  10. replace_elements_in_an_array/haskell_tests/Main.hs +24 -0
  11. replace_elements_in_an_array/java_tests/Main.java +21 -0
  12. replace_elements_in_an_array/meta.json +26 -0
  13. replace_elements_in_an_array/ocaml_tests/main.ml +26 -0
  14. replace_elements_in_an_array/scala_tests/MySuite.scala +12 -0
  15. replace_non_coprime_numbers_in_array/.DS_Store +0 -0
  16. replace_non_coprime_numbers_in_array/haskell_tests/Main.hs +24 -0
  17. replace_non_coprime_numbers_in_array/java_tests/Main.java +21 -0
  18. replace_non_coprime_numbers_in_array/meta.json +3 -0
  19. replace_non_coprime_numbers_in_array/ocaml_tests/main.ml +26 -0
  20. replace_non_coprime_numbers_in_array/scala_tests/MySuite.scala +12 -0
  21. replace_question_marks_in_string_to_minimize_its_value/haskell_tests/Main.hs +0 -0
  22. replace_question_marks_in_string_to_minimize_its_value/java_tests/Main.java +20 -0
  23. replace_question_marks_in_string_to_minimize_its_value/meta.json +0 -0
  24. replace_question_marks_in_string_to_minimize_its_value/ocaml_tests/main.ml +0 -0
  25. replace_question_marks_in_string_to_minimize_its_value/scala_tests/MySuite.scala +0 -0
  26. report_spam_message/java_tests/Main.java +21 -0
  27. right_triangles/java_tests/Main.java +24 -0
  28. robot_collisions/haskell_tests/Main.hs +0 -0
  29. robot_collisions/java_tests/Main.java +25 -0
  30. robot_collisions/meta.json +3 -0
  31. robot_collisions/ocaml_tests/main.ml +0 -0
  32. robot_collisions/scala_tests/MySuite.scala +0 -0
  33. row_with_maximum_ones/.DS_Store +0 -0
  34. row_with_maximum_ones/haskell_tests/Main.hs +27 -0
  35. row_with_maximum_ones/java_tests/Main.java +25 -0
  36. row_with_maximum_ones/meta.json +0 -0
  37. row_with_maximum_ones/ocaml_tests/main.ml +29 -0
  38. row_with_maximum_ones/scala_tests/MySuite.scala +16 -0
  39. score_of_a_string/haskell_tests/Main.hs +41 -0
  40. score_of_a_string/java_tests/Main.java +20 -0
  41. score_of_a_string/meta.json +47 -0
  42. score_of_a_string/ocaml_tests/main.ml +42 -0
  43. score_of_a_string/scala_tests/MySuite.scala +32 -0
  44. select_k_disjoint_special_substrings/haskell_tests/Main.hs +0 -0
  45. select_k_disjoint_special_substrings/java_tests/Main.java +25 -0
  46. select_k_disjoint_special_substrings/meta.json +0 -0
  47. select_k_disjoint_special_substrings/ocaml_tests/main.ml +0 -0
  48. select_k_disjoint_special_substrings/scala_tests/MySuite.scala +0 -0
  49. semi_ordered_permutation/haskell_tests/Main.hs +44 -0
  50. semi_ordered_permutation/java_tests/Main.java +24 -0
.gitattributes CHANGED
@@ -271,3 +271,5 @@ remove_methods_from_project/meta.json filter=lfs diff=lfs merge=lfs -text
271
  remove_methods_from_project/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text
272
  remove_methods_from_project/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text
273
  removing_minimum_number_of_magic_beans/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
271
  remove_methods_from_project/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text
272
  remove_methods_from_project/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text
273
  removing_minimum_number_of_magic_beans/meta.json filter=lfs diff=lfs merge=lfs -text
274
+ replace_non_coprime_numbers_in_array/meta.json filter=lfs diff=lfs merge=lfs -text
275
+ robot_collisions/meta.json filter=lfs diff=lfs merge=lfs -text
removing_minimum_number_of_magic_beans/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumRemoval(List(4,1,6,5)), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumRemoval(List(2,10,3,2)), 7)
10
+ }
11
+
12
+ }
removing_stars_from_a_string/.DS_Store ADDED
Binary file (6.15 kB). View file
 
removing_stars_from_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 (removeStars \"leet**cod*e \")," "lecoe" (removeStars "leet**cod*e"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (removeStars \"erase***** \")," "" (removeStars "erase*****"))
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
removing_stars_from_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("leet**cod*e", removeStars("leet**cod*e"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals("erase*****", removeStars("erase*****"));
19
+ }
20
+
21
+ }
removing_stars_from_a_string/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2470,
3
+ "name": "removing_stars_from_a_string",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/removing-stars-from-a-string/",
6
+ "date": "1661040000000",
7
+ "task_description": "You are given a string `s`, which contains stars `*`. In one operation, you can: Choose a star in `s`. Remove the closest **non-star** character to its **left**, as well as remove the star itself. Return _the string after **all** stars have been removed_. **Note:** The input will be generated such that the operation is always possible. It can be shown that the resulting string will always be unique. **Example 1:** ``` **Input:** s = \"leet**cod*e\" **Output:** \"lecoe\" **Explanation:** Performing the removals from left to right: - The closest character to the 1st star is 't' in \"lee**t****cod*e\". s becomes \"lee*cod*e\". - The closest character to the 2nd star is 'e' in \"le**e***cod*e\". s becomes \"lecod*e\". - The closest character to the 3rd star is 'd' in \"leco**d***e\". s becomes \"lecoe\". There are no more stars, so we return \"lecoe\". ``` **Example 2:** ``` **Input:** s = \"erase*****\" **Output:** \"\" **Explanation:** The entire string is removed, so we return an empty string. ``` **Constraints:** `1 <= s.length <= 105` `s` consists of lowercase English letters and stars `*`. The operation above can be performed on `s`.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"leet**cod*e\"",
12
+ "output": "\"lecoe\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"erase*****\"",
17
+ "output": "\"\" "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "removeStars :: String -> String\nremoveStars s ",
22
+ "ocaml_template": "let removeStars (s: string) : string = ",
23
+ "scala_template": "def removeStars(s: String): String = { \n \n}",
24
+ "java_template": "public static String removeStars(String s) {\n\n}",
25
+ "python_template": "class Solution(object):\n def removeStars(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
26
+ }
removing_stars_from_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 "lecoe" (removeStars "leet**cod*e")
12
+
13
+ let test2 _ = assert_equal "" (removeStars "erase*****")
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for removeStars" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
removing_stars_from_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.removeStars("leet**cod*e"), "lecoe")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.removeStars("erase*****"), "")
10
+ }
11
+
12
+ }
replace_elements_in_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
replace_elements_in_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 (arrayChange [1,2,4,6] [[1,3],[4,7],[6,1]])," [3,2,7,1] (arrayChange [1,2,4,6] [[1,3],[4,7],[6,1]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (arrayChange [1,2] [[1,3],[2,1],[3,2]])," [2,1] (arrayChange [1,2] [[1,3],[2,1],[3,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
replace_elements_in_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(3,2,7,1)), arrayChange(new ArrayList<>(Arrays.asList(1,2,4,6)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(4,7)),new ArrayList<>(Arrays.asList(6,1))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(2,1)), arrayChange(new ArrayList<>(Arrays.asList(1,2)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(2,1)),new ArrayList<>(Arrays.asList(3,2))))));
19
+ }
20
+
21
+ }
replace_elements_in_an_array/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2388,
3
+ "name": "replace_elements_in_an_array",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/replace-elements-in-an-array/",
6
+ "date": "1653782400000",
7
+ "task_description": "You are given a **0-indexed** array `nums` that consists of `n` **distinct** positive integers. Apply `m` operations to this array, where in the `ith` operation you replace the number `operations[i][0]` with `operations[i][1]`. It is guaranteed that in the `ith` operation: `operations[i][0]` **exists** in `nums`. `operations[i][1]` does **not** exist in `nums`. Return _the array obtained after applying all the operations_. **Example 1:** ``` **Input:** nums = [1,2,4,6], operations = [[1,3],[4,7],[6,1]] **Output:** [3,2,7,1] **Explanation:** We perform the following operations on nums: - Replace the number 1 with 3. nums becomes [**3**,2,4,6]. - Replace the number 4 with 7. nums becomes [3,2,**7**,6]. - Replace the number 6 with 1. nums becomes [3,2,7,**1**]. We return the final array [3,2,7,1]. ``` **Example 2:** ``` **Input:** nums = [1,2], operations = [[1,3],[2,1],[3,2]] **Output:** [2,1] **Explanation:** We perform the following operations to nums: - Replace the number 1 with 3. nums becomes [**3**,2]. - Replace the number 2 with 1. nums becomes [3,**1**]. - Replace the number 3 with 2. nums becomes [**2**,1]. We return the array [2,1]. ``` **Constraints:** `n == nums.length` `m == operations.length` `1 <= n, m <= 105` All the values of `nums` are **distinct**. `operations[i].length == 2` `1 <= nums[i], operations[i][0], operations[i][1] <= 106` `operations[i][0]` will exist in `nums` when applying the `ith` operation. `operations[i][1]` will not exist in `nums` when applying the `ith` operation.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,2,4,6], operations = [[1,3],[4,7],[6,1]]",
12
+ "output": "[3,2,7,1] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,2], operations = [[1,3],[2,1],[3,2]]",
17
+ "output": "[2,1] "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "arrayChange :: [Int] -> [[Int]] -> [Int]\narrayChange nums operations ",
22
+ "ocaml_template": "let arrayChange (nums: int list) (operations: int list list) : int list = ",
23
+ "scala_template": "def arrayChange(nums: List[Int],operations: List[List[Int]]): List[Int] = { \n \n}",
24
+ "java_template": "public static List<Integer> arrayChange(List<Integer> nums, List<List<Integer>> operations) {\n\n}",
25
+ "python_template": "class Solution(object):\n def arrayChange(self, nums, operations):\n \"\"\"\n :type nums: List[int]\n :type operations: List[List[int]]\n :rtype: List[int]\n \"\"\"\n "
26
+ }
replace_elements_in_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 [3;2;7;1] (arrayChange [1;2;4;6] [[1;3];[4;7];[6;1]])
12
+
13
+ let test2 _ = assert_equal [2;1] (arrayChange [1;2] [[1;3];[2;1];[3;2]])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for arrayChange" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
replace_elements_in_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.arrayChange(List(1,2,4,6),List(List(1,3),List(4,7),List(6,1))), List(3,2,7,1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.arrayChange(List(1,2),List(List(1,3),List(2,1),List(3,2))), List(2,1))
10
+ }
11
+
12
+ }
replace_non_coprime_numbers_in_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
replace_non_coprime_numbers_in_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 (replaceNonCoprimes [6,4,3,2,7,6,2])," [12,7,6] (replaceNonCoprimes [6,4,3,2,7,6,2]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (replaceNonCoprimes [2,2,1,1,3,3,3])," [2,1,1,3] (replaceNonCoprimes [2,2,1,1,3,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
replace_non_coprime_numbers_in_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(12,7,6)), replaceNonCoprimes(new ArrayList<>(Arrays.asList(6,4,3,2,7,6,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(2,1,1,3)), replaceNonCoprimes(new ArrayList<>(Arrays.asList(2,2,1,1,3,3,3))));
19
+ }
20
+
21
+ }
replace_non_coprime_numbers_in_array/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20f02c5e5414064f48ff4c8ed531a28ef83b1dca44151eafbab872bb1c36360a
3
+ size 21354474
replace_non_coprime_numbers_in_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 [12;7;6] (replaceNonCoprimes [6;4;3;2;7;6;2])
12
+
13
+ let test2 _ = assert_equal [2;1;1;3] (replaceNonCoprimes [2;2;1;1;3;3;3])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for replaceNonCoprimes" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
replace_non_coprime_numbers_in_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.replaceNonCoprimes(List(6,4,3,2,7,6,2)), List(12,7,6))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.replaceNonCoprimes(List(2,2,1,1,3,3,3)), List(2,1,1,3))
10
+ }
11
+
12
+ }
replace_question_marks_in_string_to_minimize_its_value/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
replace_question_marks_in_string_to_minimize_its_value/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("???", minimizeStringValue("???"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("a?a?", minimizeStringValue("a?a?"));
18
+ }
19
+
20
+ }
replace_question_marks_in_string_to_minimize_its_value/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
replace_question_marks_in_string_to_minimize_its_value/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
replace_question_marks_in_string_to_minimize_its_value/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
report_spam_message/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, reportSpam(new ArrayList<>(Arrays.asList("hello","world","leetcode")), new ArrayList<>(Arrays.asList("world","hello"))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, reportSpam(new ArrayList<>(Arrays.asList("hello","programming","fun")), new ArrayList<>(Arrays.asList("world","programming","leetcode"))));
19
+ }
20
+
21
+ }
right_triangles/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(2, numberOfRightTriangles(Arrays.asList(Arrays.asList(0,1,0),Arrays.asList(0,1,1),Arrays.asList(0,1,0))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(0, numberOfRightTriangles(Arrays.asList(Arrays.asList(1,0,0,0),Arrays.asList(0,1,0,1),Arrays.asList(1,0,0,0))));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(2, numberOfRightTriangles(Arrays.asList(Arrays.asList(1,0,1),Arrays.asList(1,0,0),Arrays.asList(1,0,0))));
22
+ }
23
+
24
+ }
robot_collisions/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
robot_collisions/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(new ArrayList<>(Arrays.asList(2,17,9,15,10)), survivedRobotsHealths(new ArrayList<>(Arrays.asList(5,4,3,2,1)), new ArrayList<>(Arrays.asList(2,17,9,15,10)), "RRRRR"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(14)), survivedRobotsHealths(new ArrayList<>(Arrays.asList(3,5,2,6)), new ArrayList<>(Arrays.asList(10,10,15,12)), "RLRL"));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(new ArrayList<>(), survivedRobotsHealths(new ArrayList<>(Arrays.asList(1,2,5,6)), new ArrayList<>(Arrays.asList(10,10,11,11)), "RLRL"));
23
+ }
24
+
25
+ }
robot_collisions/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3222b175943033f09102eb2d3fbd7018d881b58273dfe6be80c4e009846735ee
3
+ size 19116988
robot_collisions/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
robot_collisions/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
row_with_maximum_ones/.DS_Store ADDED
Binary file (6.15 kB). View file
 
row_with_maximum_ones/haskell_tests/Main.hs ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (rowAndMaximumOnes [[0,1],[1,0]])," [0,1] (rowAndMaximumOnes [[0,1],[1,0]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (rowAndMaximumOnes [[0,0,0],[0,1,1]])," [1,2] (rowAndMaximumOnes [[0,0,0],[0,1,1]]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (rowAndMaximumOnes [[0,0],[1,1],[0,0]])," [1,2] (rowAndMaximumOnes [[0,0],[1,1],[0,0]]))
19
+
20
+
21
+ -- Grouping test cases
22
+ tests :: Test
23
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
24
+
25
+ -- Running the tests
26
+ main :: IO Counts
27
+ main = runTestTT tests
row_with_maximum_ones/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(new ArrayList<>(Arrays.asList(0,1)), rowAndMaximumOnes(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(1,0))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(1,2)), rowAndMaximumOnes(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,0,0)),new ArrayList<>(Arrays.asList(0,1,1))))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(new ArrayList<>(Arrays.asList(1,2)), rowAndMaximumOnes(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,0)),new ArrayList<>(Arrays.asList(1,1)),new ArrayList<>(Arrays.asList(0,0))))));
23
+ }
24
+
25
+ }
row_with_maximum_ones/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
row_with_maximum_ones/ocaml_tests/main.ml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal [0;1] (rowAndMaximumOnes [[0;1];[1;0]])
12
+
13
+ let test2 _ = assert_equal [1;2] (rowAndMaximumOnes [[0;0;0];[0;1;1]])
14
+
15
+ let test3 _ = assert_equal [1;2] (rowAndMaximumOnes [[0;0];[1;1];[0;0]])
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for rowAndMaximumOnes" >::: [
20
+
21
+ "test1" >:: test1;
22
+ "test2" >:: test2;
23
+ "test3" >:: test3;
24
+ ]
25
+
26
+
27
+ (* Running the tests *)
28
+ let () = run_test_tt_main suite
29
+ end
row_with_maximum_ones/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.rowAndMaximumOnes(List(List(0,1),List(1,0))), List(0,1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.rowAndMaximumOnes(List(List(0,0,0),List(0,1,1))), List(1,2))
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.rowAndMaximumOnes(List(List(0,0),List(1,1),List(0,0))), List(1,2))
14
+ }
15
+
16
+ }
score_of_a_string/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ scoreOfString :: String -> Int
7
+ scoreOfString s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (scoreOfString \"hello \")," 13 (scoreOfString "hello"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (scoreOfString \"zaz \")," 50 (scoreOfString "zaz"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (scoreOfString \"ggmnxugmzbgeuowbrszedcmslic \")," 214 (scoreOfString "ggmnxugmzbgeuowbrszedcmslic"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (scoreOfString \"wwd \")," 19 (scoreOfString "wwd"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (scoreOfString \"ixqhyzqwfcraprwdtoijaapsjhtdahmeuizvcxcfmnmjycthgiwcetjavtkaziffkpgivsuwujrjd \")," 701 (scoreOfString "ixqhyzqwfcraprwdtoijaapsjhtdahmeuizvcxcfmnmjycthgiwcetjavtkaziffkpgivsuwujrjd"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (scoreOfString \"mwlzgfibhouglxsgmuebmwazdxokswzwtbrjxrpwpccmxrcabffahzhujjmpcliarwwk \")," 594 (scoreOfString "mwlzgfibhouglxsgmuebmwazdxokswzwtbrjxrpwpccmxrcabffahzhujjmpcliarwwk"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (scoreOfString \"xdilrjtgkglzjeg \")," 115 (scoreOfString "xdilrjtgkglzjeg"))
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
score_of_a_string/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(13, scoreOfString("hello"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(50, scoreOfString("zaz"));
18
+ }
19
+
20
+ }
score_of_a_string/meta.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3379,
3
+ "name": "score_of_a_string",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/score-of-a-string/",
6
+ "date": "2024-03-30 00:00:00",
7
+ "task_description": "You are given a string `s`. The **score** of a string is defined as the sum of the absolute difference between the **ASCII** values of adjacent characters. Return the **score** of_ _`s`. **Example 1:** **Input:** s = \"hello\" **Output:** 13 **Explanation:** The **ASCII** values of the characters in `s` are: `'h' = 104`, `'e' = 101`, `'l' = 108`, `'o' = 111`. So, the score of `s` would be `|104 - 101| + |101 - 108| + |108 - 108| + |108 - 111| = 3 + 7 + 0 + 3 = 13`. **Example 2:** **Input:** s = \"zaz\" **Output:** 50 **Explanation:** The **ASCII** values of the characters in `s` are: `'z' = 122`, `'a' = 97`. So, the score of `s` would be `|122 - 97| + |97 - 122| = 25 + 25 = 50`. **Constraints:** `2 <= s.length <= 100` `s` consists only of lowercase English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"hello\"",
12
+ "output": "13 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"zaz\"",
17
+ "output": "50 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "ggmnxugmzbgeuowbrszedcmslic",
23
+ "output": 214
24
+ },
25
+ {
26
+ "input": "wwd",
27
+ "output": 19
28
+ },
29
+ {
30
+ "input": "ixqhyzqwfcraprwdtoijaapsjhtdahmeuizvcxcfmnmjycthgiwcetjavtkaziffkpgivsuwujrjd",
31
+ "output": 701
32
+ },
33
+ {
34
+ "input": "mwlzgfibhouglxsgmuebmwazdxokswzwtbrjxrpwpccmxrcabffahzhujjmpcliarwwk",
35
+ "output": 594
36
+ },
37
+ {
38
+ "input": "xdilrjtgkglzjeg",
39
+ "output": 115
40
+ }
41
+ ],
42
+ "haskell_template": "scoreOfString :: String -> Int\nscoreOfString s ",
43
+ "ocaml_template": "let scoreOfString (s: string) : int = ",
44
+ "scala_template": "def scoreOfString(s: String): Int = { \n \n}",
45
+ "java_template": "class Solution {\n public int scoreOfString(String s) {\n \n }\n}",
46
+ "python_template": "class Solution(object):\n def scoreOfString(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n "
47
+ }
score_of_a_string/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let scoreOfString (s: string) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 13 (scoreOfString "hello")
13
+
14
+ let test2 _ = assert_equal 50 (scoreOfString "zaz")
15
+
16
+ let test3 _ = assert_equal 50 (scoreOfString "ggmnxugmzbgeuowbrszedcmslic")
17
+
18
+ let test4 _ = assert_equal 50 (scoreOfString "wwd")
19
+
20
+ let test5 _ = assert_equal 50 (scoreOfString "ixqhyzqwfcraprwdtoijaapsjhtdahmeuizvcxcfmnmjycthgiwcetjavtkaziffkpgivsuwujrjd")
21
+
22
+ let test6 _ = assert_equal 50 (scoreOfString "mwlzgfibhouglxsgmuebmwazdxokswzwtbrjxrpwpccmxrcabffahzhujjmpcliarwwk")
23
+
24
+ let test7 _ = assert_equal 50 (scoreOfString "xdilrjtgkglzjeg")
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for scoreOfString" >::: [
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
score_of_a_string/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.scoreOfString("hello"), 13)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.scoreOfString("zaz"), 50)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.scoreOfString(",g,g,m,n,x,u,g,m,z,b,g,e,u,o,w,b,r,s,z,e,d,c,m,s,l,i,c,"), 214)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.scoreOfString(",w,w,d,"), 19)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.scoreOfString(",i,x,q,h,y,z,q,w,f,c,r,a,p,r,w,d,t,o,i,j,a,a,p,s,j,h,t,d,a,h,m,e,u,i,z,v,c,x,c,f,m,n,m,j,y,c,t,h,g,i,w,c,e,t,j,a,v,t,k,a,z,i,f,f,k,p,g,i,v,s,u,w,u,j,r,j,d,"), 701)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.scoreOfString(",m,w,l,z,g,f,i,b,h,o,u,g,l,x,s,g,m,u,e,b,m,w,a,z,d,x,o,k,s,w,z,w,t,b,r,j,x,r,p,w,p,c,c,m,x,r,c,a,b,f,f,a,h,z,h,u,j,j,m,p,c,l,i,a,r,w,w,k,"), 594)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.scoreOfString(",x,d,i,l,r,j,t,g,k,g,l,z,j,e,g,"), 115)
30
+ }
31
+
32
+ }
select_k_disjoint_special_substrings/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
select_k_disjoint_special_substrings/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(true, maxSubstringLength("abcdbaefab", 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, maxSubstringLength("cdefdc", 3));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(true, maxSubstringLength("abeabe", 0));
23
+ }
24
+
25
+ }
select_k_disjoint_special_substrings/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
select_k_disjoint_special_substrings/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
select_k_disjoint_special_substrings/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
semi_ordered_permutation/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ semiOrderedPermutation :: [Int] -> Int
7
+ semiOrderedPermutation nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (semiOrderedPermutation [2,1,4,3])," 2 (semiOrderedPermutation [2,1,4,3]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (semiOrderedPermutation [2,4,1,3])," 3 (semiOrderedPermutation [2,4,1,3]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (semiOrderedPermutation [1,3,4,2,5])," 0 (semiOrderedPermutation [1,3,4,2,5]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (semiOrderedPermutation [7, 18, 21, 5, 24, 10, 1, 12, 17, 2, 9, 8, 20, 15, 22, 23, 6, 16, 13, 4, 3, 19, 14, 11])," 24 (semiOrderedPermutation [7, 18, 21, 5, 24, 10, 1, 12, 17, 2, 9, 8, 20, 15, 22, 23, 6, 16, 13, 4, 3, 19, 14, 11]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (semiOrderedPermutation [10, 15, 7, 11, 13, 14, 3, 2, 16, 5, 12, 4, 8, 9, 1, 6])," 20 (semiOrderedPermutation [10, 15, 7, 11, 13, 14, 3, 2, 16, 5, 12, 4, 8, 9, 1, 6]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (semiOrderedPermutation [3, 5, 4, 1, 2])," 5 (semiOrderedPermutation [3, 5, 4, 1, 2]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (semiOrderedPermutation [30, 5, 2, 6, 28, 26, 21, 32, 18, 27, 8, 24, 16, 34, 14, 19, 37, 4, 23, 7, 11, 1, 31, 20, 35, 33, 36, 17, 29, 25, 13, 22, 10, 12, 3, 9, 15])," 40 (semiOrderedPermutation [30, 5, 2, 6, 28, 26, 21, 32, 18, 27, 8, 24, 16, 34, 14, 19, 37, 4, 23, 7, 11, 1, 31, 20, 35, 33, 36, 17, 29, 25, 13, 22, 10, 12, 3, 9, 15]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (semiOrderedPermutation [25, 6, 11, 10, 1, 32, 14, 39, 35, 15, 20, 4, 33, 22, 24, 31, 37, 34, 19, 23, 8, 26, 36, 12, 27, 21, 16, 7, 9, 29, 3, 2, 18, 5, 38, 13, 28, 30, 17])," 35 (semiOrderedPermutation [25, 6, 11, 10, 1, 32, 14, 39, 35, 15, 20, 4, 33, 22, 24, 31, 37, 34, 19, 23, 8, 26, 36, 12, 27, 21, 16, 7, 9, 29, 3, 2, 18, 5, 38, 13, 28, 30, 17]))
36
+
37
+
38
+ -- Grouping test cases
39
+ tests :: Test
40
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
41
+
42
+ -- Running the tests
43
+ main :: IO Counts
44
+ main = runTestTT tests
semi_ordered_permutation/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(2, semiOrderedPermutation(Arrays.asList(2,1,4,3)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(3, semiOrderedPermutation(Arrays.asList(2,4,1,3)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(0, semiOrderedPermutation(Arrays.asList(1,3,4,2,5)));
22
+ }
23
+
24
+ }