a54d0744d3adeb64425139b993c3f0457b61ebc81d16aa5c021673f8c7973711
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- count_pairs_of_points_with_distance_k/meta.json +3 -0
- count_pairs_of_points_with_distance_k/ocaml_tests/main.ml +26 -0
- count_pairs_of_points_with_distance_k/scala_tests/MySuite.scala +12 -0
- count_pairs_of_similar_strings/.DS_Store +0 -0
- count_pairs_of_similar_strings/haskell_tests/Main.hs +27 -0
- count_pairs_of_similar_strings/java_tests/Main.java +25 -0
- count_pairs_of_similar_strings/meta.json +31 -0
- count_pairs_of_similar_strings/ocaml_tests/main.ml +29 -0
- count_pairs_of_similar_strings/scala_tests/MySuite.scala +16 -0
- count_pairs_that_form_a_complete_day_i/haskell_tests/Main.hs +41 -0
- count_pairs_that_form_a_complete_day_i/java_tests/Main.java +20 -0
- count_pairs_that_form_a_complete_day_i/meta.json +308 -0
- count_pairs_that_form_a_complete_day_i/ocaml_tests/main.ml +42 -0
- count_pairs_that_form_a_complete_day_i/scala_tests/MySuite.scala +32 -0
- count_pairs_that_form_a_complete_day_ii/haskell_tests/Main.hs +0 -0
- count_pairs_that_form_a_complete_day_ii/java_tests/Main.java +20 -0
- count_pairs_that_form_a_complete_day_ii/meta.json +0 -0
- count_pairs_that_form_a_complete_day_ii/ocaml_tests/main.ml +0 -0
- count_pairs_that_form_a_complete_day_ii/scala_tests/MySuite.scala +0 -0
- count_pairs_whose_sum_is_less_than_target/.DS_Store +0 -0
- count_pairs_whose_sum_is_less_than_target/haskell_tests/Main.hs +24 -0
- count_pairs_whose_sum_is_less_than_target/java_tests/Main.java +21 -0
- count_pairs_whose_sum_is_less_than_target/meta.json +266 -0
- count_pairs_whose_sum_is_less_than_target/ocaml_tests/main.ml +26 -0
- count_pairs_whose_sum_is_less_than_target/scala_tests/MySuite.scala +12 -0
- count_palindromic_subsequences/.DS_Store +0 -0
- count_palindromic_subsequences/haskell_tests/Main.hs +27 -0
- count_palindromic_subsequences/java_tests/Main.java +25 -0
- count_palindromic_subsequences/meta.json +72 -0
- count_palindromic_subsequences/ocaml_tests/main.ml +29 -0
- count_palindromic_subsequences/scala_tests/MySuite.scala +16 -0
- count_partitions_with_even_sum_difference/haskell_tests/Main.hs +47 -0
- count_partitions_with_even_sum_difference/java_tests/Main.java +24 -0
- count_partitions_with_even_sum_difference/meta.json +627 -0
- count_partitions_with_even_sum_difference/ocaml_tests/main.ml +51 -0
- count_partitions_with_even_sum_difference/scala_tests/MySuite.scala +44 -0
- count_paths_that_can_form_a_palindrome_in_a_tree/.DS_Store +0 -0
- count_paths_that_can_form_a_palindrome_in_a_tree/haskell_tests/Main.hs +24 -0
- count_paths_that_can_form_a_palindrome_in_a_tree/java_tests/Main.java +21 -0
- count_paths_that_can_form_a_palindrome_in_a_tree/meta.json +579 -0
- count_paths_that_can_form_a_palindrome_in_a_tree/ocaml_tests/main.ml +26 -0
- count_paths_that_can_form_a_palindrome_in_a_tree/scala_tests/MySuite.scala +12 -0
- count_paths_with_the_given_xor_value/haskell_tests/Main.hs +0 -0
- count_paths_with_the_given_xor_value/java_tests/Main.java +21 -0
- count_paths_with_the_given_xor_value/meta.json +0 -0
- count_paths_with_the_given_xor_value/ocaml_tests/main.ml +0 -0
- count_paths_with_the_given_xor_value/scala_tests/MySuite.scala +0 -0
- count_prefix_and_suffix_pairs_i/haskell_tests/Main.hs +44 -0
- count_prefix_and_suffix_pairs_i/java_tests/Main.java +24 -0
.gitattributes
CHANGED
|
@@ -80,3 +80,4 @@ count_good_triplets_in_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
| 80 |
count_non_decreasing_subarrays_after_k_operations/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 81 |
count_number_of_bad_pairs/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 82 |
count_of_interesting_subarrays/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 80 |
count_non_decreasing_subarrays_after_k_operations/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 81 |
count_number_of_bad_pairs/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 82 |
count_of_interesting_subarrays/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 83 |
+
count_pairs_of_points_with_distance_k/meta.json filter=lfs diff=lfs merge=lfs -text
|
count_pairs_of_points_with_distance_k/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fe39bd52f4d10921a2d860cb62dc1886528283c21e9256a22358af70912e517f
|
| 3 |
+
size 28016210
|
count_pairs_of_points_with_distance_k/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 2 (countPairs [[1;2];[4;2];[1;3];[5;2]] 5)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 10 (countPairs [[1;3];[1;3];[1;3];[1;3];[1;3]] 0)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for countPairs" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
count_pairs_of_points_with_distance_k/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countPairs(List(List(1,2),List(4,2),List(1,3),List(5,2)),5), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countPairs(List(List(1,3),List(1,3),List(1,3),List(1,3),List(1,3)),0), 10)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
count_pairs_of_similar_strings/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
count_pairs_of_similar_strings/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 (similarPairs [ \"aba \", \"aabb \", \"abcd \", \"bac \", \"aabc \"])," 2 (similarPairs ["aba","aabb","abcd","bac","aabc"]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (similarPairs [ \"aabb \", \"ab \", \"ba \"])," 3 (similarPairs ["aabb","ab","ba"]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (similarPairs [ \"nba \", \"cba \", \"dba \"])," 0 (similarPairs ["nba","cba","dba"]))
|
| 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
|
count_pairs_of_similar_strings/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(2, similarPairs(new ArrayList<>(Arrays.asList("aba","aabb","abcd","bac","aabc"))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(3, similarPairs(new ArrayList<>(Arrays.asList("aabb","ab","ba"))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(0, similarPairs(new ArrayList<>(Arrays.asList("nba","cba","dba"))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
count_pairs_of_similar_strings/meta.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2594,
|
| 3 |
+
"name": "count_pairs_of_similar_strings",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/count-pairs-of-similar-strings/",
|
| 6 |
+
"date": "1670716800000",
|
| 7 |
+
"task_description": "You are given a **0-indexed** string array `words`. Two strings are **similar** if they consist of the same characters. For example, `\"abca\"` and `\"cba\"` are similar since both consist of characters `'a'`, `'b'`, and `'c'`. However, `\"abacba\"` and `\"bcfd\"` are not similar since they do not consist of the same characters. Return _the number of pairs _`(i, j)`_ such that _`0 <= i < j <= word.length - 1`_ and the two strings _`words[i]`_ and _`words[j]`_ are similar_. **Example 1:** ``` **Input:** words = [\"aba\",\"aabb\",\"abcd\",\"bac\",\"aabc\"] **Output:** 2 **Explanation:** There are 2 pairs that satisfy the conditions: - i = 0 and j = 1 : both words[0] and words[1] only consist of characters 'a' and 'b'. - i = 3 and j = 4 : both words[3] and words[4] only consist of characters 'a', 'b', and 'c'. ``` **Example 2:** ``` **Input:** words = [\"aabb\",\"ab\",\"ba\"] **Output:** 3 **Explanation:** There are 3 pairs that satisfy the conditions: - i = 0 and j = 1 : both words[0] and words[1] only consist of characters 'a' and 'b'. - i = 0 and j = 2 : both words[0] and words[2] only consist of characters 'a' and 'b'. - i = 1 and j = 2 : both words[1] and words[2] only consist of characters 'a' and 'b'. ``` **Example 3:** ``` **Input:** words = [\"nba\",\"cba\",\"dba\"] **Output:** 0 **Explanation:** Since there does not exist any pair that satisfies the conditions, we return 0. ``` **Constraints:** `1 <= words.length <= 100` `1 <= words[i].length <= 100` `words[i]` consist of only lowercase English letters.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "words = [\"aba\",\"aabb\",\"abcd\",\"bac\",\"aabc\"]",
|
| 12 |
+
"output": "2 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "words = [\"aabb\",\"ab\",\"ba\"]",
|
| 17 |
+
"output": "3 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "words = [\"nba\",\"cba\",\"dba\"]",
|
| 22 |
+
"output": "0 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [],
|
| 26 |
+
"haskell_template": "similarPairs :: [String] -> Int\nsimilarPairs words ",
|
| 27 |
+
"ocaml_template": "let similarPairs (words: string list) : int = ",
|
| 28 |
+
"scala_template": "def similarPairs(words: List[String]): Int = { \n \n}",
|
| 29 |
+
"java_template": "public static int similarPairs(List<String> words) {\n\n}",
|
| 30 |
+
"python_template": "class Solution(object):\n def similarPairs(self, words):\n \"\"\"\n :type words: List[str]\n :rtype: int\n \"\"\"\n "
|
| 31 |
+
}
|
count_pairs_of_similar_strings/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 2 (similarPairs ["aba";"aabb";"abcd";"bac";"aabc"])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 3 (similarPairs ["aabb";"ab";"ba"])
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 0 (similarPairs ["nba";"cba";"dba"])
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for similarPairs" >::: [
|
| 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
|
count_pairs_of_similar_strings/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.similarPairs(List("aba","aabb","abcd","bac","aabc")), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.similarPairs(List("aabb","ab","ba")), 3)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.similarPairs(List("nba","cba","dba")), 0)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
count_pairs_that_form_a_complete_day_i/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
countCompleteDayPairs :: [Int] -> Int
|
| 7 |
+
countCompleteDayPairs hours = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (countCompleteDayPairs [12,12,30,24,24])," 2 (countCompleteDayPairs [12,12,30,24,24]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (countCompleteDayPairs [72,48,24,3])," 3 (countCompleteDayPairs [72,48,24,3]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (countCompleteDayPairs [484249851, 20131823, 423249632, 306507858, 267480235, 644385379, 214221130, 863070660, 913399484, 33535693, 823052413, 119998291, 791789190, 747763329, 349740924, 870030038, 889221130, 582613194, 63031737, 217611714, 413754792, 45752817, 231824638, 97115412, 300411069, 750313959, 636662712])," 13 (countCompleteDayPairs [484249851, 20131823, 423249632, 306507858, 267480235, 644385379, 214221130, 863070660, 913399484, 33535693, 823052413, 119998291, 791789190, 747763329, 349740924, 870030038, 889221130, 582613194, 63031737, 217611714, 413754792, 45752817, 231824638, 97115412, 300411069, 750313959, 636662712]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (countCompleteDayPairs [265192379, 251492627, 362613040, 576331209, 378573986, 1155128, 614150205, 637266169, 222720672])," 1 (countCompleteDayPairs [265192379, 251492627, 362613040, 576331209, 378573986, 1155128, 614150205, 637266169, 222720672]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (countCompleteDayPairs [959299844, 761641332, 226576332, 6248306, 37544232, 814604392, 790190230, 634308442, 911324956, 451569407, 29169901, 397736530, 928782919, 546317527, 678979322, 512326702, 31339121, 436313688, 797629546, 954100757, 884971463, 1191042, 955577260, 457864963, 87740485, 885378995, 542064265, 867248085, 901391749, 297300874, 633857683, 176721844, 882394721, 313124199, 118927867, 394067016, 301108225, 84437874, 801474168, 330150184, 398444875, 878677133, 517602170, 506916391, 331983268, 180385407, 317174381, 532247244, 556657910, 791501365, 334916047, 641583456, 845444603, 801837711, 50404693, 734059136, 41364658, 326358511, 643541472, 872906855, 994866722, 817834129, 321631634, 71433786, 294754562, 665179719, 881449335, 73010774, 595933678, 732890714, 106684665, 714232800, 893332836, 580321311, 16073763, 986360070, 691933437, 8363963, 352951983, 936625985, 962588148, 878415236])," 135 (countCompleteDayPairs [959299844, 761641332, 226576332, 6248306, 37544232, 814604392, 790190230, 634308442, 911324956, 451569407, 29169901, 397736530, 928782919, 546317527, 678979322, 512326702, 31339121, 436313688, 797629546, 954100757, 884971463, 1191042, 955577260, 457864963, 87740485, 885378995, 542064265, 867248085, 901391749, 297300874, 633857683, 176721844, 882394721, 313124199, 118927867, 394067016, 301108225, 84437874, 801474168, 330150184, 398444875, 878677133, 517602170, 506916391, 331983268, 180385407, 317174381, 532247244, 556657910, 791501365, 334916047, 641583456, 845444603, 801837711, 50404693, 734059136, 41364658, 326358511, 643541472, 872906855, 994866722, 817834129, 321631634, 71433786, 294754562, 665179719, 881449335, 73010774, 595933678, 732890714, 106684665, 714232800, 893332836, 580321311, 16073763, 986360070, 691933437, 8363963, 352951983, 936625985, 962588148, 878415236]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (countCompleteDayPairs [635297370, 842262050, 47951226, 553842598, 564226180, 132079688, 860183578, 597789984, 896408173, 546302081, 402136978, 120419676, 120626418, 745085032, 159309803, 354721973, 815512, 845926215, 456421865, 868676105, 611546687, 96749933, 673776359, 258276503, 316098261, 835801483, 379925373, 249076431, 763266688, 589941296, 722982600, 846555155, 269562800, 405201270, 927656154, 4734100, 842550771, 982478207, 546750710, 94852298, 382041278, 289672557, 90740594, 749839889, 677403199, 941307259, 222886603, 449089249, 88803540, 907045400, 819868345, 497317447, 749180510, 541620736, 7250842, 269689215, 900722308, 400666603, 826938836, 826358718, 384606428, 614408623, 102329937, 960338321, 233015652, 243266812])," 87 (countCompleteDayPairs [635297370, 842262050, 47951226, 553842598, 564226180, 132079688, 860183578, 597789984, 896408173, 546302081, 402136978, 120419676, 120626418, 745085032, 159309803, 354721973, 815512, 845926215, 456421865, 868676105, 611546687, 96749933, 673776359, 258276503, 316098261, 835801483, 379925373, 249076431, 763266688, 589941296, 722982600, 846555155, 269562800, 405201270, 927656154, 4734100, 842550771, 982478207, 546750710, 94852298, 382041278, 289672557, 90740594, 749839889, 677403199, 941307259, 222886603, 449089249, 88803540, 907045400, 819868345, 497317447, 749180510, 541620736, 7250842, 269689215, 900722308, 400666603, 826938836, 826358718, 384606428, 614408623, 102329937, 960338321, 233015652, 243266812]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (countCompleteDayPairs [972255106, 715135991, 657342452, 418702895, 463108707, 443025123, 466716711, 392904233, 686106138, 826213895, 93600359, 472218527, 472528555, 889710596, 530569415, 634423426, 677691419, 813261936, 773309727, 247912299, 16770414, 691517040, 471974834, 345109292, 64836279, 650461299, 679249842, 557133447, 783166173, 189419588, 845198689, 96859531, 286993384, 711659721, 934039608, 409146963, 881625966, 436867286, 597545914, 404413821, 805048355, 361974413, 395468588, 69593810, 460483016, 465016063, 183973479, 831109894, 814316619, 916030264, 901368139, 133469276, 592061153, 821462735, 830015333, 883360042, 643512811, 747545234, 907354639, 786007693, 922923586, 842947056, 632319533, 501142589, 230543679, 732967892, 992767473, 620178248, 743090941, 586983000, 79529573, 421134157])," 87 (countCompleteDayPairs [972255106, 715135991, 657342452, 418702895, 463108707, 443025123, 466716711, 392904233, 686106138, 826213895, 93600359, 472218527, 472528555, 889710596, 530569415, 634423426, 677691419, 813261936, 773309727, 247912299, 16770414, 691517040, 471974834, 345109292, 64836279, 650461299, 679249842, 557133447, 783166173, 189419588, 845198689, 96859531, 286993384, 711659721, 934039608, 409146963, 881625966, 436867286, 597545914, 404413821, 805048355, 361974413, 395468588, 69593810, 460483016, 465016063, 183973479, 831109894, 814316619, 916030264, 901368139, 133469276, 592061153, 821462735, 830015333, 883360042, 643512811, 747545234, 907354639, 786007693, 922923586, 842947056, 632319533, 501142589, 230543679, 732967892, 992767473, 620178248, 743090941, 586983000, 79529573, 421134157]))
|
| 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
|
count_pairs_that_form_a_complete_day_i/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(2, countCompleteDayPairs(Arrays.asList(12,12,30,24,24)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(3, countCompleteDayPairs(Arrays.asList(72,48,24,3)));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
count_pairs_that_form_a_complete_day_i/meta.json
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3421,
|
| 3 |
+
"name": "count_pairs_that_form_a_complete_day_i",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/count-pairs-that-form-a-complete-day-i/",
|
| 6 |
+
"date": "2024-06-09 00:00:00",
|
| 7 |
+
"task_description": "Given an integer array `hours` representing times in **hours**, return an integer denoting the number of pairs `i`, `j` where `i < j` and `hours[i] + hours[j]` forms a **complete day**. A **complete day** is defined as a time duration that is an **exact** **multiple** of 24 hours. For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so on. **Example 1:** **Input:** hours = [12,12,30,24,24] **Output:** 2 **Explanation:** The pairs of indices that form a complete day are `(0, 1)` and `(3, 4)`. **Example 2:** **Input:** hours = [72,48,24,3] **Output:** 3 **Explanation:** The pairs of indices that form a complete day are `(0, 1)`, `(0, 2)`, and `(1, 2)`. **Constraints:** `1 <= hours.length <= 100` `1 <= hours[i] <= 109`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "hours = [12,12,30,24,24]",
|
| 12 |
+
"output": "2 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "hours = [72,48,24,3]",
|
| 17 |
+
"output": "3 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
484249851,
|
| 24 |
+
20131823,
|
| 25 |
+
423249632,
|
| 26 |
+
306507858,
|
| 27 |
+
267480235,
|
| 28 |
+
644385379,
|
| 29 |
+
214221130,
|
| 30 |
+
863070660,
|
| 31 |
+
913399484,
|
| 32 |
+
33535693,
|
| 33 |
+
823052413,
|
| 34 |
+
119998291,
|
| 35 |
+
791789190,
|
| 36 |
+
747763329,
|
| 37 |
+
349740924,
|
| 38 |
+
870030038,
|
| 39 |
+
889221130,
|
| 40 |
+
582613194,
|
| 41 |
+
63031737,
|
| 42 |
+
217611714,
|
| 43 |
+
413754792,
|
| 44 |
+
45752817,
|
| 45 |
+
231824638,
|
| 46 |
+
97115412,
|
| 47 |
+
300411069,
|
| 48 |
+
750313959,
|
| 49 |
+
636662712
|
| 50 |
+
],
|
| 51 |
+
"output": 13
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"input": [
|
| 55 |
+
265192379,
|
| 56 |
+
251492627,
|
| 57 |
+
362613040,
|
| 58 |
+
576331209,
|
| 59 |
+
378573986,
|
| 60 |
+
1155128,
|
| 61 |
+
614150205,
|
| 62 |
+
637266169,
|
| 63 |
+
222720672
|
| 64 |
+
],
|
| 65 |
+
"output": 1
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"input": [
|
| 69 |
+
959299844,
|
| 70 |
+
761641332,
|
| 71 |
+
226576332,
|
| 72 |
+
6248306,
|
| 73 |
+
37544232,
|
| 74 |
+
814604392,
|
| 75 |
+
790190230,
|
| 76 |
+
634308442,
|
| 77 |
+
911324956,
|
| 78 |
+
451569407,
|
| 79 |
+
29169901,
|
| 80 |
+
397736530,
|
| 81 |
+
928782919,
|
| 82 |
+
546317527,
|
| 83 |
+
678979322,
|
| 84 |
+
512326702,
|
| 85 |
+
31339121,
|
| 86 |
+
436313688,
|
| 87 |
+
797629546,
|
| 88 |
+
954100757,
|
| 89 |
+
884971463,
|
| 90 |
+
1191042,
|
| 91 |
+
955577260,
|
| 92 |
+
457864963,
|
| 93 |
+
87740485,
|
| 94 |
+
885378995,
|
| 95 |
+
542064265,
|
| 96 |
+
867248085,
|
| 97 |
+
901391749,
|
| 98 |
+
297300874,
|
| 99 |
+
633857683,
|
| 100 |
+
176721844,
|
| 101 |
+
882394721,
|
| 102 |
+
313124199,
|
| 103 |
+
118927867,
|
| 104 |
+
394067016,
|
| 105 |
+
301108225,
|
| 106 |
+
84437874,
|
| 107 |
+
801474168,
|
| 108 |
+
330150184,
|
| 109 |
+
398444875,
|
| 110 |
+
878677133,
|
| 111 |
+
517602170,
|
| 112 |
+
506916391,
|
| 113 |
+
331983268,
|
| 114 |
+
180385407,
|
| 115 |
+
317174381,
|
| 116 |
+
532247244,
|
| 117 |
+
556657910,
|
| 118 |
+
791501365,
|
| 119 |
+
334916047,
|
| 120 |
+
641583456,
|
| 121 |
+
845444603,
|
| 122 |
+
801837711,
|
| 123 |
+
50404693,
|
| 124 |
+
734059136,
|
| 125 |
+
41364658,
|
| 126 |
+
326358511,
|
| 127 |
+
643541472,
|
| 128 |
+
872906855,
|
| 129 |
+
994866722,
|
| 130 |
+
817834129,
|
| 131 |
+
321631634,
|
| 132 |
+
71433786,
|
| 133 |
+
294754562,
|
| 134 |
+
665179719,
|
| 135 |
+
881449335,
|
| 136 |
+
73010774,
|
| 137 |
+
595933678,
|
| 138 |
+
732890714,
|
| 139 |
+
106684665,
|
| 140 |
+
714232800,
|
| 141 |
+
893332836,
|
| 142 |
+
580321311,
|
| 143 |
+
16073763,
|
| 144 |
+
986360070,
|
| 145 |
+
691933437,
|
| 146 |
+
8363963,
|
| 147 |
+
352951983,
|
| 148 |
+
936625985,
|
| 149 |
+
962588148,
|
| 150 |
+
878415236
|
| 151 |
+
],
|
| 152 |
+
"output": 135
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"input": [
|
| 156 |
+
635297370,
|
| 157 |
+
842262050,
|
| 158 |
+
47951226,
|
| 159 |
+
553842598,
|
| 160 |
+
564226180,
|
| 161 |
+
132079688,
|
| 162 |
+
860183578,
|
| 163 |
+
597789984,
|
| 164 |
+
896408173,
|
| 165 |
+
546302081,
|
| 166 |
+
402136978,
|
| 167 |
+
120419676,
|
| 168 |
+
120626418,
|
| 169 |
+
745085032,
|
| 170 |
+
159309803,
|
| 171 |
+
354721973,
|
| 172 |
+
815512,
|
| 173 |
+
845926215,
|
| 174 |
+
456421865,
|
| 175 |
+
868676105,
|
| 176 |
+
611546687,
|
| 177 |
+
96749933,
|
| 178 |
+
673776359,
|
| 179 |
+
258276503,
|
| 180 |
+
316098261,
|
| 181 |
+
835801483,
|
| 182 |
+
379925373,
|
| 183 |
+
249076431,
|
| 184 |
+
763266688,
|
| 185 |
+
589941296,
|
| 186 |
+
722982600,
|
| 187 |
+
846555155,
|
| 188 |
+
269562800,
|
| 189 |
+
405201270,
|
| 190 |
+
927656154,
|
| 191 |
+
4734100,
|
| 192 |
+
842550771,
|
| 193 |
+
982478207,
|
| 194 |
+
546750710,
|
| 195 |
+
94852298,
|
| 196 |
+
382041278,
|
| 197 |
+
289672557,
|
| 198 |
+
90740594,
|
| 199 |
+
749839889,
|
| 200 |
+
677403199,
|
| 201 |
+
941307259,
|
| 202 |
+
222886603,
|
| 203 |
+
449089249,
|
| 204 |
+
88803540,
|
| 205 |
+
907045400,
|
| 206 |
+
819868345,
|
| 207 |
+
497317447,
|
| 208 |
+
749180510,
|
| 209 |
+
541620736,
|
| 210 |
+
7250842,
|
| 211 |
+
269689215,
|
| 212 |
+
900722308,
|
| 213 |
+
400666603,
|
| 214 |
+
826938836,
|
| 215 |
+
826358718,
|
| 216 |
+
384606428,
|
| 217 |
+
614408623,
|
| 218 |
+
102329937,
|
| 219 |
+
960338321,
|
| 220 |
+
233015652,
|
| 221 |
+
243266812
|
| 222 |
+
],
|
| 223 |
+
"output": 87
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"input": [
|
| 227 |
+
972255106,
|
| 228 |
+
715135991,
|
| 229 |
+
657342452,
|
| 230 |
+
418702895,
|
| 231 |
+
463108707,
|
| 232 |
+
443025123,
|
| 233 |
+
466716711,
|
| 234 |
+
392904233,
|
| 235 |
+
686106138,
|
| 236 |
+
826213895,
|
| 237 |
+
93600359,
|
| 238 |
+
472218527,
|
| 239 |
+
472528555,
|
| 240 |
+
889710596,
|
| 241 |
+
530569415,
|
| 242 |
+
634423426,
|
| 243 |
+
677691419,
|
| 244 |
+
813261936,
|
| 245 |
+
773309727,
|
| 246 |
+
247912299,
|
| 247 |
+
16770414,
|
| 248 |
+
691517040,
|
| 249 |
+
471974834,
|
| 250 |
+
345109292,
|
| 251 |
+
64836279,
|
| 252 |
+
650461299,
|
| 253 |
+
679249842,
|
| 254 |
+
557133447,
|
| 255 |
+
783166173,
|
| 256 |
+
189419588,
|
| 257 |
+
845198689,
|
| 258 |
+
96859531,
|
| 259 |
+
286993384,
|
| 260 |
+
711659721,
|
| 261 |
+
934039608,
|
| 262 |
+
409146963,
|
| 263 |
+
881625966,
|
| 264 |
+
436867286,
|
| 265 |
+
597545914,
|
| 266 |
+
404413821,
|
| 267 |
+
805048355,
|
| 268 |
+
361974413,
|
| 269 |
+
395468588,
|
| 270 |
+
69593810,
|
| 271 |
+
460483016,
|
| 272 |
+
465016063,
|
| 273 |
+
183973479,
|
| 274 |
+
831109894,
|
| 275 |
+
814316619,
|
| 276 |
+
916030264,
|
| 277 |
+
901368139,
|
| 278 |
+
133469276,
|
| 279 |
+
592061153,
|
| 280 |
+
821462735,
|
| 281 |
+
830015333,
|
| 282 |
+
883360042,
|
| 283 |
+
643512811,
|
| 284 |
+
747545234,
|
| 285 |
+
907354639,
|
| 286 |
+
786007693,
|
| 287 |
+
922923586,
|
| 288 |
+
842947056,
|
| 289 |
+
632319533,
|
| 290 |
+
501142589,
|
| 291 |
+
230543679,
|
| 292 |
+
732967892,
|
| 293 |
+
992767473,
|
| 294 |
+
620178248,
|
| 295 |
+
743090941,
|
| 296 |
+
586983000,
|
| 297 |
+
79529573,
|
| 298 |
+
421134157
|
| 299 |
+
],
|
| 300 |
+
"output": 87
|
| 301 |
+
}
|
| 302 |
+
],
|
| 303 |
+
"haskell_template": "countCompleteDayPairs :: [Int] -> Int\ncountCompleteDayPairs hours ",
|
| 304 |
+
"ocaml_template": "let countCompleteDayPairs (hours: int list) : int = ",
|
| 305 |
+
"scala_template": "def countCompleteDayPairs(hours: List[Int]): Int = { \n \n}",
|
| 306 |
+
"java_template": "class Solution {\n public int countCompleteDayPairs(int[] hours) {\n \n }\n}",
|
| 307 |
+
"python_template": "class Solution(object):\n def countCompleteDayPairs(self, hours):\n \"\"\"\n :type hours: List[int]\n :rtype: int\n \"\"\"\n "
|
| 308 |
+
}
|
count_pairs_that_form_a_complete_day_i/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let countCompleteDayPairs (hours: int list) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 2 (countCompleteDayPairs [12;12;30;24;24])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal 3 (countCompleteDayPairs [72;48;24;3])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal 3 (countCompleteDayPairs [484249851; 20131823; 423249632; 306507858; 267480235; 644385379; 214221130; 863070660; 913399484; 33535693; 823052413; 119998291; 791789190; 747763329; 349740924; 870030038; 889221130; 582613194; 63031737; 217611714; 413754792; 45752817; 231824638; 97115412; 300411069; 750313959; 636662712])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal 3 (countCompleteDayPairs [265192379; 251492627; 362613040; 576331209; 378573986; 1155128; 614150205; 637266169; 222720672])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal 3 (countCompleteDayPairs [959299844; 761641332; 226576332; 6248306; 37544232; 814604392; 790190230; 634308442; 911324956; 451569407; 29169901; 397736530; 928782919; 546317527; 678979322; 512326702; 31339121; 436313688; 797629546; 954100757; 884971463; 1191042; 955577260; 457864963; 87740485; 885378995; 542064265; 867248085; 901391749; 297300874; 633857683; 176721844; 882394721; 313124199; 118927867; 394067016; 301108225; 84437874; 801474168; 330150184; 398444875; 878677133; 517602170; 506916391; 331983268; 180385407; 317174381; 532247244; 556657910; 791501365; 334916047; 641583456; 845444603; 801837711; 50404693; 734059136; 41364658; 326358511; 643541472; 872906855; 994866722; 817834129; 321631634; 71433786; 294754562; 665179719; 881449335; 73010774; 595933678; 732890714; 106684665; 714232800; 893332836; 580321311; 16073763; 986360070; 691933437; 8363963; 352951983; 936625985; 962588148; 878415236])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal 3 (countCompleteDayPairs [635297370; 842262050; 47951226; 553842598; 564226180; 132079688; 860183578; 597789984; 896408173; 546302081; 402136978; 120419676; 120626418; 745085032; 159309803; 354721973; 815512; 845926215; 456421865; 868676105; 611546687; 96749933; 673776359; 258276503; 316098261; 835801483; 379925373; 249076431; 763266688; 589941296; 722982600; 846555155; 269562800; 405201270; 927656154; 4734100; 842550771; 982478207; 546750710; 94852298; 382041278; 289672557; 90740594; 749839889; 677403199; 941307259; 222886603; 449089249; 88803540; 907045400; 819868345; 497317447; 749180510; 541620736; 7250842; 269689215; 900722308; 400666603; 826938836; 826358718; 384606428; 614408623; 102329937; 960338321; 233015652; 243266812])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal 3 (countCompleteDayPairs [972255106; 715135991; 657342452; 418702895; 463108707; 443025123; 466716711; 392904233; 686106138; 826213895; 93600359; 472218527; 472528555; 889710596; 530569415; 634423426; 677691419; 813261936; 773309727; 247912299; 16770414; 691517040; 471974834; 345109292; 64836279; 650461299; 679249842; 557133447; 783166173; 189419588; 845198689; 96859531; 286993384; 711659721; 934039608; 409146963; 881625966; 436867286; 597545914; 404413821; 805048355; 361974413; 395468588; 69593810; 460483016; 465016063; 183973479; 831109894; 814316619; 916030264; 901368139; 133469276; 592061153; 821462735; 830015333; 883360042; 643512811; 747545234; 907354639; 786007693; 922923586; 842947056; 632319533; 501142589; 230543679; 732967892; 992767473; 620178248; 743090941; 586983000; 79529573; 421134157])
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
(* Grouping test cases *)
|
| 28 |
+
let suite = "Test Suite for countCompleteDayPairs" >::: [
|
| 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
|
count_pairs_that_form_a_complete_day_i/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countCompleteDayPairs(List(12,12,30,24,24)), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countCompleteDayPairs(List(72,48,24,3)), 3)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.countCompleteDayPairs(484249851,20131823,423249632,306507858,267480235,644385379,214221130,863070660,913399484,33535693,823052413,119998291,791789190,747763329,349740924,870030038,889221130,582613194,63031737,217611714,413754792,45752817,231824638,97115412,300411069,750313959,636662712), 13)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.countCompleteDayPairs(265192379,251492627,362613040,576331209,378573986,1155128,614150205,637266169,222720672), 1)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.countCompleteDayPairs(959299844,761641332,226576332,6248306,37544232,814604392,790190230,634308442,911324956,451569407,29169901,397736530,928782919,546317527,678979322,512326702,31339121,436313688,797629546,954100757,884971463,1191042,955577260,457864963,87740485,885378995,542064265,867248085,901391749,297300874,633857683,176721844,882394721,313124199,118927867,394067016,301108225,84437874,801474168,330150184,398444875,878677133,517602170,506916391,331983268,180385407,317174381,532247244,556657910,791501365,334916047,641583456,845444603,801837711,50404693,734059136,41364658,326358511,643541472,872906855,994866722,817834129,321631634,71433786,294754562,665179719,881449335,73010774,595933678,732890714,106684665,714232800,893332836,580321311,16073763,986360070,691933437,8363963,352951983,936625985,962588148,878415236), 135)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.countCompleteDayPairs(635297370,842262050,47951226,553842598,564226180,132079688,860183578,597789984,896408173,546302081,402136978,120419676,120626418,745085032,159309803,354721973,815512,845926215,456421865,868676105,611546687,96749933,673776359,258276503,316098261,835801483,379925373,249076431,763266688,589941296,722982600,846555155,269562800,405201270,927656154,4734100,842550771,982478207,546750710,94852298,382041278,289672557,90740594,749839889,677403199,941307259,222886603,449089249,88803540,907045400,819868345,497317447,749180510,541620736,7250842,269689215,900722308,400666603,826938836,826358718,384606428,614408623,102329937,960338321,233015652,243266812), 87)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.countCompleteDayPairs(972255106,715135991,657342452,418702895,463108707,443025123,466716711,392904233,686106138,826213895,93600359,472218527,472528555,889710596,530569415,634423426,677691419,813261936,773309727,247912299,16770414,691517040,471974834,345109292,64836279,650461299,679249842,557133447,783166173,189419588,845198689,96859531,286993384,711659721,934039608,409146963,881625966,436867286,597545914,404413821,805048355,361974413,395468588,69593810,460483016,465016063,183973479,831109894,814316619,916030264,901368139,133469276,592061153,821462735,830015333,883360042,643512811,747545234,907354639,786007693,922923586,842947056,632319533,501142589,230543679,732967892,992767473,620178248,743090941,586983000,79529573,421134157), 87)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
}
|
count_pairs_that_form_a_complete_day_ii/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_pairs_that_form_a_complete_day_ii/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(2, countCompleteDayPairs(Arrays.asList(12,12,30,24,24)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(3, countCompleteDayPairs(Arrays.asList(72,48,24,3)));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
count_pairs_that_form_a_complete_day_ii/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_pairs_that_form_a_complete_day_ii/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_pairs_that_form_a_complete_day_ii/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_pairs_whose_sum_is_less_than_target/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
count_pairs_whose_sum_is_less_than_target/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 (countPairs [-1,1,2,3,1] 2)," 3 (countPairs [-1,1,2,3,1] 2))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (countPairs [-6,2,5,-2,-7,-1,3] ( -2))," 10 (countPairs [-6,2,5,-2,-7,-1,3] -2))
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
-- Grouping test cases
|
| 19 |
+
tests :: Test
|
| 20 |
+
tests = TestList [TestLabel "Test1" test1]
|
| 21 |
+
|
| 22 |
+
-- Running the tests
|
| 23 |
+
main :: IO Counts
|
| 24 |
+
main = runTestTT tests
|
count_pairs_whose_sum_is_less_than_target/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, countPairs(new ArrayList<>(Arrays.asList(-1,1,2,3,1)), 2));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(10, countPairs(new ArrayList<>(Arrays.asList(-6,2,5,-2,-7,-1,3)), -2));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
count_pairs_whose_sum_is_less_than_target/meta.json
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2917,
|
| 3 |
+
"name": "count_pairs_whose_sum_is_less_than_target",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/count-pairs-whose-sum-is-less-than-target/",
|
| 6 |
+
"date": "1691193600000",
|
| 7 |
+
"task_description": "Given a **0-indexed** integer array `nums` of length `n` and an integer `target`, return _the number of pairs_ `(i, j)` _where_ `0 <= i < j < n` _and_ `nums[i] + nums[j] < target`. **Example 1:** ``` **Input:** nums = [-1,1,2,3,1], target = 2 **Output:** 3 **Explanation:** There are 3 pairs of indices that satisfy the conditions in the statement: - (0, 1) since 0 < 1 and nums[0] + nums[1] = 0 < target - (0, 2) since 0 < 2 and nums[0] + nums[2] = 1 < target - (0, 4) since 0 < 4 and nums[0] + nums[4] = 0 < target Note that (0, 3) is not counted since nums[0] + nums[3] is not strictly less than the target. ``` **Example 2:** ``` **Input:** nums = [-6,2,5,-2,-7,-1,3], target = -2 **Output:** 10 **Explanation:** There are 10 pairs of indices that satisfy the conditions in the statement: - (0, 1) since 0 < 1 and nums[0] + nums[1] = -4 < target - (0, 3) since 0 < 3 and nums[0] + nums[3] = -8 < target - (0, 4) since 0 < 4 and nums[0] + nums[4] = -13 < target - (0, 5) since 0 < 5 and nums[0] + nums[5] = -7 < target - (0, 6) since 0 < 6 and nums[0] + nums[6] = -3 < target - (1, 4) since 1 < 4 and nums[1] + nums[4] = -5 < target - (3, 4) since 3 < 4 and nums[3] + nums[4] = -9 < target - (3, 5) since 3 < 5 and nums[3] + nums[5] = -3 < target - (4, 5) since 4 < 5 and nums[4] + nums[5] = -8 < target - (4, 6) since 4 < 6 and nums[4] + nums[6] = -4 < target ``` **Constraints:** `1 <= nums.length == n <= 50` `-50 <= nums[i], target <= 50`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [-1,1,2,3,1], target = 2",
|
| 12 |
+
"output": "3 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [-6,2,5,-2,-7,-1,3], target = -2",
|
| 17 |
+
"output": "10 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
[
|
| 24 |
+
-47,
|
| 25 |
+
-2,
|
| 26 |
+
18,
|
| 27 |
+
31
|
| 28 |
+
],
|
| 29 |
+
46
|
| 30 |
+
],
|
| 31 |
+
"output": 5
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"input": [
|
| 35 |
+
[
|
| 36 |
+
-18,
|
| 37 |
+
-13,
|
| 38 |
+
14,
|
| 39 |
+
28,
|
| 40 |
+
34,
|
| 41 |
+
50
|
| 42 |
+
],
|
| 43 |
+
-39
|
| 44 |
+
],
|
| 45 |
+
"output": 0
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"input": [
|
| 49 |
+
[
|
| 50 |
+
-27,
|
| 51 |
+
-6,
|
| 52 |
+
19,
|
| 53 |
+
42,
|
| 54 |
+
43
|
| 55 |
+
],
|
| 56 |
+
6
|
| 57 |
+
],
|
| 58 |
+
"output": 2
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"input": [
|
| 62 |
+
[
|
| 63 |
+
-48,
|
| 64 |
+
-29,
|
| 65 |
+
-22,
|
| 66 |
+
35,
|
| 67 |
+
46
|
| 68 |
+
],
|
| 69 |
+
-49
|
| 70 |
+
],
|
| 71 |
+
"output": 3
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"input": [
|
| 75 |
+
[
|
| 76 |
+
-40,
|
| 77 |
+
-35,
|
| 78 |
+
-31,
|
| 79 |
+
-30,
|
| 80 |
+
-29,
|
| 81 |
+
-27,
|
| 82 |
+
-25,
|
| 83 |
+
-24,
|
| 84 |
+
-22,
|
| 85 |
+
-21,
|
| 86 |
+
-12,
|
| 87 |
+
-9,
|
| 88 |
+
-5,
|
| 89 |
+
-2,
|
| 90 |
+
8,
|
| 91 |
+
9,
|
| 92 |
+
10,
|
| 93 |
+
17,
|
| 94 |
+
27,
|
| 95 |
+
31,
|
| 96 |
+
35,
|
| 97 |
+
38,
|
| 98 |
+
43,
|
| 99 |
+
49
|
| 100 |
+
],
|
| 101 |
+
3
|
| 102 |
+
],
|
| 103 |
+
"output": 152
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"input": [
|
| 107 |
+
[
|
| 108 |
+
-48,
|
| 109 |
+
-44,
|
| 110 |
+
-43,
|
| 111 |
+
-40,
|
| 112 |
+
-36,
|
| 113 |
+
-30,
|
| 114 |
+
-29,
|
| 115 |
+
-29,
|
| 116 |
+
-29,
|
| 117 |
+
-26,
|
| 118 |
+
-22,
|
| 119 |
+
-22,
|
| 120 |
+
-18,
|
| 121 |
+
-18,
|
| 122 |
+
-18,
|
| 123 |
+
-17,
|
| 124 |
+
-14,
|
| 125 |
+
-6,
|
| 126 |
+
-5,
|
| 127 |
+
-5,
|
| 128 |
+
-4,
|
| 129 |
+
-2,
|
| 130 |
+
-2,
|
| 131 |
+
3,
|
| 132 |
+
5,
|
| 133 |
+
7,
|
| 134 |
+
7,
|
| 135 |
+
9,
|
| 136 |
+
11,
|
| 137 |
+
14,
|
| 138 |
+
16,
|
| 139 |
+
17,
|
| 140 |
+
25,
|
| 141 |
+
25,
|
| 142 |
+
27,
|
| 143 |
+
28,
|
| 144 |
+
31,
|
| 145 |
+
32,
|
| 146 |
+
33,
|
| 147 |
+
38,
|
| 148 |
+
45,
|
| 149 |
+
48
|
| 150 |
+
],
|
| 151 |
+
-35
|
| 152 |
+
],
|
| 153 |
+
"output": 175
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"input": [
|
| 157 |
+
[
|
| 158 |
+
-50,
|
| 159 |
+
-47,
|
| 160 |
+
-43,
|
| 161 |
+
-43,
|
| 162 |
+
-36,
|
| 163 |
+
-32,
|
| 164 |
+
-32,
|
| 165 |
+
-28,
|
| 166 |
+
-26,
|
| 167 |
+
-23,
|
| 168 |
+
-16,
|
| 169 |
+
-3,
|
| 170 |
+
8,
|
| 171 |
+
12,
|
| 172 |
+
17,
|
| 173 |
+
28,
|
| 174 |
+
28,
|
| 175 |
+
36,
|
| 176 |
+
37,
|
| 177 |
+
37,
|
| 178 |
+
48
|
| 179 |
+
],
|
| 180 |
+
-18
|
| 181 |
+
],
|
| 182 |
+
"output": 90
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"input": [
|
| 186 |
+
[
|
| 187 |
+
-50,
|
| 188 |
+
-50,
|
| 189 |
+
-38,
|
| 190 |
+
-34,
|
| 191 |
+
-32,
|
| 192 |
+
-30,
|
| 193 |
+
-21,
|
| 194 |
+
-12,
|
| 195 |
+
-7,
|
| 196 |
+
2,
|
| 197 |
+
6,
|
| 198 |
+
27
|
| 199 |
+
],
|
| 200 |
+
1
|
| 201 |
+
],
|
| 202 |
+
"output": 60
|
| 203 |
+
},
|
| 204 |
+
{
|
| 205 |
+
"input": [
|
| 206 |
+
[
|
| 207 |
+
-45,
|
| 208 |
+
-36,
|
| 209 |
+
-26,
|
| 210 |
+
-21,
|
| 211 |
+
-20,
|
| 212 |
+
-8,
|
| 213 |
+
-6,
|
| 214 |
+
-6,
|
| 215 |
+
-3,
|
| 216 |
+
7,
|
| 217 |
+
7,
|
| 218 |
+
9,
|
| 219 |
+
11,
|
| 220 |
+
11,
|
| 221 |
+
13,
|
| 222 |
+
14,
|
| 223 |
+
25,
|
| 224 |
+
35,
|
| 225 |
+
37,
|
| 226 |
+
39,
|
| 227 |
+
40,
|
| 228 |
+
40,
|
| 229 |
+
41,
|
| 230 |
+
45,
|
| 231 |
+
49,
|
| 232 |
+
49
|
| 233 |
+
],
|
| 234 |
+
-16
|
| 235 |
+
],
|
| 236 |
+
"output": 48
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"input": [
|
| 240 |
+
[
|
| 241 |
+
-28,
|
| 242 |
+
-27,
|
| 243 |
+
-20,
|
| 244 |
+
-18,
|
| 245 |
+
-16,
|
| 246 |
+
-10,
|
| 247 |
+
11,
|
| 248 |
+
13,
|
| 249 |
+
16,
|
| 250 |
+
17,
|
| 251 |
+
19,
|
| 252 |
+
21,
|
| 253 |
+
21,
|
| 254 |
+
33
|
| 255 |
+
],
|
| 256 |
+
-6
|
| 257 |
+
],
|
| 258 |
+
"output": 30
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"haskell_template": "countPairs :: [Int] -> Int -> Int\ncountPairs nums target ",
|
| 262 |
+
"ocaml_template": "let countPairs (nums: int list) (target: int) : int = ",
|
| 263 |
+
"scala_template": "def countPairs(nums: List[Int],target: Int): Int = { \n \n}",
|
| 264 |
+
"java_template": "public static int countPairs(List<Integer> nums, int target) {\n\n}",
|
| 265 |
+
"python_template": "class Solution(object):\n def countPairs(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: int\n \"\"\"\n "
|
| 266 |
+
}
|
count_pairs_whose_sum_is_less_than_target/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 3 (countPairs [-1;1;2;3;1] 2)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 10 (countPairs [-6;2;5;-2;-7;-1;3] ( -2))
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for countPairs" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
count_pairs_whose_sum_is_less_than_target/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countPairs(List(-1,1,2,3,1),2), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countPairs(List(-6,2,5,-2,-7,-1,3),-2), 10)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
count_palindromic_subsequences/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
count_palindromic_subsequences/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 (countPalindromes \"103301 \")," 2 (countPalindromes "103301"))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (countPalindromes \"0000000 \")," 21 (countPalindromes "0000000"))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (countPalindromes \"9999900000 \")," 2 (countPalindromes "9999900000"))
|
| 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
|
count_palindromic_subsequences/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(2, countPalindromes("103301"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(21, countPalindromes("0000000"));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(2, countPalindromes("9999900000"));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
count_palindromic_subsequences/meta.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2577,
|
| 3 |
+
"name": "count_palindromic_subsequences",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/count-palindromic-subsequences/",
|
| 6 |
+
"date": "1668211200000",
|
| 7 |
+
"task_description": "Given a string of digits `s`, return _the number of **palindromic subsequences** of_ `s`_ having length _`5`. Since the answer may be very large, return it **modulo** `109 + 7`. **Note:** A string is **palindromic** if it reads the same forward and backward. A **subsequence** is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. **Example 1:** ``` **Input:** s = \"103301\" **Output:** 2 **Explanation:** There are 6 possible subsequences of length 5: \"10330\",\"10331\",\"10301\",\"10301\",\"13301\",\"03301\". Two of them (both equal to \"10301\") are palindromic. ``` **Example 2:** ``` **Input:** s = \"0000000\" **Output:** 21 **Explanation:** All 21 subsequences are \"00000\", which is palindromic. ``` **Example 3:** ``` **Input:** s = \"9999900000\" **Output:** 2 **Explanation:** The only two palindromic subsequences are \"99999\" and \"00000\". ``` **Constraints:** `1 <= s.length <= 104` `s` consists of digits.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "s = \"103301\"",
|
| 12 |
+
"output": "2 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "s = \"0000000\"",
|
| 17 |
+
"output": "21 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "s = \"9999900000\"",
|
| 22 |
+
"output": "2 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": "43189039005465682401855284277114609803946426902927018008175173354658761312483443240419199364861114044074253075408792457538582018893770021892739784424394354335707669915767204154052306522188900841694172601433616069794267052691589996258984891528116747489492940120183822065834577831047161579083573870377672320040711790597240579902319436940388685423083857845496794813288381250309078898995608823537813044129810439503981494050814906348826897283199909777131630214671745755289640073192113577064800752977848450406896142092628092493296672100793542799410642549480762865319855754207011089945545683810225746231829769525648763181152017168008719535434624697948753057377027120212944835457735715554060483343314379090846677511183919672734643138286637821322853245232239971701449844140934365425234534715967537031540175374201556598936885838658665613270264676015381689142483377541576981825751667799560772604524945031857909738919556418909606621625477383901220832135775576224415976411904050224301630934343279198424767191442936864408623948081558332297562036482249941379947392807564625153824743885469268609158968595318723605256679685908752645694279409636367618075596786035803379176649823675553648331186774075991924788192577078047912744777818877118687890231981715083450966817013754577540618366236836778929025749575150757831246298245215860375150777703613820933429898989209340259775142280082240240611893149603861528666430793780841097248625954993489803378806463778436843516042036782741011877733057415576340955565687938051443482302002059170441135986761020323135214487142287823104181092712126144614091994119745571408220430701571781061241571126604277863388736843902322085554066487947026428003140625496161045788014427254178106818440278586443133768275235629242605973388655822594511753442864257218967212348238776703453189182179640889109839484920834895055563502268911310682739576918368923397740867302087948797066739990394793412717629774314025340722825359978687524353205028094327029543057509845047624795446615597713168713585710858222167437461044568583133413534176650369482969638268406383540894366227828952878682785727131781043459082678270537220477469327597306257701559759920692990407245133218258711891096817065322706739885499215632475174640956385397377845168476121150135510231156131987767537335084871159634695695126080477522026031773332131454355278883112499162032977534339591522651618938884547589544816545159981085330246697089917569366618504465895844620860331030264551413587678482742956860862946030547697665866572533482920414831383259214909956222995479703161084536940810983837152579182320381349332004504931987342202704488959169138692414041017738156458451629602699453506585021666544198429390823172797286878083438930302194792137849628081371195942185579368019455689596195742872749087132245303877527894930565602528748004339687189065412712160642608807667604862474284120895061232085269855987036796677340493898332657104673190114600276564907797444853913473643366878837698705840363396011220363574444145506108063952961108751887496323710019018148362600192413275235104612808136722135497913844150093363842500381471726734519576180403321240585891657656367728588172832258010798350037593093025086840881655789220404945754915201279859936220494701985894849469365723227360137321540839929215395707840668965039844528402550101230894816414595055404642263599067753059313990915997917651302029084474397051347386467611907773493596238550824644789412900475243761678346761385814092163351021607310207392910677916244785241961",
|
| 28 |
+
"output": 86192140
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"input": "72862245308703552695442052725411769012490565604100426920531587543393876539635187055232101951547568504957899332220202793586923271843679067460247104215233838752395740708560755863138216874853488600680029508763054950958875255869336920758727208929851095979238704964758859028508292468921368031969461100117710379691933249774083984509771797639518316806595215324822075118468831970976410143264332854769543850370753550024502103286539736369971143187257643945176258004125247296904032465383058504842801651069887232748871000113233722510295243837535065552253694309907017833780246309126031368257667026786449730198030577731926541664759026169305479352709409779547258014884577790820131633758383865793845418664275213237424906146098296819524585550412875310439912270472892463905864416343170191498366138115271182294425602168774878645467580243562498375438162850391421680400784547347208096655633567531735838588376192968766863170376032970624896391603942999577817052965853515853282209637068720333155230052339949911684888347781990487792360433021914716026561375868586632503397738935169287480003932315580948351799900560056071621056549020489058883988760086138870474491347043292360898668929624758372608897177002692910745833265800675834582189868775575472750427273225949215765428524115377350552090216016010949124082644541506954573362368820417204485168688709228646616223984348288154505247100057603916080913120777023071671001211094168358262793527729249323981833520939016367195628372408061480937065207825754510776802618745947235154873246746709046418617909426186133829492459734948475489897827941108825886505521867613899574621453991984228135440568076276043252779520020605841080064699219324552633356627737506607293363774854357529289989363810958961704705664512006453380901793502916477056493911556579835917612449778654698856072510524589499712697164473286093239947380027773422561361875788427775753434844175141793244202217466808055777402567215849836682219338002101592423807925094221071892845591560752930905012549194290314059213458179009195203783504449456456086844358764335317667203158386180306701340107220955639990291143034805330336547673082278524719985970264787739975123824061807382814963839588255809775",
|
| 32 |
+
"output": 800887156
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"input": "76840148663056598449721507909447351065536251366078066704302298300304183627877350031794682225913857377996559947998883674672205026870293941072027651103618539087549759428910607573370246452640336361582533662144326413724232890800860150282351039500972914833232830279953411128308513161823347048038370349404777370738232545193642181287583396955860534541619519200062484632820439521423356385215251515195372188174515059360492801570443302457055445992536168570357408517539454563128073316984643176128915134920780281641104717091655034171875390649967212324788258957653276838551000858241076444609068844075960315487066038764208965911783797962321410630131442678978548183527456646039343713944528923671549074682997863821597811555854046554381320119577166501394431512803548671038215773113808710407816046943039537444566679544337808976821491151931314393616426540313522130395134168072639444684849353442877480337726728504920314513050179887473086966236034494905882726577797778942889842818330580675585896052808621260698952706004547526861310828357886914050162929053958862725174078000862576870479464713387732983628119496126699737928144363474246684789042885962810997011036155146430655821068244148823423642849872861890527891131356227793675136357777090147846624915427367870973472288320820719718252428388485348107094048077641523901423732015618891348256021537877463062672225661769277485768964077156017997742116584687312993730415089707023712417711497087393115536255787651530392990268540753032311086306477622130692434518888453831630536869247333040178847951038038451485039049480454316901154968024223437699236539902256781992476308835498759400698822985176921766165499063118484138332883315795509085872492539218212158643556551426414201126270374367987421194860310334621005203019603263463965995875577277267860348592548577105115072816389335965732904336748420880058526329541440875079848352734793881600536919306655620071388151165008857950964861114935724644682106932346060104759226832655368248826173043050339325203286138739113715373914513868385361274161756547105960836586697414716543811873150389521078586617180478443655089915380924908523071812979692352831069206253671630957964504843916968469347371812387968753189903712645492569241457712684787985113276543141648133880728855623217468718749737527948665392100247842199735483014294817977816193067250127609504608133050319244283821938662359516017820731130178398022288820015301860691206756446953028264428131010746662934062932624307965148878848892298057317009531786574978091713649013263595559479509232027315780507907788395083356407890724021232930997504797132893497824116048913793164855590121",
|
| 36 |
+
"output": 227795771
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"input": "8526721318409085603221532932063171614259649650840237763788732471234086930795896682773336435008729589941962444464503839582780737370298860719481908640963459484301051372100802207438527840354637509481741221463887379959572218219763425456589792630253113872443727393977520131122424505798951311184802866052129168800681136775123413134573199786643627256783146419931051278706439044663220231082561334140139807847441436741627419159696568892308865369531349937366569979654096377250895887179374865566860610596034198362606998524349599114844975252663588294272249387855898975678748410581171140985762075963131554424402623083338899913182262412675252638432744947602388118764567129577503549200117180830602187317242010230154853732975920572297793067594954184853369584698702946053145686357549663631445485633594604963671717860164544968625607365576283198571609724516905132336788837007623156158546683048004081462928971399644456351571650831852796028619614538542403777225059392453528744747583282126186137476619560286803362948260097686818850765724735198299518958396687855783974280245387443580811130552660809165652305338368873547471894399913265363157525487968223829585077640249639753090466263538355244667125834928264794921050865773377949453363967865158830156082722570270309127890163142568732328223222499510734597705386353647322089405004976520411879078334359099528314704493543155655373850161702135116392600133456210753468810315789831941271420285457081920082954545157770797575883177364642551756527935702502405710956570213046327094967520287470597087818653735779912307198561206807863156881496164184867600630552432394099560739048550564377793063557447360528193602700714066604881218196984375147402388354604618873880668699489555098541217713991778450162048472506632853611010039017803918189675173061853053997947444419445306756943065865374100000714294671732678085549220042294363726289766402300947474484511184938331758199031531115554273247274442831691822687853360393092691638307765619762162160932575008928880669147225110249337341769428297199906431008502105626240253106041746474516188709863291832792932953553516203144752836224134679962049867903707870962725935832430340505455785159554808605628486917806426256949487313293191999554137840042462164878000616772186940558678784336089312483188839388064806699644237474095322456646338721254566624661032847368266364977209450100115268577063512450013952433551710690928047091537407785041965059115794349358467425751129799532963766270424544285504097836151996977672810910112257324941869704633675898498609852384782134653825925047097800872335108143850880088494305543492661153367032124105097580500853489809206305694926730112691987763749122332629796479198654719942230705087151352575497225761908567689928678737477945190503226114410769484733879125668487227288868318957134014152827080565066919637570624264892779530521075944447405115820604817132454500472216403591256970008570731935080724318120940864026756478085033464954380208187797522413819934339167137609396061479507639534683129736469499741636569134734384939068479082178205456608791777849195606343987762855736761021063923997627741457583938896785897909842938781327411925847158760856069324371653985435694534946913191727801645433167774103586149369465238773851011187203528944932135655920886499577552486413442045363175352111635694221099320510309614212182678717281140857027582559419167737489915694459595360569203271822140025907593758982903424790807947754095498739741933858258473756061868414558259146466189719317026465392504799250410212327801900423764620558457205629930098636305365100167694469711060986022158007026109249866537476840494673931466651423874128013019147615226679550336127822248498126655683967498095536902380993727526861165098127621530160356990054062619433642193270948682941557254499912982565224927605710210262937514044006864559558116389855024437259362603542402304243028095179687333486239713588758903890335957506600083773796260940079167943055746090783056857703700145741455845490215666832917253680547510206630297891728977742237510501334221535745629359201011086455317929938014934338996039635038236558869835928777465609514222293595796412650285217788980538131008453408071735614315799502944353758932826422955128337942879096347880315999726637121877054680060132748081159229047260964496351899556515337322318580367095014752984534005591669405706272144943605474793121167049216349732647937988371968014549680964578439530944004301554751339389584909729759553857121058830551493030582448408955567276617423664387623835779776998302991021801603403904693445454778155767779703199916896872091803316507319555122653540894272810447191976448817744390845317383834843301128484094674416318598837519918940482740144471416620645791475314613240599288837301879188881207645238031998803645057996010544008220227248211186598275407933949572111618585437728191157062592933443358712080930147951147578521595592351940284184938368797037578139882758061771016285549940679691638142469760738967349412713999413290958009838919453713629912511602542724709093248426949034909591728347412144068388639316303079648962703112759298292034560779424891746584483700702135163308682954702089592626314365167300926022191734718788711726617598902871953862210792982671124046673412441046163094228076031053572808092730175940514540405476144171313788229929716970110701902813566251765287081014259678570702759761408452515929996866536028971391769758969901602326959144145732848838809560695471809303105664063400149428153241558711910432874078365098508074774258610286798303658448333768529304971399691280258395253900849429123087466849321227157851304809354072163957273276354729897512383665531650663143178408498424006662371605864517132461265732149566379962458627520938130517069497945607955901020965065005590188381971249585018167068203030040588735839085863665570614282579015856176145939147042211303955613428464515898620937732497793059256252157146705016634783523970807200868590404862123977753286182067722886310317181869640633424984485945265212996265514717170465731542688167887697720860055911127237767867555918752988495201989196986172839890148502380467210205061429986385809383196686133919767450709762700080021748092535717860690912703226446480924872712579583041049554560664473029083869023646399348879839582224100107682355258210291676147258079610464464157716741075084313748331422661681268372127279624425654783801310222724721773833565524074103632437191222128599879719917341557616876136460753223970026739782143949023630607756484846985657134131978036132794958721927489156119537278579356458226206195864474600902117380474758672466690383853451969691209604169978876591180111732993621701912882940236098020935037455789634221445328554090125402139517031863985804954557646794548529466150050921841246402154884393984371061756664260807660788444798862953026542710535238133209038750960906147079418996758279910511703436969749293492388960221314908312972648476152948540381664165062505936014604410537167256269613882533896179600148610305078648989328655758973402661929239348328514650768673680454327402466274181903123106002630584432933421856605382909621921185481142104757266837466589045002714134720488380447257455877232373233386657834467510296078342236741104272054749338055845086422067467986457776663760083720904597471955898250536435894562937225145571061996493828956718516156131959062266397617196376860708906931407794290196704153564383769756771882685636386862131225466864906456480954223560388332146835315797268249325422242497048873638069946619340852363705402681566452503743860308375600713765317103274510497738145671701116029376646444961686874827247969071604895318495017756957045449471365331411731671112747946531794055636735061789091795310637471497222751202780202840618806630050131974398672108147165612205949929085462999767341500565630042404562246073801660435739183548980545521788964049019155163482440573033048696910500633993080015611499597",
|
| 40 |
+
"output": 502766489
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": "36255206141499377397130235639389625155668559158090125099366456946571533242700609082936236045828792151244574844280680171516755090306675149724350667504469430004787720830548961303152756305341218985308369798478433238960558118369437858995734393608559331861022555416707010466692326411468301515782059074991239400383632190278079611045559357991300874722673233911277491640238090338683650897316913094458717434120304049526740576406996219772722367727329970312836944450843469018355102538190288728416771879534789319442734725036288903144925523756010511154543258196981090423103445929119033680516518252654505298455348821095084058455676992678720395206882127214811606170308015367074569602346456430883127986323481370816145385686710492444105722946392962177574725606379077979852910101200933659413668235241780073020356082909632825496894946586172712969449066372174399971719932770188224738629772100071669385779081300321989506589380322872413643381534903468378919323628459072988130999587129933278291769225731296953610905650931208176482567886770309246998475927917303445645511467466272200970339831333860966424320484516383007011712639029744434604367056522335160154674603477524108958480014973303084353920412492534468534507792677061731945042190177304304386621329347832545287641704685829842871514752379428866404701409830912059903135575892058853201424996739333405593326295382484148272606194616034001173801023319606863130381121031420164746208894813686306296188768168862990885282771394731352945927678331962757993091321061634002884025386156044287906909007296918637887642205828084286936799368986341347330786491146434141282678027455194230520295158192353255403700088938013865788259616049999147556668130875605900625656058526670210330720165778249333716185351613704412786042731236362034837364978049658737970025005023411306102831765971450625202741986783913676583071149090858433727609175122878050202902632977217811337404588354458544455938923364644571877098185609420619332656443748079331162816914826773799638772386123032071441833400498151472189883142519680202837858934942885002591777034107108599224749310052500656587572135642373454975494277948446830577801850521676023600325701451540849977713160267754737641284372527872853456927021638605310532147220458597519502168953845470144810188726340634059881019662024454906668892404209092916200301259933417472856045789035515761697336053694888116084954945353466492070868876517151131971482359324205209755091136097996468133948826088786928594154056260518715554763037562655078734094340116464942262731205338631799758403286653199673160724982203728371071348900507941338486404788958670874058005622806326486522915173782131926275462645091848422409866563797033012551949847555246232936997886207067602764086561827119250241130592713148870297505817739080417651329301729732820486017063081406020852442766439664380165354792866826184825318446956704660275922331981677140025136511913971988234476467165513621090655752254264279255466967424276237222473789068091260954941862289200005069298186289425386458707474215296528833958932920075408935338092036135662186637029870321764524576936430914211777950718704933829780012585258549985427263936925519611287958814788218457937289357330934114955703771296875872179787808131369634610227569484842394758887668629015591755180814852262682451882421409349238804593100618349241629842510326820138412505745188066890054687406391770475030670456017732755986357937485840298672511043519083645189241052610206498832829351569216146859526730315987819768236626003047489429632377853463945561370403786509305254480147100902485675586239921614491260959228685850944246956523651806720468903444546107991256981029213624217676764208116867859457128946683712270148679606263238363909861003526808642466504358752508070499029423029579835568577049611101232842184652289393483490621681794137420543103482187286655638566210070730275114558171167743646129691884001480938536015134861642861117378827143841223561146249450714250679918727794136788524892451125247407339885973207015027974086351848872674476403046493038581573015037561733433768608497375472325857285994129836110046552643778563734392459250800311567083605599209051426327352605890849537344522510724374637892297008464246307444166483896892406690734430041582284238574256950049872134219388224834649386312434063064319713638453726608472810761124749009539954064941106478955258759864811957413986555279776390907039661899402462258548585356378596327499001172940707331261025448562091559164674487388159032921577823005452524055920342000807658960437998405806847859379072554567302012141481892676558043088377757720012490728095343115073919903999533165407582807694847045607672670362229228813385640051569756557070777640240286219677039162264611721326802348248841843535059302455541435436476206791574633278771933595147113426992642714125036452065273175692044522370444612939917500752197086004018676130975606981180430123313135574446254231478427042145612179694537282848752021958537654527056057210304087487235747444864958333423954194580560235286917488576614945395163093922886619384568285282125338339760332908770460019147106499455747756219301320733642499236091073340685275795954912639441971565606192494764091487782587128881031448503912687707000378047132571941448625328975931616825966599121863985612356813934015755305324276088154217936465379875308473661707690118030696073362879351427296856756333161756735172185875636884731621850333861135105801124952081770589154688281252268022504472151590497720025566306634350574864031793300085900262147770961427699617189066075924224616795970282633775190517162244773578885157601896914864998485537791743215858360486741584885533622947578819356075809268638955157977747444898299937098058937656802397487966288678151948325257800694328753197275307440628794236017757522494898892970421951172251469353455114258897699737294890884397248933914694527135576844805546642567195178748086658671408504538068587576362247941134795394358928737790105184380838037078662032104927832318170070897636569603362201197058022102697763842530648270212743858139635412759165521771359184855922688612447345714573139960599650239589896286428381625637882608332325533911888370921019871051360536913880557620203798460961533763091140551232270880373512472022456186172674855159346858941846206944411348933702164609807626033540145281382053722704958784333791087718761534782348996108512174392035700342062330995030308370131497826860171719548990736549562809382234563925732387162622599360044933100201252603846083377890503177243952241588138112280571123214916495036560666808076376758392413095708136277003521370279543274904173349559951418980272290255432426384444526549731469835983968315714483349256759339449595283060756884691707555146219730146408715306880692649971478105091184547854942533728963011640682736322093809915029471202678435279549540598776086860518587591769113486599266180336423854432857717641193338907589068142113733922264011674323807100682303636625476509633828332673067370183144805635766705419161919999512800688318775526693117054411888472992561573347449993183781401530259210150146459945442249106810542532370799603273021134624461902058101119466462184567263520529739588576616648900222104735581663228974216323240238684122894072174178706292623424574603769208130865988322565064628055674843343525240283935259661692674362718504590190931086142648388957136799967631672977285753470323764169320762634618859664611461497735794130254657117140915727657504431775486191746805290360224222848613790860426843554309503067312284014306794787583125059395526088572576716757340857424250553870952052897981589403323086366859178654165775016018212309796031319614143590286965657120070145465299992635536660505237426840413633756872149952472906224759949841614649498444443294937117014114114916453452402028663510581944281328373479133404728463911508236465283856676",
|
| 44 |
+
"output": 151313958
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"input": "517540955283540546468253969248377080939914909677084743743939610432765947100317936572959813596050371516659076654888779643599263980395990884716534581556080015443758214677130602979257468060059557000253693886565679886295709963364068164600112635800390461599876739347680318048090238943643182829480100273505821916923135364205226360409324487327830337545467779594579276943823408393253964314765359846527868826067529274006979596715471768007657667657013453137368674262023448030518594413355421622159862997540419258208606225616380013201215030432852498852383581231245333606004406446229432859333802748911639014492668593669366180057821799145043459890252868807331791323794099802961475",
|
| 48 |
+
"output": 826306271
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"input": "12618836709758901644891528429333454335245410497400841393566375629273490401746353015074368068917118218697751709379620940266882973792445170856482069538131872019562000304262397520546489699225829254192063265713205990937413806538599444908819107155983385508093781472198283531487118766339665289020215692614112809555743394697506148131773011747523617326252834684115806197173387145402008520440824270993841147511918146611556001678473969709069159304326800372950272925426525514287037799584020001909304541167340152285739480678535721239918185209766561321516455251686637429456740084258426741010275447365778493385610333160685257935042038131895044106156898441529602464323356097920309155840717380402043916690431306847667218738330849424512384001088492128440364001215251610040636252031484284342737870211722299954414006973092223443413098275678940382534606251604335382790641076503724385962740819669478141853205702139255160415791347245127110912301801642816420689235586578838959536996016756940282099839632116464416320704035892825081655951321994221418887490836944999332342579583140345280992256032004593239508465194589892516828150968878956975358477256290009664747282584279896896774942629067141784821803098473924196180859773836736164774845813008782857471502197848959644003071295473002959358135556030332257666204605479087695428822102693288976171208004983714814429025851516785524709259750445509195561679880730789207042551483091648320339356064574447949448180391493132163493802862242804774598110724609630104070063220269290814898111097991549157321292740589655259412506430493461597358709760537083772443171421347477881274772703247971766972097063333904347989942444538549056569863132351931701794566007799211215377086846573748419972114457428056198034808928403364842313675518463377705861317756091608275047282947702937077410896376914818368305203458187709938832702698409353165547902702987170254599082751579240224504535835194901451094912188447604997739788694561085855562348447924226656729131809868367643694027401039181047065449386702673216753578804797946889170133682565087739245598681189428588219555959866455311828609035946135055744144630839649432429115591663888439130058552189769349210797658225769044112981519927552677703009355436208405887668740187088355185338864346502763958071583604528104548316731963790935588663451150288861959968281960396372225174544016973730449311333353844384708956043883223904380698425073486592879722148782575309367585705128127231702018791835224003225554068442844474991651379937262904851575328297568950831592123085123381015608034402112740126958758381089557671599972521548245220116576699520829036681480426023007911986941529069220698002001848685524198028984169819918954493858439813305232519993417816712785393955354357706112284437816781190612926839448741099520173619734488307199990226892133204357713319560602917631504950576724086109335546191036268724551999797830521226883228113814851564008315359412021177008846720708672269832341771606326308124856431953820484392016981929106638488868779154703104009642337681776917797999555317868248614767322664476145691012903042879424269735242375239112892312740097929286624239233579769283882911584330136906490610807819631301313409282265878521168035319554014978650500936628260128149756292266219334155840937009695148218629200323230431346578238264199716871553167691322865743726029090711744741111008349279916798127062164320116682580048015018460207174903148704787629726584",
|
| 52 |
+
"output": 339979802
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"input": "528202457565309769",
|
| 56 |
+
"output": 22
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"input": "0121542175243078579580317086213930592054549735265758465024463595312803560183291021683424551919105682812492525145895403475988050045500828499193234413289256074606725378605421587162147637798097645073639769117224381741396663273112314194588157851923283793543004709926012381840914874933045331517821025293207553716620418219225010429576278593684356017272898677745675513219154338771797736761884477980169221725470878974443560749175457004615774024293529617605849747029636065371650001630628641068470176814142074355498371538617041207843484932130718939684593098873556836293017961923041704051616455593707200831295470569498159388373535605348460245531912725954929804876467565595937809161646099091095258589303233697056406352122739799141798128683030890684388523646092949137622463422330763842962696099247814642315228161654486230606201920328991334958879850243948148595489329368736853616066010463580708898993496380813090120231365611335479018127929506729541925085979790984405104386800544653914401327499841729628243629398895161102171053661379782907656737559622079695062837904381291020569371167471603212115523923427422753844411230141682293197598368746635302713562717912065581549995819694946183136162138286295977721326029803526872929663582622771396540879416241581631211963065872375847710311681570114372234937967742933488131741723703876886027413420167510655497078059920363952160365499928531614728115770523405879878738926760123058935146665820687805575175251426233817401019494855992396661297489478444652226539117300928687443765577723938824700527819165393464088236158306641395941586690943562519036074844622778775067727587772748379751795153018542163170015527267852775859032405350372499174111310035061724769756163790685041616326430409282236749911031712979036800459378930469597957873823346646171962310509097220008871457430048603899772540306304832209246364300475032779285803786546210554610268829386690108485043042003436142458875549629566255966552262064724745080447987395351527318387793454106939798655493253969923377184194258727882814283988366592320607666650935580598988081556462138632161717284533035231438377023951618611869397323100578368867261446804685162416128858977690532803240599204009335543941012970747977864339777696318146191935395492213069688188300039898671874906261266966508424757384502887833001183060897428884399997498117157500502565778504655772823542843925472854705087382507892274507634593730126080725353216760936639713070967210770933515537136465334802985885820943506399571704852686505328089283007331612892947704156948144575731286498287312917244098377956697946612529603261110598682641532677207218180298047963316050830023716493813503178054694051797799778594271244476935497508749908371738468552555239912224095718116474424953530533983266676667883213110751722837008561456006637152491757981280037290715713572977338094040135090575332414997981580447679731088627308119374455046036035809541288422443305450062372081504671207482761155999892286403469668216902028459990982293285426058631046278875506636962203166191421225185031391399291907600607094475014104834689538859977793468454196641269739496143182918768984370324102998412853685345945329288827019156930524095348476667249623805474055098058603078853717172750819316724347816902921124351526652215982310176319511148747383386566838390863101824284261789259207370284653221884492930538053014791480207595775770426583980609060806670873030885777407446579177851327006666584178868098615772831141995576481925143712829580901201236642537955315696342913722538081030519055886510666525100389074701038526500008863812712808978358968114558995015528690500268729369768912894386409902670885922253821127103764485143409993406578657993271573667851477048413128062107154234085057605823528261298423074975004252381984499461878120078837941243841615111364508506128108852624028150981444260642261259798840719548018127504488649172665110568527116056401845242133339286455214387478477611213817034948049846966676330093969199591827341810740617268458935556503166006573412407637240504057215200709390591938261228460224947769116116648097354574520818449307205998818617323517803963377583773765395951540386307320245912016628116115750567493257343006759963978891871554398487486748733153965455653544186484335423637099552960240670513874741866467499366800185340765021990458983365385733187525782889726837117381985597197654396891686210865082233817213714194597566477691156503211271979159615010152193090474164732539202487689064189138174247558568518445059591635000387915744430164783895141341408398634047461024113591831550942564003559383096359344227436680315176089668305004699590990878940481643178397080083419621139674053093393611581012877374943057917686241774944926062925225629859909897933786105505129206220729804760758474080159242132494639729075188116389267639251325731684451709941683127604655508071075901430023592961597957240126358593322192240275982534856027999489178553028973875086863475919283086692721281299469159853459385160354664970921095867714517610917845172656092828108575702421273795486668855497787165474363469235800050388579490340272955983498680992606684230221922944781347944865872858178227595402463974720515646772540902785482387607883264670904154031472187507825691469139840703032981537482686243765759156763470172952572297213049354720689126073830415977786397608050661777510017351369007567641316874862711968302150704869660960094076300391990198427901839513915247068945690440876433182226865804967948244355824536440194061901194936408757521696594761728917891650558745605300088173657468137012556665221047362275569717434711913882064069969541225648925550176794533757507773479704764682038728982139424204569819662667850563743127284683976644157669130665743308038268087252901546087644788596690944495990237941829038673916162133514265344352245400050566509781310704972455495028130393892347035291885098060467524720017181936398603814994382382650772574920951573251326841845596316117299555997520916921915693160390299946008037680731260289695663573328090295537184696109232961090256422746522240472779037947295553726890564541773183477341602385951250433066652436138907902513589141738984934035007118664457476702936175650532509974018859439897886938198705640224223531234161260494322835831910378739588878491486617772807256473907034615046017101979937448218760285712584115288239247068231185957731208040921969180687753816193332137470856155246184949408134208200781940331836165445332930527471325714699759663858697807486050516493915324687842049986638734797535077595009741573159086455865094526903507403634911304373642720947632743385606283416611803212276401655933319426477128718287531667778383534047329884055641156991461477580852875209605005145126748824382422847181771750227196469595493271083814929516966438279233349067301095431409428514479262217459082711535063579295954517279717019222487411853321959691007874959969382951749153769062624470174891136832493132751789744689002779946207134317564465466868986305955401344546226513276461770171598322199796692440179181149263369957672925710529737582477570506008201364256571321370582099438144554856585474638067857043555384561909623097403981896849326106625220840982935046845517776048403410501066898143708554149005399240996930382819006299171651966865527052594658559148162164850496698238956358965052198094985758695630319101476782538225392487875419849624494502743109905783246387795074137385993953050307885761184985209650716568685151159403316194109560691917965623867997472288170185221416185561997921101763718270130455973547946909667850091771922688048132643522108486530483599928660497610701288891298635225865489831006664914734730335115161838593766426180355837690007795667535486442163512499332635827265006022538662366857118923222980300313936536891113241485469164188684199653997706795776586276769930953065966487166850696007092826917265587038628308195665627167813312761372348899276132601392810647168421100568203290802884486785941798199652583036959236350315978749180415243235311007507023929580635402944864694590835553719502820113821297204073191863656436873858831721599499885250300760758484259992227301861236545662335949945517466343812052793386728604582059049449343375199803935786163907946776582594181507949291932626561926690681337554251000803620491072815168478108453190751005524662783384589693550237048310181652741373807092873209705738802574214720855114634403354253192584116444613872964351464889696804538927765143013290236177530879357079154295378964836800967387498009278823505418082233180006877353115724768897469405954950349676687678953031771064775190917103549673750061122539395946840907221362090537925968678051436241846562377239469706611359945730366914573367208324505498627301315873392341956694605327947337828073199230024745806178976815005235572717045279485106899342694233541752603518934163216412574201030261719425030676358173715925568214410817460762496238944168873854733415534318062060282196739349414494752656954535126420360317478133545659492793838167786318693603951211345748867871040880220521236987280365895875214617686119033584199197678121258801288108651169108459118044307573718850994680163665483464332243250384121519611150751542426324288473994555080400758915525472819602309183435029002301959162380153838709916673857914495250994642492169101393607995528992941633654323837752230754485070146124686015936891266363971709141915706319618799866404489122038347175600560148756284230439814037035479423833885071317442707889637670148396628747936885352344230110937443906976520885933709719988197796174220594997595235960607848107601135358641885671272374961802255117386521847735642710832170144020485390382120783904081464196555991762353088278514699741326336020255646379232399526671628567189445773205607837",
|
| 60 |
+
"output": 699903097
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"input": "60024048105337522711773417464783263324832094585692964392472883697604993898414906626822307996148832646298751146332145488220054254768335562598507380541031596951106051525006787601683802231050144251757656510911040085260639305851358667929740757690711180385073042513942092438842121122396266152706103016099264301002910819572034544440314536590791523707430242769364948666975724636014062998446655597688919654431339321475294817157468940993294111484075421309961659491552768691673193424872747460816705135733933550893172072984360864501842709156441074587703487082882966978770929605450200936680303802513351265079224573650414192909521958718102163256006656648841744374065338264664043467372956063182083453362475551976353769881088646193766530405903985898604592661462725398350037123672500009003166936209487473954501343880695347087974713347417574874402434513682543323662322969149530269722772530702449461261860315454403864761806643605321020782686898781386596910471806638194509349174691552873642396026991100171354566961903129452288080588012927839221034318971318161759918116960069307342199421387050101240036399008283369556711389217884288619589590031573349742596033310937757047197688855207912668652044672867406622794208317622566248174995747803549291274352253023415823715387604064036300376135666334008452989797174372768371183286819034194782885678185924646520672132199038266784102965447056666031241976091977515604563990026438424381364656082581565546242731456127652039829909110360783242471145760273661843765957863999581342847138899513786654515468891851221894629459538836443586899892684591306838706395892573126832852419991957792849866744299670435725493388141288393188979329863404944025897954019091035046067875412730541376796756643537828273552585730107875032078597244609003309655110049327289034312700048011671521920004525681581628283760429557412037888964109235966661243796796271336122201020347592178557271172322593985217541954445116319007390856680174060324079595270892470350236737329301110997062575215274123651501416185878093334316219023943132570551511367737682644708217619118089785109650151004750433860011342018484275433125217846434670556766236440729849791999787680087979947405268291993374050595470626203599067026813791218331491188120532678193552150902288777747774128662056644297455302127414257594683059257234329250824684442532265498537181918559873109465152261283850326765266691746233225788322619778726907779252796988216418482232194180123017415339329441194590487150530386834065748515241603281137529385383137800788581704687980227838782358594981409728506685397449601184933679347435401926523260405324557636855816538589132823191593370763820132312399050622128452396474338357868391233092987256379015807438574026222346083108954499257081363703640751167319437262617026235744586999217658237025268750213516396328425293627873352447767351208780266886156715803704075490368179617869041950342066973024221419229066233725892337474759503227640182398975667771422761847680230366458983409107978983044256253914165375293361340839896737869787926639408660955550088225519240854346463797442749850971437793140401890816218944707975818117136491892652231440824313246513599996662215922923579651771393854749800816816100132425225937175988028722378677837128983205027456589067909250901126829321385628966272131571766773507666998893491976895862053556366241291868640922704580155186806839779901773580969658342711274649256853843556014374286317850314671887354414297565239621342067205288316679745246844953259534698027542736861958589473536254473520475735674801399087244954935419144336598717295781627421008883657554392241343956258154964167756716031499893243329509369376979989509296916967747586552012331642862331364320355688289425625493578370422585637348209891538309287680821427406666857700036450645555918113537550139869488395802376209685384520982369762945096198572131641343784882343952036342023199398654456993653024759810921374894530620338796992304539232062511297193304373203235510016875309218428693188510265677921892939015547226732880495372174467660791662494732803061776151088135113753324469673067720107189259478738726579610174219150837311466854126647974064460544416649803583303132684200862193122920424294620030086640525322134042750169653392005746573512071935440844054566437808613369536932389537149915515361533279507480995630321884353561954604562347929683502975863994306722895764127577732033623770828483164335236",
|
| 64 |
+
"output": 295826001
|
| 65 |
+
}
|
| 66 |
+
],
|
| 67 |
+
"haskell_template": "countPalindromes :: String -> Int\ncountPalindromes s ",
|
| 68 |
+
"ocaml_template": "let countPalindromes (s: string) : int = ",
|
| 69 |
+
"scala_template": "def countPalindromes(s: String): Int = { \n \n}",
|
| 70 |
+
"java_template": "public static int countPalindromes(String s) {\n\n}",
|
| 71 |
+
"python_template": "class Solution(object):\n def countPalindromes(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n "
|
| 72 |
+
}
|
count_palindromic_subsequences/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 2 (countPalindromes "103301")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 21 (countPalindromes "0000000")
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 2 (countPalindromes "9999900000")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for countPalindromes" >::: [
|
| 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
|
count_palindromic_subsequences/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countPalindromes("103301"), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countPalindromes("0000000"), 21)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.countPalindromes("9999900000"), 2)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
count_partitions_with_even_sum_difference/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
countPartitions :: [Int] -> Int
|
| 7 |
+
countPartitions nums = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (countPartitions [10,10,3,7,6])," 4 (countPartitions [10,10,3,7,6]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (countPartitions [1,2,2])," 0 (countPartitions [1,2,2]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (countPartitions [2,4,6,8])," 3 (countPartitions [2,4,6,8]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (countPartitions [52, 48, 75, 98, 57, 68, 78, 16, 15, 63, 22, 68, 84, 83, 7, 96, 28, 6, 39, 42, 5, 91, 27, 89, 51, 22, 61, 69, 14, 4, 46, 48, 72, 7, 33, 22, 16, 1, 6, 56, 2, 84, 68, 27, 84, 13, 100, 98, 88, 35, 60, 79, 2, 78, 76, 40, 17, 39, 32, 3, 8, 23, 79, 76, 73, 64, 32, 58, 5, 89, 71, 43, 45])," 72 (countPartitions [52, 48, 75, 98, 57, 68, 78, 16, 15, 63, 22, 68, 84, 83, 7, 96, 28, 6, 39, 42, 5, 91, 27, 89, 51, 22, 61, 69, 14, 4, 46, 48, 72, 7, 33, 22, 16, 1, 6, 56, 2, 84, 68, 27, 84, 13, 100, 98, 88, 35, 60, 79, 2, 78, 76, 40, 17, 39, 32, 3, 8, 23, 79, 76, 73, 64, 32, 58, 5, 89, 71, 43, 45]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (countPartitions [87, 41, 31, 40, 93, 87, 72, 75, 22, 83, 59, 93, 51, 79, 57, 45, 69, 34, 28, 63, 70, 75, 43, 63, 11, 5, 88, 28, 74, 11])," 0 (countPartitions [87, 41, 31, 40, 93, 87, 72, 75, 22, 83, 59, 93, 51, 79, 57, 45, 69, 34, 28, 63, 70, 75, 43, 63, 11, 5, 88, 28, 74, 11]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (countPartitions [35, 13, 9, 30, 94, 30, 5, 33, 33, 93, 21, 61, 93, 57, 37, 15, 58, 6, 22, 20, 19, 67, 63])," 22 (countPartitions [35, 13, 9, 30, 94, 30, 5, 33, 33, 93, 21, 61, 93, 57, 37, 15, 58, 6, 22, 20, 19, 67, 63]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (countPartitions [56, 19, 68, 86, 70, 24, 82, 91, 92, 80, 43, 48, 81, 3, 16, 57, 2, 56, 66, 58, 2, 31, 57, 61, 36, 100, 41, 13, 1, 84, 58, 91, 95, 23, 98, 5, 51, 48, 19, 29, 65, 27, 49, 89, 56, 9, 78, 43, 31, 60, 68, 73])," 0 (countPartitions [56, 19, 68, 86, 70, 24, 82, 91, 92, 80, 43, 48, 81, 3, 16, 57, 2, 56, 66, 58, 2, 31, 57, 61, 36, 100, 41, 13, 1, 84, 58, 91, 95, 23, 98, 5, 51, 48, 19, 29, 65, 27, 49, 89, 56, 9, 78, 43, 31, 60, 68, 73]))
|
| 33 |
+
|
| 34 |
+
test8 :: Test
|
| 35 |
+
test8 = TestCase (assertEqual "for (countPartitions [15, 11, 3, 6, 81, 52, 74, 97, 100, 67, 68, 47, 83, 68, 75, 75, 70, 99, 62, 62, 51, 60, 40, 62, 97, 49, 60, 94, 41, 87, 99, 76, 73, 28, 78, 20, 69, 98, 2, 23, 64, 99, 72, 68, 84, 88, 29, 22, 50, 56, 56, 20, 52, 43, 100, 8, 17, 87, 10, 55, 57, 81, 79, 84, 57, 12, 44, 62, 92, 89, 56, 94, 13, 48, 35, 12, 43, 35, 72, 56])," 0 (countPartitions [15, 11, 3, 6, 81, 52, 74, 97, 100, 67, 68, 47, 83, 68, 75, 75, 70, 99, 62, 62, 51, 60, 40, 62, 97, 49, 60, 94, 41, 87, 99, 76, 73, 28, 78, 20, 69, 98, 2, 23, 64, 99, 72, 68, 84, 88, 29, 22, 50, 56, 56, 20, 52, 43, 100, 8, 17, 87, 10, 55, 57, 81, 79, 84, 57, 12, 44, 62, 92, 89, 56, 94, 13, 48, 35, 12, 43, 35, 72, 56]))
|
| 36 |
+
|
| 37 |
+
test9 :: Test
|
| 38 |
+
test9 = TestCase (assertEqual "for (countPartitions [55, 1, 32, 65, 3, 46, 72, 75, 91, 42, 81, 30, 25, 96, 15, 30, 23, 28, 55, 23, 20, 36, 81, 38, 4, 91, 22, 68, 1, 63, 2])," 30 (countPartitions [55, 1, 32, 65, 3, 46, 72, 75, 91, 42, 81, 30, 25, 96, 15, 30, 23, 28, 55, 23, 20, 36, 81, 38, 4, 91, 22, 68, 1, 63, 2]))
|
| 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
|
count_partitions_with_even_sum_difference/java_tests/Main.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(4, countPartitions(Arrays.asList(10,10,3,7,6)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(0, countPartitions(Arrays.asList(1,2,2)));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(3, countPartitions(Arrays.asList(2,4,6,8)));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
count_partitions_with_even_sum_difference/meta.json
ADDED
|
@@ -0,0 +1,627 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3704,
|
| 3 |
+
"name": "count_partitions_with_even_sum_difference",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/count-partitions-with-even-sum-difference/",
|
| 6 |
+
"date": "2025-01-19 00:00:00",
|
| 7 |
+
"task_description": "You are given an integer array `nums` of length `n`. A **partition** is defined as an index `i` where `0 <= i < n - 1`, splitting the array into two **non-empty** subarrays such that: Left subarray contains indices `[0, i]`. Right subarray contains indices `[i + 1, n - 1]`. Return the number of **partitions** where the **difference** between the **sum** of the left and right subarrays is **even**. **Example 1:** **Input:** nums = [10,10,3,7,6] **Output:** 4 **Explanation:** The 4 partitions are: `[10]`, `[10, 3, 7, 6]` with a sum difference of `10 - 26 = -16`, which is even. `[10, 10]`, `[3, 7, 6]` with a sum difference of `20 - 16 = 4`, which is even. `[10, 10, 3]`, `[7, 6]` with a sum difference of `23 - 13 = 10`, which is even. `[10, 10, 3, 7]`, `[6]` with a sum difference of `30 - 6 = 24`, which is even. **Example 2:** **Input:** nums = [1,2,2] **Output:** 0 **Explanation:** No partition results in an even sum difference. **Example 3:** **Input:** nums = [2,4,6,8] **Output:** 3 **Explanation:** All partitions result in an even sum difference. **Constraints:** `2 <= n == nums.length <= 100` `1 <= nums[i] <= 100`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [10,10,3,7,6]",
|
| 12 |
+
"output": "4 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [1,2,2]",
|
| 17 |
+
"output": "0 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "nums = [2,4,6,8]",
|
| 22 |
+
"output": "3 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
52,
|
| 29 |
+
48,
|
| 30 |
+
75,
|
| 31 |
+
98,
|
| 32 |
+
57,
|
| 33 |
+
68,
|
| 34 |
+
78,
|
| 35 |
+
16,
|
| 36 |
+
15,
|
| 37 |
+
63,
|
| 38 |
+
22,
|
| 39 |
+
68,
|
| 40 |
+
84,
|
| 41 |
+
83,
|
| 42 |
+
7,
|
| 43 |
+
96,
|
| 44 |
+
28,
|
| 45 |
+
6,
|
| 46 |
+
39,
|
| 47 |
+
42,
|
| 48 |
+
5,
|
| 49 |
+
91,
|
| 50 |
+
27,
|
| 51 |
+
89,
|
| 52 |
+
51,
|
| 53 |
+
22,
|
| 54 |
+
61,
|
| 55 |
+
69,
|
| 56 |
+
14,
|
| 57 |
+
4,
|
| 58 |
+
46,
|
| 59 |
+
48,
|
| 60 |
+
72,
|
| 61 |
+
7,
|
| 62 |
+
33,
|
| 63 |
+
22,
|
| 64 |
+
16,
|
| 65 |
+
1,
|
| 66 |
+
6,
|
| 67 |
+
56,
|
| 68 |
+
2,
|
| 69 |
+
84,
|
| 70 |
+
68,
|
| 71 |
+
27,
|
| 72 |
+
84,
|
| 73 |
+
13,
|
| 74 |
+
100,
|
| 75 |
+
98,
|
| 76 |
+
88,
|
| 77 |
+
35,
|
| 78 |
+
60,
|
| 79 |
+
79,
|
| 80 |
+
2,
|
| 81 |
+
78,
|
| 82 |
+
76,
|
| 83 |
+
40,
|
| 84 |
+
17,
|
| 85 |
+
39,
|
| 86 |
+
32,
|
| 87 |
+
3,
|
| 88 |
+
8,
|
| 89 |
+
23,
|
| 90 |
+
79,
|
| 91 |
+
76,
|
| 92 |
+
73,
|
| 93 |
+
64,
|
| 94 |
+
32,
|
| 95 |
+
58,
|
| 96 |
+
5,
|
| 97 |
+
89,
|
| 98 |
+
71,
|
| 99 |
+
43,
|
| 100 |
+
45
|
| 101 |
+
],
|
| 102 |
+
"output": 72
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"input": [
|
| 106 |
+
87,
|
| 107 |
+
41,
|
| 108 |
+
31,
|
| 109 |
+
40,
|
| 110 |
+
93,
|
| 111 |
+
87,
|
| 112 |
+
72,
|
| 113 |
+
75,
|
| 114 |
+
22,
|
| 115 |
+
83,
|
| 116 |
+
59,
|
| 117 |
+
93,
|
| 118 |
+
51,
|
| 119 |
+
79,
|
| 120 |
+
57,
|
| 121 |
+
45,
|
| 122 |
+
69,
|
| 123 |
+
34,
|
| 124 |
+
28,
|
| 125 |
+
63,
|
| 126 |
+
70,
|
| 127 |
+
75,
|
| 128 |
+
43,
|
| 129 |
+
63,
|
| 130 |
+
11,
|
| 131 |
+
5,
|
| 132 |
+
88,
|
| 133 |
+
28,
|
| 134 |
+
74,
|
| 135 |
+
11
|
| 136 |
+
],
|
| 137 |
+
"output": 0
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"input": [
|
| 141 |
+
35,
|
| 142 |
+
13,
|
| 143 |
+
9,
|
| 144 |
+
30,
|
| 145 |
+
94,
|
| 146 |
+
30,
|
| 147 |
+
5,
|
| 148 |
+
33,
|
| 149 |
+
33,
|
| 150 |
+
93,
|
| 151 |
+
21,
|
| 152 |
+
61,
|
| 153 |
+
93,
|
| 154 |
+
57,
|
| 155 |
+
37,
|
| 156 |
+
15,
|
| 157 |
+
58,
|
| 158 |
+
6,
|
| 159 |
+
22,
|
| 160 |
+
20,
|
| 161 |
+
19,
|
| 162 |
+
67,
|
| 163 |
+
63
|
| 164 |
+
],
|
| 165 |
+
"output": 22
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"input": [
|
| 169 |
+
56,
|
| 170 |
+
19,
|
| 171 |
+
68,
|
| 172 |
+
86,
|
| 173 |
+
70,
|
| 174 |
+
24,
|
| 175 |
+
82,
|
| 176 |
+
91,
|
| 177 |
+
92,
|
| 178 |
+
80,
|
| 179 |
+
43,
|
| 180 |
+
48,
|
| 181 |
+
81,
|
| 182 |
+
3,
|
| 183 |
+
16,
|
| 184 |
+
57,
|
| 185 |
+
2,
|
| 186 |
+
56,
|
| 187 |
+
66,
|
| 188 |
+
58,
|
| 189 |
+
2,
|
| 190 |
+
31,
|
| 191 |
+
57,
|
| 192 |
+
61,
|
| 193 |
+
36,
|
| 194 |
+
100,
|
| 195 |
+
41,
|
| 196 |
+
13,
|
| 197 |
+
1,
|
| 198 |
+
84,
|
| 199 |
+
58,
|
| 200 |
+
91,
|
| 201 |
+
95,
|
| 202 |
+
23,
|
| 203 |
+
98,
|
| 204 |
+
5,
|
| 205 |
+
51,
|
| 206 |
+
48,
|
| 207 |
+
19,
|
| 208 |
+
29,
|
| 209 |
+
65,
|
| 210 |
+
27,
|
| 211 |
+
49,
|
| 212 |
+
89,
|
| 213 |
+
56,
|
| 214 |
+
9,
|
| 215 |
+
78,
|
| 216 |
+
43,
|
| 217 |
+
31,
|
| 218 |
+
60,
|
| 219 |
+
68,
|
| 220 |
+
73
|
| 221 |
+
],
|
| 222 |
+
"output": 0
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"input": [
|
| 226 |
+
15,
|
| 227 |
+
11,
|
| 228 |
+
3,
|
| 229 |
+
6,
|
| 230 |
+
81,
|
| 231 |
+
52,
|
| 232 |
+
74,
|
| 233 |
+
97,
|
| 234 |
+
100,
|
| 235 |
+
67,
|
| 236 |
+
68,
|
| 237 |
+
47,
|
| 238 |
+
83,
|
| 239 |
+
68,
|
| 240 |
+
75,
|
| 241 |
+
75,
|
| 242 |
+
70,
|
| 243 |
+
99,
|
| 244 |
+
62,
|
| 245 |
+
62,
|
| 246 |
+
51,
|
| 247 |
+
60,
|
| 248 |
+
40,
|
| 249 |
+
62,
|
| 250 |
+
97,
|
| 251 |
+
49,
|
| 252 |
+
60,
|
| 253 |
+
94,
|
| 254 |
+
41,
|
| 255 |
+
87,
|
| 256 |
+
99,
|
| 257 |
+
76,
|
| 258 |
+
73,
|
| 259 |
+
28,
|
| 260 |
+
78,
|
| 261 |
+
20,
|
| 262 |
+
69,
|
| 263 |
+
98,
|
| 264 |
+
2,
|
| 265 |
+
23,
|
| 266 |
+
64,
|
| 267 |
+
99,
|
| 268 |
+
72,
|
| 269 |
+
68,
|
| 270 |
+
84,
|
| 271 |
+
88,
|
| 272 |
+
29,
|
| 273 |
+
22,
|
| 274 |
+
50,
|
| 275 |
+
56,
|
| 276 |
+
56,
|
| 277 |
+
20,
|
| 278 |
+
52,
|
| 279 |
+
43,
|
| 280 |
+
100,
|
| 281 |
+
8,
|
| 282 |
+
17,
|
| 283 |
+
87,
|
| 284 |
+
10,
|
| 285 |
+
55,
|
| 286 |
+
57,
|
| 287 |
+
81,
|
| 288 |
+
79,
|
| 289 |
+
84,
|
| 290 |
+
57,
|
| 291 |
+
12,
|
| 292 |
+
44,
|
| 293 |
+
62,
|
| 294 |
+
92,
|
| 295 |
+
89,
|
| 296 |
+
56,
|
| 297 |
+
94,
|
| 298 |
+
13,
|
| 299 |
+
48,
|
| 300 |
+
35,
|
| 301 |
+
12,
|
| 302 |
+
43,
|
| 303 |
+
35,
|
| 304 |
+
72,
|
| 305 |
+
56
|
| 306 |
+
],
|
| 307 |
+
"output": 0
|
| 308 |
+
},
|
| 309 |
+
{
|
| 310 |
+
"input": [
|
| 311 |
+
55,
|
| 312 |
+
1,
|
| 313 |
+
32,
|
| 314 |
+
65,
|
| 315 |
+
3,
|
| 316 |
+
46,
|
| 317 |
+
72,
|
| 318 |
+
75,
|
| 319 |
+
91,
|
| 320 |
+
42,
|
| 321 |
+
81,
|
| 322 |
+
30,
|
| 323 |
+
25,
|
| 324 |
+
96,
|
| 325 |
+
15,
|
| 326 |
+
30,
|
| 327 |
+
23,
|
| 328 |
+
28,
|
| 329 |
+
55,
|
| 330 |
+
23,
|
| 331 |
+
20,
|
| 332 |
+
36,
|
| 333 |
+
81,
|
| 334 |
+
38,
|
| 335 |
+
4,
|
| 336 |
+
91,
|
| 337 |
+
22,
|
| 338 |
+
68,
|
| 339 |
+
1,
|
| 340 |
+
63,
|
| 341 |
+
2
|
| 342 |
+
],
|
| 343 |
+
"output": 30
|
| 344 |
+
},
|
| 345 |
+
{
|
| 346 |
+
"input": [
|
| 347 |
+
15,
|
| 348 |
+
3,
|
| 349 |
+
73,
|
| 350 |
+
9,
|
| 351 |
+
8,
|
| 352 |
+
90,
|
| 353 |
+
94,
|
| 354 |
+
77,
|
| 355 |
+
26,
|
| 356 |
+
3,
|
| 357 |
+
38,
|
| 358 |
+
16,
|
| 359 |
+
40,
|
| 360 |
+
17,
|
| 361 |
+
6,
|
| 362 |
+
40,
|
| 363 |
+
92,
|
| 364 |
+
56,
|
| 365 |
+
14,
|
| 366 |
+
13,
|
| 367 |
+
81,
|
| 368 |
+
60,
|
| 369 |
+
58,
|
| 370 |
+
21,
|
| 371 |
+
92,
|
| 372 |
+
49,
|
| 373 |
+
39,
|
| 374 |
+
71,
|
| 375 |
+
89,
|
| 376 |
+
87,
|
| 377 |
+
6,
|
| 378 |
+
88,
|
| 379 |
+
39,
|
| 380 |
+
84,
|
| 381 |
+
24,
|
| 382 |
+
54,
|
| 383 |
+
24,
|
| 384 |
+
71,
|
| 385 |
+
77,
|
| 386 |
+
53,
|
| 387 |
+
16,
|
| 388 |
+
2,
|
| 389 |
+
34,
|
| 390 |
+
28,
|
| 391 |
+
33,
|
| 392 |
+
69,
|
| 393 |
+
77,
|
| 394 |
+
89,
|
| 395 |
+
63,
|
| 396 |
+
49,
|
| 397 |
+
42,
|
| 398 |
+
85,
|
| 399 |
+
79,
|
| 400 |
+
31,
|
| 401 |
+
78,
|
| 402 |
+
41,
|
| 403 |
+
86,
|
| 404 |
+
33,
|
| 405 |
+
36,
|
| 406 |
+
91,
|
| 407 |
+
53,
|
| 408 |
+
58,
|
| 409 |
+
89,
|
| 410 |
+
83,
|
| 411 |
+
97,
|
| 412 |
+
59
|
| 413 |
+
],
|
| 414 |
+
"output": 65
|
| 415 |
+
},
|
| 416 |
+
{
|
| 417 |
+
"input": [
|
| 418 |
+
96,
|
| 419 |
+
52,
|
| 420 |
+
76,
|
| 421 |
+
66,
|
| 422 |
+
45,
|
| 423 |
+
3,
|
| 424 |
+
15,
|
| 425 |
+
70,
|
| 426 |
+
2,
|
| 427 |
+
49,
|
| 428 |
+
16,
|
| 429 |
+
2,
|
| 430 |
+
74,
|
| 431 |
+
79,
|
| 432 |
+
54,
|
| 433 |
+
93,
|
| 434 |
+
25,
|
| 435 |
+
91,
|
| 436 |
+
85,
|
| 437 |
+
62,
|
| 438 |
+
7,
|
| 439 |
+
98,
|
| 440 |
+
66,
|
| 441 |
+
1,
|
| 442 |
+
31,
|
| 443 |
+
86,
|
| 444 |
+
9,
|
| 445 |
+
25,
|
| 446 |
+
78,
|
| 447 |
+
99,
|
| 448 |
+
64,
|
| 449 |
+
13,
|
| 450 |
+
4,
|
| 451 |
+
64,
|
| 452 |
+
14,
|
| 453 |
+
3,
|
| 454 |
+
70,
|
| 455 |
+
47,
|
| 456 |
+
78,
|
| 457 |
+
63,
|
| 458 |
+
76,
|
| 459 |
+
45,
|
| 460 |
+
67,
|
| 461 |
+
89,
|
| 462 |
+
69,
|
| 463 |
+
92,
|
| 464 |
+
11,
|
| 465 |
+
76,
|
| 466 |
+
34,
|
| 467 |
+
60,
|
| 468 |
+
92,
|
| 469 |
+
18,
|
| 470 |
+
44,
|
| 471 |
+
35,
|
| 472 |
+
72,
|
| 473 |
+
82,
|
| 474 |
+
71,
|
| 475 |
+
53,
|
| 476 |
+
2,
|
| 477 |
+
6,
|
| 478 |
+
36,
|
| 479 |
+
29,
|
| 480 |
+
9,
|
| 481 |
+
23,
|
| 482 |
+
84,
|
| 483 |
+
64,
|
| 484 |
+
53,
|
| 485 |
+
89,
|
| 486 |
+
60,
|
| 487 |
+
68,
|
| 488 |
+
11,
|
| 489 |
+
14,
|
| 490 |
+
21,
|
| 491 |
+
65,
|
| 492 |
+
41,
|
| 493 |
+
57,
|
| 494 |
+
50,
|
| 495 |
+
20,
|
| 496 |
+
92,
|
| 497 |
+
84,
|
| 498 |
+
91,
|
| 499 |
+
25,
|
| 500 |
+
52,
|
| 501 |
+
55,
|
| 502 |
+
51,
|
| 503 |
+
76,
|
| 504 |
+
80,
|
| 505 |
+
45,
|
| 506 |
+
53,
|
| 507 |
+
14,
|
| 508 |
+
40,
|
| 509 |
+
27,
|
| 510 |
+
51,
|
| 511 |
+
1,
|
| 512 |
+
51,
|
| 513 |
+
16,
|
| 514 |
+
52,
|
| 515 |
+
25,
|
| 516 |
+
83,
|
| 517 |
+
7
|
| 518 |
+
],
|
| 519 |
+
"output": 99
|
| 520 |
+
},
|
| 521 |
+
{
|
| 522 |
+
"input": [
|
| 523 |
+
51,
|
| 524 |
+
42,
|
| 525 |
+
23,
|
| 526 |
+
66,
|
| 527 |
+
95,
|
| 528 |
+
47,
|
| 529 |
+
17,
|
| 530 |
+
21,
|
| 531 |
+
6,
|
| 532 |
+
60,
|
| 533 |
+
7,
|
| 534 |
+
45,
|
| 535 |
+
7,
|
| 536 |
+
61,
|
| 537 |
+
55,
|
| 538 |
+
21,
|
| 539 |
+
70,
|
| 540 |
+
79,
|
| 541 |
+
4,
|
| 542 |
+
46,
|
| 543 |
+
4,
|
| 544 |
+
62,
|
| 545 |
+
71,
|
| 546 |
+
90,
|
| 547 |
+
70,
|
| 548 |
+
47,
|
| 549 |
+
72,
|
| 550 |
+
6,
|
| 551 |
+
79,
|
| 552 |
+
76,
|
| 553 |
+
98,
|
| 554 |
+
70,
|
| 555 |
+
69,
|
| 556 |
+
62,
|
| 557 |
+
93,
|
| 558 |
+
77,
|
| 559 |
+
3,
|
| 560 |
+
58,
|
| 561 |
+
67,
|
| 562 |
+
40,
|
| 563 |
+
65,
|
| 564 |
+
87,
|
| 565 |
+
86,
|
| 566 |
+
70,
|
| 567 |
+
78,
|
| 568 |
+
61,
|
| 569 |
+
22,
|
| 570 |
+
20,
|
| 571 |
+
40,
|
| 572 |
+
44,
|
| 573 |
+
47,
|
| 574 |
+
27,
|
| 575 |
+
76,
|
| 576 |
+
25,
|
| 577 |
+
63,
|
| 578 |
+
70,
|
| 579 |
+
94,
|
| 580 |
+
14,
|
| 581 |
+
38,
|
| 582 |
+
54,
|
| 583 |
+
81,
|
| 584 |
+
76,
|
| 585 |
+
58,
|
| 586 |
+
40,
|
| 587 |
+
86,
|
| 588 |
+
15,
|
| 589 |
+
16,
|
| 590 |
+
93,
|
| 591 |
+
33,
|
| 592 |
+
56,
|
| 593 |
+
34,
|
| 594 |
+
14
|
| 595 |
+
],
|
| 596 |
+
"output": 71
|
| 597 |
+
},
|
| 598 |
+
{
|
| 599 |
+
"input": [
|
| 600 |
+
40,
|
| 601 |
+
91,
|
| 602 |
+
86,
|
| 603 |
+
12,
|
| 604 |
+
31,
|
| 605 |
+
79,
|
| 606 |
+
93,
|
| 607 |
+
29,
|
| 608 |
+
27,
|
| 609 |
+
12,
|
| 610 |
+
8,
|
| 611 |
+
96,
|
| 612 |
+
13,
|
| 613 |
+
49,
|
| 614 |
+
5,
|
| 615 |
+
5,
|
| 616 |
+
63,
|
| 617 |
+
85
|
| 618 |
+
],
|
| 619 |
+
"output": 17
|
| 620 |
+
}
|
| 621 |
+
],
|
| 622 |
+
"haskell_template": "countPartitions :: [Int] -> Int\ncountPartitions nums ",
|
| 623 |
+
"ocaml_template": "let countPartitions (nums: int list) : int = ",
|
| 624 |
+
"scala_template": "def countPartitions(nums: List[Int]): Int = { \n \n}",
|
| 625 |
+
"java_template": "class Solution {\n public int countPartitions(int[] nums) {\n \n }\n}",
|
| 626 |
+
"python_template": "class Solution(object):\n def countPartitions(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
|
| 627 |
+
}
|
count_partitions_with_even_sum_difference/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let countPartitions (nums: int list) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 4 (countPartitions [10;10;3;7;6])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal 0 (countPartitions [1;2;2])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal 3 (countPartitions [2;4;6;8])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal 3 (countPartitions [52; 48; 75; 98; 57; 68; 78; 16; 15; 63; 22; 68; 84; 83; 7; 96; 28; 6; 39; 42; 5; 91; 27; 89; 51; 22; 61; 69; 14; 4; 46; 48; 72; 7; 33; 22; 16; 1; 6; 56; 2; 84; 68; 27; 84; 13; 100; 98; 88; 35; 60; 79; 2; 78; 76; 40; 17; 39; 32; 3; 8; 23; 79; 76; 73; 64; 32; 58; 5; 89; 71; 43; 45])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal 3 (countPartitions [87; 41; 31; 40; 93; 87; 72; 75; 22; 83; 59; 93; 51; 79; 57; 45; 69; 34; 28; 63; 70; 75; 43; 63; 11; 5; 88; 28; 74; 11])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal 3 (countPartitions [35; 13; 9; 30; 94; 30; 5; 33; 33; 93; 21; 61; 93; 57; 37; 15; 58; 6; 22; 20; 19; 67; 63])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal 3 (countPartitions [56; 19; 68; 86; 70; 24; 82; 91; 92; 80; 43; 48; 81; 3; 16; 57; 2; 56; 66; 58; 2; 31; 57; 61; 36; 100; 41; 13; 1; 84; 58; 91; 95; 23; 98; 5; 51; 48; 19; 29; 65; 27; 49; 89; 56; 9; 78; 43; 31; 60; 68; 73])
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal 3 (countPartitions [15; 11; 3; 6; 81; 52; 74; 97; 100; 67; 68; 47; 83; 68; 75; 75; 70; 99; 62; 62; 51; 60; 40; 62; 97; 49; 60; 94; 41; 87; 99; 76; 73; 28; 78; 20; 69; 98; 2; 23; 64; 99; 72; 68; 84; 88; 29; 22; 50; 56; 56; 20; 52; 43; 100; 8; 17; 87; 10; 55; 57; 81; 79; 84; 57; 12; 44; 62; 92; 89; 56; 94; 13; 48; 35; 12; 43; 35; 72; 56])
|
| 27 |
+
|
| 28 |
+
let test9 _ = assert_equal 3 (countPartitions [55; 1; 32; 65; 3; 46; 72; 75; 91; 42; 81; 30; 25; 96; 15; 30; 23; 28; 55; 23; 20; 36; 81; 38; 4; 91; 22; 68; 1; 63; 2])
|
| 29 |
+
|
| 30 |
+
let test10 _ = assert_equal 3 (countPartitions [15; 3; 73; 9; 8; 90; 94; 77; 26; 3; 38; 16; 40; 17; 6; 40; 92; 56; 14; 13; 81; 60; 58; 21; 92; 49; 39; 71; 89; 87; 6; 88; 39; 84; 24; 54; 24; 71; 77; 53; 16; 2; 34; 28; 33; 69; 77; 89; 63; 49; 42; 85; 79; 31; 78; 41; 86; 33; 36; 91; 53; 58; 89; 83; 97; 59])
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
(* Grouping test cases *)
|
| 34 |
+
let suite = "Test Suite for countPartitions" >::: [
|
| 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
|
count_partitions_with_even_sum_difference/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countPartitions(List(10,10,3,7,6)), 4)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countPartitions(List(1,2,2)), 0)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.countPartitions(List(2,4,6,8)), 3)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.countPartitions(52,48,75,98,57,68,78,16,15,63,22,68,84,83,7,96,28,6,39,42,5,91,27,89,51,22,61,69,14,4,46,48,72,7,33,22,16,1,6,56,2,84,68,27,84,13,100,98,88,35,60,79,2,78,76,40,17,39,32,3,8,23,79,76,73,64,32,58,5,89,71,43,45), 72)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.countPartitions(87,41,31,40,93,87,72,75,22,83,59,93,51,79,57,45,69,34,28,63,70,75,43,63,11,5,88,28,74,11), 0)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.countPartitions(35,13,9,30,94,30,5,33,33,93,21,61,93,57,37,15,58,6,22,20,19,67,63), 22)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.countPartitions(56,19,68,86,70,24,82,91,92,80,43,48,81,3,16,57,2,56,66,58,2,31,57,61,36,100,41,13,1,84,58,91,95,23,98,5,51,48,19,29,65,27,49,89,56,9,78,43,31,60,68,73), 0)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.countPartitions(15,11,3,6,81,52,74,97,100,67,68,47,83,68,75,75,70,99,62,62,51,60,40,62,97,49,60,94,41,87,99,76,73,28,78,20,69,98,2,23,64,99,72,68,84,88,29,22,50,56,56,20,52,43,100,8,17,87,10,55,57,81,79,84,57,12,44,62,92,89,56,94,13,48,35,12,43,35,72,56), 0)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.countPartitions(55,1,32,65,3,46,72,75,91,42,81,30,25,96,15,30,23,28,55,23,20,36,81,38,4,91,22,68,1,63,2), 30)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.countPartitions(15,3,73,9,8,90,94,77,26,3,38,16,40,17,6,40,92,56,14,13,81,60,58,21,92,49,39,71,89,87,6,88,39,84,24,54,24,71,77,53,16,2,34,28,33,69,77,89,63,49,42,85,79,31,78,41,86,33,36,91,53,58,89,83,97,59), 65)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
count_paths_that_can_form_a_palindrome_in_a_tree/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
count_paths_that_can_form_a_palindrome_in_a_tree/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 (countPalindromePaths [-1,0,0,1,1,2] \"acaabc \")," 8 (countPalindromePaths [-1,0,0,1,1,2] "acaabc"))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (countPalindromePaths [-1,0,0,0,0] \"aaaaa \")," 10 (countPalindromePaths [-1,0,0,0,0] "aaaaa"))
|
| 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
|
count_paths_that_can_form_a_palindrome_in_a_tree/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(8, countPalindromePaths(new ArrayList<>(Arrays.asList(-1,0,0,1,1,2)), "acaabc"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(10, countPalindromePaths(new ArrayList<>(Arrays.asList(-1,0,0,0,0)), "aaaaa"));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
count_paths_that_can_form_a_palindrome_in_a_tree/meta.json
ADDED
|
@@ -0,0 +1,579 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2905,
|
| 3 |
+
"name": "count_paths_that_can_form_a_palindrome_in_a_tree",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/count-paths-that-can-form-a-palindrome-in-a-tree/",
|
| 6 |
+
"date": "1689465600000",
|
| 7 |
+
"task_description": "You are given a **tree** (i.e. a connected, undirected graph that has no cycles) **rooted** at node `0` consisting of `n` nodes numbered from `0` to `n - 1`. The tree is represented by a **0-indexed** array `parent` of size `n`, where `parent[i]` is the parent of node `i`. Since node `0` is the root, `parent[0] == -1`. You are also given a string `s` of length `n`, where `s[i]` is the character assigned to the edge between `i` and `parent[i]`. `s[0]` can be ignored. Return _the number of pairs of nodes _`(u, v)`_ such that _`u < v`_ and the characters assigned to edges on the path from _`u`_ to _`v`_ can be **rearranged** to form a **palindrome**_. A string is a **palindrome** when it reads the same backwards as forwards. **Example 1:** ``` **Input:** parent = [-1,0,0,1,1,2], s = \"acaabc\" **Output:** 8 **Explanation:** The valid pairs are: - All the pairs (0,1), (0,2), (1,3), (1,4) and (2,5) result in one character which is always a palindrome. - The pair (2,3) result in the string \"aca\" which is a palindrome. - The pair (1,5) result in the string \"cac\" which is a palindrome. - The pair (3,5) result in the string \"acac\" which can be rearranged into the palindrome \"acca\". ``` **Example 2:** ``` **Input:** parent = [-1,0,0,0,0], s = \"aaaaa\" **Output:** 10 **Explanation:** Any pair of nodes (u,v) where u < v is valid. ``` **Constraints:** `n == parent.length == s.length` `1 <= n <= 105` `0 <= parent[i] <= n - 1` for all `i >= 1` `parent[0] == -1` `parent` represents a valid tree. `s` consists of only lowercase English letters.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "parent = [-1,0,0,1,1,2], s = \"acaabc\"",
|
| 12 |
+
"output": "8 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "parent = [-1,0,0,0,0], s = \"aaaaa\"",
|
| 17 |
+
"output": "10 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
[
|
| 24 |
+
-1,
|
| 25 |
+
0,
|
| 26 |
+
1,
|
| 27 |
+
2,
|
| 28 |
+
1,
|
| 29 |
+
1,
|
| 30 |
+
2,
|
| 31 |
+
4,
|
| 32 |
+
0,
|
| 33 |
+
2,
|
| 34 |
+
0,
|
| 35 |
+
4,
|
| 36 |
+
0,
|
| 37 |
+
7,
|
| 38 |
+
13,
|
| 39 |
+
11,
|
| 40 |
+
7,
|
| 41 |
+
9,
|
| 42 |
+
7,
|
| 43 |
+
15,
|
| 44 |
+
2,
|
| 45 |
+
19,
|
| 46 |
+
13,
|
| 47 |
+
0,
|
| 48 |
+
1,
|
| 49 |
+
5,
|
| 50 |
+
23,
|
| 51 |
+
5,
|
| 52 |
+
2,
|
| 53 |
+
13,
|
| 54 |
+
24,
|
| 55 |
+
13,
|
| 56 |
+
31,
|
| 57 |
+
17,
|
| 58 |
+
27,
|
| 59 |
+
1,
|
| 60 |
+
30,
|
| 61 |
+
6,
|
| 62 |
+
25,
|
| 63 |
+
9,
|
| 64 |
+
15,
|
| 65 |
+
30,
|
| 66 |
+
23,
|
| 67 |
+
33,
|
| 68 |
+
24,
|
| 69 |
+
16,
|
| 70 |
+
22,
|
| 71 |
+
42,
|
| 72 |
+
34,
|
| 73 |
+
9,
|
| 74 |
+
4,
|
| 75 |
+
49,
|
| 76 |
+
38,
|
| 77 |
+
2,
|
| 78 |
+
51,
|
| 79 |
+
42,
|
| 80 |
+
11,
|
| 81 |
+
6,
|
| 82 |
+
39,
|
| 83 |
+
9,
|
| 84 |
+
37,
|
| 85 |
+
26,
|
| 86 |
+
55,
|
| 87 |
+
1,
|
| 88 |
+
30,
|
| 89 |
+
39,
|
| 90 |
+
9,
|
| 91 |
+
32,
|
| 92 |
+
52,
|
| 93 |
+
40,
|
| 94 |
+
24,
|
| 95 |
+
0,
|
| 96 |
+
4,
|
| 97 |
+
15,
|
| 98 |
+
67,
|
| 99 |
+
23,
|
| 100 |
+
12,
|
| 101 |
+
6,
|
| 102 |
+
37,
|
| 103 |
+
62,
|
| 104 |
+
6,
|
| 105 |
+
77,
|
| 106 |
+
78,
|
| 107 |
+
10,
|
| 108 |
+
46,
|
| 109 |
+
82,
|
| 110 |
+
19,
|
| 111 |
+
6,
|
| 112 |
+
86,
|
| 113 |
+
64,
|
| 114 |
+
87,
|
| 115 |
+
31,
|
| 116 |
+
73,
|
| 117 |
+
0,
|
| 118 |
+
93,
|
| 119 |
+
45
|
| 120 |
+
],
|
| 121 |
+
"\"brhgekbocwhjkgzlylgqzfyuytfqmrzzyuoemarevgytqabypcexkgncoxjodafegcqlwqsvssaagvptolbojlxrvsiwgujv\""
|
| 122 |
+
],
|
| 123 |
+
"output": 145
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"input": [
|
| 127 |
+
[
|
| 128 |
+
-1,
|
| 129 |
+
0,
|
| 130 |
+
0,
|
| 131 |
+
1,
|
| 132 |
+
2,
|
| 133 |
+
1,
|
| 134 |
+
4,
|
| 135 |
+
3,
|
| 136 |
+
0,
|
| 137 |
+
8,
|
| 138 |
+
1,
|
| 139 |
+
5,
|
| 140 |
+
2,
|
| 141 |
+
9,
|
| 142 |
+
0,
|
| 143 |
+
10,
|
| 144 |
+
8,
|
| 145 |
+
15,
|
| 146 |
+
0,
|
| 147 |
+
3,
|
| 148 |
+
7,
|
| 149 |
+
8,
|
| 150 |
+
12,
|
| 151 |
+
21,
|
| 152 |
+
3,
|
| 153 |
+
3,
|
| 154 |
+
8,
|
| 155 |
+
10,
|
| 156 |
+
4,
|
| 157 |
+
1,
|
| 158 |
+
11,
|
| 159 |
+
27,
|
| 160 |
+
15,
|
| 161 |
+
8,
|
| 162 |
+
26,
|
| 163 |
+
1,
|
| 164 |
+
17,
|
| 165 |
+
34,
|
| 166 |
+
8,
|
| 167 |
+
2,
|
| 168 |
+
33,
|
| 169 |
+
28,
|
| 170 |
+
39,
|
| 171 |
+
39,
|
| 172 |
+
9,
|
| 173 |
+
44,
|
| 174 |
+
44,
|
| 175 |
+
6,
|
| 176 |
+
28,
|
| 177 |
+
34,
|
| 178 |
+
6,
|
| 179 |
+
13,
|
| 180 |
+
46,
|
| 181 |
+
13,
|
| 182 |
+
9,
|
| 183 |
+
50
|
| 184 |
+
],
|
| 185 |
+
"\"eqvzwwxcamwddvngplrleasubmjsrmriwcenzylymwnynqkrcaxznbus\""
|
| 186 |
+
],
|
| 187 |
+
"output": 84
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"input": [
|
| 191 |
+
[
|
| 192 |
+
-1,
|
| 193 |
+
0,
|
| 194 |
+
0,
|
| 195 |
+
0,
|
| 196 |
+
3,
|
| 197 |
+
2,
|
| 198 |
+
5,
|
| 199 |
+
1,
|
| 200 |
+
4,
|
| 201 |
+
3,
|
| 202 |
+
7,
|
| 203 |
+
6,
|
| 204 |
+
8,
|
| 205 |
+
11,
|
| 206 |
+
6,
|
| 207 |
+
3,
|
| 208 |
+
10,
|
| 209 |
+
6,
|
| 210 |
+
7,
|
| 211 |
+
6,
|
| 212 |
+
13,
|
| 213 |
+
18
|
| 214 |
+
],
|
| 215 |
+
"\"ghpdzzxedatcllldocdnby\""
|
| 216 |
+
],
|
| 217 |
+
"output": 30
|
| 218 |
+
},
|
| 219 |
+
{
|
| 220 |
+
"input": [
|
| 221 |
+
[
|
| 222 |
+
-1,
|
| 223 |
+
0,
|
| 224 |
+
1,
|
| 225 |
+
0,
|
| 226 |
+
2,
|
| 227 |
+
1,
|
| 228 |
+
5,
|
| 229 |
+
1,
|
| 230 |
+
7,
|
| 231 |
+
1,
|
| 232 |
+
8,
|
| 233 |
+
2,
|
| 234 |
+
5,
|
| 235 |
+
8,
|
| 236 |
+
4,
|
| 237 |
+
5,
|
| 238 |
+
11,
|
| 239 |
+
9,
|
| 240 |
+
11,
|
| 241 |
+
6,
|
| 242 |
+
16,
|
| 243 |
+
19,
|
| 244 |
+
4,
|
| 245 |
+
18,
|
| 246 |
+
21,
|
| 247 |
+
5,
|
| 248 |
+
23,
|
| 249 |
+
16,
|
| 250 |
+
13,
|
| 251 |
+
28,
|
| 252 |
+
22,
|
| 253 |
+
6,
|
| 254 |
+
28,
|
| 255 |
+
18,
|
| 256 |
+
0,
|
| 257 |
+
5,
|
| 258 |
+
20,
|
| 259 |
+
23,
|
| 260 |
+
16,
|
| 261 |
+
28,
|
| 262 |
+
2,
|
| 263 |
+
25,
|
| 264 |
+
23,
|
| 265 |
+
22,
|
| 266 |
+
9,
|
| 267 |
+
14,
|
| 268 |
+
10,
|
| 269 |
+
31,
|
| 270 |
+
0,
|
| 271 |
+
21,
|
| 272 |
+
12,
|
| 273 |
+
5,
|
| 274 |
+
6,
|
| 275 |
+
43,
|
| 276 |
+
22,
|
| 277 |
+
19,
|
| 278 |
+
53,
|
| 279 |
+
7,
|
| 280 |
+
41,
|
| 281 |
+
0,
|
| 282 |
+
3,
|
| 283 |
+
7,
|
| 284 |
+
8,
|
| 285 |
+
23,
|
| 286 |
+
31,
|
| 287 |
+
46,
|
| 288 |
+
31,
|
| 289 |
+
4,
|
| 290 |
+
61,
|
| 291 |
+
37,
|
| 292 |
+
8,
|
| 293 |
+
39,
|
| 294 |
+
24,
|
| 295 |
+
28,
|
| 296 |
+
32,
|
| 297 |
+
60,
|
| 298 |
+
42,
|
| 299 |
+
45,
|
| 300 |
+
14,
|
| 301 |
+
47,
|
| 302 |
+
2,
|
| 303 |
+
21,
|
| 304 |
+
70,
|
| 305 |
+
12,
|
| 306 |
+
62,
|
| 307 |
+
64
|
| 308 |
+
],
|
| 309 |
+
"\"cnsjxmrjmpbxlruodastllsthvgvtijfgvfzcnynltviadvsxwkdfqqzmrdoiayrczvcaqjzwcqpxageyrnqbz\""
|
| 310 |
+
],
|
| 311 |
+
"output": 136
|
| 312 |
+
},
|
| 313 |
+
{
|
| 314 |
+
"input": [
|
| 315 |
+
[
|
| 316 |
+
-1,
|
| 317 |
+
0,
|
| 318 |
+
0,
|
| 319 |
+
2,
|
| 320 |
+
1,
|
| 321 |
+
4,
|
| 322 |
+
3,
|
| 323 |
+
1,
|
| 324 |
+
3,
|
| 325 |
+
5,
|
| 326 |
+
6,
|
| 327 |
+
5,
|
| 328 |
+
2,
|
| 329 |
+
3,
|
| 330 |
+
12,
|
| 331 |
+
3,
|
| 332 |
+
1,
|
| 333 |
+
7,
|
| 334 |
+
3,
|
| 335 |
+
11,
|
| 336 |
+
8,
|
| 337 |
+
15,
|
| 338 |
+
16,
|
| 339 |
+
13,
|
| 340 |
+
22,
|
| 341 |
+
12,
|
| 342 |
+
1,
|
| 343 |
+
9,
|
| 344 |
+
6,
|
| 345 |
+
17,
|
| 346 |
+
8,
|
| 347 |
+
24,
|
| 348 |
+
6,
|
| 349 |
+
1,
|
| 350 |
+
7,
|
| 351 |
+
2,
|
| 352 |
+
34,
|
| 353 |
+
13,
|
| 354 |
+
26,
|
| 355 |
+
22,
|
| 356 |
+
26,
|
| 357 |
+
12,
|
| 358 |
+
1,
|
| 359 |
+
33,
|
| 360 |
+
24,
|
| 361 |
+
34,
|
| 362 |
+
45,
|
| 363 |
+
30,
|
| 364 |
+
23,
|
| 365 |
+
45,
|
| 366 |
+
15,
|
| 367 |
+
34,
|
| 368 |
+
36,
|
| 369 |
+
49,
|
| 370 |
+
26,
|
| 371 |
+
32,
|
| 372 |
+
47,
|
| 373 |
+
48,
|
| 374 |
+
14,
|
| 375 |
+
15,
|
| 376 |
+
45,
|
| 377 |
+
20,
|
| 378 |
+
15,
|
| 379 |
+
51,
|
| 380 |
+
42,
|
| 381 |
+
55
|
| 382 |
+
],
|
| 383 |
+
"\"lldslfpjifwjbojmpumthwpanuzsufdzmdwlpoaascbuaxeamdtgilitwmrvttppjy\""
|
| 384 |
+
],
|
| 385 |
+
"output": 116
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"input": [
|
| 389 |
+
[
|
| 390 |
+
-1,
|
| 391 |
+
0,
|
| 392 |
+
1,
|
| 393 |
+
1,
|
| 394 |
+
0,
|
| 395 |
+
3,
|
| 396 |
+
0,
|
| 397 |
+
1,
|
| 398 |
+
2,
|
| 399 |
+
2,
|
| 400 |
+
0,
|
| 401 |
+
9,
|
| 402 |
+
2,
|
| 403 |
+
2,
|
| 404 |
+
0,
|
| 405 |
+
12,
|
| 406 |
+
4,
|
| 407 |
+
9,
|
| 408 |
+
3,
|
| 409 |
+
2,
|
| 410 |
+
17,
|
| 411 |
+
9,
|
| 412 |
+
16,
|
| 413 |
+
7,
|
| 414 |
+
21,
|
| 415 |
+
15,
|
| 416 |
+
24,
|
| 417 |
+
20,
|
| 418 |
+
18,
|
| 419 |
+
0,
|
| 420 |
+
10,
|
| 421 |
+
17,
|
| 422 |
+
12,
|
| 423 |
+
19,
|
| 424 |
+
16,
|
| 425 |
+
4,
|
| 426 |
+
4,
|
| 427 |
+
32,
|
| 428 |
+
32,
|
| 429 |
+
32,
|
| 430 |
+
36,
|
| 431 |
+
21,
|
| 432 |
+
6,
|
| 433 |
+
38,
|
| 434 |
+
30,
|
| 435 |
+
18,
|
| 436 |
+
21,
|
| 437 |
+
17,
|
| 438 |
+
35,
|
| 439 |
+
36,
|
| 440 |
+
6,
|
| 441 |
+
24
|
| 442 |
+
],
|
| 443 |
+
"\"ngdxhlyawjsimebbaznaruptuucwuttincjctydcwblniilscigr\""
|
| 444 |
+
],
|
| 445 |
+
"output": 69
|
| 446 |
+
},
|
| 447 |
+
{
|
| 448 |
+
"input": [
|
| 449 |
+
[
|
| 450 |
+
-1,
|
| 451 |
+
0,
|
| 452 |
+
1,
|
| 453 |
+
0,
|
| 454 |
+
0,
|
| 455 |
+
1,
|
| 456 |
+
0,
|
| 457 |
+
4,
|
| 458 |
+
1,
|
| 459 |
+
4,
|
| 460 |
+
0,
|
| 461 |
+
2,
|
| 462 |
+
5,
|
| 463 |
+
8,
|
| 464 |
+
10,
|
| 465 |
+
6,
|
| 466 |
+
11,
|
| 467 |
+
6,
|
| 468 |
+
6,
|
| 469 |
+
15,
|
| 470 |
+
5,
|
| 471 |
+
1,
|
| 472 |
+
7,
|
| 473 |
+
1,
|
| 474 |
+
15,
|
| 475 |
+
22,
|
| 476 |
+
20,
|
| 477 |
+
25,
|
| 478 |
+
19,
|
| 479 |
+
2,
|
| 480 |
+
0,
|
| 481 |
+
18,
|
| 482 |
+
29,
|
| 483 |
+
30,
|
| 484 |
+
22,
|
| 485 |
+
4,
|
| 486 |
+
30,
|
| 487 |
+
30,
|
| 488 |
+
20,
|
| 489 |
+
29,
|
| 490 |
+
10,
|
| 491 |
+
6,
|
| 492 |
+
22,
|
| 493 |
+
11,
|
| 494 |
+
13,
|
| 495 |
+
38,
|
| 496 |
+
41,
|
| 497 |
+
29,
|
| 498 |
+
5,
|
| 499 |
+
28,
|
| 500 |
+
25,
|
| 501 |
+
44,
|
| 502 |
+
12,
|
| 503 |
+
28,
|
| 504 |
+
22,
|
| 505 |
+
43,
|
| 506 |
+
37,
|
| 507 |
+
13,
|
| 508 |
+
39,
|
| 509 |
+
40,
|
| 510 |
+
41,
|
| 511 |
+
41,
|
| 512 |
+
17,
|
| 513 |
+
22,
|
| 514 |
+
19,
|
| 515 |
+
55
|
| 516 |
+
],
|
| 517 |
+
"\"gyflaflwodsjtsegttmknzkmcektkbdqdixieztdnxgqhcnwxbbwwkrdbmnfmlwjgf\""
|
| 518 |
+
],
|
| 519 |
+
"output": 93
|
| 520 |
+
},
|
| 521 |
+
{
|
| 522 |
+
"input": [
|
| 523 |
+
[
|
| 524 |
+
-1
|
| 525 |
+
],
|
| 526 |
+
"k"
|
| 527 |
+
],
|
| 528 |
+
"output": 0
|
| 529 |
+
},
|
| 530 |
+
{
|
| 531 |
+
"input": [
|
| 532 |
+
[
|
| 533 |
+
-1,
|
| 534 |
+
0,
|
| 535 |
+
0,
|
| 536 |
+
2,
|
| 537 |
+
0,
|
| 538 |
+
0,
|
| 539 |
+
4,
|
| 540 |
+
4,
|
| 541 |
+
1,
|
| 542 |
+
1,
|
| 543 |
+
4,
|
| 544 |
+
6,
|
| 545 |
+
2,
|
| 546 |
+
6,
|
| 547 |
+
11,
|
| 548 |
+
11,
|
| 549 |
+
4,
|
| 550 |
+
8,
|
| 551 |
+
9,
|
| 552 |
+
11,
|
| 553 |
+
7
|
| 554 |
+
],
|
| 555 |
+
"yfdigwrhbguolivqcpsbz"
|
| 556 |
+
],
|
| 557 |
+
"output": 21
|
| 558 |
+
},
|
| 559 |
+
{
|
| 560 |
+
"input": [
|
| 561 |
+
[
|
| 562 |
+
-1,
|
| 563 |
+
0,
|
| 564 |
+
1,
|
| 565 |
+
1,
|
| 566 |
+
3,
|
| 567 |
+
0
|
| 568 |
+
],
|
| 569 |
+
"ojcpyi"
|
| 570 |
+
],
|
| 571 |
+
"output": 5
|
| 572 |
+
}
|
| 573 |
+
],
|
| 574 |
+
"haskell_template": "countPalindromePaths :: [Int] -> String -> Int\ncountPalindromePaths parent s ",
|
| 575 |
+
"ocaml_template": "let countPalindromePaths (parent: int list) (s: string) : int = ",
|
| 576 |
+
"scala_template": "def countPalindromePaths(parent: List[Int],s: String): Int = { \n \n}",
|
| 577 |
+
"java_template": "public static int countPalindromePaths(List<Integer> parent, String s) {\n\n}",
|
| 578 |
+
"python_template": "class Solution(object):\n def countPalindromePaths(self, parent, s):\n \"\"\"\n :type parent: List[int]\n :type s: str\n :rtype: int\n \"\"\"\n "
|
| 579 |
+
}
|
count_paths_that_can_form_a_palindrome_in_a_tree/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 8 (countPalindromePaths [-1;0;0;1;1;2] "acaabc")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 10 (countPalindromePaths [-1;0;0;0;0] "aaaaa")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for countPalindromePaths" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
count_paths_that_can_form_a_palindrome_in_a_tree/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countPalindromePaths(List(-1,0,0,1,1,2),"acaabc"), 8)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countPalindromePaths(List(-1,0,0,0,0),"aaaaa"), 10)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
count_paths_with_the_given_xor_value/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_paths_with_the_given_xor_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(3, countPathsWithXorValue(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2, 1, 5)), new ArrayList<>(Arrays.asList(7, 10, 0)), new ArrayList<>(Arrays.asList(12, 6, 4)))), 11));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(5, countPathsWithXorValue(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1, 3, 3, 3)), new ArrayList<>(Arrays.asList(0, 3, 3, 2)), new ArrayList<>(Arrays.asList(3, 0, 1, 1)))), 2));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
count_paths_with_the_given_xor_value/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_paths_with_the_given_xor_value/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_paths_with_the_given_xor_value/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
count_prefix_and_suffix_pairs_i/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
countPrefixSuffixPairs :: [String] -> Int
|
| 7 |
+
countPrefixSuffixPairs words = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"a \", \"aba \", \"ababa \", \"aa \"])," 4 (countPrefixSuffixPairs ["a","aba","ababa","aa"]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"pa \", \"papa \", \"ma \", \"mama \"])," 2 (countPrefixSuffixPairs ["pa","papa","ma","mama"]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"abab \", \"ab \"])," 0 (countPrefixSuffixPairs ["abab","ab"]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"zyfn \", \"ujuvsucqd \", \"fin \", \"vkzcgb \", \"odgfyz \", \"focupzrq \", \"jocaylejk \", \"bgm \", \"fpmavzz \", \"pmeuqcapjg \", \"w \", \"lbt \", \"tqcbdaopp \", \"jx \", \"jrn \", \"uyoqpbxl \", \"csn \", \"deorcs \", \"tkwvtvfpls \", \"zxwifl \", \"jqfc \", \"nyrrfiwojv \", \"whwl \", \"x \", \"ydsrxiplz \", \"arzz \", \"ymngfqx \"])," 0 (countPrefixSuffixPairs ["zyfn", "ujuvsucqd", "fin", "vkzcgb", "odgfyz", "focupzrq", "jocaylejk", "bgm", "fpmavzz", "pmeuqcapjg", "w", "lbt", "tqcbdaopp", "jx", "jrn", "uyoqpbxl", "csn", "deorcs", "tkwvtvfpls", "zxwifl", "jqfc", "nyrrfiwojv", "whwl", "x", "ydsrxiplz", "arzz", "ymngfqx"]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"agtqjfw \", \"i \", \"ffnfx \", \"fxdud \", \"oq \", \"nyoadavbp \", \"fvvcbr \", \"mcfox \", \"nlmrkr \", \"sgmwin \", \"anthihed \", \"kaajld \", \"ak \", \"wnp \", \"ijklwgrb \", \"puqktr \", \"by \", \"xwq \", \"rkbphyelux \", \"hjom \", \"ptp \", \"xahpd \", \"ztmealb \", \"cmnmeiyl \", \"xckksy \", \"gzojok \", \"canomipks \", \"udpgrrnhz \"])," 0 (countPrefixSuffixPairs ["agtqjfw", "i", "ffnfx", "fxdud", "oq", "nyoadavbp", "fvvcbr", "mcfox", "nlmrkr", "sgmwin", "anthihed", "kaajld", "ak", "wnp", "ijklwgrb", "puqktr", "by", "xwq", "rkbphyelux", "hjom", "ptp", "xahpd", "ztmealb", "cmnmeiyl", "xckksy", "gzojok", "canomipks", "udpgrrnhz"]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"cql \", \"lfeaau \", \"hghzxkea \", \"arw \", \"esfgwzhiy \", \"joomofen \", \"s \", \"mb \", \"gfums \", \"cslailpgz \", \"alrrcpzm \", \"zwbsi \", \"szdswocnji \", \"w \", \"we \", \"m \", \"zfniocou \", \"e \", \"mwzjl \", \"gpbs \", \"cxzkhltg \", \"bvktqilzl \", \"dwdqhi \", \"hajxu \", \"fnprdxxgdv \", \"hhj \", \"nrwjnkv \", \"jietmjj \", \"vxauqqmht \", \"opmplgs \", \"swdzgbmu \", \"ek \", \"sojcvovdny \", \"szs \", \"g \", \"jxoattqel \", \"mtrjn \", \"wl \"])," 1 (countPrefixSuffixPairs ["cql", "lfeaau", "hghzxkea", "arw", "esfgwzhiy", "joomofen", "s", "mb", "gfums", "cslailpgz", "alrrcpzm", "zwbsi", "szdswocnji", "w", "we", "m", "zfniocou", "e", "mwzjl", "gpbs", "cxzkhltg", "bvktqilzl", "dwdqhi", "hajxu", "fnprdxxgdv", "hhj", "nrwjnkv", "jietmjj", "vxauqqmht", "opmplgs", "swdzgbmu", "ek", "sojcvovdny", "szs", "g", "jxoattqel", "mtrjn", "wl"]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"jzspzok \", \"lvcmouwhdr \", \"rnhwwiikw \", \"ykzhqidutg \", \"jizyv \", \"lv \", \"sksgsmp \", \"otevict \", \"xshdigu \", \"xji \", \"ggymskwnpv \", \"hre \", \"jsk \", \"chhol \", \"glnyoo \", \"zk \", \"kwp \", \"vk \", \"kjqgjaftr \", \"rrt \", \"tjhrk \", \"epj \", \"i \", \"uxlvexs \", \"zkrtksdgvs \", \"jeuhmsnad \", \"opqunjyc \", \"szut \", \"ljtz \", \"hmq \", \"deie \", \"ahak \"])," 0 (countPrefixSuffixPairs ["jzspzok", "lvcmouwhdr", "rnhwwiikw", "ykzhqidutg", "jizyv", "lv", "sksgsmp", "otevict", "xshdigu", "xji", "ggymskwnpv", "hre", "jsk", "chhol", "glnyoo", "zk", "kwp", "vk", "kjqgjaftr", "rrt", "tjhrk", "epj", "i", "uxlvexs", "zkrtksdgvs", "jeuhmsnad", "opqunjyc", "szut", "ljtz", "hmq", "deie", "ahak"]))
|
| 33 |
+
|
| 34 |
+
test8 :: Test
|
| 35 |
+
test8 = TestCase (assertEqual "for (countPrefixSuffixPairs [ \"tioefbiyzd \", \"x \", \"tx \", \"zgvaelmla \", \"lezuiqxwcu \", \"mraf \", \"fi \", \"fxkq \", \"qcejhxlgfr \", \"wgyacuewhz \", \"ooij \", \"uo \", \"qx \", \"dhr \", \"tbmx \", \"xgbtnouan \", \"xbetthbx \", \"bpoq \", \"jgropqunp \", \"qqzwd \", \"srgwdcqorb \", \"yqcqrpvasi \", \"f \", \"gepw \", \"hokn \", \"edkqckl \", \"qdzrfs \", \"mznhanzqf \", \"bshbc \", \"xotl \", \"wkeiwlidg \", \"icet \", \"qmtwngj \", \"poodfvmes \"])," 1 (countPrefixSuffixPairs ["tioefbiyzd", "x", "tx", "zgvaelmla", "lezuiqxwcu", "mraf", "fi", "fxkq", "qcejhxlgfr", "wgyacuewhz", "ooij", "uo", "qx", "dhr", "tbmx", "xgbtnouan", "xbetthbx", "bpoq", "jgropqunp", "qqzwd", "srgwdcqorb", "yqcqrpvasi", "f", "gepw", "hokn", "edkqckl", "qdzrfs", "mznhanzqf", "bshbc", "xotl", "wkeiwlidg", "icet", "qmtwngj", "poodfvmes"]))
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
-- Grouping test cases
|
| 39 |
+
tests :: Test
|
| 40 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
|
| 41 |
+
|
| 42 |
+
-- Running the tests
|
| 43 |
+
main :: IO Counts
|
| 44 |
+
main = runTestTT tests
|
count_prefix_and_suffix_pairs_i/java_tests/Main.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(4, countPrefixSuffixPairs(Arrays.asList("a","aba","ababa","aa")));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(2, countPrefixSuffixPairs(Arrays.asList("pa","papa","ma","mama")));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(0, countPrefixSuffixPairs(Arrays.asList("abab","ab")));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|