92988b1e4e7745ed81cac53dcd42a92de49fde9a78668977a27ff3a15c81c91a
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- find_substring_with_given_hash_value/haskell_tests/Main.hs +24 -0
- find_substring_with_given_hash_value/java_tests/Main.java +21 -0
- find_substring_with_given_hash_value/meta.json +0 -0
- find_substring_with_given_hash_value/ocaml_tests/main.ml +26 -0
- find_substring_with_given_hash_value/scala_tests/MySuite.scala +12 -0
- find_subtree_sizes_after_changes/haskell_tests/Main.hs +0 -0
- find_subtree_sizes_after_changes/java_tests/Main.java +21 -0
- find_subtree_sizes_after_changes/meta.json +3 -0
- find_subtree_sizes_after_changes/ocaml_tests/main.ml +0 -0
- find_subtree_sizes_after_changes/scala_tests/MySuite.scala +0 -0
- find_the_array_concatenation_value/.DS_Store +0 -0
- find_the_array_concatenation_value/haskell_tests/Main.hs +24 -0
- find_the_array_concatenation_value/java_tests/Main.java +21 -0
- find_the_array_concatenation_value/meta.json +0 -0
- find_the_array_concatenation_value/ocaml_tests/main.ml +26 -0
- find_the_array_concatenation_value/scala_tests/MySuite.scala +12 -0
- find_the_child_who_has_the_ball_after_k_seconds/haskell_tests/Main.hs +45 -0
- find_the_child_who_has_the_ball_after_k_seconds/java_tests/Main.java +25 -0
- find_the_child_who_has_the_ball_after_k_seconds/meta.json +102 -0
- find_the_child_who_has_the_ball_after_k_seconds/ocaml_tests/main.ml +50 -0
- find_the_child_who_has_the_ball_after_k_seconds/scala_tests/MySuite.scala +44 -0
- find_the_count_of_good_integers/haskell_tests/Main.hs +45 -0
- find_the_count_of_good_integers/java_tests/Main.java +25 -0
- find_the_count_of_good_integers/meta.json +102 -0
- find_the_count_of_good_integers/ocaml_tests/main.ml +50 -0
- find_the_count_of_good_integers/scala_tests/MySuite.scala +44 -0
- find_the_distinct_difference_array/haskell_tests/Main.hs +47 -0
- find_the_distinct_difference_array/java_tests/Main.java +20 -0
- find_the_distinct_difference_array/meta.json +481 -0
- find_the_distinct_difference_array/ocaml_tests/main.ml +51 -0
- find_the_distinct_difference_array/scala_tests/MySuite.scala +44 -0
- find_the_divisibility_array_of_a_string/.DS_Store +0 -0
- find_the_divisibility_array_of_a_string/haskell_tests/Main.hs +24 -0
- find_the_divisibility_array_of_a_string/java_tests/Main.java +21 -0
- find_the_divisibility_array_of_a_string/meta.json +0 -0
- find_the_divisibility_array_of_a_string/ocaml_tests/main.ml +26 -0
- find_the_divisibility_array_of_a_string/scala_tests/MySuite.scala +12 -0
- find_the_encrypted_string/haskell_tests/Main.hs +45 -0
- find_the_encrypted_string/java_tests/Main.java +21 -0
- find_the_encrypted_string/meta.json +97 -0
- find_the_encrypted_string/ocaml_tests/main.ml +50 -0
- find_the_encrypted_string/scala_tests/MySuite.scala +44 -0
- find_the_first_player_to_win_k_games_in_a_row/haskell_tests/Main.hs +0 -0
- find_the_first_player_to_win_k_games_in_a_row/java_tests/Main.java +21 -0
- find_the_first_player_to_win_k_games_in_a_row/meta.json +3 -0
- find_the_first_player_to_win_k_games_in_a_row/ocaml_tests/main.ml +0 -0
- find_the_first_player_to_win_k_games_in_a_row/scala_tests/MySuite.scala +0 -0
- find_the_grid_of_region_average/java_tests/Main.java +25 -0
- find_the_integer_added_to_array_i/haskell_tests/Main.hs +45 -0
.gitattributes
CHANGED
|
@@ -120,3 +120,5 @@ find_closest_node_to_given_two_nodes/meta.json filter=lfs diff=lfs merge=lfs -te
|
|
| 120 |
find_indices_with_index_and_value_difference_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 121 |
find_number_of_coins_to_place_in_tree_nodes/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 122 |
find_occurrences_of_an_element_in_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 120 |
find_indices_with_index_and_value_difference_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 121 |
find_number_of_coins_to_place_in_tree_nodes/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 122 |
find_occurrences_of_an_element_in_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 123 |
+
find_subtree_sizes_after_changes/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 124 |
+
find_the_first_player_to_win_k_games_in_a_row/meta.json filter=lfs diff=lfs merge=lfs -text
|
find_substring_with_given_hash_value/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 (subStrHash \"leetcode \" 7 20 2 0)," "ee" (subStrHash "leetcode" 7 20 2 0))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (subStrHash \"fbxzaad \" 31 100 3 32)," "fbx" (subStrHash "fbxzaad" 31 100 3 32))
|
| 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
|
find_substring_with_given_hash_value/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("0", subStrHash("leetcode", 7, 20, 2, 0));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals("32", subStrHash("fbxzaad", 31, 100, 3, 32));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
find_substring_with_given_hash_value/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_substring_with_given_hash_value/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 "ee" (subStrHash "leetcode" 7 20 2 0)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal "fbx" (subStrHash "fbxzaad" 31 100 3 32)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for subStrHash" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
find_substring_with_given_hash_value/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.subStrHash("leetcode",7,20,2,0), "ee")
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.subStrHash("fbxzaad",31,100,3,32), "fbx")
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
find_subtree_sizes_after_changes/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_subtree_sizes_after_changes/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(6,3,1,1,1,1)), findSubtreeSizes(new ArrayList<>(Arrays.asList(-1,0,0,1,1,1)), "abaabc"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(new ArrayList<>(Arrays.asList(5,2,1,1,1)), findSubtreeSizes(new ArrayList<>(Arrays.asList(-1,0,4,0,1)), "abbba"));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
find_subtree_sizes_after_changes/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:079d0120883ce9891ed205500e9c0a6307e577d4817d8e04ef3a8c4b68b7d374
|
| 3 |
+
size 16095875
|
find_subtree_sizes_after_changes/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_subtree_sizes_after_changes/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_the_array_concatenation_value/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
find_the_array_concatenation_value/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 (findTheArrayConcVal [7,52,2,4])," 596 (findTheArrayConcVal [7,52,2,4]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (findTheArrayConcVal [5,14,13,8,12])," 673 (findTheArrayConcVal [5,14,13,8,12]))
|
| 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
|
find_the_array_concatenation_value/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(596, findTheArrayConcVal(new ArrayList<>(Arrays.asList(7,52,2,4))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(673, findTheArrayConcVal(new ArrayList<>(Arrays.asList(5,14,13,8,12))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
find_the_array_concatenation_value/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_the_array_concatenation_value/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 596 (findTheArrayConcVal [7;52;2;4])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 673 (findTheArrayConcVal [5;14;13;8;12])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for findTheArrayConcVal" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
find_the_array_concatenation_value/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.findTheArrayConcVal(List(7,52,2,4)), 596)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.findTheArrayConcVal(List(5,14,13,8,12)), 673)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
find_the_child_who_has_the_ball_after_k_seconds/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 (numberOfChild 3 5)," 1 (numberOfChild 3 5))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (numberOfChild 5 6)," 2 (numberOfChild 5 6))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (numberOfChild 4 2)," 2 (numberOfChild 4 2))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (numberOfChild 46 27)," 27 (numberOfChild 46 27))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (numberOfChild 11 18)," 2 (numberOfChild 11 18))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (numberOfChild 39 46)," 30 (numberOfChild 39 46))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (numberOfChild 41 50)," 30 (numberOfChild 41 50))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (numberOfChild 32 33)," 29 (numberOfChild 32 33))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (numberOfChild 27 47)," 5 (numberOfChild 27 47))
|
| 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
|
find_the_child_who_has_the_ball_after_k_seconds/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(1, numberOfChild(3, 5));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, numberOfChild(5, 6));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(2, numberOfChild(4, 2));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
find_the_child_who_has_the_ball_after_k_seconds/meta.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3450,
|
| 3 |
+
"name": "find_the_child_who_has_the_ball_after_k_seconds",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds/",
|
| 6 |
+
"date": "2024-06-02 00:00:00",
|
| 7 |
+
"task_description": "You are given two **positive** integers `n` and `k`. There are `n` children numbered from `0` to `n - 1` standing in a queue _in order_ from left to right. Initially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to them. Once the ball reaches **either** end of the line, i.e. child 0 or child `n - 1`, the direction of passing is **reversed**. Return the number of the child who receives the ball after `k` seconds. **Example 1:** **Input:** n = 3, k = 5 **Output:** 1 **Explanation:** Time elapsed Children `0` `[0, 1, 2]` `1` `[0, 1, 2]` `2` `[0, 1, 2]` `3` `[0, 1, 2]` `4` `[0, 1, 2]` `5` `[0, 1, 2]` **Example 2:** **Input:** n = 5, k = 6 **Output:** 2 **Explanation:** Time elapsed Children `0` `[0, 1, 2, 3, 4]` `1` `[0, 1, 2, 3, 4]` `2` `[0, 1, 2, 3, 4]` `3` `[0, 1, 2, 3, 4]` `4` `[0, 1, 2, 3, 4]` `5` `[0, 1, 2, 3, 4]` `6` `[0, 1, 2, 3, 4]` **Example 3:** **Input:** n = 4, k = 2 **Output:** 2 **Explanation:** Time elapsed Children `0` `[0, 1, 2, 3]` `1` `[0, 1, 2, 3]` `2` `[0, 1, 2, 3]` **Constraints:** `2 <= n <= 50` `1 <= k <= 50` **Note:** This question is the same as 2582: Pass the Pillow.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "n = 3, k = 5",
|
| 12 |
+
"output": "1 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "n = 5, k = 6",
|
| 17 |
+
"output": "2 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "n = 4, k = 2",
|
| 22 |
+
"output": "2 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
46,
|
| 29 |
+
27
|
| 30 |
+
],
|
| 31 |
+
"output": 27
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"input": [
|
| 35 |
+
11,
|
| 36 |
+
18
|
| 37 |
+
],
|
| 38 |
+
"output": 2
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"input": [
|
| 42 |
+
39,
|
| 43 |
+
46
|
| 44 |
+
],
|
| 45 |
+
"output": 30
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"input": [
|
| 49 |
+
41,
|
| 50 |
+
50
|
| 51 |
+
],
|
| 52 |
+
"output": 30
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"input": [
|
| 56 |
+
32,
|
| 57 |
+
33
|
| 58 |
+
],
|
| 59 |
+
"output": 29
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"input": [
|
| 63 |
+
27,
|
| 64 |
+
47
|
| 65 |
+
],
|
| 66 |
+
"output": 5
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"input": [
|
| 70 |
+
47,
|
| 71 |
+
24
|
| 72 |
+
],
|
| 73 |
+
"output": 24
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"input": [
|
| 77 |
+
18,
|
| 78 |
+
4
|
| 79 |
+
],
|
| 80 |
+
"output": 4
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"input": [
|
| 84 |
+
41,
|
| 85 |
+
35
|
| 86 |
+
],
|
| 87 |
+
"output": 35
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"input": [
|
| 91 |
+
36,
|
| 92 |
+
10
|
| 93 |
+
],
|
| 94 |
+
"output": 10
|
| 95 |
+
}
|
| 96 |
+
],
|
| 97 |
+
"haskell_template": "numberOfChild :: Int -> Int -> Int\nnumberOfChild n k ",
|
| 98 |
+
"ocaml_template": "let numberOfChild (n: int) (k: int) : int = ",
|
| 99 |
+
"scala_template": "def numberOfChild(n: Int,k: Int): Int = { \n \n}",
|
| 100 |
+
"java_template": "class Solution {\n public int numberOfChild(int n, int k) {\n \n }\n}",
|
| 101 |
+
"python_template": "class Solution(object):\n def numberOfChild(self, n, k):\n \"\"\"\n :type n: int\n :type k: int\n :rtype: int\n \"\"\"\n "
|
| 102 |
+
}
|
find_the_child_who_has_the_ball_after_k_seconds/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 1 (numberOfChild 3 5)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (numberOfChild 5 6)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 2 (numberOfChild 4 2)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 27 (numberOfChild 46 27)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 2 (numberOfChild 11 18)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 30 (numberOfChild 39 46)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 30 (numberOfChild 41 50)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 29 (numberOfChild 32 33)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 5 (numberOfChild 27 47)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 24 (numberOfChild 47 24)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for numberOfChild" >::: [
|
| 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
|
find_the_child_who_has_the_ball_after_k_seconds/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.numberOfChild(3,5), 1)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.numberOfChild(5,6), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.numberOfChild(4,2), 2)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.numberOfChild(46,27), 27)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.numberOfChild(11,18), 2)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.numberOfChild(39,46), 30)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.numberOfChild(41,50), 30)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.numberOfChild(32,33), 29)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.numberOfChild(27,47), 5)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.numberOfChild(47,24), 24)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
find_the_count_of_good_integers/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 (countGoodIntegers 3 5)," 27 (countGoodIntegers 3 5))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (countGoodIntegers 1 4)," 2 (countGoodIntegers 1 4))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (countGoodIntegers 5 6)," 246 (countGoodIntegers 5 6))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (countGoodIntegers 2 4)," 2 (countGoodIntegers 2 4))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (countGoodIntegers 9 6)," 12476696 (countGoodIntegers 9 6))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (countGoodIntegers 10 5)," 19284856 (countGoodIntegers 10 5))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (countGoodIntegers 4 5)," 52 (countGoodIntegers 4 5))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (countGoodIntegers 10 1)," 41457024 (countGoodIntegers 10 1))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (countGoodIntegers 7 5)," 182335 (countGoodIntegers 7 5))
|
| 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
|
find_the_count_of_good_integers/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(27, countGoodIntegers(3, 5));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, countGoodIntegers(1, 4));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(246, countGoodIntegers(5, 6));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
find_the_count_of_good_integers/meta.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3548,
|
| 3 |
+
"name": "find_the_count_of_good_integers",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/find-the-count-of-good-integers/",
|
| 6 |
+
"date": "2024-08-17 00:00:00",
|
| 7 |
+
"task_description": "You are given two **positive** integers `n` and `k`. An integer `x` is called **k-palindromic** if: `x` is a palindrome. `x` is divisible by `k`. An integer is called **good** if its digits can be _rearranged_ to form a **k-palindromic** integer. For example, for `k = 2`, 2020 can be rearranged to form the _k-palindromic_ integer 2002, whereas 1010 cannot be rearranged to form a _k-palindromic_ integer. Return the count of **good** integers containing `n` digits. **Note** that _any_ integer must **not** have leading zeros, **neither** before **nor** after rearrangement. For example, 1010 _cannot_ be rearranged to form 101. **Example 1:** **Input:** n = 3, k = 5 **Output:** 27 **Explanation:** _Some_ of the good integers are: 551 because it can be rearranged to form 515. 525 because it is already k-palindromic. **Example 2:** **Input:** n = 1, k = 4 **Output:** 2 **Explanation:** The two good integers are 4 and 8. **Example 3:** **Input:** n = 5, k = 6 **Output:** 2468 **Constraints:** `1 <= n <= 10` `1 <= k <= 9`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "n = 3, k = 5",
|
| 12 |
+
"output": "27 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "n = 1, k = 4",
|
| 17 |
+
"output": "2 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "n = 5, k = 6",
|
| 22 |
+
"output": "246"
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
2,
|
| 29 |
+
4
|
| 30 |
+
],
|
| 31 |
+
"output": 2
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"input": [
|
| 35 |
+
9,
|
| 36 |
+
6
|
| 37 |
+
],
|
| 38 |
+
"output": 12476696
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"input": [
|
| 42 |
+
10,
|
| 43 |
+
5
|
| 44 |
+
],
|
| 45 |
+
"output": 19284856
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"input": [
|
| 49 |
+
4,
|
| 50 |
+
5
|
| 51 |
+
],
|
| 52 |
+
"output": 52
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"input": [
|
| 56 |
+
10,
|
| 57 |
+
1
|
| 58 |
+
],
|
| 59 |
+
"output": 41457024
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"input": [
|
| 63 |
+
7,
|
| 64 |
+
5
|
| 65 |
+
],
|
| 66 |
+
"output": 182335
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"input": [
|
| 70 |
+
4,
|
| 71 |
+
7
|
| 72 |
+
],
|
| 73 |
+
"output": 76
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"input": [
|
| 77 |
+
4,
|
| 78 |
+
3
|
| 79 |
+
],
|
| 80 |
+
"output": 84
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"input": [
|
| 84 |
+
5,
|
| 85 |
+
1
|
| 86 |
+
],
|
| 87 |
+
"output": 10935
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"input": [
|
| 91 |
+
9,
|
| 92 |
+
8
|
| 93 |
+
],
|
| 94 |
+
"output": 30771543
|
| 95 |
+
}
|
| 96 |
+
],
|
| 97 |
+
"haskell_template": "countGoodIntegers :: Int -> Int -> Int\ncountGoodIntegers n k ",
|
| 98 |
+
"ocaml_template": "let countGoodIntegers (n: int) (k: int) : int = ",
|
| 99 |
+
"scala_template": "def countGoodIntegers(n: Int,k: Int): Int = { \n \n}",
|
| 100 |
+
"java_template": "class Solution {\n public long countGoodIntegers(int n, int k) {\n \n }\n}",
|
| 101 |
+
"python_template": "class Solution(object):\n def countGoodIntegers(self, n, k):\n \"\"\"\n :type n: int\n :type k: int\n :rtype: int\n \"\"\"\n "
|
| 102 |
+
}
|
find_the_count_of_good_integers/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 27 (countGoodIntegers 3 5)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (countGoodIntegers 1 4)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 246 (countGoodIntegers 5 6)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 2 (countGoodIntegers 2 4)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 12476696 (countGoodIntegers 9 6)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 19284856 (countGoodIntegers 10 5)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 52 (countGoodIntegers 4 5)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 41457024 (countGoodIntegers 10 1)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 182335 (countGoodIntegers 7 5)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 76 (countGoodIntegers 4 7)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for countGoodIntegers" >::: [
|
| 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
|
find_the_count_of_good_integers/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countGoodIntegers(3,5), 27)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countGoodIntegers(1,4), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.countGoodIntegers(5,6), 246)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.countGoodIntegers(2,4), 2)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.countGoodIntegers(9,6), 12476696)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.countGoodIntegers(10,5), 19284856)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.countGoodIntegers(4,5), 52)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.countGoodIntegers(10,1), 41457024)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.countGoodIntegers(7,5), 182335)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.countGoodIntegers(4,7), 76)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
find_the_distinct_difference_array/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
distinctDifferenceArray :: [Int] -> [Int]
|
| 7 |
+
distinctDifferenceArray nums = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (distinctDifferenceArray [1,2,3,4,5])," [-3,-1,1,3,5] (distinctDifferenceArray [1,2,3,4,5]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (distinctDifferenceArray [3,2,3,4,2])," [-2,-1,0,2,3] (distinctDifferenceArray [3,2,3,4,2]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (distinctDifferenceArray [44, 1, 46, 10, 5, 7, 50, 2, 44, 32, 1, 26, 34, 21, 33, 30, 5, 6, 33, 12, 13, 1, 37])," [-17,(-16),(-14),(-12),(-11),(-9),(-7),(-5),(-4),(-2),(-2),0,2,4,5,7,8,10,11,13,15,16,18] (distinctDifferenceArray [44, 1, 46, 10, 5, 7, 50, 2, 44, 32, 1, 26, 34, 21, 33, 30, 5, 6, 33, 12, 13, 1, 37]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (distinctDifferenceArray [37])," [1] (distinctDifferenceArray [37]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (distinctDifferenceArray [17, 31, 15, 24, 8, 5, 41, 12, 33, 23, 44, 3, 33, 45, 45, 44, 35, 37, 2, 31, 11, 38, 5, 10, 4, 48, 35, 1, 40, 3, 13])," [-22,(-21),(-19),(-17),(-15),(-14),(-12),(-10),(-9),(-7),(-6),(-5),(-4),(-3),(-2),(-1),0,2,4,5,7,9,10,12,14,16,17,19,21,22,24] (distinctDifferenceArray [17, 31, 15, 24, 8, 5, 41, 12, 33, 23, 44, 3, 33, 45, 45, 44, 35, 37, 2, 31, 11, 38, 5, 10, 4, 48, 35, 1, 40, 3, 13]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (distinctDifferenceArray [13, 1, 39, 29, 17, 39])," [-3,(-1),0,2,4,5] (distinctDifferenceArray [13, 1, 39, 29, 17, 39]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (distinctDifferenceArray [14, 21, 34, 43, 2, 3, 48, 17, 1, 16, 40, 50, 27, 36, 6, 28, 26, 2, 44, 33, 43, 6, 13, 20, 21, 4, 6, 41, 38, 19, 39, 42, 14, 7, 35, 4, 39, 12, 6, 10, 25, 18])," [-32,(-31),(-29),(-28),(-27),(-25),(-23),(-21),(-19),(-17),(-15),(-13),(-11),(-9),(-8),(-6),(-4),(-3),(-1),1,2,2,4,6,7,8,8,10,12,14,15,17,18,20,22,23,24,26,27,29,31,33] (distinctDifferenceArray [14, 21, 34, 43, 2, 3, 48, 17, 1, 16, 40, 50, 27, 36, 6, 28, 26, 2, 44, 33, 43, 6, 13, 20, 21, 4, 6, 41, 38, 19, 39, 42, 14, 7, 35, 4, 39, 12, 6, 10, 25, 18]))
|
| 33 |
+
|
| 34 |
+
test8 :: Test
|
| 35 |
+
test8 = TestCase (assertEqual "for (distinctDifferenceArray [10, 8, 44, 4, 33, 21, 50, 46, 29, 41, 45, 24, 30, 10, 43, 29, 38, 31, 14, 7, 3, 19, 27, 32, 5, 43, 24, 32, 6, 15, 24])," [-24,(-22),(-20),(-18),(-16),(-14),(-12),(-10),(-9),(-7),(-5),(-4),(-2),(-1),0,1,3,5,7,9,11,13,15,16,18,19,19,20,22,24,25] (distinctDifferenceArray [10, 8, 44, 4, 33, 21, 50, 46, 29, 41, 45, 24, 30, 10, 43, 29, 38, 31, 14, 7, 3, 19, 27, 32, 5, 43, 24, 32, 6, 15, 24]))
|
| 36 |
+
|
| 37 |
+
test9 :: Test
|
| 38 |
+
test9 = TestCase (assertEqual "for (distinctDifferenceArray [2, 2, 1, 39, 18, 15, 15, 3, 18, 4, 47, 6, 8, 26, 28, 37, 30, 4, 22, 2, 12, 12, 32, 13, 18, 39, 13])," [-17,(-17),(-15),(-14),(-13),(-12),(-11),(-9),(-9),(-8),(-6),(-4),(-2),0,2,4,6,7,9,10,11,12,14,15,16,17,18] (distinctDifferenceArray [2, 2, 1, 39, 18, 15, 15, 3, 18, 4, 47, 6, 8, 26, 28, 37, 30, 4, 22, 2, 12, 12, 32, 13, 18, 39, 13]))
|
| 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, TestLabel "Test9" test9]
|
| 44 |
+
|
| 45 |
+
-- Running the tests
|
| 46 |
+
main :: IO Counts
|
| 47 |
+
main = runTestTT tests
|
find_the_distinct_difference_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(-3,-1,1,3,5), distinctDifferenceArray(Arrays.asList(1,2,3,4,5)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(Arrays.asList(-2,-1,0,2,3), distinctDifferenceArray(Arrays.asList(3,2,3,4,2)));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
find_the_distinct_difference_array/meta.json
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2777,
|
| 3 |
+
"name": "find_the_distinct_difference_array",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/find-the-distinct-difference-array/",
|
| 6 |
+
"date": "2023-04-30 00:00:00",
|
| 7 |
+
"task_description": "You are given a **0-indexed** array `nums` of length `n`. The **distinct difference** array of `nums` is an array `diff` of length `n` such that `diff[i]` is equal to the number of distinct elements in the suffix `nums[i + 1, ..., n - 1]` **subtracted from** the number of distinct elements in the prefix `nums[0, ..., i]`. Return _the **distinct difference** array of _`nums`. Note that `nums[i, ..., j]` denotes the subarray of `nums` starting at index `i` and ending at index `j` inclusive. Particularly, if `i > j` then `nums[i, ..., j]` denotes an empty subarray. **Example 1:** ``` **Input:** nums = [1,2,3,4,5] **Output:** [-3,-1,1,3,5] **Explanation:** For index i = 0, there is 1 element in the prefix and 4 distinct elements in the suffix. Thus, diff[0] = 1 - 4 = -3. For index i = 1, there are 2 distinct elements in the prefix and 3 distinct elements in the suffix. Thus, diff[1] = 2 - 3 = -1. For index i = 2, there are 3 distinct elements in the prefix and 2 distinct elements in the suffix. Thus, diff[2] = 3 - 2 = 1. For index i = 3, there are 4 distinct elements in the prefix and 1 distinct element in the suffix. Thus, diff[3] = 4 - 1 = 3. For index i = 4, there are 5 distinct elements in the prefix and no elements in the suffix. Thus, diff[4] = 5 - 0 = 5. ``` **Example 2:** ``` **Input:** nums = [3,2,3,4,2] **Output:** [-2,-1,0,2,3] **Explanation:** For index i = 0, there is 1 element in the prefix and 3 distinct elements in the suffix. Thus, diff[0] = 1 - 3 = -2. For index i = 1, there are 2 distinct elements in the prefix and 3 distinct elements in the suffix. Thus, diff[1] = 2 - 3 = -1. For index i = 2, there are 2 distinct elements in the prefix and 2 distinct elements in the suffix. Thus, diff[2] = 2 - 2 = 0. For index i = 3, there are 3 distinct elements in the prefix and 1 distinct element in the suffix. Thus, diff[3] = 3 - 1 = 2. For index i = 4, there are 3 distinct elements in the prefix and no elements in the suffix. Thus, diff[4] = 3 - 0 = 3. ``` **Constraints:** `1 <= n == nums.length <= 50` `1 <= nums[i] <= 50`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [1,2,3,4,5]",
|
| 12 |
+
"output": "[-3,-1,1,3,5] "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [3,2,3,4,2]",
|
| 17 |
+
"output": "[-2,-1,0,2,3] "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
44,
|
| 24 |
+
1,
|
| 25 |
+
46,
|
| 26 |
+
10,
|
| 27 |
+
5,
|
| 28 |
+
7,
|
| 29 |
+
50,
|
| 30 |
+
2,
|
| 31 |
+
44,
|
| 32 |
+
32,
|
| 33 |
+
1,
|
| 34 |
+
26,
|
| 35 |
+
34,
|
| 36 |
+
21,
|
| 37 |
+
33,
|
| 38 |
+
30,
|
| 39 |
+
5,
|
| 40 |
+
6,
|
| 41 |
+
33,
|
| 42 |
+
12,
|
| 43 |
+
13,
|
| 44 |
+
1,
|
| 45 |
+
37
|
| 46 |
+
],
|
| 47 |
+
"output": [
|
| 48 |
+
-17,
|
| 49 |
+
-16,
|
| 50 |
+
-14,
|
| 51 |
+
-12,
|
| 52 |
+
-11,
|
| 53 |
+
-9,
|
| 54 |
+
-7,
|
| 55 |
+
-5,
|
| 56 |
+
-4,
|
| 57 |
+
-2,
|
| 58 |
+
-2,
|
| 59 |
+
0,
|
| 60 |
+
2,
|
| 61 |
+
4,
|
| 62 |
+
5,
|
| 63 |
+
7,
|
| 64 |
+
8,
|
| 65 |
+
10,
|
| 66 |
+
11,
|
| 67 |
+
13,
|
| 68 |
+
15,
|
| 69 |
+
16,
|
| 70 |
+
18
|
| 71 |
+
]
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"input": [
|
| 75 |
+
37
|
| 76 |
+
],
|
| 77 |
+
"output": [
|
| 78 |
+
1
|
| 79 |
+
]
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"input": [
|
| 83 |
+
17,
|
| 84 |
+
31,
|
| 85 |
+
15,
|
| 86 |
+
24,
|
| 87 |
+
8,
|
| 88 |
+
5,
|
| 89 |
+
41,
|
| 90 |
+
12,
|
| 91 |
+
33,
|
| 92 |
+
23,
|
| 93 |
+
44,
|
| 94 |
+
3,
|
| 95 |
+
33,
|
| 96 |
+
45,
|
| 97 |
+
45,
|
| 98 |
+
44,
|
| 99 |
+
35,
|
| 100 |
+
37,
|
| 101 |
+
2,
|
| 102 |
+
31,
|
| 103 |
+
11,
|
| 104 |
+
38,
|
| 105 |
+
5,
|
| 106 |
+
10,
|
| 107 |
+
4,
|
| 108 |
+
48,
|
| 109 |
+
35,
|
| 110 |
+
1,
|
| 111 |
+
40,
|
| 112 |
+
3,
|
| 113 |
+
13
|
| 114 |
+
],
|
| 115 |
+
"output": [
|
| 116 |
+
-22,
|
| 117 |
+
-21,
|
| 118 |
+
-19,
|
| 119 |
+
-17,
|
| 120 |
+
-15,
|
| 121 |
+
-14,
|
| 122 |
+
-12,
|
| 123 |
+
-10,
|
| 124 |
+
-9,
|
| 125 |
+
-7,
|
| 126 |
+
-6,
|
| 127 |
+
-5,
|
| 128 |
+
-4,
|
| 129 |
+
-3,
|
| 130 |
+
-2,
|
| 131 |
+
-1,
|
| 132 |
+
0,
|
| 133 |
+
2,
|
| 134 |
+
4,
|
| 135 |
+
5,
|
| 136 |
+
7,
|
| 137 |
+
9,
|
| 138 |
+
10,
|
| 139 |
+
12,
|
| 140 |
+
14,
|
| 141 |
+
16,
|
| 142 |
+
17,
|
| 143 |
+
19,
|
| 144 |
+
21,
|
| 145 |
+
22,
|
| 146 |
+
24
|
| 147 |
+
]
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"input": [
|
| 151 |
+
13,
|
| 152 |
+
1,
|
| 153 |
+
39,
|
| 154 |
+
29,
|
| 155 |
+
17,
|
| 156 |
+
39
|
| 157 |
+
],
|
| 158 |
+
"output": [
|
| 159 |
+
-3,
|
| 160 |
+
-1,
|
| 161 |
+
0,
|
| 162 |
+
2,
|
| 163 |
+
4,
|
| 164 |
+
5
|
| 165 |
+
]
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"input": [
|
| 169 |
+
14,
|
| 170 |
+
21,
|
| 171 |
+
34,
|
| 172 |
+
43,
|
| 173 |
+
2,
|
| 174 |
+
3,
|
| 175 |
+
48,
|
| 176 |
+
17,
|
| 177 |
+
1,
|
| 178 |
+
16,
|
| 179 |
+
40,
|
| 180 |
+
50,
|
| 181 |
+
27,
|
| 182 |
+
36,
|
| 183 |
+
6,
|
| 184 |
+
28,
|
| 185 |
+
26,
|
| 186 |
+
2,
|
| 187 |
+
44,
|
| 188 |
+
33,
|
| 189 |
+
43,
|
| 190 |
+
6,
|
| 191 |
+
13,
|
| 192 |
+
20,
|
| 193 |
+
21,
|
| 194 |
+
4,
|
| 195 |
+
6,
|
| 196 |
+
41,
|
| 197 |
+
38,
|
| 198 |
+
19,
|
| 199 |
+
39,
|
| 200 |
+
42,
|
| 201 |
+
14,
|
| 202 |
+
7,
|
| 203 |
+
35,
|
| 204 |
+
4,
|
| 205 |
+
39,
|
| 206 |
+
12,
|
| 207 |
+
6,
|
| 208 |
+
10,
|
| 209 |
+
25,
|
| 210 |
+
18
|
| 211 |
+
],
|
| 212 |
+
"output": [
|
| 213 |
+
-32,
|
| 214 |
+
-31,
|
| 215 |
+
-29,
|
| 216 |
+
-28,
|
| 217 |
+
-27,
|
| 218 |
+
-25,
|
| 219 |
+
-23,
|
| 220 |
+
-21,
|
| 221 |
+
-19,
|
| 222 |
+
-17,
|
| 223 |
+
-15,
|
| 224 |
+
-13,
|
| 225 |
+
-11,
|
| 226 |
+
-9,
|
| 227 |
+
-8,
|
| 228 |
+
-6,
|
| 229 |
+
-4,
|
| 230 |
+
-3,
|
| 231 |
+
-1,
|
| 232 |
+
1,
|
| 233 |
+
2,
|
| 234 |
+
2,
|
| 235 |
+
4,
|
| 236 |
+
6,
|
| 237 |
+
7,
|
| 238 |
+
8,
|
| 239 |
+
8,
|
| 240 |
+
10,
|
| 241 |
+
12,
|
| 242 |
+
14,
|
| 243 |
+
15,
|
| 244 |
+
17,
|
| 245 |
+
18,
|
| 246 |
+
20,
|
| 247 |
+
22,
|
| 248 |
+
23,
|
| 249 |
+
24,
|
| 250 |
+
26,
|
| 251 |
+
27,
|
| 252 |
+
29,
|
| 253 |
+
31,
|
| 254 |
+
33
|
| 255 |
+
]
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"input": [
|
| 259 |
+
10,
|
| 260 |
+
8,
|
| 261 |
+
44,
|
| 262 |
+
4,
|
| 263 |
+
33,
|
| 264 |
+
21,
|
| 265 |
+
50,
|
| 266 |
+
46,
|
| 267 |
+
29,
|
| 268 |
+
41,
|
| 269 |
+
45,
|
| 270 |
+
24,
|
| 271 |
+
30,
|
| 272 |
+
10,
|
| 273 |
+
43,
|
| 274 |
+
29,
|
| 275 |
+
38,
|
| 276 |
+
31,
|
| 277 |
+
14,
|
| 278 |
+
7,
|
| 279 |
+
3,
|
| 280 |
+
19,
|
| 281 |
+
27,
|
| 282 |
+
32,
|
| 283 |
+
5,
|
| 284 |
+
43,
|
| 285 |
+
24,
|
| 286 |
+
32,
|
| 287 |
+
6,
|
| 288 |
+
15,
|
| 289 |
+
24
|
| 290 |
+
],
|
| 291 |
+
"output": [
|
| 292 |
+
-24,
|
| 293 |
+
-22,
|
| 294 |
+
-20,
|
| 295 |
+
-18,
|
| 296 |
+
-16,
|
| 297 |
+
-14,
|
| 298 |
+
-12,
|
| 299 |
+
-10,
|
| 300 |
+
-9,
|
| 301 |
+
-7,
|
| 302 |
+
-5,
|
| 303 |
+
-4,
|
| 304 |
+
-2,
|
| 305 |
+
-1,
|
| 306 |
+
0,
|
| 307 |
+
1,
|
| 308 |
+
3,
|
| 309 |
+
5,
|
| 310 |
+
7,
|
| 311 |
+
9,
|
| 312 |
+
11,
|
| 313 |
+
13,
|
| 314 |
+
15,
|
| 315 |
+
16,
|
| 316 |
+
18,
|
| 317 |
+
19,
|
| 318 |
+
19,
|
| 319 |
+
20,
|
| 320 |
+
22,
|
| 321 |
+
24,
|
| 322 |
+
25
|
| 323 |
+
]
|
| 324 |
+
},
|
| 325 |
+
{
|
| 326 |
+
"input": [
|
| 327 |
+
2,
|
| 328 |
+
2,
|
| 329 |
+
1,
|
| 330 |
+
39,
|
| 331 |
+
18,
|
| 332 |
+
15,
|
| 333 |
+
15,
|
| 334 |
+
3,
|
| 335 |
+
18,
|
| 336 |
+
4,
|
| 337 |
+
47,
|
| 338 |
+
6,
|
| 339 |
+
8,
|
| 340 |
+
26,
|
| 341 |
+
28,
|
| 342 |
+
37,
|
| 343 |
+
30,
|
| 344 |
+
4,
|
| 345 |
+
22,
|
| 346 |
+
2,
|
| 347 |
+
12,
|
| 348 |
+
12,
|
| 349 |
+
32,
|
| 350 |
+
13,
|
| 351 |
+
18,
|
| 352 |
+
39,
|
| 353 |
+
13
|
| 354 |
+
],
|
| 355 |
+
"output": [
|
| 356 |
+
-17,
|
| 357 |
+
-17,
|
| 358 |
+
-15,
|
| 359 |
+
-14,
|
| 360 |
+
-13,
|
| 361 |
+
-12,
|
| 362 |
+
-11,
|
| 363 |
+
-9,
|
| 364 |
+
-9,
|
| 365 |
+
-8,
|
| 366 |
+
-6,
|
| 367 |
+
-4,
|
| 368 |
+
-2,
|
| 369 |
+
0,
|
| 370 |
+
2,
|
| 371 |
+
4,
|
| 372 |
+
6,
|
| 373 |
+
7,
|
| 374 |
+
9,
|
| 375 |
+
10,
|
| 376 |
+
11,
|
| 377 |
+
12,
|
| 378 |
+
14,
|
| 379 |
+
15,
|
| 380 |
+
16,
|
| 381 |
+
17,
|
| 382 |
+
18
|
| 383 |
+
]
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"input": [
|
| 387 |
+
44,
|
| 388 |
+
41,
|
| 389 |
+
17,
|
| 390 |
+
11,
|
| 391 |
+
3,
|
| 392 |
+
21,
|
| 393 |
+
7,
|
| 394 |
+
1,
|
| 395 |
+
23,
|
| 396 |
+
48,
|
| 397 |
+
39,
|
| 398 |
+
41,
|
| 399 |
+
44,
|
| 400 |
+
26,
|
| 401 |
+
28,
|
| 402 |
+
46,
|
| 403 |
+
46,
|
| 404 |
+
9,
|
| 405 |
+
5,
|
| 406 |
+
29,
|
| 407 |
+
38,
|
| 408 |
+
5,
|
| 409 |
+
1,
|
| 410 |
+
4,
|
| 411 |
+
17
|
| 412 |
+
],
|
| 413 |
+
"output": [
|
| 414 |
+
-18,
|
| 415 |
+
-17,
|
| 416 |
+
-16,
|
| 417 |
+
-14,
|
| 418 |
+
-12,
|
| 419 |
+
-10,
|
| 420 |
+
-8,
|
| 421 |
+
-7,
|
| 422 |
+
-5,
|
| 423 |
+
-3,
|
| 424 |
+
-1,
|
| 425 |
+
0,
|
| 426 |
+
1,
|
| 427 |
+
3,
|
| 428 |
+
5,
|
| 429 |
+
6,
|
| 430 |
+
7,
|
| 431 |
+
9,
|
| 432 |
+
10,
|
| 433 |
+
12,
|
| 434 |
+
14,
|
| 435 |
+
15,
|
| 436 |
+
16,
|
| 437 |
+
18,
|
| 438 |
+
19
|
| 439 |
+
]
|
| 440 |
+
},
|
| 441 |
+
{
|
| 442 |
+
"input": [
|
| 443 |
+
19,
|
| 444 |
+
35,
|
| 445 |
+
2,
|
| 446 |
+
8,
|
| 447 |
+
30,
|
| 448 |
+
46
|
| 449 |
+
],
|
| 450 |
+
"output": [
|
| 451 |
+
-4,
|
| 452 |
+
-2,
|
| 453 |
+
0,
|
| 454 |
+
2,
|
| 455 |
+
4,
|
| 456 |
+
6
|
| 457 |
+
]
|
| 458 |
+
},
|
| 459 |
+
{
|
| 460 |
+
"input": [
|
| 461 |
+
19,
|
| 462 |
+
41,
|
| 463 |
+
16,
|
| 464 |
+
40,
|
| 465 |
+
20
|
| 466 |
+
],
|
| 467 |
+
"output": [
|
| 468 |
+
-3,
|
| 469 |
+
-1,
|
| 470 |
+
1,
|
| 471 |
+
3,
|
| 472 |
+
5
|
| 473 |
+
]
|
| 474 |
+
}
|
| 475 |
+
],
|
| 476 |
+
"haskell_template": "distinctDifferenceArray :: [Int] -> [Int]\ndistinctDifferenceArray nums ",
|
| 477 |
+
"ocaml_template": "let distinctDifferenceArray (nums: int list) : int list = ",
|
| 478 |
+
"scala_template": "def distinctDifferenceArray(nums: List[Int]): List[Int] = { \n \n}",
|
| 479 |
+
"java_template": "class Solution {\n public int[] distinctDifferenceArray(int[] nums) {\n \n }\n}",
|
| 480 |
+
"python_template": "class Solution(object):\n def distinctDifferenceArray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n "
|
| 481 |
+
}
|
find_the_distinct_difference_array/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let distinctDifferenceArray (nums: int list) : int list = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal [-3;-1;1;3;5] (distinctDifferenceArray [1;2;3;4;5])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [3;2;3;4;2])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [44; 1; 46; 10; 5; 7; 50; 2; 44; 32; 1; 26; 34; 21; 33; 30; 5; 6; 33; 12; 13; 1; 37])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [37])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [17; 31; 15; 24; 8; 5; 41; 12; 33; 23; 44; 3; 33; 45; 45; 44; 35; 37; 2; 31; 11; 38; 5; 10; 4; 48; 35; 1; 40; 3; 13])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [13; 1; 39; 29; 17; 39])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [14; 21; 34; 43; 2; 3; 48; 17; 1; 16; 40; 50; 27; 36; 6; 28; 26; 2; 44; 33; 43; 6; 13; 20; 21; 4; 6; 41; 38; 19; 39; 42; 14; 7; 35; 4; 39; 12; 6; 10; 25; 18])
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [10; 8; 44; 4; 33; 21; 50; 46; 29; 41; 45; 24; 30; 10; 43; 29; 38; 31; 14; 7; 3; 19; 27; 32; 5; 43; 24; 32; 6; 15; 24])
|
| 27 |
+
|
| 28 |
+
let test9 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [2; 2; 1; 39; 18; 15; 15; 3; 18; 4; 47; 6; 8; 26; 28; 37; 30; 4; 22; 2; 12; 12; 32; 13; 18; 39; 13])
|
| 29 |
+
|
| 30 |
+
let test10 _ = assert_equal [-2;-1;0;2;3] (distinctDifferenceArray [44; 41; 17; 11; 3; 21; 7; 1; 23; 48; 39; 41; 44; 26; 28; 46; 46; 9; 5; 29; 38; 5; 1; 4; 17])
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
(* Grouping test cases *)
|
| 34 |
+
let suite = "Test Suite for distinctDifferenceArray" >::: [
|
| 35 |
+
|
| 36 |
+
"test1" >:: test1;
|
| 37 |
+
"test2" >:: test2;
|
| 38 |
+
"test3" >:: test3;
|
| 39 |
+
"test4" >:: test4;
|
| 40 |
+
"test5" >:: test5;
|
| 41 |
+
"test6" >:: test6;
|
| 42 |
+
"test7" >:: test7;
|
| 43 |
+
"test8" >:: test8;
|
| 44 |
+
"test9" >:: test9;
|
| 45 |
+
"test10" >:: test10;
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
(* Running the tests *)
|
| 50 |
+
let () = run_test_tt_main suite
|
| 51 |
+
end
|
find_the_distinct_difference_array/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.distinctDifferenceArray(List(1,2,3,4,5)), List(-3,-1,1,3,5))
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.distinctDifferenceArray(List(3,2,3,4,2)), List(-2,-1,0,2,3))
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.distinctDifferenceArray(44,1,46,10,5,7,50,2,44,32,1,26,34,21,33,30,5,6,33,12,13,1,37), List(-17,-16,-14,-12,-11,-9,-7,-5,-4,-2,-2,0,2,4,5,7,8,10,11,13,15,16,18))
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.distinctDifferenceArray(37), List(1))
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.distinctDifferenceArray(17,31,15,24,8,5,41,12,33,23,44,3,33,45,45,44,35,37,2,31,11,38,5,10,4,48,35,1,40,3,13), List(-22,-21,-19,-17,-15,-14,-12,-10,-9,-7,-6,-5,-4,-3,-2,-1,0,2,4,5,7,9,10,12,14,16,17,19,21,22,24))
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.distinctDifferenceArray(13,1,39,29,17,39), List(-3,-1,0,2,4,5))
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.distinctDifferenceArray(14,21,34,43,2,3,48,17,1,16,40,50,27,36,6,28,26,2,44,33,43,6,13,20,21,4,6,41,38,19,39,42,14,7,35,4,39,12,6,10,25,18), List(-32,-31,-29,-28,-27,-25,-23,-21,-19,-17,-15,-13,-11,-9,-8,-6,-4,-3,-1,1,2,2,4,6,7,8,8,10,12,14,15,17,18,20,22,23,24,26,27,29,31,33))
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.distinctDifferenceArray(10,8,44,4,33,21,50,46,29,41,45,24,30,10,43,29,38,31,14,7,3,19,27,32,5,43,24,32,6,15,24), List(-24,-22,-20,-18,-16,-14,-12,-10,-9,-7,-5,-4,-2,-1,0,1,3,5,7,9,11,13,15,16,18,19,19,20,22,24,25))
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.distinctDifferenceArray(2,2,1,39,18,15,15,3,18,4,47,6,8,26,28,37,30,4,22,2,12,12,32,13,18,39,13), List(-17,-17,-15,-14,-13,-12,-11,-9,-9,-8,-6,-4,-2,0,2,4,6,7,9,10,11,12,14,15,16,17,18))
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.distinctDifferenceArray(44,41,17,11,3,21,7,1,23,48,39,41,44,26,28,46,46,9,5,29,38,5,1,4,17), List(-18,-17,-16,-14,-12,-10,-8,-7,-5,-3,-1,0,1,3,5,6,7,9,10,12,14,15,16,18,19))
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
find_the_divisibility_array_of_a_string/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
find_the_divisibility_array_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 (divisibilityArray \"998244353 \" 3)," [1,1,0,0,0,1,1,0,0] (divisibilityArray "998244353" 3))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (divisibilityArray \"1010 \" 10)," [0,1,0,1] (divisibilityArray "1010" 10))
|
| 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
|
find_the_divisibility_array_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(new ArrayList<>(Arrays.asList(1,1,0,0,0,1,1,0,0)), divisibilityArray("998244353", 3));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(new ArrayList<>(Arrays.asList(0,1,0,1)), divisibilityArray("1010", 10));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
find_the_divisibility_array_of_a_string/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_the_divisibility_array_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 [1;1;0;0;0;1;1;0;0] (divisibilityArray "998244353" 3)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal [0;1;0;1] (divisibilityArray "1010" 10)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for divisibilityArray" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
find_the_divisibility_array_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.divisibilityArray("998244353",3), List(1,1,0,0,0,1,1,0,0))
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.divisibilityArray("1010",10), List(0,1,0,1))
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
find_the_encrypted_string/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 (getEncryptedString \"dart \" 3)," "tdar" (getEncryptedString "dart" 3))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (getEncryptedString \"aaa \" 1)," "aaa" (getEncryptedString "aaa" 1))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (getEncryptedString \"rbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxrmio \" 7741)," "miorbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxr" (getEncryptedString "rbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxrmio" 7741))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (getEncryptedString \"hvhqfefrfsrrnzulrpiwithkpxofnpkulntdhbinzhxqyxkmnffmqytnvoxb \" 2798)," "inzhxqyxkmnffmqytnvoxbhvhqfefrfsrrnzulrpiwithkpxofnpkulntdhb" (getEncryptedString "hvhqfefrfsrrnzulrpiwithkpxofnpkulntdhbinzhxqyxkmnffmqytnvoxb" 2798))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (getEncryptedString \"zgbvjxqqdqvlqgggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqe \" 4109)," "ggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqezgbvjxqqdqvlqg" (getEncryptedString "zgbvjxqqdqvlqgggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqe" 4109))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (getEncryptedString \"nxwxpleawbsjapojgdy \" 3352)," "wbsjapojgdynxwxplea" (getEncryptedString "nxwxpleawbsjapojgdy" 3352))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (getEncryptedString \"dwratwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkw \" 7103)," "atwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkwdwr" (getEncryptedString "dwratwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkw" 7103))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (getEncryptedString \"xxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilove \" 328)," "vexxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilo" (getEncryptedString "xxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilove" 328))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (getEncryptedString \"rezrxaokhzkrvtkbmezlcqwjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbprae \" 7727)," "wjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbpraerezrxaokhzkrvtkbmezlcq" (getEncryptedString "rezrxaokhzkrvtkbmezlcqwjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbprae" 7727))
|
| 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
|
find_the_encrypted_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("3", getEncryptedString("dart", 3));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals("1", getEncryptedString("aaa", 1));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
find_the_encrypted_string/meta.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3468,
|
| 3 |
+
"name": "find_the_encrypted_string",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/find-the-encrypted-string/",
|
| 6 |
+
"date": "2024-06-30 00:00:00",
|
| 7 |
+
"task_description": "You are given a string `s` and an integer `k`. Encrypt the string using the following algorithm: For each character `c` in `s`, replace `c` with the `kth` character after `c` in the string (in a cyclic manner). Return the _encrypted string_. **Example 1:** **Input:** s = \"dart\", k = 3 **Output:** \"tdar\" **Explanation:** For `i = 0`, the 3rd character after `'d'` is `'t'`. For `i = 1`, the 3rd character after `'a'` is `'d'`. For `i = 2`, the 3rd character after `'r'` is `'a'`. For `i = 3`, the 3rd character after `'t'` is `'r'`. **Example 2:** **Input:** s = \"aaa\", k = 1 **Output:** \"aaa\" **Explanation:** As all the characters are the same, the encrypted string will also be the same. **Constraints:** `1 <= s.length <= 100` `1 <= k <= 104` `s` consists only of lowercase English letters.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "s = \"dart\", k = 3",
|
| 12 |
+
"output": "\"tdar\" "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "s = \"aaa\", k = 1",
|
| 17 |
+
"output": "\"aaa\" "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
"\"rbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxrmio\"",
|
| 24 |
+
7741
|
| 25 |
+
],
|
| 26 |
+
"output": "miorbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxr"
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"input": [
|
| 30 |
+
"\"hvhqfefrfsrrnzulrpiwithkpxofnpkulntdhbinzhxqyxkmnffmqytnvoxb\"",
|
| 31 |
+
2798
|
| 32 |
+
],
|
| 33 |
+
"output": "inzhxqyxkmnffmqytnvoxbhvhqfefrfsrrnzulrpiwithkpxofnpkulntdhb"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"input": [
|
| 37 |
+
"\"zgbvjxqqdqvlqgggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqe\"",
|
| 38 |
+
4109
|
| 39 |
+
],
|
| 40 |
+
"output": "ggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqezgbvjxqqdqvlqg"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": [
|
| 44 |
+
"\"nxwxpleawbsjapojgdy\"",
|
| 45 |
+
3352
|
| 46 |
+
],
|
| 47 |
+
"output": "wbsjapojgdynxwxplea"
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"input": [
|
| 51 |
+
"\"dwratwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkw\"",
|
| 52 |
+
7103
|
| 53 |
+
],
|
| 54 |
+
"output": "atwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkwdwr"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"input": [
|
| 58 |
+
"\"xxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilove\"",
|
| 59 |
+
328
|
| 60 |
+
],
|
| 61 |
+
"output": "vexxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilo"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"input": [
|
| 65 |
+
"\"rezrxaokhzkrvtkbmezlcqwjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbprae\"",
|
| 66 |
+
7727
|
| 67 |
+
],
|
| 68 |
+
"output": "wjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbpraerezrxaokhzkrvtkbmezlcq"
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"input": [
|
| 72 |
+
"\"hftlmhlrdtkfmlzukcyazjbglrizzhyhupqzxyybtiiddsgzhfqhavqacrlimfhusrrgarplrqwr\"",
|
| 73 |
+
6417
|
| 74 |
+
],
|
| 75 |
+
"output": "pqzxyybtiiddsgzhfqhavqacrlimfhusrrgarplrqwrhftlmhlrdtkfmlzukcyazjbglrizzhyhu"
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"input": [
|
| 79 |
+
"iurvokhadhprgjlpdase",
|
| 80 |
+
4012
|
| 81 |
+
],
|
| 82 |
+
"output": "gjlpdaseiurvokhadhpr"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"input": [
|
| 86 |
+
"zlodkbooipzfdfoflitcduiqcbxphftkmcpphnshpldvtad",
|
| 87 |
+
3091
|
| 88 |
+
],
|
| 89 |
+
"output": "hnshpldvtadzlodkbooipzfdfoflitcduiqcbxphftkmcpp"
|
| 90 |
+
}
|
| 91 |
+
],
|
| 92 |
+
"haskell_template": "getEncryptedString :: String -> Int -> String\ngetEncryptedString s k ",
|
| 93 |
+
"ocaml_template": "let getEncryptedString (s: string) (k: int) : string = ",
|
| 94 |
+
"scala_template": "def getEncryptedString(s: String,k: Int): String = { \n \n}",
|
| 95 |
+
"java_template": "class Solution {\n public String getEncryptedString(String s, int k) {\n \n }\n}",
|
| 96 |
+
"python_template": "class Solution(object):\n def getEncryptedString(self, s, k):\n \"\"\"\n :type s: str\n :type k: int\n :rtype: str\n \"\"\"\n "
|
| 97 |
+
}
|
find_the_encrypted_string/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 "tdar" (getEncryptedString "dart" 3)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal "aaa" (getEncryptedString "aaa" 1)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal "miorbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxr" (getEncryptedString "rbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxrmio" 7741)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal "inzhxqyxkmnffmqytnvoxbhvhqfefrfsrrnzulrpiwithkpxofnpkulntdhb" (getEncryptedString "hvhqfefrfsrrnzulrpiwithkpxofnpkulntdhbinzhxqyxkmnffmqytnvoxb" 2798)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal "ggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqezgbvjxqqdqvlqg" (getEncryptedString "zgbvjxqqdqvlqgggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqe" 4109)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal "wbsjapojgdynxwxplea" (getEncryptedString "nxwxpleawbsjapojgdy" 3352)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal "atwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkwdwr" (getEncryptedString "dwratwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkw" 7103)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal "vexxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilo" (getEncryptedString "xxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilove" 328)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal "wjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbpraerezrxaokhzkrvtkbmezlcq" (getEncryptedString "rezrxaokhzkrvtkbmezlcqwjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbprae" 7727)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal "pqzxyybtiiddsgzhfqhavqacrlimfhusrrgarplrqwrhftlmhlrdtkfmlzukcyazjbglrizzhyhu" (getEncryptedString "hftlmhlrdtkfmlzukcyazjbglrizzhyhupqzxyybtiiddsgzhfqhavqacrlimfhusrrgarplrqwr" 6417)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for getEncryptedString" >::: [
|
| 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
|
find_the_encrypted_string/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.getEncryptedString("dart",3), "tdar")
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.getEncryptedString("aaa",1), "aaa")
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.getEncryptedString("rbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxrmio",7741), "miorbbuoygmhvmavtzmldkjebyivpuowhrivdwbptxxr")
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.getEncryptedString("hvhqfefrfsrrnzulrpiwithkpxofnpkulntdhbinzhxqyxkmnffmqytnvoxb",2798), "inzhxqyxkmnffmqytnvoxbhvhqfefrfsrrnzulrpiwithkpxofnpkulntdhb")
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.getEncryptedString("zgbvjxqqdqvlqgggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqe",4109), "ggyblhcdukedgcayseoppquyjrtrwzclevblddphqzhkozxqezgbvjxqqdqvlqg")
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.getEncryptedString("nxwxpleawbsjapojgdy",3352), "wbsjapojgdynxwxplea")
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.getEncryptedString("dwratwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkw",7103), "atwxwsycospwwsvgyapifwgxqsekzkgguhqnlcclmnthlcbebbnoprqjacebuzgzxwkwdwr")
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.getEncryptedString("xxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilove",328), "vexxdstahykrysrgeqhhttsaqfqbwfpdgtymrfxnmkotfswvpzzphhwwjbpfrkgilo")
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.getEncryptedString("rezrxaokhzkrvtkbmezlcqwjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbprae",7727), "wjfxbaeeaafdwxzffckzmvshncjipexriwcqnffkbpraerezrxaokhzkrvtkbmezlcq")
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.getEncryptedString("hftlmhlrdtkfmlzukcyazjbglrizzhyhupqzxyybtiiddsgzhfqhavqacrlimfhusrrgarplrqwr",6417), "pqzxyybtiiddsgzhfqhavqacrlimfhusrrgarplrqwrhftlmhlrdtkfmlzukcyazjbglrizzhyhu")
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
find_the_first_player_to_win_k_games_in_a_row/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_the_first_player_to_win_k_games_in_a_row/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(2, findWinningPlayer(new ArrayList<>(Arrays.asList(4,2,6,3,9)), 2));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, findWinningPlayer(new ArrayList<>(Arrays.asList(2,5,4)), 3));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
find_the_first_player_to_win_k_games_in_a_row/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae7c57d5917e64628d2b6cd5ab8b28e0a84f8fb8905cddf0658b4537bb7d84c2
|
| 3 |
+
size 13751452
|
find_the_first_player_to_win_k_games_in_a_row/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_the_first_player_to_win_k_games_in_a_row/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
find_the_grid_of_region_average/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(new ArrayList<>(Arrays.asList(9,9,9,9)),new ArrayList<>(Arrays.asList(9,9,9,9)),new ArrayList<>(Arrays.asList(9,9,9,9)))), resultGrid(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,6,7,10)),new ArrayList<>(Arrays.asList(8,9,10,10)),new ArrayList<>(Arrays.asList(11,12,13,10)))), 3));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(25,25,25)),new ArrayList<>(Arrays.asList(27,27,27)),new ArrayList<>(Arrays.asList(27,27,27)),new ArrayList<>(Arrays.asList(30,30,30)))), resultGrid(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(10,20,30)),new ArrayList<>(Arrays.asList(15,25,35)),new ArrayList<>(Arrays.asList(20,30,40)),new ArrayList<>(Arrays.asList(25,35,45)))), 12));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,6,7)),new ArrayList<>(Arrays.asList(8,9,10)),new ArrayList<>(Arrays.asList(11,12,13)))), resultGrid(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,6,7)),new ArrayList<>(Arrays.asList(8,9,10)),new ArrayList<>(Arrays.asList(11,12,13)))), 1));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
find_the_integer_added_to_array_i/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 (addedInteger [2,6,4] [9,7,5])," 3 (addedInteger [2,6,4] [9,7,5]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (addedInteger [10] [5])," (-5) (addedInteger [10] [5]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (addedInteger [1,1,1,1] [1,1,1,1])," 0 (addedInteger [1,1,1,1] [1,1,1,1]))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (addedInteger [900, 406, 917, 736, 331, 89, 81, 268, 776, 577, 299, 33, 555, 191, 54, 329, 85, 429, 623, 887, 533, 290, 806, 636, 946, 105] [697, 203, 714, 533, 128, ( -114), ( -122), 65, 573, 374, 96, ( -170), 352, ( -12), ( -149), 126, ( -118), 226, 420, 684, 330, 87, 603, 433, 743, ( -98)])," (-203) (addedInteger [900, 406, 917, 736, 331, 89, 81, 268, 776, 577, 299, 33, 555, 191, 54, 329, 85, 429, 623, 887, 533, 290, 806, 636, 946, 105] [697, 203, 714, 533, 128, -114, -122, 65, 573, 374, 96, -170, 352, -12, -149, 126, -118, 226, 420, 684, 330, 87, 603, 433, 743, -98]))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (addedInteger [102, 64, 584, 874, 258, 453, 115, 505, 147, 784, 692, 257, 884, 872, 194, 380, 23, 268, 125, 419, 704, 749, 149, 458, 730, 731, 113, 649, 697, 895, 172, 384, 568, 414, 69, 407, 696, 501, 285, 478, 524, 198, 11, 942, 464, 816, 461, 869, 211] [673, 635, 1155, 1445, 829, 1024, 686, 1076, 718, 1355, 1263, 828, 1455, 1443, 765, 951, 594, 839, 696, 990, 1275, 1320, 720, 1029, 1301, 1302, 684, 1220, 1268, 1466, 743, 955, 1139, 985, 640, 978, 1267, 1072, 856, 1049, 1095, 769, 582, 1513, 1035, 1387, 1032, 1440, 782])," 571 (addedInteger [102, 64, 584, 874, 258, 453, 115, 505, 147, 784, 692, 257, 884, 872, 194, 380, 23, 268, 125, 419, 704, 749, 149, 458, 730, 731, 113, 649, 697, 895, 172, 384, 568, 414, 69, 407, 696, 501, 285, 478, 524, 198, 11, 942, 464, 816, 461, 869, 211] [673, 635, 1155, 1445, 829, 1024, 686, 1076, 718, 1355, 1263, 828, 1455, 1443, 765, 951, 594, 839, 696, 990, 1275, 1320, 720, 1029, 1301, 1302, 684, 1220, 1268, 1466, 743, 955, 1139, 985, 640, 978, 1267, 1072, 856, 1049, 1095, 769, 582, 1513, 1035, 1387, 1032, 1440, 782]))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (addedInteger [728, 220, 82] [1309, 801, 663])," 581 (addedInteger [728, 220, 82] [1309, 801, 663]))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (addedInteger [382, 525, 20, 929, 409, 352, 407, 278, 120, 425, 299, 168, 262, 257, 274, 447, 147, 941, 307, 991, 380, 775, 384, 536, 143, 384, 600, 131, 870, 20, 937, 71, 809, 664, 524, 707, 930, 724, 730, 477, 326, 390, 310] [1308, 1451, 946, 1855, 1335, 1278, 1333, 1204, 1046, 1351, 1225, 1094, 1188, 1183, 1200, 1373, 1073, 1867, 1233, 1917, 1306, 1701, 1310, 1462, 1069, 1310, 1526, 1057, 1796, 946, 1863, 997, 1735, 1590, 1450, 1633, 1856, 1650, 1656, 1403, 1252, 1316, 1236])," 926 (addedInteger [382, 525, 20, 929, 409, 352, 407, 278, 120, 425, 299, 168, 262, 257, 274, 447, 147, 941, 307, 991, 380, 775, 384, 536, 143, 384, 600, 131, 870, 20, 937, 71, 809, 664, 524, 707, 930, 724, 730, 477, 326, 390, 310] [1308, 1451, 946, 1855, 1335, 1278, 1333, 1204, 1046, 1351, 1225, 1094, 1188, 1183, 1200, 1373, 1073, 1867, 1233, 1917, 1306, 1701, 1310, 1462, 1069, 1310, 1526, 1057, 1796, 946, 1863, 997, 1735, 1590, 1450, 1633, 1856, 1650, 1656, 1403, 1252, 1316, 1236]))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (addedInteger [106, 441, 732, 944, 345, 134, 985, 522, 51, 242, 685, 270, 710, 946, 769, 870, 910, 453, 753, 495, 794, 779, 553, 821, 359, 604, 964, 885, 919, 341, 454, 829, 473, 39, 135, 560, 189, 590, 584] [569, 904, 1195, 1407, 808, 597, 1448, 985, 514, 705, 1148, 733, 1173, 1409, 1232, 1333, 1373, 916, 1216, 958, 1257, 1242, 1016, 1284, 822, 1067, 1427, 1348, 1382, 804, 917, 1292, 936, 502, 598, 1023, 652, 1053, 1047])," 463 (addedInteger [106, 441, 732, 944, 345, 134, 985, 522, 51, 242, 685, 270, 710, 946, 769, 870, 910, 453, 753, 495, 794, 779, 553, 821, 359, 604, 964, 885, 919, 341, 454, 829, 473, 39, 135, 560, 189, 590, 584] [569, 904, 1195, 1407, 808, 597, 1448, 985, 514, 705, 1148, 733, 1173, 1409, 1232, 1333, 1373, 916, 1216, 958, 1257, 1242, 1016, 1284, 822, 1067, 1427, 1348, 1382, 804, 917, 1292, 936, 502, 598, 1023, 652, 1053, 1047]))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (addedInteger [181, 844, 69, 52, 815, 368, 150, 273, 872, 972, 198, 926, 818, 534, 488, 182, 708, 254, 89, 601, 769, 401, 340, 593, 28, 429, 25, 624, 594, 406, 479, 171, 556, 757, 988, 478, 763, 833, 795, 382, 374, 936, 572, 509, 169, 781, 745, 538, 905, 632, 868, 274, 758, 955, 468, 771, 192, 627, 77, 606, 971, 571, 409, 381, 932, 810, 508, 143, 735, 616, 233, 367, 396, 413, 119, 970, 96, 637, 325, 188, 421, 551, 547, 443, 570, 428] [808, 1471, 696, 679, 1442, 995, 777, 900, 1499, 1599, 825, 1553, 1445, 1161, 1115, 809, 1335, 881, 716, 1228, 1396, 1028, 967, 1220, 655, 1056, 652, 1251, 1221, 1033, 1106, 798, 1183, 1384, 1615, 1105, 1390, 1460, 1422, 1009, 1001, 1563, 1199, 1136, 796, 1408, 1372, 1165, 1532, 1259, 1495, 901, 1385, 1582, 1095, 1398, 819, 1254, 704, 1233, 1598, 1198, 1036, 1008, 1559, 1437, 1135, 770, 1362, 1243, 860, 994, 1023, 1040, 746, 1597, 723, 1264, 952, 815, 1048, 1178, 1174, 1070, 1197, 1055])," 627 (addedInteger [181, 844, 69, 52, 815, 368, 150, 273, 872, 972, 198, 926, 818, 534, 488, 182, 708, 254, 89, 601, 769, 401, 340, 593, 28, 429, 25, 624, 594, 406, 479, 171, 556, 757, 988, 478, 763, 833, 795, 382, 374, 936, 572, 509, 169, 781, 745, 538, 905, 632, 868, 274, 758, 955, 468, 771, 192, 627, 77, 606, 971, 571, 409, 381, 932, 810, 508, 143, 735, 616, 233, 367, 396, 413, 119, 970, 96, 637, 325, 188, 421, 551, 547, 443, 570, 428] [808, 1471, 696, 679, 1442, 995, 777, 900, 1499, 1599, 825, 1553, 1445, 1161, 1115, 809, 1335, 881, 716, 1228, 1396, 1028, 967, 1220, 655, 1056, 652, 1251, 1221, 1033, 1106, 798, 1183, 1384, 1615, 1105, 1390, 1460, 1422, 1009, 1001, 1563, 1199, 1136, 796, 1408, 1372, 1165, 1532, 1259, 1495, 901, 1385, 1582, 1095, 1398, 819, 1254, 704, 1233, 1598, 1198, 1036, 1008, 1559, 1437, 1135, 770, 1362, 1243, 860, 994, 1023, 1040, 746, 1597, 723, 1264, 952, 815, 1048, 1178, 1174, 1070, 1197, 1055]))
|
| 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
|