DatasetRepo commited on
Commit
e082442
·
verified ·
1 Parent(s): 2be5fb2

353c15902798457bfcfe773894f1f96829c77e28e06534d5893bcd1bf0591cb1

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. check_if_strings_can_be_made_equal_with_operations_ii/.DS_Store +0 -0
  3. check_if_strings_can_be_made_equal_with_operations_ii/haskell_tests/Main.hs +24 -0
  4. check_if_strings_can_be_made_equal_with_operations_ii/java_tests/Main.java +21 -0
  5. check_if_strings_can_be_made_equal_with_operations_ii/meta.json +0 -0
  6. check_if_strings_can_be_made_equal_with_operations_ii/ocaml_tests/main.ml +26 -0
  7. check_if_strings_can_be_made_equal_with_operations_ii/scala_tests/MySuite.scala +12 -0
  8. check_if_the_rectangle_corner_is_reachable/haskell_tests/Main.hs +0 -0
  9. check_if_the_rectangle_corner_is_reachable/java_tests/Main.java +29 -0
  10. check_if_the_rectangle_corner_is_reachable/meta.json +0 -0
  11. check_if_the_rectangle_corner_is_reachable/ocaml_tests/main.ml +0 -0
  12. check_if_the_rectangle_corner_is_reachable/scala_tests/MySuite.scala +0 -0
  13. check_if_there_is_a_valid_parentheses_string_path/.DS_Store +0 -0
  14. check_if_there_is_a_valid_parentheses_string_path/haskell_tests/Main.hs +24 -0
  15. check_if_there_is_a_valid_parentheses_string_path/java_tests/Main.java +21 -0
  16. check_if_there_is_a_valid_parentheses_string_path/meta.json +0 -0
  17. check_if_there_is_a_valid_parentheses_string_path/ocaml_tests/main.ml +26 -0
  18. check_if_there_is_a_valid_parentheses_string_path/scala_tests/MySuite.scala +12 -0
  19. check_if_there_is_a_valid_partition_for_the_array/.DS_Store +0 -0
  20. check_if_there_is_a_valid_partition_for_the_array/haskell_tests/Main.hs +24 -0
  21. check_if_there_is_a_valid_partition_for_the_array/java_tests/Main.java +21 -0
  22. check_if_there_is_a_valid_partition_for_the_array/meta.json +0 -0
  23. check_if_there_is_a_valid_partition_for_the_array/ocaml_tests/main.ml +26 -0
  24. check_if_there_is_a_valid_partition_for_the_array/scala_tests/MySuite.scala +12 -0
  25. check_if_two_chessboard_squares_have_the_same_color/haskell_tests/Main.hs +45 -0
  26. check_if_two_chessboard_squares_have_the_same_color/java_tests/Main.java +21 -0
  27. check_if_two_chessboard_squares_have_the_same_color/meta.json +97 -0
  28. check_if_two_chessboard_squares_have_the_same_color/ocaml_tests/main.ml +50 -0
  29. check_if_two_chessboard_squares_have_the_same_color/scala_tests/MySuite.scala +44 -0
  30. circular_sentence/.DS_Store +0 -0
  31. circular_sentence/haskell_tests/Main.hs +27 -0
  32. circular_sentence/java_tests/Main.java +25 -0
  33. circular_sentence/meta.json +72 -0
  34. circular_sentence/ocaml_tests/main.ml +29 -0
  35. circular_sentence/scala_tests/MySuite.scala +16 -0
  36. clear_digits/haskell_tests/Main.hs +41 -0
  37. clear_digits/java_tests/Main.java +20 -0
  38. clear_digits/meta.json +47 -0
  39. clear_digits/ocaml_tests/main.ml +42 -0
  40. clear_digits/scala_tests/MySuite.scala +32 -0
  41. closest_equal_element_queries/haskell_tests/Main.hs +0 -0
  42. closest_equal_element_queries/java_tests/Main.java +21 -0
  43. closest_equal_element_queries/meta.json +3 -0
  44. closest_equal_element_queries/ocaml_tests/main.ml +0 -0
  45. closest_equal_element_queries/scala_tests/MySuite.scala +0 -0
  46. closest_prime_numbers_in_range/.DS_Store +0 -0
  47. closest_prime_numbers_in_range/haskell_tests/Main.hs +24 -0
  48. closest_prime_numbers_in_range/java_tests/Main.java +21 -0
  49. closest_prime_numbers_in_range/meta.json +127 -0
  50. closest_prime_numbers_in_range/ocaml_tests/main.ml +26 -0
.gitattributes CHANGED
@@ -71,3 +71,4 @@ check_if_grid_can_be_cut_into_sections/haskell_tests/Main.hs filter=lfs diff=lfs
71
  check_if_grid_can_be_cut_into_sections/meta.json filter=lfs diff=lfs merge=lfs -text
72
  check_if_grid_can_be_cut_into_sections/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text
73
  check_if_grid_can_be_cut_into_sections/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text
 
 
71
  check_if_grid_can_be_cut_into_sections/meta.json filter=lfs diff=lfs merge=lfs -text
72
  check_if_grid_can_be_cut_into_sections/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text
73
  check_if_grid_can_be_cut_into_sections/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text
74
+ closest_equal_element_queries/meta.json filter=lfs diff=lfs merge=lfs -text
check_if_strings_can_be_made_equal_with_operations_ii/.DS_Store ADDED
Binary file (6.15 kB). View file
 
check_if_strings_can_be_made_equal_with_operations_ii/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (checkStrings \"abcdba \" \"cabdab \")," True (checkStrings "abcdba" "cabdab"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (checkStrings \"abe \" \"bea \")," False (checkStrings "abe" "bea"))
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
check_if_strings_can_be_made_equal_with_operations_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(true, checkStrings("abcdba", "cabdab"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, checkStrings("abe", "bea"));
19
+ }
20
+
21
+ }
check_if_strings_can_be_made_equal_with_operations_ii/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
check_if_strings_can_be_made_equal_with_operations_ii/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal true (checkStrings "abcdba" "cabdab")
12
+
13
+ let test2 _ = assert_equal false (checkStrings "abe" "bea")
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for checkStrings" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
check_if_strings_can_be_made_equal_with_operations_ii/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.checkStrings("abcdba","cabdab"), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.checkStrings("abe","bea"), false)
10
+ }
11
+
12
+ }
check_if_the_rectangle_corner_is_reachable/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
check_if_the_rectangle_corner_is_reachable/java_tests/Main.java ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, canReachCorner(3, 4, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,1,1))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, canReachCorner(3, 3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,1,2))))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(false, canReachCorner(3, 3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,1,1)),new ArrayList<>(Arrays.asList(1,2,1))))));
23
+ }
24
+ @Test
25
+ public void test4() {
26
+ assertEquals(true, canReachCorner(4, 4, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,5,1))))));
27
+ }
28
+
29
+ }
check_if_the_rectangle_corner_is_reachable/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
check_if_the_rectangle_corner_is_reachable/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
check_if_the_rectangle_corner_is_reachable/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
check_if_there_is_a_valid_parentheses_string_path/.DS_Store ADDED
Binary file (6.15 kB). View file
 
check_if_there_is_a_valid_parentheses_string_path/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 (hasValidPath [[ \"( \", \"( \", \"( \"],[ \") \", \"( \", \") \"],[ \"( \", \"( \", \") \"],[ \"( \", \"( \", \") \"]])," True (hasValidPath [["(","(","("],[")","(",")"],["(","(",")"],["(","(",")"]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (hasValidPath [[ \") \", \") \"],[ \"( \", \"( \"]])," False (hasValidPath [[")",")"],["(","("]]))
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
check_if_there_is_a_valid_parentheses_string_path/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, hasValidPath(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("(","(","(")),new ArrayList<>(Arrays.asList(")","(",")")),new ArrayList<>(Arrays.asList("(","(",")")),new ArrayList<>(Arrays.asList("(","(",")"))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, hasValidPath(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(")",")")),new ArrayList<>(Arrays.asList("(","("))))));
19
+ }
20
+
21
+ }
check_if_there_is_a_valid_parentheses_string_path/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
check_if_there_is_a_valid_parentheses_string_path/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal true (hasValidPath [["(";"(";"("];[")";"(";")"];["(";"(";")"];["(";"(";")"]])
12
+
13
+ let test2 _ = assert_equal false (hasValidPath [[")";")"];["(";"("]])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for hasValidPath" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
check_if_there_is_a_valid_parentheses_string_path/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.hasValidPath(List(List("(","(","("),List(")","(",")"),List("(","(",")"),List("(","(",")"))), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.hasValidPath(List(List(")",")"),List("(","("))), false)
10
+ }
11
+
12
+ }
check_if_there_is_a_valid_partition_for_the_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
check_if_there_is_a_valid_partition_for_the_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 (validPartition [4,4,4,5,6])," True (validPartition [4,4,4,5,6]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (validPartition [1,1,1,2])," False (validPartition [1,1,1,2]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
check_if_there_is_a_valid_partition_for_the_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(true, validPartition(new ArrayList<>(Arrays.asList(4,4,4,5,6))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, validPartition(new ArrayList<>(Arrays.asList(1,1,1,2))));
19
+ }
20
+
21
+ }
check_if_there_is_a_valid_partition_for_the_array/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
check_if_there_is_a_valid_partition_for_the_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 true (validPartition [4;4;4;5;6])
12
+
13
+ let test2 _ = assert_equal false (validPartition [1;1;1;2])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for validPartition" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
check_if_there_is_a_valid_partition_for_the_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.validPartition(List(4,4,4,5,6)), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.validPartition(List(1,1,1,2)), false)
10
+ }
11
+
12
+ }
check_if_two_chessboard_squares_have_the_same_color/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 (checkTwoChessboards \"a1 \" \"c3 \")," True (checkTwoChessboards "a1" "c3"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (checkTwoChessboards \"a1 \" \"h3 \")," False (checkTwoChessboards "a1" "h3"))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (checkTwoChessboards \"e4 \" \"b5 \")," True (checkTwoChessboards "e4" "b5"))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (checkTwoChessboards \"c3 \" \"c5 \")," True (checkTwoChessboards "c3" "c5"))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (checkTwoChessboards \"g8 \" \"d6 \")," False (checkTwoChessboards "g8" "d6"))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (checkTwoChessboards \"e6 \" \"a8 \")," True (checkTwoChessboards "e6" "a8"))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (checkTwoChessboards \"d6 \" \"g7 \")," True (checkTwoChessboards "d6" "g7"))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (checkTwoChessboards \"c8 \" \"b5 \")," True (checkTwoChessboards "c8" "b5"))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (checkTwoChessboards \"c4 \" \"b3 \")," True (checkTwoChessboards "c4" "b3"))
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
check_if_two_chessboard_squares_have_the_same_color/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, checkTwoChessboards("a1", "c3"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, checkTwoChessboards("a1", "h3"));
19
+ }
20
+
21
+ }
check_if_two_chessboard_squares_have_the_same_color/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3553,
3
+ "name": "check_if_two_chessboard_squares_have_the_same_color",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/check-if-two-chessboard-squares-have-the-same-color/",
6
+ "date": "2024-08-25 00:00:00",
7
+ "task_description": "You are given two strings, `coordinate1` and `coordinate2`, representing the coordinates of a square on an `8 x 8` chessboard. Below is the chessboard for reference. Return `true` if these two squares have the same color and `false` otherwise. The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first (indicating its column), and the number second (indicating its row). **Example 1:** **Input:** coordinate1 = \"a1\", coordinate2 = \"c3\" **Output:** true **Explanation:** Both squares are black. **Example 2:** **Input:** coordinate1 = \"a1\", coordinate2 = \"h3\" **Output:** false **Explanation:** Square `\"a1\"` is black and `\"h3\"` is white. **Constraints:** `coordinate1.length == coordinate2.length == 2` `'a' <= coordinate1[0], coordinate2[0] <= 'h'` `'1' <= coordinate1[1], coordinate2[1] <= '8'`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "coordinate1 = \"a1\", coordinate2 = \"c3\"",
12
+ "output": "true "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "coordinate1 = \"a1\", coordinate2 = \"h3\"",
17
+ "output": "false "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"e4\"",
24
+ "\"b5\""
25
+ ],
26
+ "output": true
27
+ },
28
+ {
29
+ "input": [
30
+ "\"c3\"",
31
+ "\"c5\""
32
+ ],
33
+ "output": true
34
+ },
35
+ {
36
+ "input": [
37
+ "\"g8\"",
38
+ "\"d6\""
39
+ ],
40
+ "output": false
41
+ },
42
+ {
43
+ "input": [
44
+ "\"e6\"",
45
+ "\"a8\""
46
+ ],
47
+ "output": true
48
+ },
49
+ {
50
+ "input": [
51
+ "\"d6\"",
52
+ "\"g7\""
53
+ ],
54
+ "output": true
55
+ },
56
+ {
57
+ "input": [
58
+ "\"c8\"",
59
+ "\"b5\""
60
+ ],
61
+ "output": true
62
+ },
63
+ {
64
+ "input": [
65
+ "\"c4\"",
66
+ "\"b3\""
67
+ ],
68
+ "output": true
69
+ },
70
+ {
71
+ "input": [
72
+ "\"c7\"",
73
+ "\"f3\""
74
+ ],
75
+ "output": false
76
+ },
77
+ {
78
+ "input": [
79
+ "c3",
80
+ "d3"
81
+ ],
82
+ "output": false
83
+ },
84
+ {
85
+ "input": [
86
+ "e6",
87
+ "a6"
88
+ ],
89
+ "output": true
90
+ }
91
+ ],
92
+ "haskell_template": "checkTwoChessboards :: String -> String -> Bool\ncheckTwoChessboards coordinate1 coordinate2 ",
93
+ "ocaml_template": "let checkTwoChessboards (coordinate1: string) (coordinate2: string) : bool = ",
94
+ "scala_template": "def checkTwoChessboards(coordinate1: String,coordinate2: String): Boolean = { \n \n}",
95
+ "java_template": "class Solution {\n public boolean checkTwoChessboards(String coordinate1, String coordinate2) {\n \n }\n}",
96
+ "python_template": "class Solution(object):\n def checkTwoChessboards(self, coordinate1, coordinate2):\n \"\"\"\n :type coordinate1: str\n :type coordinate2: str\n :rtype: bool\n \"\"\"\n "
97
+ }
check_if_two_chessboard_squares_have_the_same_color/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 true (checkTwoChessboards "a1" "c3")
12
+
13
+ let test2 _ = assert_equal false (checkTwoChessboards "a1" "h3")
14
+
15
+ let test3 _ = assert_equal true (checkTwoChessboards "e4" "b5")
16
+
17
+ let test4 _ = assert_equal true (checkTwoChessboards "c3" "c5")
18
+
19
+ let test5 _ = assert_equal false (checkTwoChessboards "g8" "d6")
20
+
21
+ let test6 _ = assert_equal true (checkTwoChessboards "e6" "a8")
22
+
23
+ let test7 _ = assert_equal true (checkTwoChessboards "d6" "g7")
24
+
25
+ let test8 _ = assert_equal true (checkTwoChessboards "c8" "b5")
26
+
27
+ let test9 _ = assert_equal true (checkTwoChessboards "c4" "b3")
28
+
29
+ let test10 _ = assert_equal false (checkTwoChessboards "c7" "f3")
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for checkTwoChessboards" >::: [
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
check_if_two_chessboard_squares_have_the_same_color/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.checkTwoChessboards("a1","c3"), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.checkTwoChessboards("a1","h3"), false)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.checkTwoChessboards("e4","b5"), true)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.checkTwoChessboards("c3","c5"), true)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.checkTwoChessboards("g8","d6"), false)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.checkTwoChessboards("e6","a8"), true)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.checkTwoChessboards("d6","g7"), true)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.checkTwoChessboards("c8","b5"), true)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.checkTwoChessboards("c4","b3"), true)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.checkTwoChessboards("c7","f3"), false)
42
+ }
43
+
44
+ }
circular_sentence/.DS_Store ADDED
Binary file (6.15 kB). View file
 
circular_sentence/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 (isCircularSentence \"leetcode exercises sound delightful \")," True (isCircularSentence "leetcode exercises sound delightful"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (isCircularSentence \"eetcode \")," True (isCircularSentence "eetcode"))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (isCircularSentence \"Leetcode is cool \")," False (isCircularSentence "Leetcode is cool"))
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
circular_sentence/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, isCircularSentence("leetcode exercises sound delightful"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(true, isCircularSentence("eetcode"));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(false, isCircularSentence("Leetcode is cool"));
23
+ }
24
+
25
+ }
circular_sentence/meta.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2580,
3
+ "name": "circular_sentence",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/circular-sentence/",
6
+ "date": "1669507200000",
7
+ "task_description": "A **sentence** is a list of words that are separated by a** single** space with no leading or trailing spaces. For example, `\"Hello World\"`, `\"HELLO\"`, `\"hello world hello world\"` are all sentences. Words consist of **only** uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different. A sentence is **circular **if: The last character of each word in the sentence is equal to the first character of its next word. The last character of the last word is equal to the first character of the first word. For example, `\"leetcode exercises sound delightful\"`, `\"eetcode\"`, `\"leetcode eats soul\" `are all circular sentences. However, `\"Leetcode is cool\"`, `\"happy Leetcode\"`, `\"Leetcode\"` and `\"I like Leetcode\"` are **not** circular sentences. Given a string `sentence`, return `true`_ if it is circular_. Otherwise, return `false`. **Example 1:** ``` **Input:** sentence = \"leetcode exercises sound delightful\" **Output:** true **Explanation:** The words in sentence are [\"leetcode\", \"exercises\", \"sound\", \"delightful\"]. - leetcode's last character is equal to exercises's first character. - exercises's last character is equal to sound's first character. - sound's last character is equal to delightful's first character. - delightful's last character is equal to leetcode's first character. The sentence is circular. ``` **Example 2:** ``` **Input:** sentence = \"eetcode\" **Output:** true **Explanation:** The words in sentence are [\"eetcode\"]. - eetcode's last character is equal to eetcode's first character. The sentence is circular. ``` **Example 3:** ``` **Input:** sentence = \"Leetcode is cool\" **Output:** false **Explanation:** The words in sentence are [\"Leetcode\", \"is\", \"cool\"]. - Leetcode's last character is **not** equal to is's first character. The sentence is **not** circular. ``` **Constraints:** `1 <= sentence.length <= 500` `sentence` consist of only lowercase and uppercase English letters and spaces. The words in `sentence` are separated by a single space. There are no leading or trailing spaces.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "sentence = \"leetcode exercises sound delightful\"",
12
+ "output": "true "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "sentence = \"eetcode\"",
17
+ "output": "true "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "sentence = \"Leetcode is cool\"",
22
+ "output": "false "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": "fcZnbHp pei iAoZbnqm mWDGGD Di iMXRcUGLK Kz zcRGYyAnBf f",
28
+ "output": true
29
+ },
30
+ {
31
+ "input": "D uaJqqD",
32
+ "output": false
33
+ },
34
+ {
35
+ "input": "N NrEM MkoAiuySGT TOiZfnD DCgIEUdRqU UE E EZSM MpUNnDcbqG rLKN",
36
+ "output": false
37
+ },
38
+ {
39
+ "input": "UBtlaUe eg gpOO OnbRcYOZN Nh hYxI IF FNKcF U",
40
+ "output": false
41
+ },
42
+ {
43
+ "input": "EzMT T TmQWKWYkHb LnAE",
44
+ "output": false
45
+ },
46
+ {
47
+ "input": "IqbYMzrYe ZtJvpaCsKI",
48
+ "output": false
49
+ },
50
+ {
51
+ "input": "OHl lGnrlCD DsaTqWr ruFmGmrZIL LpeRgq qHqB BsnpLsO OcyPtyuNMh YdDWaGhNO",
52
+ "output": false
53
+ },
54
+ {
55
+ "input": "hGcSvPns s sb bIle efi idzVBlgKC CZwfPL LxrdEKsP PQhv uh",
56
+ "output": false
57
+ },
58
+ {
59
+ "input": "BDdnaHx xhzXRF FFOLQDOY fxtlLB",
60
+ "output": false
61
+ },
62
+ {
63
+ "input": "STFrHQT Tgq qksvHxq qaKXv vwmLoyUT TsVq S",
64
+ "output": false
65
+ }
66
+ ],
67
+ "haskell_template": "isCircularSentence :: String -> Bool\nisCircularSentence sentence ",
68
+ "ocaml_template": "let isCircularSentence (sentence: string) : bool = ",
69
+ "scala_template": "def isCircularSentence(sentence: String): Boolean = { \n \n}",
70
+ "java_template": "public static boolean isCircularSentence(String sentence) {\n\n}",
71
+ "python_template": "class Solution(object):\n def isCircularSentence(self, sentence):\n \"\"\"\n :type sentence: str\n :rtype: bool\n \"\"\"\n "
72
+ }
circular_sentence/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 true (isCircularSentence "leetcode exercises sound delightful")
12
+
13
+ let test2 _ = assert_equal true (isCircularSentence "eetcode")
14
+
15
+ let test3 _ = assert_equal false (isCircularSentence "Leetcode is cool")
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for isCircularSentence" >::: [
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
circular_sentence/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.isCircularSentence("leetcode exercises sound delightful"), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.isCircularSentence("eetcode"), true)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.isCircularSentence("Leetcode is cool"), false)
14
+ }
15
+
16
+ }
clear_digits/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ clearDigits :: String -> String
7
+ clearDigits s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (clearDigits \"abc \")," "abc" (clearDigits "abc"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (clearDigits \"cb34 \")," "" (clearDigits "cb34"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (clearDigits \"zkjf6chmfz72qgdpdyzty389j8dh \")," "zkjchmqgdpdydh" (clearDigits "zkjf6chmfz72qgdpdyzty389j8dh"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (clearDigits \"anar1l9tiiyl4pgt24zhc7qt7ixv4fetd9je34r5w8xsvb7yl7xvd78mayqqgy93jkwk5j2s2wwam7a0hkqsd \")," "anatiiypzhqixfetxsvyxmayqqjkwwwahkqsd" (clearDigits "anar1l9tiiyl4pgt24zhc7qt7ixv4fetd9je34r5w8xsvb7yl7xvd78mayqqgy93jkwk5j2s2wwam7a0hkqsd"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (clearDigits \"ies3kufsimsq5x6ilfx1mf2u16f7hikc6lmf7cptlvd4bdv82x62rwm2 \")," "iekufsimsilfhiklmcptlvrw" (clearDigits "ies3kufsimsq5x6ilfx1mf2u16f7hikc6lmf7cptlvd4bdv82x62rwm2"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (clearDigits \"5nq7mkio3abr9hx6y98dj965uhq55ehhen9f9xlgfnrkosl7i5xnse0ezbodlmjdsleucs \")," "mkiauehhexlgfnrkosxnsezbodlmjdsleucn" (clearDigits "5nq7mkio3abr9hx6y98dj965uhq55ehhen9f9xlgfnrkosl7i5xnse0ezbodlmjdsleucs"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (clearDigits \"9j9mihoo9i0083t0ew7b2onsmd6zv974js4uuhvtca5taauie6f6mpllei3uuvstb9qnap7reomimrh7n03 \")," "eonsjuuhvtctaauimplleuuvstqnareomimrm" (clearDigits "9j9mihoo9i0083t0ew7b2onsmd6zv974js4uuhvtca5taauie6f6mpllei3uuvstb9qnap7reomimrh7n03"))
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
clear_digits/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("abc", clearDigits("abc"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("cb34", clearDigits("cb34"));
18
+ }
19
+
20
+ }
clear_digits/meta.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3447,
3
+ "name": "clear_digits",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/clear-digits/",
6
+ "date": "2024-05-25 00:00:00",
7
+ "task_description": "You are given a string `s`. Your task is to remove **all** digits by doing this operation repeatedly: Delete the _first_ digit and the **closest** non-digit character to its _left_. Return the resulting string after removing all digits. **Note** that the operation _cannot_ be performed on a digit that does not have any non-digit character to its left. **Example 1:** **Input:** s = \"abc\" **Output:** \"abc\" **Explanation:** There is no digit in the string. **Example 2:** **Input:** s = \"cb34\" **Output:** \"\" **Explanation:** First, we apply the operation on `s[2]`, and `s` becomes `\"c4\"`. Then we apply the operation on `s[1]`, and `s` becomes `\"\"`. **Constraints:** `1 <= s.length <= 100` `s` consists only of lowercase English letters and digits. The input is generated such that it is possible to delete all digits.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"abc\"",
12
+ "output": "\"abc\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"cb34\"",
17
+ "output": "\"\" "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "zkjf6chmfz72qgdpdyzty389j8dh",
23
+ "output": "zkjchmqgdpdydh"
24
+ },
25
+ {
26
+ "input": "anar1l9tiiyl4pgt24zhc7qt7ixv4fetd9je34r5w8xsvb7yl7xvd78mayqqgy93jkwk5j2s2wwam7a0hkqsd",
27
+ "output": "anatiiypzhqixfetxsvyxmayqqjkwwwahkqsd"
28
+ },
29
+ {
30
+ "input": "ies3kufsimsq5x6ilfx1mf2u16f7hikc6lmf7cptlvd4bdv82x62rwm2",
31
+ "output": "iekufsimsilfhiklmcptlvrw"
32
+ },
33
+ {
34
+ "input": "5nq7mkio3abr9hx6y98dj965uhq55ehhen9f9xlgfnrkosl7i5xnse0ezbodlmjdsleucs",
35
+ "output": "mkiauehhexlgfnrkosxnsezbodlmjdsleucn"
36
+ },
37
+ {
38
+ "input": "9j9mihoo9i0083t0ew7b2onsmd6zv974js4uuhvtca5taauie6f6mpllei3uuvstb9qnap7reomimrh7n03",
39
+ "output": "eonsjuuhvtctaauimplleuuvstqnareomimrm"
40
+ }
41
+ ],
42
+ "haskell_template": "clearDigits :: String -> String\nclearDigits s ",
43
+ "ocaml_template": "let clearDigits (s: string) : string = ",
44
+ "scala_template": "def clearDigits(s: String): String = { \n \n}",
45
+ "java_template": "class Solution {\n public String clearDigits(String s) {\n \n }\n}",
46
+ "python_template": "class Solution(object):\n def clearDigits(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
47
+ }
clear_digits/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let clearDigits (s: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "abc" (clearDigits "abc")
13
+
14
+ let test2 _ = assert_equal "" (clearDigits "cb34")
15
+
16
+ let test3 _ = assert_equal "" (clearDigits "zkjf6chmfz72qgdpdyzty389j8dh")
17
+
18
+ let test4 _ = assert_equal "" (clearDigits "anar1l9tiiyl4pgt24zhc7qt7ixv4fetd9je34r5w8xsvb7yl7xvd78mayqqgy93jkwk5j2s2wwam7a0hkqsd")
19
+
20
+ let test5 _ = assert_equal "" (clearDigits "ies3kufsimsq5x6ilfx1mf2u16f7hikc6lmf7cptlvd4bdv82x62rwm2")
21
+
22
+ let test6 _ = assert_equal "" (clearDigits "5nq7mkio3abr9hx6y98dj965uhq55ehhen9f9xlgfnrkosl7i5xnse0ezbodlmjdsleucs")
23
+
24
+ let test7 _ = assert_equal "" (clearDigits "9j9mihoo9i0083t0ew7b2onsmd6zv974js4uuhvtca5taauie6f6mpllei3uuvstb9qnap7reomimrh7n03")
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for clearDigits" >::: [
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
clear_digits/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.clearDigits("abc"), "abc")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.clearDigits("cb34"), "")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.clearDigits(",z,k,j,f,6,c,h,m,f,z,7,2,q,g,d,p,d,y,z,t,y,3,8,9,j,8,d,h,"), "zkjchmqgdpdydh")
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.clearDigits(",a,n,a,r,1,l,9,t,i,i,y,l,4,p,g,t,2,4,z,h,c,7,q,t,7,i,x,v,4,f,e,t,d,9,j,e,3,4,r,5,w,8,x,s,v,b,7,y,l,7,x,v,d,7,8,m,a,y,q,q,g,y,9,3,j,k,w,k,5,j,2,s,2,w,w,a,m,7,a,0,h,k,q,s,d,"), "anatiiypzhqixfetxsvyxmayqqjkwwwahkqsd")
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.clearDigits(",i,e,s,3,k,u,f,s,i,m,s,q,5,x,6,i,l,f,x,1,m,f,2,u,1,6,f,7,h,i,k,c,6,l,m,f,7,c,p,t,l,v,d,4,b,d,v,8,2,x,6,2,r,w,m,2,"), "iekufsimsilfhiklmcptlvrw")
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.clearDigits(",5,n,q,7,m,k,i,o,3,a,b,r,9,h,x,6,y,9,8,d,j,9,6,5,u,h,q,5,5,e,h,h,e,n,9,f,9,x,l,g,f,n,r,k,o,s,l,7,i,5,x,n,s,e,0,e,z,b,o,d,l,m,j,d,s,l,e,u,c,s,"), "mkiauehhexlgfnrkosxnsezbodlmjdsleucn")
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.clearDigits(",9,j,9,m,i,h,o,o,9,i,0,0,8,3,t,0,e,w,7,b,2,o,n,s,m,d,6,z,v,9,7,4,j,s,4,u,u,h,v,t,c,a,5,t,a,a,u,i,e,6,f,6,m,p,l,l,e,i,3,u,u,v,s,t,b,9,q,n,a,p,7,r,e,o,m,i,m,r,h,7,n,0,3,"), "eonsjuuhvtctaauimplleuuvstqnareomimrm")
30
+ }
31
+
32
+ }
closest_equal_element_queries/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
closest_equal_element_queries/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(2,-1,3)), solveQueries(new ArrayList<>(Arrays.asList(1,3,1,4,1,3,2)), new ArrayList<>(Arrays.asList(0,3,5))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(-1,-1,-1,-1)), solveQueries(new ArrayList<>(Arrays.asList(1,2,3,4)), new ArrayList<>(Arrays.asList(0,1,2,3))));
19
+ }
20
+
21
+ }
closest_equal_element_queries/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb167dce3f39c0272be80859ab67fe0989fcc16f51b322df64d2b30365059a77
3
+ size 16565040
closest_equal_element_queries/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
closest_equal_element_queries/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
closest_prime_numbers_in_range/.DS_Store ADDED
Binary file (6.15 kB). View file
 
closest_prime_numbers_in_range/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 (closestPrimes 10 19)," [11,13] (closestPrimes 10 19))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (closestPrimes 4 6)," [-1,-1] (closestPrimes 4 6))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
closest_prime_numbers_in_range/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(11,13)), closestPrimes(10, 19));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(-1,-1)), closestPrimes(4, 6));
19
+ }
20
+
21
+ }
closest_prime_numbers_in_range/meta.json ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2610,
3
+ "name": "closest_prime_numbers_in_range",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/closest-prime-numbers-in-range/",
6
+ "date": "1671926400000",
7
+ "task_description": "Given two positive integers `left` and `right`, find the two integers `num1` and `num2` such that: `left <= num1 < num2 <= right `. Both `num1` and `num2` are prime numbers. `num2 - num1` is the **minimum** amongst all other pairs satisfying the above conditions. Return the positive integer array `ans = [num1, num2]`. If there are multiple pairs satisfying these conditions, return the one with the **smallest** `num1` value. If no such numbers exist, return `[-1, -1]`_._ **Example 1:** ``` **Input:** left = 10, right = 19 **Output:** [11,13] **Explanation:** The prime numbers between 10 and 19 are 11, 13, 17, and 19. The closest gap between any pair is 2, which can be achieved by [11,13] or [17,19]. Since 11 is smaller than 17, we return the first pair. ``` **Example 2:** ``` **Input:** left = 4, right = 6 **Output:** [-1,-1] **Explanation:** There exists only one prime number in the given range, so the conditions cannot be satisfied. ``` **Constraints:** `1 <= left <= right <= 106`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "left = 10, right = 19",
12
+ "output": "[11,13] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "left = 4, right = 6",
17
+ "output": "[-1,-1] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 259000,
24
+ 604761
25
+ ],
26
+ "output": [
27
+ 259121,
28
+ 259123
29
+ ]
30
+ },
31
+ {
32
+ "input": [
33
+ 957158,
34
+ 972359
35
+ ],
36
+ "output": [
37
+ 957431,
38
+ 957433
39
+ ]
40
+ },
41
+ {
42
+ "input": [
43
+ 55246,
44
+ 763571
45
+ ],
46
+ "output": [
47
+ 55331,
48
+ 55333
49
+ ]
50
+ },
51
+ {
52
+ "input": [
53
+ 649910,
54
+ 686398
55
+ ],
56
+ "output": [
57
+ 650327,
58
+ 650329
59
+ ]
60
+ },
61
+ {
62
+ "input": [
63
+ 331636,
64
+ 938904
65
+ ],
66
+ "output": [
67
+ 331691,
68
+ 331693
69
+ ]
70
+ },
71
+ {
72
+ "input": [
73
+ 725612,
74
+ 912608
75
+ ],
76
+ "output": [
77
+ 725861,
78
+ 725863
79
+ ]
80
+ },
81
+ {
82
+ "input": [
83
+ 124471,
84
+ 281197
85
+ ],
86
+ "output": [
87
+ 124541,
88
+ 124543
89
+ ]
90
+ },
91
+ {
92
+ "input": [
93
+ 523427,
94
+ 663663
95
+ ],
96
+ "output": [
97
+ 523487,
98
+ 523489
99
+ ]
100
+ },
101
+ {
102
+ "input": [
103
+ 863522,
104
+ 999759
105
+ ],
106
+ "output": [
107
+ 863537,
108
+ 863539
109
+ ]
110
+ },
111
+ {
112
+ "input": [
113
+ 508948,
114
+ 963261
115
+ ],
116
+ "output": [
117
+ 509147,
118
+ 509149
119
+ ]
120
+ }
121
+ ],
122
+ "haskell_template": "closestPrimes :: Int -> Int -> [Int]\nclosestPrimes left right ",
123
+ "ocaml_template": "let closestPrimes (left: int) (right: int) : int list = ",
124
+ "scala_template": "def closestPrimes(left: Int,right: Int): List[Int] = { \n \n}",
125
+ "java_template": "public static List<Integer> closestPrimes(int left, int right) {\n\n}",
126
+ "python_template": "class Solution(object):\n def closestPrimes(self, left, right):\n \"\"\"\n :type left: int\n :type right: int\n :rtype: List[int]\n \"\"\"\n "
127
+ }
closest_prime_numbers_in_range/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;13] (closestPrimes 10 19)
12
+
13
+ let test2 _ = assert_equal [-1;-1] (closestPrimes 4 6)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for closestPrimes" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end