DatasetRepo commited on
Commit
5bf0765
·
verified ·
1 Parent(s): 1e6908c

7260b1a7e5f9ee987460047d0344a7f8745c5a35488691f344f81d40f6088db5

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. make_string_a_subsequence_using_cyclic_increments/ocaml_tests/main.ml +0 -0
  3. make_string_a_subsequence_using_cyclic_increments/scala_tests/MySuite.scala +0 -0
  4. make_three_strings_equal/haskell_tests/Main.hs +45 -0
  5. make_three_strings_equal/java_tests/Main.java +21 -0
  6. make_three_strings_equal/meta.json +107 -0
  7. make_three_strings_equal/ocaml_tests/main.ml +50 -0
  8. make_three_strings_equal/scala_tests/MySuite.scala +44 -0
  9. manhattan_distances_of_all_arrangements_of_pieces/haskell_tests/Main.hs +45 -0
  10. manhattan_distances_of_all_arrangements_of_pieces/java_tests/Main.java +21 -0
  11. manhattan_distances_of_all_arrangements_of_pieces/meta.json +107 -0
  12. manhattan_distances_of_all_arrangements_of_pieces/ocaml_tests/main.ml +50 -0
  13. manhattan_distances_of_all_arrangements_of_pieces/scala_tests/MySuite.scala +44 -0
  14. match_substring_after_replacement/.DS_Store +0 -0
  15. match_substring_after_replacement/haskell_tests/Main.hs +27 -0
  16. match_substring_after_replacement/java_tests/Main.java +25 -0
  17. match_substring_after_replacement/meta.json +31 -0
  18. match_substring_after_replacement/ocaml_tests/main.ml +29 -0
  19. match_substring_after_replacement/scala_tests/MySuite.scala +16 -0
  20. matrix_similarity_after_cyclic_shifts/haskell_tests/Main.hs +45 -0
  21. matrix_similarity_after_cyclic_shifts/java_tests/Main.java +25 -0
  22. matrix_similarity_after_cyclic_shifts/meta.json +1283 -0
  23. matrix_similarity_after_cyclic_shifts/ocaml_tests/main.ml +50 -0
  24. matrix_similarity_after_cyclic_shifts/scala_tests/MySuite.scala +44 -0
  25. max_pair_sum_in_an_array/.DS_Store +0 -0
  26. max_pair_sum_in_an_array/haskell_tests/Main.hs +27 -0
  27. max_pair_sum_in_an_array/java_tests/Main.java +25 -0
  28. max_pair_sum_in_an_array/meta.json +598 -0
  29. max_pair_sum_in_an_array/ocaml_tests/main.ml +29 -0
  30. max_pair_sum_in_an_array/scala_tests/MySuite.scala +16 -0
  31. max_sum_of_a_pair_with_equal_sum_of_digits/.DS_Store +0 -0
  32. max_sum_of_a_pair_with_equal_sum_of_digits/haskell_tests/Main.hs +24 -0
  33. max_sum_of_a_pair_with_equal_sum_of_digits/java_tests/Main.java +21 -0
  34. max_sum_of_a_pair_with_equal_sum_of_digits/meta.json +3 -0
  35. max_sum_of_a_pair_with_equal_sum_of_digits/ocaml_tests/main.ml +26 -0
  36. max_sum_of_a_pair_with_equal_sum_of_digits/scala_tests/MySuite.scala +12 -0
  37. maximal_score_after_applying_k_operations/.DS_Store +0 -0
  38. maximal_score_after_applying_k_operations/haskell_tests/Main.hs +24 -0
  39. maximal_score_after_applying_k_operations/java_tests/Main.java +21 -0
  40. maximal_score_after_applying_k_operations/meta.json +3 -0
  41. maximal_score_after_applying_k_operations/ocaml_tests/main.ml +26 -0
  42. maximal_score_after_applying_k_operations/scala_tests/MySuite.scala +12 -0
  43. maximize_amount_after_two_days_of_conversions/java_tests/Main.java +25 -0
  44. maximize_area_of_square_hole_in_grid/haskell_tests/Main.hs +45 -0
  45. maximize_area_of_square_hole_in_grid/java_tests/Main.java +25 -0
  46. maximize_area_of_square_hole_in_grid/meta.json +819 -0
  47. maximize_area_of_square_hole_in_grid/ocaml_tests/main.ml +50 -0
  48. maximize_area_of_square_hole_in_grid/scala_tests/MySuite.scala +44 -0
  49. maximize_consecutive_elements_in_an_array_after_modification/haskell_tests/Main.hs +0 -0
  50. maximize_consecutive_elements_in_an_array_after_modification/java_tests/Main.java +20 -0
.gitattributes CHANGED
@@ -152,3 +152,5 @@ longest_path_with_different_adjacent_characters/meta.json filter=lfs diff=lfs me
152
  longest_special_path/meta.json filter=lfs diff=lfs merge=lfs -text
153
  longest_special_path_ii/meta.json filter=lfs diff=lfs merge=lfs -text
154
  longest_subarray_with_maximum_bitwise_and/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
152
  longest_special_path/meta.json filter=lfs diff=lfs merge=lfs -text
153
  longest_special_path_ii/meta.json filter=lfs diff=lfs merge=lfs -text
154
  longest_subarray_with_maximum_bitwise_and/meta.json filter=lfs diff=lfs merge=lfs -text
155
+ max_sum_of_a_pair_with_equal_sum_of_digits/meta.json filter=lfs diff=lfs merge=lfs -text
156
+ maximal_score_after_applying_k_operations/meta.json filter=lfs diff=lfs merge=lfs -text
make_string_a_subsequence_using_cyclic_increments/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
make_string_a_subsequence_using_cyclic_increments/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
make_three_strings_equal/haskell_tests/Main.hs ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (findMinimumOperations \"abc \" \"abb \" \"ab \")," 2 (findMinimumOperations "abc" "abb" "ab"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (findMinimumOperations \"dac \" \"bac \" \"cac \")," (-1) (findMinimumOperations "dac" "bac" "cac"))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (findMinimumOperations \"xqkqhgglsustxvwxndsvkoowxkp \" \"cbwmjwfuwlcrqbkopolwnzrnevyzbburgnvqteafhoqvtlchnnamkhpgmuduicvnuudtyswtbddkstsjgtaghmtlm \" \"dhtalmmraervdjgtnmgzmcsajgecrggnuoulouqhllrtdylkhzbbycqfjvneauanmyv \")," (-1) (findMinimumOperations "xqkqhgglsustxvwxndsvkoowxkp" "cbwmjwfuwlcrqbkopolwnzrnevyzbburgnvqteafhoqvtlchnnamkhpgmuduicvnuudtyswtbddkstsjgtaghmtlm" "dhtalmmraervdjgtnmgzmcsajgecrggnuoulouqhllrtdylkhzbbycqfjvneauanmyv"))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (findMinimumOperations \"xslmewugvdaaobpgkizaddbwtefynig \" \"fxnsrpsjrtbswpphrtkulgitmtblkyehrlknotfkpwdqhwualiqchmbzckxzlfzedutuwvglwxzuxodqjxvhv \" \"hvv \")," (-1) (findMinimumOperations "xslmewugvdaaobpgkizaddbwtefynig" "fxnsrpsjrtbswpphrtkulgitmtblkyehrlknotfkpwdqhwualiqchmbzckxzlfzedutuwvglwxzuxodqjxvhv" "hvv"))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (findMinimumOperations \"anklygpkcmezpyvobmzjljirwhsfcxajjhtraogxrlfdsvqd \" \"fhiujkvaxmufgjzplbfebnxdmywnnovwhvwhmsdcfzcekctcpqsnnhrqigqcuawbdzsxdbqxbuqkdlzpifafjjkrkmgtdrwqfnzj \" \"mjxuwelhdnscmzfhwetjobbcjnjvbhzocxzlrnaazotckzwsuwrbwmcabfuhompsgdbqzd \")," (-1) (findMinimumOperations "anklygpkcmezpyvobmzjljirwhsfcxajjhtraogxrlfdsvqd" "fhiujkvaxmufgjzplbfebnxdmywnnovwhvwhmsdcfzcekctcpqsnnhrqigqcuawbdzsxdbqxbuqkdlzpifafjjkrkmgtdrwqfnzj" "mjxuwelhdnscmzfhwetjobbcjnjvbhzocxzlrnaazotckzwsuwrbwmcabfuhompsgdbqzd"))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (findMinimumOperations \"jmszcpqqaqjlwxuzwgxiyxrjsewdspinqbmpd \" \"gymnmqbaqqhqqyaimrwdjmanfhkelavaucznszzoxeynonaujfcitqixcthhmohcaaflkfszmzyvgeacgkktlm \" \"bbazqvqpwchbtkwlbxqgyphthtqnviuvgkcggfafltgeuzgpesslphxunbjpwlnvsoxxxizbkpozsqbuhcjjzpzuzvk \")," (-1) (findMinimumOperations "jmszcpqqaqjlwxuzwgxiyxrjsewdspinqbmpd" "gymnmqbaqqhqqyaimrwdjmanfhkelavaucznszzoxeynonaujfcitqixcthhmohcaaflkfszmzyvgeacgkktlm" "bbazqvqpwchbtkwlbxqgyphthtqnviuvgkcggfafltgeuzgpesslphxunbjpwlnvsoxxxizbkpozsqbuhcjjzpzuzvk"))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (findMinimumOperations \"tzwaooirwrsn \" \"mpcgachqmdsrwuujodvbgcdpxtysqgbnyxhtsew \" \"czqykpxejfumndejfugzfphgsublykowhdpanouszafciycdwlybbrjatikhaakcpgwwomsubkcshmuqeijrwpi \")," (-1) (findMinimumOperations "tzwaooirwrsn" "mpcgachqmdsrwuujodvbgcdpxtysqgbnyxhtsew" "czqykpxejfumndejfugzfphgsublykowhdpanouszafciycdwlybbrjatikhaakcpgwwomsubkcshmuqeijrwpi"))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (findMinimumOperations \"zsahdtrwtdhnrmlqrqxjrnybnmkyaqniruyuc \" \"sqsgqkmvzuomyfpzpuzssgkmoxuyxzpwyivhzjwjqgqnqjycsofonpba \" \"hxwoznldoquhoeadtvwgaewvcmlaydyckpyakqnnynmghoptxqtozf \")," (-1) (findMinimumOperations "zsahdtrwtdhnrmlqrqxjrnybnmkyaqniruyuc" "sqsgqkmvzuomyfpzpuzssgkmoxuyxzpwyivhzjwjqgqnqjycsofonpba" "hxwoznldoquhoeadtvwgaewvcmlaydyckpyakqnnynmghoptxqtozf"))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (findMinimumOperations \"zucgojgsmpsagsjdanltuwoxqoytjuxgvzaiepiolmrjxaepcjnhgdqxowfntbrftmci \" \"qhgfnxxmsjjgpdumxjppxydfjfpvcizqgztrhf \" \"xjmubvjbgyblqtuvjb \")," (-1) (findMinimumOperations "zucgojgsmpsagsjdanltuwoxqoytjuxgvzaiepiolmrjxaepcjnhgdqxowfntbrftmci" "qhgfnxxmsjjgpdumxjppxydfjfpvcizqgztrhf" "xjmubvjbgyblqtuvjb"))
37
+
38
+
39
+ -- Grouping test cases
40
+ tests :: Test
41
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
make_three_strings_equal/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(2, findMinimumOperations("abc", "abb", "ab"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, findMinimumOperations("dac", "bac", "cac"));
19
+ }
20
+
21
+ }
make_three_strings_equal/meta.json ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3207,
3
+ "name": "make_three_strings_equal",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/make-three-strings-equal/",
6
+ "date": "2023-11-12 00:00:00",
7
+ "task_description": "You are given three strings: `s1`, `s2`, and `s3`. In one operation you can choose one of these strings and delete its **rightmost** character. Note that you **cannot** completely empty a string. Return the _minimum number of operations_ required to make the strings equal_. _If it is impossible to make them equal, return `-1`. **Example 1:** **Input: **s1 = \"abc\", s2 = \"abb\", s3 = \"ab\" **Output: **2 **Explanation: **Deleting the rightmost character from both `s1` and `s2` will result in three equal strings. **Example 2:** **Input: **s1 = \"dac\", s2 = \"bac\", s3 = \"cac\" **Output: **-1 **Explanation:** Since the first letters of `s1` and `s2` differ, they cannot be made equal. **Constraints:** `1 <= s1.length, s2.length, s3.length <= 100` `s1`, `s2` and `s3` consist only of lowercase English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s1 = \"abc\", s2 = \"abb\", s3 = \"ab\"",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s1 = \"dac\", s2 = \"bac\", s3 = \"cac\"",
17
+ "output": "-1 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"xqkqhgglsustxvwxndsvkoowxkp\"",
24
+ "\"cbwmjwfuwlcrqbkopolwnzrnevyzbburgnvqteafhoqvtlchnnamkhpgmuduicvnuudtyswtbddkstsjgtaghmtlm\"",
25
+ "\"dhtalmmraervdjgtnmgzmcsajgecrggnuoulouqhllrtdylkhzbbycqfjvneauanmyv\""
26
+ ],
27
+ "output": -1
28
+ },
29
+ {
30
+ "input": [
31
+ "\"xslmewugvdaaobpgkizaddbwtefynig\"",
32
+ "\"fxnsrpsjrtbswpphrtkulgitmtblkyehrlknotfkpwdqhwualiqchmbzckxzlfzedutuwvglwxzuxodqjxvhv\"",
33
+ "\"hvv\""
34
+ ],
35
+ "output": -1
36
+ },
37
+ {
38
+ "input": [
39
+ "\"anklygpkcmezpyvobmzjljirwhsfcxajjhtraogxrlfdsvqd\"",
40
+ "\"fhiujkvaxmufgjzplbfebnxdmywnnovwhvwhmsdcfzcekctcpqsnnhrqigqcuawbdzsxdbqxbuqkdlzpifafjjkrkmgtdrwqfnzj\"",
41
+ "\"mjxuwelhdnscmzfhwetjobbcjnjvbhzocxzlrnaazotckzwsuwrbwmcabfuhompsgdbqzd\""
42
+ ],
43
+ "output": -1
44
+ },
45
+ {
46
+ "input": [
47
+ "\"jmszcpqqaqjlwxuzwgxiyxrjsewdspinqbmpd\"",
48
+ "\"gymnmqbaqqhqqyaimrwdjmanfhkelavaucznszzoxeynonaujfcitqixcthhmohcaaflkfszmzyvgeacgkktlm\"",
49
+ "\"bbazqvqpwchbtkwlbxqgyphthtqnviuvgkcggfafltgeuzgpesslphxunbjpwlnvsoxxxizbkpozsqbuhcjjzpzuzvk\""
50
+ ],
51
+ "output": -1
52
+ },
53
+ {
54
+ "input": [
55
+ "\"tzwaooirwrsn\"",
56
+ "\"mpcgachqmdsrwuujodvbgcdpxtysqgbnyxhtsew\"",
57
+ "\"czqykpxejfumndejfugzfphgsublykowhdpanouszafciycdwlybbrjatikhaakcpgwwomsubkcshmuqeijrwpi\""
58
+ ],
59
+ "output": -1
60
+ },
61
+ {
62
+ "input": [
63
+ "\"zsahdtrwtdhnrmlqrqxjrnybnmkyaqniruyuc\"",
64
+ "\"sqsgqkmvzuomyfpzpuzssgkmoxuyxzpwyivhzjwjqgqnqjycsofonpba\"",
65
+ "\"hxwoznldoquhoeadtvwgaewvcmlaydyckpyakqnnynmghoptxqtozf\""
66
+ ],
67
+ "output": -1
68
+ },
69
+ {
70
+ "input": [
71
+ "\"zucgojgsmpsagsjdanltuwoxqoytjuxgvzaiepiolmrjxaepcjnhgdqxowfntbrftmci\"",
72
+ "\"qhgfnxxmsjjgpdumxjppxydfjfpvcizqgztrhf\"",
73
+ "\"xjmubvjbgyblqtuvjb\""
74
+ ],
75
+ "output": -1
76
+ },
77
+ {
78
+ "input": [
79
+ "\"yqiutibyecl\"",
80
+ "\"ongjjorhininybqctpvqbkxkbrnltyraygwcuuhfrsxmhrjntvvmaxqwuilqpdvxundpnxfradws\"",
81
+ "\"wowepoqzrzpcxmjddthkodjnxjhzzryzcrwsorvgapdusbtmasgilvxtcezlhtdewfhwuqeckoqphhrfr\""
82
+ ],
83
+ "output": -1
84
+ },
85
+ {
86
+ "input": [
87
+ "wnbf",
88
+ "vjmineuvfutwcsojysykicdwhqpwxpocsgdhtduqeipdpkagrwiqupwiipoaaftqtekjqhfxyqicfcrd",
89
+ "kduesuwvtmhalmbmozvwutjhxwvanoxgv"
90
+ ],
91
+ "output": -1
92
+ },
93
+ {
94
+ "input": [
95
+ "xvbffebdhdjehgkhvapvmtsabthjjufhtrlhmmeoolxohuwjurdpvogxyzjickyidbnafdllgfpszmrbvarllhwnl",
96
+ "navygnpkhfpfbseqsupvdwvsvgsxiujwifbxuzylyvficyemqkwlzhlgnnceh",
97
+ "qhvsytmspzvplezbeemxvyzmdxqrbrxrwuhetdxdiriwztaknjgslnxkrwgwnsflexfwj"
98
+ ],
99
+ "output": -1
100
+ }
101
+ ],
102
+ "haskell_template": "findMinimumOperations :: String -> String -> String -> Int\nfindMinimumOperations s1 s2 s3 ",
103
+ "ocaml_template": "let findMinimumOperations (s1: string) (s2: string) (s3: string) : int = ",
104
+ "scala_template": "def findMinimumOperations(s1: String,s2: String,s3: String): Int = { \n \n}",
105
+ "java_template": "class Solution {\n public int findMinimumOperations(String s1, String s2, String s3) {\n \n }\n}",
106
+ "python_template": "class Solution(object):\n def findMinimumOperations(self, s1, s2, s3):\n \"\"\"\n :type s1: str\n :type s2: str\n :type s3: str\n :rtype: int\n \"\"\"\n "
107
+ }
make_three_strings_equal/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 2 (findMinimumOperations "abc" "abb" "ab")
12
+
13
+ let test2 _ = assert_equal (-1) (findMinimumOperations "dac" "bac" "cac")
14
+
15
+ let test3 _ = assert_equal (-1) (findMinimumOperations "xqkqhgglsustxvwxndsvkoowxkp" "cbwmjwfuwlcrqbkopolwnzrnevyzbburgnvqteafhoqvtlchnnamkhpgmuduicvnuudtyswtbddkstsjgtaghmtlm" "dhtalmmraervdjgtnmgzmcsajgecrggnuoulouqhllrtdylkhzbbycqfjvneauanmyv")
16
+
17
+ let test4 _ = assert_equal (-1) (findMinimumOperations "xslmewugvdaaobpgkizaddbwtefynig" "fxnsrpsjrtbswpphrtkulgitmtblkyehrlknotfkpwdqhwualiqchmbzckxzlfzedutuwvglwxzuxodqjxvhv" "hvv")
18
+
19
+ let test5 _ = assert_equal (-1) (findMinimumOperations "anklygpkcmezpyvobmzjljirwhsfcxajjhtraogxrlfdsvqd" "fhiujkvaxmufgjzplbfebnxdmywnnovwhvwhmsdcfzcekctcpqsnnhrqigqcuawbdzsxdbqxbuqkdlzpifafjjkrkmgtdrwqfnzj" "mjxuwelhdnscmzfhwetjobbcjnjvbhzocxzlrnaazotckzwsuwrbwmcabfuhompsgdbqzd")
20
+
21
+ let test6 _ = assert_equal (-1) (findMinimumOperations "jmszcpqqaqjlwxuzwgxiyxrjsewdspinqbmpd" "gymnmqbaqqhqqyaimrwdjmanfhkelavaucznszzoxeynonaujfcitqixcthhmohcaaflkfszmzyvgeacgkktlm" "bbazqvqpwchbtkwlbxqgyphthtqnviuvgkcggfafltgeuzgpesslphxunbjpwlnvsoxxxizbkpozsqbuhcjjzpzuzvk")
22
+
23
+ let test7 _ = assert_equal (-1) (findMinimumOperations "tzwaooirwrsn" "mpcgachqmdsrwuujodvbgcdpxtysqgbnyxhtsew" "czqykpxejfumndejfugzfphgsublykowhdpanouszafciycdwlybbrjatikhaakcpgwwomsubkcshmuqeijrwpi")
24
+
25
+ let test8 _ = assert_equal (-1) (findMinimumOperations "zsahdtrwtdhnrmlqrqxjrnybnmkyaqniruyuc" "sqsgqkmvzuomyfpzpuzssgkmoxuyxzpwyivhzjwjqgqnqjycsofonpba" "hxwoznldoquhoeadtvwgaewvcmlaydyckpyakqnnynmghoptxqtozf")
26
+
27
+ let test9 _ = assert_equal (-1) (findMinimumOperations "zucgojgsmpsagsjdanltuwoxqoytjuxgvzaiepiolmrjxaepcjnhgdqxowfntbrftmci" "qhgfnxxmsjjgpdumxjppxydfjfpvcizqgztrhf" "xjmubvjbgyblqtuvjb")
28
+
29
+ let test10 _ = assert_equal (-1) (findMinimumOperations "yqiutibyecl" "ongjjorhininybqctpvqbkxkbrnltyraygwcuuhfrsxmhrjntvvmaxqwuilqpdvxundpnxfradws" "wowepoqzrzpcxmjddthkodjnxjhzzryzcrwsorvgapdusbtmasgilvxtcezlhtdewfhwuqeckoqphhrfr")
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for findMinimumOperations" >::: [
34
+
35
+ "test1" >:: test1;
36
+ "test2" >:: test2;
37
+ "test3" >:: test3;
38
+ "test4" >:: test4;
39
+ "test5" >:: test5;
40
+ "test6" >:: test6;
41
+ "test7" >:: test7;
42
+ "test8" >:: test8;
43
+ "test9" >:: test9;
44
+ "test10" >:: test10;
45
+ ]
46
+
47
+
48
+ (* Running the tests *)
49
+ let () = run_test_tt_main suite
50
+ end
make_three_strings_equal/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findMinimumOperations("abc","abb","ab"), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findMinimumOperations("dac","bac","cac"), -1)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.findMinimumOperations("xqkqhgglsustxvwxndsvkoowxkp","cbwmjwfuwlcrqbkopolwnzrnevyzbburgnvqteafhoqvtlchnnamkhpgmuduicvnuudtyswtbddkstsjgtaghmtlm","dhtalmmraervdjgtnmgzmcsajgecrggnuoulouqhllrtdylkhzbbycqfjvneauanmyv"), -1)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.findMinimumOperations("xslmewugvdaaobpgkizaddbwtefynig","fxnsrpsjrtbswpphrtkulgitmtblkyehrlknotfkpwdqhwualiqchmbzckxzlfzedutuwvglwxzuxodqjxvhv","hvv"), -1)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.findMinimumOperations("anklygpkcmezpyvobmzjljirwhsfcxajjhtraogxrlfdsvqd","fhiujkvaxmufgjzplbfebnxdmywnnovwhvwhmsdcfzcekctcpqsnnhrqigqcuawbdzsxdbqxbuqkdlzpifafjjkrkmgtdrwqfnzj","mjxuwelhdnscmzfhwetjobbcjnjvbhzocxzlrnaazotckzwsuwrbwmcabfuhompsgdbqzd"), -1)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.findMinimumOperations("jmszcpqqaqjlwxuzwgxiyxrjsewdspinqbmpd","gymnmqbaqqhqqyaimrwdjmanfhkelavaucznszzoxeynonaujfcitqixcthhmohcaaflkfszmzyvgeacgkktlm","bbazqvqpwchbtkwlbxqgyphthtqnviuvgkcggfafltgeuzgpesslphxunbjpwlnvsoxxxizbkpozsqbuhcjjzpzuzvk"), -1)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.findMinimumOperations("tzwaooirwrsn","mpcgachqmdsrwuujodvbgcdpxtysqgbnyxhtsew","czqykpxejfumndejfugzfphgsublykowhdpanouszafciycdwlybbrjatikhaakcpgwwomsubkcshmuqeijrwpi"), -1)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.findMinimumOperations("zsahdtrwtdhnrmlqrqxjrnybnmkyaqniruyuc","sqsgqkmvzuomyfpzpuzssgkmoxuyxzpwyivhzjwjqgqnqjycsofonpba","hxwoznldoquhoeadtvwgaewvcmlaydyckpyakqnnynmghoptxqtozf"), -1)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.findMinimumOperations("zucgojgsmpsagsjdanltuwoxqoytjuxgvzaiepiolmrjxaepcjnhgdqxowfntbrftmci","qhgfnxxmsjjgpdumxjppxydfjfpvcizqgztrhf","xjmubvjbgyblqtuvjb"), -1)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.findMinimumOperations("yqiutibyecl","ongjjorhininybqctpvqbkxkbrnltyraygwcuuhfrsxmhrjntvvmaxqwuilqpdvxundpnxfradws","wowepoqzrzpcxmjddthkodjnxjhzzryzcrwsorvgapdusbtmasgilvxtcezlhtdewfhwuqeckoqphhrfr"), -1)
42
+ }
43
+
44
+ }
manhattan_distances_of_all_arrangements_of_pieces/haskell_tests/Main.hs ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (distanceSum 2 2 2)," 8 (distanceSum 2 2 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (distanceSum 1 4 3)," 20 (distanceSum 1 4 3))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (distanceSum 88 243 15262)," 864617655 (distanceSum 88 243 15262))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (distanceSum 88 478 28002)," 755784665 (distanceSum 88 478 28002))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (distanceSum 56 1143 37060)," 41260206 (distanceSum 56 1143 37060))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (distanceSum 34 2927 47404)," 761413360 (distanceSum 34 2927 47404))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (distanceSum 88 715 62886)," 810421682 (distanceSum 88 715 62886))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (distanceSum 17 2896 9298)," 489701420 (distanceSum 17 2896 9298))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (distanceSum 50 180 1709)," 564667214 (distanceSum 50 180 1709))
37
+
38
+
39
+ -- Grouping test cases
40
+ tests :: Test
41
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
manhattan_distances_of_all_arrangements_of_pieces/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, distanceSum(2, 2, 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(20, distanceSum(1, 4, 3));
19
+ }
20
+
21
+ }
manhattan_distances_of_all_arrangements_of_pieces/meta.json ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3739,
3
+ "name": "manhattan_distances_of_all_arrangements_of_pieces",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/manhattan-distances-of-all-arrangements-of-pieces/",
6
+ "date": "2025-01-04 00:00:00",
7
+ "task_description": "You are given three integers `m`, `n`, and `k`. There is a rectangular grid of size `m × n` containing `k` identical pieces. Return the sum of Manhattan distances between every pair of pieces over all **valid arrangements** of pieces. A **valid arrangement** is a placement of all `k` pieces on the grid with **at most** one piece per cell. Since the answer may be very large, return it **modulo** `109 + 7`. The Manhattan Distance between two cells `(xi, yi)` and `(xj, yj)` is `|xi - xj| + |yi - yj|`. **Example 1:** **Input:** m = 2, n = 2, k = 2 **Output:** 8 **Explanation:** The valid arrangements of pieces on the board are: In the first 4 arrangements, the Manhattan distance between the two pieces is 1. In the last 2 arrangements, the Manhattan distance between the two pieces is 2. Thus, the total Manhattan distance across all valid arrangements is `1 + 1 + 1 + 1 + 2 + 2 = 8`. **Example 2:** **Input:** m = 1, n = 4, k = 3 **Output:** 20 **Explanation:** The valid arrangements of pieces on the board are: The first and last arrangements have a total Manhattan distance of `1 + 1 + 2 = 4`. The middle two arrangements have a total Manhattan distance of `1 + 2 + 3 = 6`. The total Manhattan distance between all pairs of pieces across all arrangements is `4 + 6 + 6 + 4 = 20`. **Constraints:** `1 <= m, n <= 105` `2 <= m * n <= 105` `2 <= k <= m * n`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "m = 2, n = 2, k = 2",
12
+ "output": "8 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "m = 1, n = 4, k = 3",
17
+ "output": "20 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 88,
24
+ 243,
25
+ 15262
26
+ ],
27
+ "output": 864617655
28
+ },
29
+ {
30
+ "input": [
31
+ 88,
32
+ 478,
33
+ 28002
34
+ ],
35
+ "output": 755784665
36
+ },
37
+ {
38
+ "input": [
39
+ 56,
40
+ 1143,
41
+ 37060
42
+ ],
43
+ "output": 41260206
44
+ },
45
+ {
46
+ "input": [
47
+ 34,
48
+ 2927,
49
+ 47404
50
+ ],
51
+ "output": 761413360
52
+ },
53
+ {
54
+ "input": [
55
+ 88,
56
+ 715,
57
+ 62886
58
+ ],
59
+ "output": 810421682
60
+ },
61
+ {
62
+ "input": [
63
+ 17,
64
+ 2896,
65
+ 9298
66
+ ],
67
+ "output": 489701420
68
+ },
69
+ {
70
+ "input": [
71
+ 50,
72
+ 180,
73
+ 1709
74
+ ],
75
+ "output": 564667214
76
+ },
77
+ {
78
+ "input": [
79
+ 45,
80
+ 1771,
81
+ 5662
82
+ ],
83
+ "output": 572466774
84
+ },
85
+ {
86
+ "input": [
87
+ 35,
88
+ 159,
89
+ 5510
90
+ ],
91
+ "output": 212429333
92
+ },
93
+ {
94
+ "input": [
95
+ 13,
96
+ 2267,
97
+ 2152
98
+ ],
99
+ "output": 943274957
100
+ }
101
+ ],
102
+ "haskell_template": "distanceSum :: Int -> Int -> Int -> Int\ndistanceSum m n k ",
103
+ "ocaml_template": "let distanceSum (m: int) (n: int) (k: int) : int = ",
104
+ "scala_template": "def distanceSum(m: Int,n: Int,k: Int): Int = { \n \n}",
105
+ "java_template": "class Solution {\n public int distanceSum(int m, int n, int k) {\n \n }\n}",
106
+ "python_template": "class Solution(object):\n def distanceSum(self, m, n, k):\n \"\"\"\n :type m: int\n :type n: int\n :type k: int\n :rtype: int\n \"\"\"\n "
107
+ }
manhattan_distances_of_all_arrangements_of_pieces/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 8 (distanceSum 2 2 2)
12
+
13
+ let test2 _ = assert_equal 20 (distanceSum 1 4 3)
14
+
15
+ let test3 _ = assert_equal 864617655 (distanceSum 88 243 15262)
16
+
17
+ let test4 _ = assert_equal 755784665 (distanceSum 88 478 28002)
18
+
19
+ let test5 _ = assert_equal 41260206 (distanceSum 56 1143 37060)
20
+
21
+ let test6 _ = assert_equal 761413360 (distanceSum 34 2927 47404)
22
+
23
+ let test7 _ = assert_equal 810421682 (distanceSum 88 715 62886)
24
+
25
+ let test8 _ = assert_equal 489701420 (distanceSum 17 2896 9298)
26
+
27
+ let test9 _ = assert_equal 564667214 (distanceSum 50 180 1709)
28
+
29
+ let test10 _ = assert_equal 572466774 (distanceSum 45 1771 5662)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for distanceSum" >::: [
34
+
35
+ "test1" >:: test1;
36
+ "test2" >:: test2;
37
+ "test3" >:: test3;
38
+ "test4" >:: test4;
39
+ "test5" >:: test5;
40
+ "test6" >:: test6;
41
+ "test7" >:: test7;
42
+ "test8" >:: test8;
43
+ "test9" >:: test9;
44
+ "test10" >:: test10;
45
+ ]
46
+
47
+
48
+ (* Running the tests *)
49
+ let () = run_test_tt_main suite
50
+ end
manhattan_distances_of_all_arrangements_of_pieces/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.distanceSum(2,2,2), 8)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.distanceSum(1,4,3), 20)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.distanceSum(88,243,15262), 864617655)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.distanceSum(88,478,28002), 755784665)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.distanceSum(56,1143,37060), 41260206)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.distanceSum(34,2927,47404), 761413360)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.distanceSum(88,715,62886), 810421682)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.distanceSum(17,2896,9298), 489701420)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.distanceSum(50,180,1709), 564667214)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.distanceSum(45,1771,5662), 572466774)
42
+ }
43
+
44
+ }
match_substring_after_replacement/.DS_Store ADDED
Binary file (6.15 kB). View file
 
match_substring_after_replacement/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 (matchReplacement \"fool3e7bar \" \"leet \" [[ \"e \", \"3 \"],[ \"t \", \"7 \"],[ \"t \", \"8 \"]])," True (matchReplacement "fool3e7bar" "leet" [["e","3"],["t","7"],["t","8"]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (matchReplacement \"fooleetbar \" \"f00l \" [[ \"o \", \"0 \"]])," False (matchReplacement "fooleetbar" "f00l" [["o","0"]]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (matchReplacement \"Fool33tbaR \" \"leetd \" [[ \"e \", \"3 \"],[ \"t \", \"7 \"],[ \"t \", \"8 \"],[ \"d \", \"b \"],[ \"p \", \"b \"]])," True (matchReplacement "Fool33tbaR" "leetd" [["e","3"],["t","7"],["t","8"],["d","b"],["p","b"]]))
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
match_substring_after_replacement/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(true, matchReplacement("fool3e7bar", "leet", new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("e","3")),new ArrayList<>(Arrays.asList("t","7")),new ArrayList<>(Arrays.asList("t","8"))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, matchReplacement("fooleetbar", "f00l", new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("o","0"))))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(true, matchReplacement("Fool33tbaR", "leetd", new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("e","3")),new ArrayList<>(Arrays.asList("t","7")),new ArrayList<>(Arrays.asList("t","8")),new ArrayList<>(Arrays.asList("d","b")),new ArrayList<>(Arrays.asList("p","b"))))));
23
+ }
24
+
25
+ }
match_substring_after_replacement/meta.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2393,
3
+ "name": "match_substring_after_replacement",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/match-substring-after-replacement/",
6
+ "date": "1653696000000",
7
+ "task_description": "You are given two strings `s` and `sub`. You are also given a 2D character array `mappings` where `mappings[i] = [oldi, newi]` indicates that you may perform the following operation **any** number of times: **Replace** a character `oldi` of `sub` with `newi`. Each character in `sub` **cannot** be replaced more than once. Return `true`_ if it is possible to make _`sub`_ a substring of _`s`_ by replacing zero or more characters according to _`mappings`. Otherwise, return `false`. A **substring** is a contiguous non-empty sequence of characters within a string. **Example 1:** ``` **Input:** s = \"fool3e7bar\", sub = \"leet\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"]] **Output:** true **Explanation:** Replace the first 'e' in sub with '3' and 't' in sub with '7'. Now sub = \"l3e7\" is a substring of s, so we return true. ``` **Example 2:** ``` **Input:** s = \"fooleetbar\", sub = \"f00l\", mappings = [[\"o\",\"0\"]] **Output:** false **Explanation:** The string \"f00l\" is not a substring of s and no replacements can be made. Note that we cannot replace '0' with 'o'. ``` **Example 3:** ``` **Input:** s = \"Fool33tbaR\", sub = \"leetd\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"],[\"d\",\"b\"],[\"p\",\"b\"]] **Output:** true **Explanation:** Replace the first and second 'e' in sub with '3' and 'd' in sub with 'b'. Now sub = \"l33tb\" is a substring of s, so we return true. ``` **Constraints:** `1 <= sub.length <= s.length <= 5000` `0 <= mappings.length <= 1000` `mappings[i].length == 2` `oldi != newi` `s` and `sub` consist of uppercase and lowercase English letters and digits. `oldi` and `newi` are either uppercase or lowercase English letters or digits.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"fool3e7bar\", sub = \"leet\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"]]",
12
+ "output": "true "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"fooleetbar\", sub = \"f00l\", mappings = [[\"o\",\"0\"]]",
17
+ "output": "false "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "s = \"Fool33tbaR\", sub = \"leetd\", mappings = [[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"],[\"d\",\"b\"],[\"p\",\"b\"]]",
22
+ "output": "true "
23
+ }
24
+ ],
25
+ "private_test_cases": [],
26
+ "haskell_template": "matchReplacement :: String -> String -> [[String]] -> Bool\nmatchReplacement s sub mappings ",
27
+ "ocaml_template": "let matchReplacement (s: string) (sub: string) (mappings: string list list) : bool = ",
28
+ "scala_template": "def matchReplacement(s: String,sub: String,mappings: List[List[String]]): Boolean = { \n \n}",
29
+ "java_template": "public static boolean matchReplacement(String s, String sub, List<List<String>> mappings) {\n\n}",
30
+ "python_template": "class Solution(object):\n def matchReplacement(self, s, sub, mappings):\n \"\"\"\n :type s: str\n :type sub: str\n :type mappings: List[List[str]]\n :rtype: bool\n \"\"\"\n "
31
+ }
match_substring_after_replacement/ocaml_tests/main.ml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal true (matchReplacement "fool3e7bar" "leet" [["e";"3"];["t";"7"];["t";"8"]])
12
+
13
+ let test2 _ = assert_equal false (matchReplacement "fooleetbar" "f00l" [["o";"0"]])
14
+
15
+ let test3 _ = assert_equal true (matchReplacement "Fool33tbaR" "leetd" [["e";"3"];["t";"7"];["t";"8"];["d";"b"];["p";"b"]])
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for matchReplacement" >::: [
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
match_substring_after_replacement/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.matchReplacement("fool3e7bar","leet",[["e","3"],["t","7"],["t","8"]]), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.matchReplacement("fooleetbar","f00l",[["o","0"]]), false)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.matchReplacement("Fool33tbaR","leetd",[["e","3"],["t","7"],["t","8"],["d","b"],["p","b"]]), true)
14
+ }
15
+
16
+ }
matrix_similarity_after_cyclic_shifts/haskell_tests/Main.hs ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (areSimilar [[1,2,3],[4,5,6],[7,8,9]] 4)," False (areSimilar [[1,2,3],[4,5,6],[7,8,9]] 4))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (areSimilar [[1,2,1,2],[5,5,5,5],[6,3,6,3]] 2)," True (areSimilar [[1,2,1,2],[5,5,5,5],[6,3,6,3]] 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (areSimilar [[2,2],[2,2]] 3)," True (areSimilar [[2,2],[2,2]] 3))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (areSimilar [[6, 24, 22, 21, 22, 13, 23, 5, 25, 19, 1, 5, 10], [2, 22, 6, 14, 8, 14, 5, 12, 24, 9, 19, 6, 9], [16, 25, 21, 2, 3, 23, 3, 20, 8, 23, 14, 5, 21], [16, 19, 21, 11, 5, 17, 23, 12, 1, 10, 1, 18, 16], [11, 11, 7, 24, 15, 13, 12, 21, 15, 11, 10, 13, 3], [6, 2, 20, 25, 5, 8, 7, 24, 13, 16, 23, 14, 13], [11, 12, 10, 3, 18, 13, 8, 13, 24, 3, 6, 10, 5], [4, 2, 18, 3, 23, 4, 24, 14, 7, 11, 13, 23, 1], [19, 20, 22, 12, 12, 8, 13, 1, 18, 17, 10, 20, 12], [17, 8, 18, 6, 1, 24, 19, 4, 12, 20, 25, 8, 13], [2, 21, 7, 17, 15, 25, 6, 4, 12, 6, 11, 12, 13], [23, 2, 15, 2, 3, 25, 6, 4, 18, 19, 18, 10, 15], [10, 12, 17, 19, 9, 11, 23, 20, 11, 16, 24, 8, 18], [7, 1, 5, 2, 10, 22, 8, 23, 16, 13, 19, 6, 9], [7, 20, 12, 6, 13, 17, 10, 21, 20, 11, 21, 8, 15], [7, 2, 5, 22, 10, 9, 24, 11, 23, 11, 17, 23, 16], [22, 23, 20, 18, 11, 5, 20, 24, 5, 24, 15, 9, 8]] 30)," False (areSimilar [[6, 24, 22, 21, 22, 13, 23, 5, 25, 19, 1, 5, 10], [2, 22, 6, 14, 8, 14, 5, 12, 24, 9, 19, 6, 9], [16, 25, 21, 2, 3, 23, 3, 20, 8, 23, 14, 5, 21], [16, 19, 21, 11, 5, 17, 23, 12, 1, 10, 1, 18, 16], [11, 11, 7, 24, 15, 13, 12, 21, 15, 11, 10, 13, 3], [6, 2, 20, 25, 5, 8, 7, 24, 13, 16, 23, 14, 13], [11, 12, 10, 3, 18, 13, 8, 13, 24, 3, 6, 10, 5], [4, 2, 18, 3, 23, 4, 24, 14, 7, 11, 13, 23, 1], [19, 20, 22, 12, 12, 8, 13, 1, 18, 17, 10, 20, 12], [17, 8, 18, 6, 1, 24, 19, 4, 12, 20, 25, 8, 13], [2, 21, 7, 17, 15, 25, 6, 4, 12, 6, 11, 12, 13], [23, 2, 15, 2, 3, 25, 6, 4, 18, 19, 18, 10, 15], [10, 12, 17, 19, 9, 11, 23, 20, 11, 16, 24, 8, 18], [7, 1, 5, 2, 10, 22, 8, 23, 16, 13, 19, 6, 9], [7, 20, 12, 6, 13, 17, 10, 21, 20, 11, 21, 8, 15], [7, 2, 5, 22, 10, 9, 24, 11, 23, 11, 17, 23, 16], [22, 23, 20, 18, 11, 5, 20, 24, 5, 24, 15, 9, 8]] 30))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (areSimilar [[1, 15, 17, 4, 14, 1, 3, 19, 20, 18, 16, 19, 8, 2], [11, 13, 14, 24, 12, 19, 25, 15, 16, 12, 12, 15, 1, 22], [24, 5, 23, 25, 17, 19, 2, 1, 14, 20, 11, 6, 16, 16], [1, 14, 21, 11, 20, 3, 19, 7, 11, 1, 2, 1, 21, 24], [11, 15, 7, 19, 22, 19, 5, 14, 12, 19, 12, 11, 12, 1], [23, 24, 18, 2, 4, 17, 22, 16, 12, 24, 20, 11, 23, 16], [8, 8, 22, 10, 4, 10, 7, 22, 21, 6, 21, 9, 23, 21], [15, 8, 22, 18, 13, 24, 3, 11, 23, 2, 19, 14, 17, 11]] 11)," False (areSimilar [[1, 15, 17, 4, 14, 1, 3, 19, 20, 18, 16, 19, 8, 2], [11, 13, 14, 24, 12, 19, 25, 15, 16, 12, 12, 15, 1, 22], [24, 5, 23, 25, 17, 19, 2, 1, 14, 20, 11, 6, 16, 16], [1, 14, 21, 11, 20, 3, 19, 7, 11, 1, 2, 1, 21, 24], [11, 15, 7, 19, 22, 19, 5, 14, 12, 19, 12, 11, 12, 1], [23, 24, 18, 2, 4, 17, 22, 16, 12, 24, 20, 11, 23, 16], [8, 8, 22, 10, 4, 10, 7, 22, 21, 6, 21, 9, 23, 21], [15, 8, 22, 18, 13, 24, 3, 11, 23, 2, 19, 14, 17, 11]] 11))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (areSimilar [[1, 14, 3, 11, 7, 16, 2, 22, 21, 23, 6], [21, 22, 11, 10, 16, 1, 23, 11, 7, 11, 20], [14, 3, 25, 16, 13, 23, 14, 21, 2, 12, 14], [2, 3, 18, 25, 21, 5, 15, 19, 4, 10, 22], [23, 16, 25, 19, 6, 10, 13, 12, 7, 20, 3], [13, 21, 17, 5, 11, 8, 22, 10, 5, 18, 14], [18, 2, 12, 24, 12, 11, 4, 7, 24, 18, 2], [25, 14, 20, 14, 4, 20, 25, 17, 7, 24, 15], [16, 24, 11, 13, 23, 2, 18, 13, 11, 20, 22], [13, 24, 21, 15, 1, 6, 2, 12, 11, 23, 20], [5, 19, 4, 5, 6, 4, 1, 9, 6, 25, 15], [4, 24, 11, 14, 17, 3, 3, 4, 24, 14, 15], [15, 13, 23, 25, 24, 22, 4, 3, 11, 1, 10], [11, 3, 7, 12, 7, 22, 8, 17, 19, 5, 21], [13, 7, 14, 2, 23, 1, 3, 13, 3, 15, 21], [22, 13, 23, 12, 16, 11, 17, 14, 6, 19, 3], [18, 12, 12, 23, 13, 1, 16, 2, 13, 10, 3], [2, 9, 12, 18, 23, 24, 19, 14, 1, 1, 21], [1, 2, 17, 22, 14, 14, 21, 19, 1, 21, 16], [14, 23, 12, 13, 20, 16, 1, 5, 13, 25, 2]] 3)," False (areSimilar [[1, 14, 3, 11, 7, 16, 2, 22, 21, 23, 6], [21, 22, 11, 10, 16, 1, 23, 11, 7, 11, 20], [14, 3, 25, 16, 13, 23, 14, 21, 2, 12, 14], [2, 3, 18, 25, 21, 5, 15, 19, 4, 10, 22], [23, 16, 25, 19, 6, 10, 13, 12, 7, 20, 3], [13, 21, 17, 5, 11, 8, 22, 10, 5, 18, 14], [18, 2, 12, 24, 12, 11, 4, 7, 24, 18, 2], [25, 14, 20, 14, 4, 20, 25, 17, 7, 24, 15], [16, 24, 11, 13, 23, 2, 18, 13, 11, 20, 22], [13, 24, 21, 15, 1, 6, 2, 12, 11, 23, 20], [5, 19, 4, 5, 6, 4, 1, 9, 6, 25, 15], [4, 24, 11, 14, 17, 3, 3, 4, 24, 14, 15], [15, 13, 23, 25, 24, 22, 4, 3, 11, 1, 10], [11, 3, 7, 12, 7, 22, 8, 17, 19, 5, 21], [13, 7, 14, 2, 23, 1, 3, 13, 3, 15, 21], [22, 13, 23, 12, 16, 11, 17, 14, 6, 19, 3], [18, 12, 12, 23, 13, 1, 16, 2, 13, 10, 3], [2, 9, 12, 18, 23, 24, 19, 14, 1, 1, 21], [1, 2, 17, 22, 14, 14, 21, 19, 1, 21, 16], [14, 23, 12, 13, 20, 16, 1, 5, 13, 25, 2]] 3))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (areSimilar [[5, 19, 18, 7, 3, 23, 2], [24, 17, 24, 19, 3, 24, 1], [12, 11, 22, 22, 5, 24, 17], [7, 12, 1, 16, 2, 16, 21], [17, 8, 15, 22, 24, 8, 16], [2, 13, 14, 14, 9, 12, 22], [16, 18, 24, 19, 18, 2, 19], [3, 6, 12, 3, 1, 1, 3], [4, 2, 13, 3, 14, 4, 17], [16, 3, 1, 25, 10, 6, 21]] 25)," False (areSimilar [[5, 19, 18, 7, 3, 23, 2], [24, 17, 24, 19, 3, 24, 1], [12, 11, 22, 22, 5, 24, 17], [7, 12, 1, 16, 2, 16, 21], [17, 8, 15, 22, 24, 8, 16], [2, 13, 14, 14, 9, 12, 22], [16, 18, 24, 19, 18, 2, 19], [3, 6, 12, 3, 1, 1, 3], [4, 2, 13, 3, 14, 4, 17], [16, 3, 1, 25, 10, 6, 21]] 25))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (areSimilar [[21, 5, 16, 21, 9, 11, 5, 22, 17, 2, 23, 15, 9, 13, 14, 8, 12, 21, 7, 22, 13, 18, 1], [13, 11, 3, 7, 20, 16, 13, 10, 24, 23, 15, 17, 21, 24, 19, 22, 2, 3, 25, 3, 21, 24, 23], [16, 10, 1, 5, 22, 6, 18, 5, 22, 12, 10, 18, 16, 12, 3, 9, 7, 11, 15, 8, 10, 8, 12], [3, 11, 13, 16, 9, 3, 12, 3, 20, 2, 11, 13, 17, 10, 13, 1, 2, 1, 14, 17, 23, 15, 22], [19, 24, 17, 6, 3, 5, 2, 11, 13, 9, 24, 19, 23, 13, 20, 13, 1, 15, 17, 10, 25, 25, 3], [6, 10, 22, 15, 17, 5, 13, 7, 1, 13, 21, 3, 24, 24, 9, 1, 10, 5, 8, 2, 18, 16, 21]] 11)," False (areSimilar [[21, 5, 16, 21, 9, 11, 5, 22, 17, 2, 23, 15, 9, 13, 14, 8, 12, 21, 7, 22, 13, 18, 1], [13, 11, 3, 7, 20, 16, 13, 10, 24, 23, 15, 17, 21, 24, 19, 22, 2, 3, 25, 3, 21, 24, 23], [16, 10, 1, 5, 22, 6, 18, 5, 22, 12, 10, 18, 16, 12, 3, 9, 7, 11, 15, 8, 10, 8, 12], [3, 11, 13, 16, 9, 3, 12, 3, 20, 2, 11, 13, 17, 10, 13, 1, 2, 1, 14, 17, 23, 15, 22], [19, 24, 17, 6, 3, 5, 2, 11, 13, 9, 24, 19, 23, 13, 20, 13, 1, 15, 17, 10, 25, 25, 3], [6, 10, 22, 15, 17, 5, 13, 7, 1, 13, 21, 3, 24, 24, 9, 1, 10, 5, 8, 2, 18, 16, 21]] 11))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (areSimilar [[12, 3, 5, 13, 16, 20, 16, 3, 11, 5, 11, 19, 20, 17, 21, 6, 14, 8, 14, 7, 20, 17, 25, 18]] 28)," False (areSimilar [[12, 3, 5, 13, 16, 20, 16, 3, 11, 5, 11, 19, 20, 17, 21, 6, 14, 8, 14, 7, 20, 17, 25, 18]] 28))
37
+
38
+
39
+ -- Grouping test cases
40
+ tests :: Test
41
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
matrix_similarity_after_cyclic_shifts/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(false, areSimilar(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2,3)),new ArrayList<>(Arrays.asList(4,5,6)),new ArrayList<>(Arrays.asList(7,8,9)))), 4));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(true, areSimilar(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2,1,2)),new ArrayList<>(Arrays.asList(5,5,5,5)),new ArrayList<>(Arrays.asList(6,3,6,3)))), 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(true, areSimilar(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,2)),new ArrayList<>(Arrays.asList(2,2)))), 3));
23
+ }
24
+
25
+ }
matrix_similarity_after_cyclic_shifts/meta.json ADDED
@@ -0,0 +1,1283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3215,
3
+ "name": "matrix_similarity_after_cyclic_shifts",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/matrix-similarity-after-cyclic-shifts/",
6
+ "date": "2023-11-19 00:00:00",
7
+ "task_description": "You are given an `m x n` integer matrix `mat` and an integer `k`. The matrix rows are 0-indexed. The following proccess happens `k` times: **Even-indexed** rows (0, 2, 4, ...) are cyclically shifted to the left. **Odd-indexed** rows (1, 3, 5, ...) are cyclically shifted to the right. Return `true` if the final modified matrix after `k` steps is identical to the original matrix, and `false` otherwise. **Example 1:** **Input:** mat = [[1,2,3],[4,5,6],[7,8,9]], k = 4 **Output:** false **Explanation:** In each step left shift is applied to rows 0 and 2 (even indices), and right shift to row 1 (odd index). **Example 2:** **Input:** mat = [[1,2,1,2],[5,5,5,5],[6,3,6,3]], k = 2 **Output:** true **Explanation:** **Example 3:** **Input:** mat = [[2,2],[2,2]], k = 3 **Output:** true **Explanation:** As all the values are equal in the matrix, even after performing cyclic shifts the matrix will remain the same. **Constraints:** `1 <= mat.length <= 25` `1 <= mat[i].length <= 25` `1 <= mat[i][j] <= 25` `1 <= k <= 50`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "mat = [[1,2,3],[4,5,6],[7,8,9]], k = 4",
12
+ "output": "false "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "mat = [[1,2,1,2],[5,5,5,5],[6,3,6,3]], k = 2",
17
+ "output": "true "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "mat = [[2,2],[2,2]], k = 3",
22
+ "output": "true "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ [
29
+ [
30
+ 6,
31
+ 24,
32
+ 22,
33
+ 21,
34
+ 22,
35
+ 13,
36
+ 23,
37
+ 5,
38
+ 25,
39
+ 19,
40
+ 1,
41
+ 5,
42
+ 10
43
+ ],
44
+ [
45
+ 2,
46
+ 22,
47
+ 6,
48
+ 14,
49
+ 8,
50
+ 14,
51
+ 5,
52
+ 12,
53
+ 24,
54
+ 9,
55
+ 19,
56
+ 6,
57
+ 9
58
+ ],
59
+ [
60
+ 16,
61
+ 25,
62
+ 21,
63
+ 2,
64
+ 3,
65
+ 23,
66
+ 3,
67
+ 20,
68
+ 8,
69
+ 23,
70
+ 14,
71
+ 5,
72
+ 21
73
+ ],
74
+ [
75
+ 16,
76
+ 19,
77
+ 21,
78
+ 11,
79
+ 5,
80
+ 17,
81
+ 23,
82
+ 12,
83
+ 1,
84
+ 10,
85
+ 1,
86
+ 18,
87
+ 16
88
+ ],
89
+ [
90
+ 11,
91
+ 11,
92
+ 7,
93
+ 24,
94
+ 15,
95
+ 13,
96
+ 12,
97
+ 21,
98
+ 15,
99
+ 11,
100
+ 10,
101
+ 13,
102
+ 3
103
+ ],
104
+ [
105
+ 6,
106
+ 2,
107
+ 20,
108
+ 25,
109
+ 5,
110
+ 8,
111
+ 7,
112
+ 24,
113
+ 13,
114
+ 16,
115
+ 23,
116
+ 14,
117
+ 13
118
+ ],
119
+ [
120
+ 11,
121
+ 12,
122
+ 10,
123
+ 3,
124
+ 18,
125
+ 13,
126
+ 8,
127
+ 13,
128
+ 24,
129
+ 3,
130
+ 6,
131
+ 10,
132
+ 5
133
+ ],
134
+ [
135
+ 4,
136
+ 2,
137
+ 18,
138
+ 3,
139
+ 23,
140
+ 4,
141
+ 24,
142
+ 14,
143
+ 7,
144
+ 11,
145
+ 13,
146
+ 23,
147
+ 1
148
+ ],
149
+ [
150
+ 19,
151
+ 20,
152
+ 22,
153
+ 12,
154
+ 12,
155
+ 8,
156
+ 13,
157
+ 1,
158
+ 18,
159
+ 17,
160
+ 10,
161
+ 20,
162
+ 12
163
+ ],
164
+ [
165
+ 17,
166
+ 8,
167
+ 18,
168
+ 6,
169
+ 1,
170
+ 24,
171
+ 19,
172
+ 4,
173
+ 12,
174
+ 20,
175
+ 25,
176
+ 8,
177
+ 13
178
+ ],
179
+ [
180
+ 2,
181
+ 21,
182
+ 7,
183
+ 17,
184
+ 15,
185
+ 25,
186
+ 6,
187
+ 4,
188
+ 12,
189
+ 6,
190
+ 11,
191
+ 12,
192
+ 13
193
+ ],
194
+ [
195
+ 23,
196
+ 2,
197
+ 15,
198
+ 2,
199
+ 3,
200
+ 25,
201
+ 6,
202
+ 4,
203
+ 18,
204
+ 19,
205
+ 18,
206
+ 10,
207
+ 15
208
+ ],
209
+ [
210
+ 10,
211
+ 12,
212
+ 17,
213
+ 19,
214
+ 9,
215
+ 11,
216
+ 23,
217
+ 20,
218
+ 11,
219
+ 16,
220
+ 24,
221
+ 8,
222
+ 18
223
+ ],
224
+ [
225
+ 7,
226
+ 1,
227
+ 5,
228
+ 2,
229
+ 10,
230
+ 22,
231
+ 8,
232
+ 23,
233
+ 16,
234
+ 13,
235
+ 19,
236
+ 6,
237
+ 9
238
+ ],
239
+ [
240
+ 7,
241
+ 20,
242
+ 12,
243
+ 6,
244
+ 13,
245
+ 17,
246
+ 10,
247
+ 21,
248
+ 20,
249
+ 11,
250
+ 21,
251
+ 8,
252
+ 15
253
+ ],
254
+ [
255
+ 7,
256
+ 2,
257
+ 5,
258
+ 22,
259
+ 10,
260
+ 9,
261
+ 24,
262
+ 11,
263
+ 23,
264
+ 11,
265
+ 17,
266
+ 23,
267
+ 16
268
+ ],
269
+ [
270
+ 22,
271
+ 23,
272
+ 20,
273
+ 18,
274
+ 11,
275
+ 5,
276
+ 20,
277
+ 24,
278
+ 5,
279
+ 24,
280
+ 15,
281
+ 9,
282
+ 8
283
+ ]
284
+ ],
285
+ 30
286
+ ],
287
+ "output": false
288
+ },
289
+ {
290
+ "input": [
291
+ [
292
+ [
293
+ 1,
294
+ 15,
295
+ 17,
296
+ 4,
297
+ 14,
298
+ 1,
299
+ 3,
300
+ 19,
301
+ 20,
302
+ 18,
303
+ 16,
304
+ 19,
305
+ 8,
306
+ 2
307
+ ],
308
+ [
309
+ 11,
310
+ 13,
311
+ 14,
312
+ 24,
313
+ 12,
314
+ 19,
315
+ 25,
316
+ 15,
317
+ 16,
318
+ 12,
319
+ 12,
320
+ 15,
321
+ 1,
322
+ 22
323
+ ],
324
+ [
325
+ 24,
326
+ 5,
327
+ 23,
328
+ 25,
329
+ 17,
330
+ 19,
331
+ 2,
332
+ 1,
333
+ 14,
334
+ 20,
335
+ 11,
336
+ 6,
337
+ 16,
338
+ 16
339
+ ],
340
+ [
341
+ 1,
342
+ 14,
343
+ 21,
344
+ 11,
345
+ 20,
346
+ 3,
347
+ 19,
348
+ 7,
349
+ 11,
350
+ 1,
351
+ 2,
352
+ 1,
353
+ 21,
354
+ 24
355
+ ],
356
+ [
357
+ 11,
358
+ 15,
359
+ 7,
360
+ 19,
361
+ 22,
362
+ 19,
363
+ 5,
364
+ 14,
365
+ 12,
366
+ 19,
367
+ 12,
368
+ 11,
369
+ 12,
370
+ 1
371
+ ],
372
+ [
373
+ 23,
374
+ 24,
375
+ 18,
376
+ 2,
377
+ 4,
378
+ 17,
379
+ 22,
380
+ 16,
381
+ 12,
382
+ 24,
383
+ 20,
384
+ 11,
385
+ 23,
386
+ 16
387
+ ],
388
+ [
389
+ 8,
390
+ 8,
391
+ 22,
392
+ 10,
393
+ 4,
394
+ 10,
395
+ 7,
396
+ 22,
397
+ 21,
398
+ 6,
399
+ 21,
400
+ 9,
401
+ 23,
402
+ 21
403
+ ],
404
+ [
405
+ 15,
406
+ 8,
407
+ 22,
408
+ 18,
409
+ 13,
410
+ 24,
411
+ 3,
412
+ 11,
413
+ 23,
414
+ 2,
415
+ 19,
416
+ 14,
417
+ 17,
418
+ 11
419
+ ]
420
+ ],
421
+ 11
422
+ ],
423
+ "output": false
424
+ },
425
+ {
426
+ "input": [
427
+ [
428
+ [
429
+ 1,
430
+ 14,
431
+ 3,
432
+ 11,
433
+ 7,
434
+ 16,
435
+ 2,
436
+ 22,
437
+ 21,
438
+ 23,
439
+ 6
440
+ ],
441
+ [
442
+ 21,
443
+ 22,
444
+ 11,
445
+ 10,
446
+ 16,
447
+ 1,
448
+ 23,
449
+ 11,
450
+ 7,
451
+ 11,
452
+ 20
453
+ ],
454
+ [
455
+ 14,
456
+ 3,
457
+ 25,
458
+ 16,
459
+ 13,
460
+ 23,
461
+ 14,
462
+ 21,
463
+ 2,
464
+ 12,
465
+ 14
466
+ ],
467
+ [
468
+ 2,
469
+ 3,
470
+ 18,
471
+ 25,
472
+ 21,
473
+ 5,
474
+ 15,
475
+ 19,
476
+ 4,
477
+ 10,
478
+ 22
479
+ ],
480
+ [
481
+ 23,
482
+ 16,
483
+ 25,
484
+ 19,
485
+ 6,
486
+ 10,
487
+ 13,
488
+ 12,
489
+ 7,
490
+ 20,
491
+ 3
492
+ ],
493
+ [
494
+ 13,
495
+ 21,
496
+ 17,
497
+ 5,
498
+ 11,
499
+ 8,
500
+ 22,
501
+ 10,
502
+ 5,
503
+ 18,
504
+ 14
505
+ ],
506
+ [
507
+ 18,
508
+ 2,
509
+ 12,
510
+ 24,
511
+ 12,
512
+ 11,
513
+ 4,
514
+ 7,
515
+ 24,
516
+ 18,
517
+ 2
518
+ ],
519
+ [
520
+ 25,
521
+ 14,
522
+ 20,
523
+ 14,
524
+ 4,
525
+ 20,
526
+ 25,
527
+ 17,
528
+ 7,
529
+ 24,
530
+ 15
531
+ ],
532
+ [
533
+ 16,
534
+ 24,
535
+ 11,
536
+ 13,
537
+ 23,
538
+ 2,
539
+ 18,
540
+ 13,
541
+ 11,
542
+ 20,
543
+ 22
544
+ ],
545
+ [
546
+ 13,
547
+ 24,
548
+ 21,
549
+ 15,
550
+ 1,
551
+ 6,
552
+ 2,
553
+ 12,
554
+ 11,
555
+ 23,
556
+ 20
557
+ ],
558
+ [
559
+ 5,
560
+ 19,
561
+ 4,
562
+ 5,
563
+ 6,
564
+ 4,
565
+ 1,
566
+ 9,
567
+ 6,
568
+ 25,
569
+ 15
570
+ ],
571
+ [
572
+ 4,
573
+ 24,
574
+ 11,
575
+ 14,
576
+ 17,
577
+ 3,
578
+ 3,
579
+ 4,
580
+ 24,
581
+ 14,
582
+ 15
583
+ ],
584
+ [
585
+ 15,
586
+ 13,
587
+ 23,
588
+ 25,
589
+ 24,
590
+ 22,
591
+ 4,
592
+ 3,
593
+ 11,
594
+ 1,
595
+ 10
596
+ ],
597
+ [
598
+ 11,
599
+ 3,
600
+ 7,
601
+ 12,
602
+ 7,
603
+ 22,
604
+ 8,
605
+ 17,
606
+ 19,
607
+ 5,
608
+ 21
609
+ ],
610
+ [
611
+ 13,
612
+ 7,
613
+ 14,
614
+ 2,
615
+ 23,
616
+ 1,
617
+ 3,
618
+ 13,
619
+ 3,
620
+ 15,
621
+ 21
622
+ ],
623
+ [
624
+ 22,
625
+ 13,
626
+ 23,
627
+ 12,
628
+ 16,
629
+ 11,
630
+ 17,
631
+ 14,
632
+ 6,
633
+ 19,
634
+ 3
635
+ ],
636
+ [
637
+ 18,
638
+ 12,
639
+ 12,
640
+ 23,
641
+ 13,
642
+ 1,
643
+ 16,
644
+ 2,
645
+ 13,
646
+ 10,
647
+ 3
648
+ ],
649
+ [
650
+ 2,
651
+ 9,
652
+ 12,
653
+ 18,
654
+ 23,
655
+ 24,
656
+ 19,
657
+ 14,
658
+ 1,
659
+ 1,
660
+ 21
661
+ ],
662
+ [
663
+ 1,
664
+ 2,
665
+ 17,
666
+ 22,
667
+ 14,
668
+ 14,
669
+ 21,
670
+ 19,
671
+ 1,
672
+ 21,
673
+ 16
674
+ ],
675
+ [
676
+ 14,
677
+ 23,
678
+ 12,
679
+ 13,
680
+ 20,
681
+ 16,
682
+ 1,
683
+ 5,
684
+ 13,
685
+ 25,
686
+ 2
687
+ ]
688
+ ],
689
+ 3
690
+ ],
691
+ "output": false
692
+ },
693
+ {
694
+ "input": [
695
+ [
696
+ [
697
+ 5,
698
+ 19,
699
+ 18,
700
+ 7,
701
+ 3,
702
+ 23,
703
+ 2
704
+ ],
705
+ [
706
+ 24,
707
+ 17,
708
+ 24,
709
+ 19,
710
+ 3,
711
+ 24,
712
+ 1
713
+ ],
714
+ [
715
+ 12,
716
+ 11,
717
+ 22,
718
+ 22,
719
+ 5,
720
+ 24,
721
+ 17
722
+ ],
723
+ [
724
+ 7,
725
+ 12,
726
+ 1,
727
+ 16,
728
+ 2,
729
+ 16,
730
+ 21
731
+ ],
732
+ [
733
+ 17,
734
+ 8,
735
+ 15,
736
+ 22,
737
+ 24,
738
+ 8,
739
+ 16
740
+ ],
741
+ [
742
+ 2,
743
+ 13,
744
+ 14,
745
+ 14,
746
+ 9,
747
+ 12,
748
+ 22
749
+ ],
750
+ [
751
+ 16,
752
+ 18,
753
+ 24,
754
+ 19,
755
+ 18,
756
+ 2,
757
+ 19
758
+ ],
759
+ [
760
+ 3,
761
+ 6,
762
+ 12,
763
+ 3,
764
+ 1,
765
+ 1,
766
+ 3
767
+ ],
768
+ [
769
+ 4,
770
+ 2,
771
+ 13,
772
+ 3,
773
+ 14,
774
+ 4,
775
+ 17
776
+ ],
777
+ [
778
+ 16,
779
+ 3,
780
+ 1,
781
+ 25,
782
+ 10,
783
+ 6,
784
+ 21
785
+ ]
786
+ ],
787
+ 25
788
+ ],
789
+ "output": false
790
+ },
791
+ {
792
+ "input": [
793
+ [
794
+ [
795
+ 21,
796
+ 5,
797
+ 16,
798
+ 21,
799
+ 9,
800
+ 11,
801
+ 5,
802
+ 22,
803
+ 17,
804
+ 2,
805
+ 23,
806
+ 15,
807
+ 9,
808
+ 13,
809
+ 14,
810
+ 8,
811
+ 12,
812
+ 21,
813
+ 7,
814
+ 22,
815
+ 13,
816
+ 18,
817
+ 1
818
+ ],
819
+ [
820
+ 13,
821
+ 11,
822
+ 3,
823
+ 7,
824
+ 20,
825
+ 16,
826
+ 13,
827
+ 10,
828
+ 24,
829
+ 23,
830
+ 15,
831
+ 17,
832
+ 21,
833
+ 24,
834
+ 19,
835
+ 22,
836
+ 2,
837
+ 3,
838
+ 25,
839
+ 3,
840
+ 21,
841
+ 24,
842
+ 23
843
+ ],
844
+ [
845
+ 16,
846
+ 10,
847
+ 1,
848
+ 5,
849
+ 22,
850
+ 6,
851
+ 18,
852
+ 5,
853
+ 22,
854
+ 12,
855
+ 10,
856
+ 18,
857
+ 16,
858
+ 12,
859
+ 3,
860
+ 9,
861
+ 7,
862
+ 11,
863
+ 15,
864
+ 8,
865
+ 10,
866
+ 8,
867
+ 12
868
+ ],
869
+ [
870
+ 3,
871
+ 11,
872
+ 13,
873
+ 16,
874
+ 9,
875
+ 3,
876
+ 12,
877
+ 3,
878
+ 20,
879
+ 2,
880
+ 11,
881
+ 13,
882
+ 17,
883
+ 10,
884
+ 13,
885
+ 1,
886
+ 2,
887
+ 1,
888
+ 14,
889
+ 17,
890
+ 23,
891
+ 15,
892
+ 22
893
+ ],
894
+ [
895
+ 19,
896
+ 24,
897
+ 17,
898
+ 6,
899
+ 3,
900
+ 5,
901
+ 2,
902
+ 11,
903
+ 13,
904
+ 9,
905
+ 24,
906
+ 19,
907
+ 23,
908
+ 13,
909
+ 20,
910
+ 13,
911
+ 1,
912
+ 15,
913
+ 17,
914
+ 10,
915
+ 25,
916
+ 25,
917
+ 3
918
+ ],
919
+ [
920
+ 6,
921
+ 10,
922
+ 22,
923
+ 15,
924
+ 17,
925
+ 5,
926
+ 13,
927
+ 7,
928
+ 1,
929
+ 13,
930
+ 21,
931
+ 3,
932
+ 24,
933
+ 24,
934
+ 9,
935
+ 1,
936
+ 10,
937
+ 5,
938
+ 8,
939
+ 2,
940
+ 18,
941
+ 16,
942
+ 21
943
+ ]
944
+ ],
945
+ 11
946
+ ],
947
+ "output": false
948
+ },
949
+ {
950
+ "input": [
951
+ [
952
+ [
953
+ 12,
954
+ 3,
955
+ 5,
956
+ 13,
957
+ 16,
958
+ 20,
959
+ 16,
960
+ 3,
961
+ 11,
962
+ 5,
963
+ 11,
964
+ 19,
965
+ 20,
966
+ 17,
967
+ 21,
968
+ 6,
969
+ 14,
970
+ 8,
971
+ 14,
972
+ 7,
973
+ 20,
974
+ 17,
975
+ 25,
976
+ 18
977
+ ]
978
+ ],
979
+ 28
980
+ ],
981
+ "output": false
982
+ },
983
+ {
984
+ "input": [
985
+ [
986
+ [
987
+ 21,
988
+ 2,
989
+ 2,
990
+ 25,
991
+ 9,
992
+ 22,
993
+ 6,
994
+ 2,
995
+ 8,
996
+ 7,
997
+ 25,
998
+ 19,
999
+ 7,
1000
+ 2,
1001
+ 7,
1002
+ 6,
1003
+ 16,
1004
+ 12,
1005
+ 1,
1006
+ 12,
1007
+ 22,
1008
+ 8,
1009
+ 24,
1010
+ 6
1011
+ ],
1012
+ [
1013
+ 3,
1014
+ 2,
1015
+ 10,
1016
+ 3,
1017
+ 20,
1018
+ 13,
1019
+ 13,
1020
+ 16,
1021
+ 11,
1022
+ 23,
1023
+ 9,
1024
+ 24,
1025
+ 16,
1026
+ 13,
1027
+ 5,
1028
+ 20,
1029
+ 21,
1030
+ 11,
1031
+ 13,
1032
+ 24,
1033
+ 20,
1034
+ 18,
1035
+ 20,
1036
+ 15
1037
+ ],
1038
+ [
1039
+ 23,
1040
+ 15,
1041
+ 17,
1042
+ 16,
1043
+ 9,
1044
+ 1,
1045
+ 10,
1046
+ 9,
1047
+ 12,
1048
+ 2,
1049
+ 8,
1050
+ 24,
1051
+ 21,
1052
+ 6,
1053
+ 19,
1054
+ 20,
1055
+ 9,
1056
+ 24,
1057
+ 3,
1058
+ 17,
1059
+ 18,
1060
+ 1,
1061
+ 17,
1062
+ 9
1063
+ ],
1064
+ [
1065
+ 13,
1066
+ 21,
1067
+ 6,
1068
+ 9,
1069
+ 22,
1070
+ 2,
1071
+ 19,
1072
+ 24,
1073
+ 10,
1074
+ 17,
1075
+ 15,
1076
+ 10,
1077
+ 3,
1078
+ 20,
1079
+ 12,
1080
+ 14,
1081
+ 22,
1082
+ 1,
1083
+ 20,
1084
+ 4,
1085
+ 15,
1086
+ 12,
1087
+ 2,
1088
+ 22
1089
+ ],
1090
+ [
1091
+ 20,
1092
+ 7,
1093
+ 6,
1094
+ 12,
1095
+ 10,
1096
+ 15,
1097
+ 5,
1098
+ 18,
1099
+ 19,
1100
+ 20,
1101
+ 4,
1102
+ 2,
1103
+ 14,
1104
+ 2,
1105
+ 8,
1106
+ 18,
1107
+ 7,
1108
+ 2,
1109
+ 1,
1110
+ 15,
1111
+ 7,
1112
+ 2,
1113
+ 22,
1114
+ 2
1115
+ ],
1116
+ [
1117
+ 19,
1118
+ 5,
1119
+ 6,
1120
+ 3,
1121
+ 4,
1122
+ 3,
1123
+ 13,
1124
+ 9,
1125
+ 16,
1126
+ 3,
1127
+ 2,
1128
+ 2,
1129
+ 10,
1130
+ 25,
1131
+ 11,
1132
+ 23,
1133
+ 25,
1134
+ 19,
1135
+ 1,
1136
+ 17,
1137
+ 1,
1138
+ 11,
1139
+ 2,
1140
+ 13
1141
+ ],
1142
+ [
1143
+ 20,
1144
+ 11,
1145
+ 10,
1146
+ 1,
1147
+ 8,
1148
+ 3,
1149
+ 7,
1150
+ 24,
1151
+ 7,
1152
+ 12,
1153
+ 4,
1154
+ 3,
1155
+ 23,
1156
+ 18,
1157
+ 2,
1158
+ 10,
1159
+ 20,
1160
+ 20,
1161
+ 18,
1162
+ 23,
1163
+ 21,
1164
+ 16,
1165
+ 22,
1166
+ 12
1167
+ ],
1168
+ [
1169
+ 23,
1170
+ 6,
1171
+ 1,
1172
+ 16,
1173
+ 21,
1174
+ 6,
1175
+ 15,
1176
+ 7,
1177
+ 13,
1178
+ 22,
1179
+ 2,
1180
+ 22,
1181
+ 17,
1182
+ 15,
1183
+ 8,
1184
+ 21,
1185
+ 10,
1186
+ 16,
1187
+ 16,
1188
+ 21,
1189
+ 17,
1190
+ 18,
1191
+ 8,
1192
+ 7
1193
+ ],
1194
+ [
1195
+ 7,
1196
+ 19,
1197
+ 8,
1198
+ 25,
1199
+ 23,
1200
+ 20,
1201
+ 10,
1202
+ 20,
1203
+ 2,
1204
+ 24,
1205
+ 22,
1206
+ 12,
1207
+ 18,
1208
+ 2,
1209
+ 20,
1210
+ 2,
1211
+ 12,
1212
+ 2,
1213
+ 17,
1214
+ 25,
1215
+ 2,
1216
+ 16,
1217
+ 24,
1218
+ 13
1219
+ ],
1220
+ [
1221
+ 10,
1222
+ 6,
1223
+ 19,
1224
+ 11,
1225
+ 15,
1226
+ 24,
1227
+ 5,
1228
+ 9,
1229
+ 2,
1230
+ 22,
1231
+ 12,
1232
+ 21,
1233
+ 14,
1234
+ 5,
1235
+ 15,
1236
+ 25,
1237
+ 15,
1238
+ 20,
1239
+ 12,
1240
+ 25,
1241
+ 13,
1242
+ 9,
1243
+ 4,
1244
+ 23
1245
+ ],
1246
+ [
1247
+ 5,
1248
+ 7,
1249
+ 17,
1250
+ 22,
1251
+ 25,
1252
+ 19,
1253
+ 5,
1254
+ 13,
1255
+ 15,
1256
+ 25,
1257
+ 3,
1258
+ 25,
1259
+ 4,
1260
+ 7,
1261
+ 17,
1262
+ 13,
1263
+ 21,
1264
+ 21,
1265
+ 11,
1266
+ 23,
1267
+ 16,
1268
+ 24,
1269
+ 8,
1270
+ 14
1271
+ ]
1272
+ ],
1273
+ 49
1274
+ ],
1275
+ "output": false
1276
+ }
1277
+ ],
1278
+ "haskell_template": "areSimilar :: [[Int]] -> Int -> Bool\nareSimilar mat k ",
1279
+ "ocaml_template": "let areSimilar (mat: int list list) (k: int) : bool = ",
1280
+ "scala_template": "def areSimilar(mat: List[List[Int]],k: Int): Boolean = { \n \n}",
1281
+ "java_template": "class Solution {\n public boolean areSimilar(int[][] mat, int k) {\n \n }\n}",
1282
+ "python_template": "class Solution(object):\n def areSimilar(self, mat, k):\n \"\"\"\n :type mat: List[List[int]]\n :type k: int\n :rtype: bool\n \"\"\"\n "
1283
+ }
matrix_similarity_after_cyclic_shifts/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal false (areSimilar [[1;2;3];[4;5;6];[7;8;9]] 4)
12
+
13
+ let test2 _ = assert_equal true (areSimilar [[1;2;1;2];[5;5;5;5];[6;3;6;3]] 2)
14
+
15
+ let test3 _ = assert_equal true (areSimilar [[2;2];[2;2]] 3)
16
+
17
+ let test4 _ = assert_equal false (areSimilar [[6; 24; 22; 21; 22; 13; 23; 5; 25; 19; 1; 5; 10]; [2; 22; 6; 14; 8; 14; 5; 12; 24; 9; 19; 6; 9]; [16; 25; 21; 2; 3; 23; 3; 20; 8; 23; 14; 5; 21]; [16; 19; 21; 11; 5; 17; 23; 12; 1; 10; 1; 18; 16]; [11; 11; 7; 24; 15; 13; 12; 21; 15; 11; 10; 13; 3]; [6; 2; 20; 25; 5; 8; 7; 24; 13; 16; 23; 14; 13]; [11; 12; 10; 3; 18; 13; 8; 13; 24; 3; 6; 10; 5]; [4; 2; 18; 3; 23; 4; 24; 14; 7; 11; 13; 23; 1]; [19; 20; 22; 12; 12; 8; 13; 1; 18; 17; 10; 20; 12]; [17; 8; 18; 6; 1; 24; 19; 4; 12; 20; 25; 8; 13]; [2; 21; 7; 17; 15; 25; 6; 4; 12; 6; 11; 12; 13]; [23; 2; 15; 2; 3; 25; 6; 4; 18; 19; 18; 10; 15]; [10; 12; 17; 19; 9; 11; 23; 20; 11; 16; 24; 8; 18]; [7; 1; 5; 2; 10; 22; 8; 23; 16; 13; 19; 6; 9]; [7; 20; 12; 6; 13; 17; 10; 21; 20; 11; 21; 8; 15]; [7; 2; 5; 22; 10; 9; 24; 11; 23; 11; 17; 23; 16]; [22; 23; 20; 18; 11; 5; 20; 24; 5; 24; 15; 9; 8]] 30)
18
+
19
+ let test5 _ = assert_equal false (areSimilar [[1; 15; 17; 4; 14; 1; 3; 19; 20; 18; 16; 19; 8; 2]; [11; 13; 14; 24; 12; 19; 25; 15; 16; 12; 12; 15; 1; 22]; [24; 5; 23; 25; 17; 19; 2; 1; 14; 20; 11; 6; 16; 16]; [1; 14; 21; 11; 20; 3; 19; 7; 11; 1; 2; 1; 21; 24]; [11; 15; 7; 19; 22; 19; 5; 14; 12; 19; 12; 11; 12; 1]; [23; 24; 18; 2; 4; 17; 22; 16; 12; 24; 20; 11; 23; 16]; [8; 8; 22; 10; 4; 10; 7; 22; 21; 6; 21; 9; 23; 21]; [15; 8; 22; 18; 13; 24; 3; 11; 23; 2; 19; 14; 17; 11]] 11)
20
+
21
+ let test6 _ = assert_equal false (areSimilar [[1; 14; 3; 11; 7; 16; 2; 22; 21; 23; 6]; [21; 22; 11; 10; 16; 1; 23; 11; 7; 11; 20]; [14; 3; 25; 16; 13; 23; 14; 21; 2; 12; 14]; [2; 3; 18; 25; 21; 5; 15; 19; 4; 10; 22]; [23; 16; 25; 19; 6; 10; 13; 12; 7; 20; 3]; [13; 21; 17; 5; 11; 8; 22; 10; 5; 18; 14]; [18; 2; 12; 24; 12; 11; 4; 7; 24; 18; 2]; [25; 14; 20; 14; 4; 20; 25; 17; 7; 24; 15]; [16; 24; 11; 13; 23; 2; 18; 13; 11; 20; 22]; [13; 24; 21; 15; 1; 6; 2; 12; 11; 23; 20]; [5; 19; 4; 5; 6; 4; 1; 9; 6; 25; 15]; [4; 24; 11; 14; 17; 3; 3; 4; 24; 14; 15]; [15; 13; 23; 25; 24; 22; 4; 3; 11; 1; 10]; [11; 3; 7; 12; 7; 22; 8; 17; 19; 5; 21]; [13; 7; 14; 2; 23; 1; 3; 13; 3; 15; 21]; [22; 13; 23; 12; 16; 11; 17; 14; 6; 19; 3]; [18; 12; 12; 23; 13; 1; 16; 2; 13; 10; 3]; [2; 9; 12; 18; 23; 24; 19; 14; 1; 1; 21]; [1; 2; 17; 22; 14; 14; 21; 19; 1; 21; 16]; [14; 23; 12; 13; 20; 16; 1; 5; 13; 25; 2]] 3)
22
+
23
+ let test7 _ = assert_equal false (areSimilar [[5; 19; 18; 7; 3; 23; 2]; [24; 17; 24; 19; 3; 24; 1]; [12; 11; 22; 22; 5; 24; 17]; [7; 12; 1; 16; 2; 16; 21]; [17; 8; 15; 22; 24; 8; 16]; [2; 13; 14; 14; 9; 12; 22]; [16; 18; 24; 19; 18; 2; 19]; [3; 6; 12; 3; 1; 1; 3]; [4; 2; 13; 3; 14; 4; 17]; [16; 3; 1; 25; 10; 6; 21]] 25)
24
+
25
+ let test8 _ = assert_equal false (areSimilar [[21; 5; 16; 21; 9; 11; 5; 22; 17; 2; 23; 15; 9; 13; 14; 8; 12; 21; 7; 22; 13; 18; 1]; [13; 11; 3; 7; 20; 16; 13; 10; 24; 23; 15; 17; 21; 24; 19; 22; 2; 3; 25; 3; 21; 24; 23]; [16; 10; 1; 5; 22; 6; 18; 5; 22; 12; 10; 18; 16; 12; 3; 9; 7; 11; 15; 8; 10; 8; 12]; [3; 11; 13; 16; 9; 3; 12; 3; 20; 2; 11; 13; 17; 10; 13; 1; 2; 1; 14; 17; 23; 15; 22]; [19; 24; 17; 6; 3; 5; 2; 11; 13; 9; 24; 19; 23; 13; 20; 13; 1; 15; 17; 10; 25; 25; 3]; [6; 10; 22; 15; 17; 5; 13; 7; 1; 13; 21; 3; 24; 24; 9; 1; 10; 5; 8; 2; 18; 16; 21]] 11)
26
+
27
+ let test9 _ = assert_equal false (areSimilar [[12; 3; 5; 13; 16; 20; 16; 3; 11; 5; 11; 19; 20; 17; 21; 6; 14; 8; 14; 7; 20; 17; 25; 18]] 28)
28
+
29
+ let test10 _ = assert_equal false (areSimilar [[21; 2; 2; 25; 9; 22; 6; 2; 8; 7; 25; 19; 7; 2; 7; 6; 16; 12; 1; 12; 22; 8; 24; 6]; [3; 2; 10; 3; 20; 13; 13; 16; 11; 23; 9; 24; 16; 13; 5; 20; 21; 11; 13; 24; 20; 18; 20; 15]; [23; 15; 17; 16; 9; 1; 10; 9; 12; 2; 8; 24; 21; 6; 19; 20; 9; 24; 3; 17; 18; 1; 17; 9]; [13; 21; 6; 9; 22; 2; 19; 24; 10; 17; 15; 10; 3; 20; 12; 14; 22; 1; 20; 4; 15; 12; 2; 22]; [20; 7; 6; 12; 10; 15; 5; 18; 19; 20; 4; 2; 14; 2; 8; 18; 7; 2; 1; 15; 7; 2; 22; 2]; [19; 5; 6; 3; 4; 3; 13; 9; 16; 3; 2; 2; 10; 25; 11; 23; 25; 19; 1; 17; 1; 11; 2; 13]; [20; 11; 10; 1; 8; 3; 7; 24; 7; 12; 4; 3; 23; 18; 2; 10; 20; 20; 18; 23; 21; 16; 22; 12]; [23; 6; 1; 16; 21; 6; 15; 7; 13; 22; 2; 22; 17; 15; 8; 21; 10; 16; 16; 21; 17; 18; 8; 7]; [7; 19; 8; 25; 23; 20; 10; 20; 2; 24; 22; 12; 18; 2; 20; 2; 12; 2; 17; 25; 2; 16; 24; 13]; [10; 6; 19; 11; 15; 24; 5; 9; 2; 22; 12; 21; 14; 5; 15; 25; 15; 20; 12; 25; 13; 9; 4; 23]; [5; 7; 17; 22; 25; 19; 5; 13; 15; 25; 3; 25; 4; 7; 17; 13; 21; 21; 11; 23; 16; 24; 8; 14]] 49)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for areSimilar" >::: [
34
+
35
+ "test1" >:: test1;
36
+ "test2" >:: test2;
37
+ "test3" >:: test3;
38
+ "test4" >:: test4;
39
+ "test5" >:: test5;
40
+ "test6" >:: test6;
41
+ "test7" >:: test7;
42
+ "test8" >:: test8;
43
+ "test9" >:: test9;
44
+ "test10" >:: test10;
45
+ ]
46
+
47
+
48
+ (* Running the tests *)
49
+ let () = run_test_tt_main suite
50
+ end
matrix_similarity_after_cyclic_shifts/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.areSimilar(List(List(1,2,3),List(4,5,6),List(7,8,9)),4), false)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.areSimilar(List(List(1,2,1,2),List(5,5,5,5),List(6,3,6,3)),2), true)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.areSimilar(List(List(2,2),List(2,2)),3), true)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.areSimilar(List(List(6, 24, 22, 21, 22, 13, 23, 5, 25, 19, 1, 5, 10), List(2, 22, 6, 14, 8, 14, 5, 12, 24, 9, 19, 6, 9), List(16, 25, 21, 2, 3, 23, 3, 20, 8, 23, 14, 5, 21), List(16, 19, 21, 11, 5, 17, 23, 12, 1, 10, 1, 18, 16), List(11, 11, 7, 24, 15, 13, 12, 21, 15, 11, 10, 13, 3), List(6, 2, 20, 25, 5, 8, 7, 24, 13, 16, 23, 14, 13), List(11, 12, 10, 3, 18, 13, 8, 13, 24, 3, 6, 10, 5), List(4, 2, 18, 3, 23, 4, 24, 14, 7, 11, 13, 23, 1), List(19, 20, 22, 12, 12, 8, 13, 1, 18, 17, 10, 20, 12), List(17, 8, 18, 6, 1, 24, 19, 4, 12, 20, 25, 8, 13), List(2, 21, 7, 17, 15, 25, 6, 4, 12, 6, 11, 12, 13), List(23, 2, 15, 2, 3, 25, 6, 4, 18, 19, 18, 10, 15), List(10, 12, 17, 19, 9, 11, 23, 20, 11, 16, 24, 8, 18), List(7, 1, 5, 2, 10, 22, 8, 23, 16, 13, 19, 6, 9), List(7, 20, 12, 6, 13, 17, 10, 21, 20, 11, 21, 8, 15), List(7, 2, 5, 22, 10, 9, 24, 11, 23, 11, 17, 23, 16), List(22, 23, 20, 18, 11, 5, 20, 24, 5, 24, 15, 9, 8)),30), false)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.areSimilar(List(List(1, 15, 17, 4, 14, 1, 3, 19, 20, 18, 16, 19, 8, 2), List(11, 13, 14, 24, 12, 19, 25, 15, 16, 12, 12, 15, 1, 22), List(24, 5, 23, 25, 17, 19, 2, 1, 14, 20, 11, 6, 16, 16), List(1, 14, 21, 11, 20, 3, 19, 7, 11, 1, 2, 1, 21, 24), List(11, 15, 7, 19, 22, 19, 5, 14, 12, 19, 12, 11, 12, 1), List(23, 24, 18, 2, 4, 17, 22, 16, 12, 24, 20, 11, 23, 16), List(8, 8, 22, 10, 4, 10, 7, 22, 21, 6, 21, 9, 23, 21), List(15, 8, 22, 18, 13, 24, 3, 11, 23, 2, 19, 14, 17, 11)),11), false)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.areSimilar(List(List(1, 14, 3, 11, 7, 16, 2, 22, 21, 23, 6), List(21, 22, 11, 10, 16, 1, 23, 11, 7, 11, 20), List(14, 3, 25, 16, 13, 23, 14, 21, 2, 12, 14), List(2, 3, 18, 25, 21, 5, 15, 19, 4, 10, 22), List(23, 16, 25, 19, 6, 10, 13, 12, 7, 20, 3), List(13, 21, 17, 5, 11, 8, 22, 10, 5, 18, 14), List(18, 2, 12, 24, 12, 11, 4, 7, 24, 18, 2), List(25, 14, 20, 14, 4, 20, 25, 17, 7, 24, 15), List(16, 24, 11, 13, 23, 2, 18, 13, 11, 20, 22), List(13, 24, 21, 15, 1, 6, 2, 12, 11, 23, 20), List(5, 19, 4, 5, 6, 4, 1, 9, 6, 25, 15), List(4, 24, 11, 14, 17, 3, 3, 4, 24, 14, 15), List(15, 13, 23, 25, 24, 22, 4, 3, 11, 1, 10), List(11, 3, 7, 12, 7, 22, 8, 17, 19, 5, 21), List(13, 7, 14, 2, 23, 1, 3, 13, 3, 15, 21), List(22, 13, 23, 12, 16, 11, 17, 14, 6, 19, 3), List(18, 12, 12, 23, 13, 1, 16, 2, 13, 10, 3), List(2, 9, 12, 18, 23, 24, 19, 14, 1, 1, 21), List(1, 2, 17, 22, 14, 14, 21, 19, 1, 21, 16), List(14, 23, 12, 13, 20, 16, 1, 5, 13, 25, 2)),3), false)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.areSimilar(List(List(5, 19, 18, 7, 3, 23, 2), List(24, 17, 24, 19, 3, 24, 1), List(12, 11, 22, 22, 5, 24, 17), List(7, 12, 1, 16, 2, 16, 21), List(17, 8, 15, 22, 24, 8, 16), List(2, 13, 14, 14, 9, 12, 22), List(16, 18, 24, 19, 18, 2, 19), List(3, 6, 12, 3, 1, 1, 3), List(4, 2, 13, 3, 14, 4, 17), List(16, 3, 1, 25, 10, 6, 21)),25), false)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.areSimilar(List(List(21, 5, 16, 21, 9, 11, 5, 22, 17, 2, 23, 15, 9, 13, 14, 8, 12, 21, 7, 22, 13, 18, 1), List(13, 11, 3, 7, 20, 16, 13, 10, 24, 23, 15, 17, 21, 24, 19, 22, 2, 3, 25, 3, 21, 24, 23), List(16, 10, 1, 5, 22, 6, 18, 5, 22, 12, 10, 18, 16, 12, 3, 9, 7, 11, 15, 8, 10, 8, 12), List(3, 11, 13, 16, 9, 3, 12, 3, 20, 2, 11, 13, 17, 10, 13, 1, 2, 1, 14, 17, 23, 15, 22), List(19, 24, 17, 6, 3, 5, 2, 11, 13, 9, 24, 19, 23, 13, 20, 13, 1, 15, 17, 10, 25, 25, 3), List(6, 10, 22, 15, 17, 5, 13, 7, 1, 13, 21, 3, 24, 24, 9, 1, 10, 5, 8, 2, 18, 16, 21)),11), false)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.areSimilar(List(List(12, 3, 5, 13, 16, 20, 16, 3, 11, 5, 11, 19, 20, 17, 21, 6, 14, 8, 14, 7, 20, 17, 25, 18)),28), false)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.areSimilar(List(List(21, 2, 2, 25, 9, 22, 6, 2, 8, 7, 25, 19, 7, 2, 7, 6, 16, 12, 1, 12, 22, 8, 24, 6), List(3, 2, 10, 3, 20, 13, 13, 16, 11, 23, 9, 24, 16, 13, 5, 20, 21, 11, 13, 24, 20, 18, 20, 15), List(23, 15, 17, 16, 9, 1, 10, 9, 12, 2, 8, 24, 21, 6, 19, 20, 9, 24, 3, 17, 18, 1, 17, 9), List(13, 21, 6, 9, 22, 2, 19, 24, 10, 17, 15, 10, 3, 20, 12, 14, 22, 1, 20, 4, 15, 12, 2, 22), List(20, 7, 6, 12, 10, 15, 5, 18, 19, 20, 4, 2, 14, 2, 8, 18, 7, 2, 1, 15, 7, 2, 22, 2), List(19, 5, 6, 3, 4, 3, 13, 9, 16, 3, 2, 2, 10, 25, 11, 23, 25, 19, 1, 17, 1, 11, 2, 13), List(20, 11, 10, 1, 8, 3, 7, 24, 7, 12, 4, 3, 23, 18, 2, 10, 20, 20, 18, 23, 21, 16, 22, 12), List(23, 6, 1, 16, 21, 6, 15, 7, 13, 22, 2, 22, 17, 15, 8, 21, 10, 16, 16, 21, 17, 18, 8, 7), List(7, 19, 8, 25, 23, 20, 10, 20, 2, 24, 22, 12, 18, 2, 20, 2, 12, 2, 17, 25, 2, 16, 24, 13), List(10, 6, 19, 11, 15, 24, 5, 9, 2, 22, 12, 21, 14, 5, 15, 25, 15, 20, 12, 25, 13, 9, 4, 23), List(5, 7, 17, 22, 25, 19, 5, 13, 15, 25, 3, 25, 4, 7, 17, 13, 21, 21, 11, 23, 16, 24, 8, 14)),49), false)
42
+ }
43
+
44
+ }
max_pair_sum_in_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
max_pair_sum_in_an_array/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 (maxSum [112,131,411])," (-1) (maxSum [112,131,411]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maxSum [2536,1613,3366,162])," 5902 (maxSum [2536,1613,3366,162]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (maxSum [51,71,17,24,42])," 88 (maxSum [51,71,17,24,42]))
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
max_pair_sum_in_an_array/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(-1, maxSum(new ArrayList<>(Arrays.asList(112,131,411))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(5902, maxSum(new ArrayList<>(Arrays.asList(2536,1613,3366,162))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(88, maxSum(new ArrayList<>(Arrays.asList(51,71,17,24,42))));
23
+ }
24
+
25
+ }
max_pair_sum_in_an_array/meta.json ADDED
@@ -0,0 +1,598 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2902,
3
+ "name": "max_pair_sum_in_an_array",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/max-pair-sum-in-an-array/",
6
+ "date": "1691280000000",
7
+ "task_description": "You are given an integer array `nums`. You have to find the **maximum** sum of a pair of numbers from `nums` such that the **largest digit **in both numbers is equal. For example, 2373 is made up of three distinct digits: 2, 3, and 7, where 7 is the largest among them. Return the **maximum** sum or -1 if no such pair exists. **Example 1:** **Input:** nums = [112,131,411] **Output:** -1 **Explanation:** Each numbers largest digit in order is [2,3,4]. **Example 2:** **Input:** nums = [2536,1613,3366,162] **Output:** 5902 **Explanation:** All the numbers have 6 as their largest digit, so the answer is 2536 + 3366 = 5902. **Example 3:** **Input:** nums = [51,71,17,24,42] **Output:** 88 **Explanation:** Each number's largest digit in order is [5,7,7,4,4]. So we have only two possible pairs, 71 + 17 = 88 and 24 + 42 = 66. **Constraints:** `2 <= nums.length <= 100` `1 <= nums[i] <= 104`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [112,131,411]",
12
+ "output": "-1 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [2536,1613,3366,162]",
17
+ "output": "5902 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [51,71,17,24,42]",
22
+ "output": "88 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 5922,
29
+ 5663,
30
+ 6159,
31
+ 9462,
32
+ 4816,
33
+ 4367,
34
+ 6722,
35
+ 7009,
36
+ 772,
37
+ 6853,
38
+ 973,
39
+ 451,
40
+ 2758,
41
+ 7628,
42
+ 7299,
43
+ 7926,
44
+ 6867,
45
+ 6226,
46
+ 43,
47
+ 9667,
48
+ 4856,
49
+ 9411,
50
+ 6437,
51
+ 4421,
52
+ 8975,
53
+ 8424,
54
+ 6831,
55
+ 9115,
56
+ 7796,
57
+ 7183,
58
+ 1295,
59
+ 5184,
60
+ 5277,
61
+ 4578,
62
+ 5683,
63
+ 4688,
64
+ 9703,
65
+ 1870,
66
+ 6290,
67
+ 1215,
68
+ 7113,
69
+ 6067,
70
+ 2970,
71
+ 9535,
72
+ 1678,
73
+ 7707,
74
+ 1082,
75
+ 6279,
76
+ 6614,
77
+ 9058,
78
+ 1842,
79
+ 4746,
80
+ 6609,
81
+ 625,
82
+ 1375,
83
+ 4458,
84
+ 9839,
85
+ 7354,
86
+ 4922,
87
+ 5971,
88
+ 5296,
89
+ 4246,
90
+ 6069,
91
+ 374,
92
+ 153,
93
+ 1820,
94
+ 8044,
95
+ 4552,
96
+ 3442,
97
+ 8024,
98
+ 4949,
99
+ 934,
100
+ 5724,
101
+ 924,
102
+ 9792,
103
+ 8392,
104
+ 1811,
105
+ 5595,
106
+ 9383,
107
+ 9572,
108
+ 4111,
109
+ 839,
110
+ 9542,
111
+ 8510
112
+ ],
113
+ "output": 19631
114
+ },
115
+ {
116
+ "input": [
117
+ 9114,
118
+ 840,
119
+ 5229,
120
+ 7107,
121
+ 6001,
122
+ 9192,
123
+ 1334,
124
+ 3717,
125
+ 7873,
126
+ 4232,
127
+ 9669,
128
+ 8733,
129
+ 6403,
130
+ 2530,
131
+ 6532,
132
+ 2024,
133
+ 4364,
134
+ 3430,
135
+ 67,
136
+ 6085,
137
+ 8013,
138
+ 6350,
139
+ 6006,
140
+ 4914,
141
+ 9017,
142
+ 1393,
143
+ 3866
144
+ ],
145
+ "output": 18861
146
+ },
147
+ {
148
+ "input": [
149
+ 9177,
150
+ 4017,
151
+ 4954,
152
+ 1018,
153
+ 6193,
154
+ 1472,
155
+ 9034
156
+ ],
157
+ "output": 18211
158
+ },
159
+ {
160
+ "input": [
161
+ 7250,
162
+ 5385,
163
+ 1996,
164
+ 2445,
165
+ 5016,
166
+ 7462,
167
+ 5275,
168
+ 7121,
169
+ 9855,
170
+ 7304,
171
+ 8384,
172
+ 1024,
173
+ 3554,
174
+ 8000,
175
+ 7756,
176
+ 4599,
177
+ 3020,
178
+ 1470,
179
+ 3725,
180
+ 8653,
181
+ 8100,
182
+ 2177,
183
+ 2384,
184
+ 2502,
185
+ 7273,
186
+ 347,
187
+ 4273,
188
+ 8292,
189
+ 6256,
190
+ 4541,
191
+ 877,
192
+ 4004,
193
+ 3883,
194
+ 4731,
195
+ 6211,
196
+ 7809,
197
+ 6145,
198
+ 9253,
199
+ 133,
200
+ 1730,
201
+ 3932,
202
+ 3214,
203
+ 4041,
204
+ 8038,
205
+ 41,
206
+ 4585,
207
+ 8236,
208
+ 217,
209
+ 5327,
210
+ 8681,
211
+ 939,
212
+ 817,
213
+ 1996,
214
+ 9615,
215
+ 1020,
216
+ 146,
217
+ 3331,
218
+ 9846,
219
+ 2019
220
+ ],
221
+ "output": 19701
222
+ },
223
+ {
224
+ "input": [
225
+ 7514,
226
+ 5023,
227
+ 8849,
228
+ 1247,
229
+ 3102,
230
+ 2105,
231
+ 9012,
232
+ 9775,
233
+ 7202,
234
+ 6872,
235
+ 9304,
236
+ 4713,
237
+ 5262,
238
+ 2409,
239
+ 4259,
240
+ 791,
241
+ 6027,
242
+ 8258,
243
+ 6165,
244
+ 495,
245
+ 8585,
246
+ 8168,
247
+ 3518,
248
+ 4588,
249
+ 9057,
250
+ 3766,
251
+ 8419,
252
+ 64,
253
+ 5217,
254
+ 8812,
255
+ 3609,
256
+ 8897,
257
+ 4748,
258
+ 3557,
259
+ 4479,
260
+ 6376,
261
+ 7708,
262
+ 9973,
263
+ 355,
264
+ 5570,
265
+ 4403,
266
+ 2784,
267
+ 988,
268
+ 2298,
269
+ 3839
270
+ ],
271
+ "output": 19748
272
+ },
273
+ {
274
+ "input": [
275
+ 6092,
276
+ 4067,
277
+ 6376,
278
+ 8630,
279
+ 590,
280
+ 9703,
281
+ 1858,
282
+ 5504,
283
+ 7849,
284
+ 4678,
285
+ 8480,
286
+ 47,
287
+ 3660,
288
+ 7643,
289
+ 5610,
290
+ 197,
291
+ 6634,
292
+ 4442,
293
+ 6055,
294
+ 3818,
295
+ 841,
296
+ 3228,
297
+ 670,
298
+ 7199,
299
+ 723,
300
+ 7477,
301
+ 2716,
302
+ 6359,
303
+ 2626,
304
+ 7255,
305
+ 6897,
306
+ 6894,
307
+ 9076,
308
+ 5040,
309
+ 4411,
310
+ 7876,
311
+ 2184,
312
+ 6187,
313
+ 1465,
314
+ 3339,
315
+ 9260,
316
+ 8974,
317
+ 1630,
318
+ 9812,
319
+ 4157,
320
+ 7046,
321
+ 579,
322
+ 3271,
323
+ 2677,
324
+ 5840,
325
+ 1527,
326
+ 2535,
327
+ 2454,
328
+ 9339,
329
+ 9036,
330
+ 4916,
331
+ 579,
332
+ 5454,
333
+ 8484
334
+ ],
335
+ "output": 19515
336
+ },
337
+ {
338
+ "input": [
339
+ 4050,
340
+ 1912,
341
+ 3099,
342
+ 3954,
343
+ 9380,
344
+ 5038,
345
+ 5730,
346
+ 2456,
347
+ 4940,
348
+ 2560,
349
+ 9247,
350
+ 4781,
351
+ 2800,
352
+ 3059,
353
+ 9151,
354
+ 6838,
355
+ 3860,
356
+ 869,
357
+ 1432,
358
+ 6785,
359
+ 4786,
360
+ 8309,
361
+ 93,
362
+ 9462,
363
+ 4989,
364
+ 6688,
365
+ 3648,
366
+ 4098,
367
+ 3679,
368
+ 9879,
369
+ 2370,
370
+ 6114,
371
+ 2555,
372
+ 9483,
373
+ 982,
374
+ 3015,
375
+ 9046,
376
+ 1164,
377
+ 3292,
378
+ 1874,
379
+ 234,
380
+ 8766,
381
+ 1925,
382
+ 4045,
383
+ 7917,
384
+ 5649,
385
+ 4028,
386
+ 5120
387
+ ],
388
+ "output": 19362
389
+ },
390
+ {
391
+ "input": [
392
+ 7237,
393
+ 8049,
394
+ 5557,
395
+ 6022,
396
+ 7302,
397
+ 9613,
398
+ 330,
399
+ 6978,
400
+ 8884,
401
+ 780,
402
+ 7592,
403
+ 8840,
404
+ 7175,
405
+ 2447,
406
+ 1758,
407
+ 6579,
408
+ 4498,
409
+ 9113,
410
+ 3745,
411
+ 1119,
412
+ 8836,
413
+ 6613,
414
+ 4889,
415
+ 7478,
416
+ 1630,
417
+ 4774,
418
+ 301,
419
+ 702,
420
+ 6146,
421
+ 7012,
422
+ 5021,
423
+ 4378,
424
+ 5419,
425
+ 3585,
426
+ 3979,
427
+ 8548,
428
+ 3391,
429
+ 6742,
430
+ 3289,
431
+ 4361,
432
+ 5625,
433
+ 3876,
434
+ 2033,
435
+ 2597,
436
+ 8224,
437
+ 3587,
438
+ 3683,
439
+ 4788,
440
+ 1213,
441
+ 9007,
442
+ 7547,
443
+ 3800,
444
+ 8684,
445
+ 8630,
446
+ 4388,
447
+ 242,
448
+ 5438
449
+ ],
450
+ "output": 18726
451
+ },
452
+ {
453
+ "input": [
454
+ 6353,
455
+ 7488,
456
+ 1738,
457
+ 6770,
458
+ 3605,
459
+ 9297,
460
+ 8795,
461
+ 17,
462
+ 9816,
463
+ 2835,
464
+ 3751,
465
+ 9903,
466
+ 5757,
467
+ 8895,
468
+ 4543,
469
+ 5049,
470
+ 5343,
471
+ 1408,
472
+ 8463,
473
+ 9163,
474
+ 7340,
475
+ 6501,
476
+ 5935,
477
+ 7212,
478
+ 6504,
479
+ 2050,
480
+ 5906,
481
+ 2267,
482
+ 5090,
483
+ 9962,
484
+ 1665,
485
+ 3495,
486
+ 849,
487
+ 9404,
488
+ 7479,
489
+ 8618,
490
+ 5634,
491
+ 6491,
492
+ 4179,
493
+ 7126,
494
+ 9132,
495
+ 2762,
496
+ 8315,
497
+ 2979,
498
+ 1645,
499
+ 7987,
500
+ 9629
501
+ ],
502
+ "output": 19865
503
+ },
504
+ {
505
+ "input": [
506
+ 9502,
507
+ 895,
508
+ 9107,
509
+ 47,
510
+ 9994,
511
+ 1896,
512
+ 5076,
513
+ 6437,
514
+ 125,
515
+ 5657,
516
+ 8564,
517
+ 5680,
518
+ 7331,
519
+ 5345,
520
+ 5205,
521
+ 5695,
522
+ 7872,
523
+ 3403,
524
+ 5772,
525
+ 909,
526
+ 49,
527
+ 265,
528
+ 2633,
529
+ 7649,
530
+ 2581,
531
+ 3216,
532
+ 1563,
533
+ 7681,
534
+ 4407,
535
+ 6365,
536
+ 1145,
537
+ 6246,
538
+ 1286,
539
+ 709,
540
+ 3550,
541
+ 5777,
542
+ 4075,
543
+ 8917,
544
+ 6350,
545
+ 4968,
546
+ 2860,
547
+ 2964,
548
+ 1241,
549
+ 2753,
550
+ 7497,
551
+ 1786,
552
+ 2992,
553
+ 335,
554
+ 8817,
555
+ 5136,
556
+ 3475,
557
+ 5071,
558
+ 8433,
559
+ 5349,
560
+ 2242,
561
+ 2328,
562
+ 3691,
563
+ 6293,
564
+ 3350,
565
+ 1638,
566
+ 677,
567
+ 9361,
568
+ 4816,
569
+ 4644,
570
+ 6861,
571
+ 7581,
572
+ 9103,
573
+ 2752,
574
+ 9994,
575
+ 1855,
576
+ 2571,
577
+ 4089,
578
+ 4924,
579
+ 6930,
580
+ 9354,
581
+ 5013,
582
+ 9307,
583
+ 8432,
584
+ 4799,
585
+ 5551,
586
+ 3167,
587
+ 5039,
588
+ 5095
589
+ ],
590
+ "output": 19988
591
+ }
592
+ ],
593
+ "haskell_template": "maxSum :: [Int] -> Int\nmaxSum nums ",
594
+ "ocaml_template": "let maxSum (nums: int list) : int = ",
595
+ "scala_template": "def maxSum(nums: List[Int]): Int = { \n \n}",
596
+ "java_template": "public static int maxSum(List<Integer> nums) {\n\n}",
597
+ "python_template": "class Solution(object):\n def maxSum(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
598
+ }
max_pair_sum_in_an_array/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 (-1) (maxSum [112;131;411])
12
+
13
+ let test2 _ = assert_equal 5902 (maxSum [2536;1613;3366;162])
14
+
15
+ let test3 _ = assert_equal 88 (maxSum [51;71;17;24;42])
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for maxSum" >::: [
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
max_pair_sum_in_an_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maxSum(List(112,131,411)), -1)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maxSum(List(2536,1613,3366,162)), 5902)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maxSum(List(51,71,17,24,42)), 88)
14
+ }
15
+
16
+ }
max_sum_of_a_pair_with_equal_sum_of_digits/.DS_Store ADDED
Binary file (6.15 kB). View file
 
max_sum_of_a_pair_with_equal_sum_of_digits/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 (maximumSum [18,43,36,13,7])," 54 (maximumSum [18,43,36,13,7]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximumSum [10,12,19,14])," (-1) (maximumSum [10,12,19,14]))
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
max_sum_of_a_pair_with_equal_sum_of_digits/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(54, maximumSum(new ArrayList<>(Arrays.asList(18,43,36,13,7))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, maximumSum(new ArrayList<>(Arrays.asList(10,12,19,14))));
19
+ }
20
+
21
+ }
max_sum_of_a_pair_with_equal_sum_of_digits/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52e93d04e8d646ecfb3f6195f07b528fe39cbd037de16659d92d2bf21a798cf5
3
+ size 12127390
max_sum_of_a_pair_with_equal_sum_of_digits/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 54 (maximumSum [18;43;36;13;7])
12
+
13
+ let test2 _ = assert_equal (-1) (maximumSum [10;12;19;14])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maximumSum" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
max_sum_of_a_pair_with_equal_sum_of_digits/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximumSum(List(18,43,36,13,7)), 54)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximumSum(List(10,12,19,14)), -1)
10
+ }
11
+
12
+ }
maximal_score_after_applying_k_operations/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximal_score_after_applying_k_operations/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 (maxKelements [10,10,10,10,10] 5)," 50 (maxKelements [10,10,10,10,10] 5))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maxKelements [1,10,3,3,3] 3)," 17 (maxKelements [1,10,3,3,3] 3))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
maximal_score_after_applying_k_operations/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(50, maxKelements(new ArrayList<>(Arrays.asList(10,10,10,10,10)), 5));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(17, maxKelements(new ArrayList<>(Arrays.asList(1,10,3,3,3)), 3));
19
+ }
20
+
21
+ }
maximal_score_after_applying_k_operations/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d82f3ba32de6e3fd42406b4657ffd00da2ffe52e090d2bf43699d369edd3286
3
+ size 20201237
maximal_score_after_applying_k_operations/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 50 (maxKelements [10;10;10;10;10] 5)
12
+
13
+ let test2 _ = assert_equal 17 (maxKelements [1;10;3;3;3] 3)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maxKelements" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
maximal_score_after_applying_k_operations/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maxKelements(List(10,10,10,10,10),5), 50)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maxKelements(List(1,10,3,3,3),3), 17)
10
+ }
11
+
12
+ }
maximize_amount_after_two_days_of_conversions/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(720.00000, maxAmount("EUR", new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("EUR","USD")),new ArrayList<>(Arrays.asList("USD","JPY")))), new ArrayList<>(Arrays.asList(2.0,3.0)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("JPY","USD")),new ArrayList<>(Arrays.asList("USD","CHF")),new ArrayList<>(Arrays.asList("CHF","EUR")))), new ArrayList<>(Arrays.asList(4.0,5.0,6.0))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1.50000, maxAmount("NGN", new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("NGN","EUR")))) , rates1 = new ArrayList<>(Arrays.asList(9.0)) , pairs2 = new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("NGN","EUR")))) , rates2 = new ArrayList<>(Arrays.asList(6.0)), new ArrayList<>(Arrays.asList(9.0)) , pairs2 = new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("NGN","EUR")))) , rates2 = new ArrayList<>(Arrays.asList(6.0)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("NGN","EUR")))) , rates2 = new ArrayList<>(Arrays.asList(6.0)), new ArrayList<>(Arrays.asList(6.0))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(1.00000, maxAmount("USD", new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("USD","EUR")))), new ArrayList<>(Arrays.asList(1.0)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList("EUR","JPY")))), new ArrayList<>(Arrays.asList(10.0))));
23
+ }
24
+
25
+ }
maximize_area_of_square_hole_in_grid/haskell_tests/Main.hs ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (maximizeSquareHoleArea 2 1 [2,3] [2])," 4 (maximizeSquareHoleArea 2 1 [2,3] [2]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximizeSquareHoleArea 1 1 [2] [2])," 4 (maximizeSquareHoleArea 1 1 [2] [2]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (maximizeSquareHoleArea 2 3 [2,3] [2,4])," 4 (maximizeSquareHoleArea 2 3 [2,3] [2,4]))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (maximizeSquareHoleArea 824467728 221817438 [56096705, 57870720, 69469937, 111791310, 129788017, 224924663, 244126653, 373088654, 478648892, 479737344, 484027317, 577078428, 613845263, 623404704, 652011224, 693982805, 726122581, 757518028, 774930667, 788601394] [2188056, 45814255, 51635174, 95034604, 121130097, 126531814, 179968387, 186279251, 193100682, 204173076])," 4 (maximizeSquareHoleArea 824467728 221817438 [56096705, 57870720, 69469937, 111791310, 129788017, 224924663, 244126653, 373088654, 478648892, 479737344, 484027317, 577078428, 613845263, 623404704, 652011224, 693982805, 726122581, 757518028, 774930667, 788601394] [2188056, 45814255, 51635174, 95034604, 121130097, 126531814, 179968387, 186279251, 193100682, 204173076]))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (maximizeSquareHoleArea 648154527 195491926 [6430521, 7662717, 14849099, 26729809, 34176525, 41416403, 43987631, 48927292, 59693806, 62867826, 63453627, 64973441, 73601229, 79276448, 84680728, 85005753, 89143319, 104246247, 112714767, 122033194, 134082507, 138491454, 150121923, 153922492, 177333276, 182168611, 186177986, 187117991, 193176285, 213168822, 217262633, 247009037, 252072557, 277050717, 277682614, 279480841, 295854348, 297703110, 302050964, 307032990, 308251895, 318537633, 329614972, 333618784, 334944731, 357626935, 360357188, 364551661, 400905292, 425738119, 427251943, 427438495, 430124900, 437443272, 452394867, 454476726, 456980047, 496329465, 503394056, 504896085, 508835065, 515695951, 522010615, 545056106, 550060412, 557832075, 566679909, 572459454, 579926387, 583147436, 585416538, 598188067, 600334621, 605754453, 619694351, 622515687, 625846917, 626010943, 638107878] [2321378, 4728768, 11190795, 22081869, 25588634, 25895890, 26934109, 27020593, 28711634, 36829047, 37341986, 43605991, 52537708, 54499808, 55275646, 55565717, 60970108, 66532120, 67215985, 67255256, 82268913, 86949955, 94715373, 100371042, 106605467, 108763282, 113409434, 127318992, 131467381, 134614906, 135710242, 137155445, 146012774, 151819645, 156567230, 158046183, 165292480, 174238526, 174665425, 182107718, 187191249, 190269183, 191586393, 195268811])," 4 (maximizeSquareHoleArea 648154527 195491926 [6430521, 7662717, 14849099, 26729809, 34176525, 41416403, 43987631, 48927292, 59693806, 62867826, 63453627, 64973441, 73601229, 79276448, 84680728, 85005753, 89143319, 104246247, 112714767, 122033194, 134082507, 138491454, 150121923, 153922492, 177333276, 182168611, 186177986, 187117991, 193176285, 213168822, 217262633, 247009037, 252072557, 277050717, 277682614, 279480841, 295854348, 297703110, 302050964, 307032990, 308251895, 318537633, 329614972, 333618784, 334944731, 357626935, 360357188, 364551661, 400905292, 425738119, 427251943, 427438495, 430124900, 437443272, 452394867, 454476726, 456980047, 496329465, 503394056, 504896085, 508835065, 515695951, 522010615, 545056106, 550060412, 557832075, 566679909, 572459454, 579926387, 583147436, 585416538, 598188067, 600334621, 605754453, 619694351, 622515687, 625846917, 626010943, 638107878] [2321378, 4728768, 11190795, 22081869, 25588634, 25895890, 26934109, 27020593, 28711634, 36829047, 37341986, 43605991, 52537708, 54499808, 55275646, 55565717, 60970108, 66532120, 67215985, 67255256, 82268913, 86949955, 94715373, 100371042, 106605467, 108763282, 113409434, 127318992, 131467381, 134614906, 135710242, 137155445, 146012774, 151819645, 156567230, 158046183, 165292480, 174238526, 174665425, 182107718, 187191249, 190269183, 191586393, 195268811]))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (maximizeSquareHoleArea 359468690 454270785 [9255764, 24817170, 25231024, 27200073, 28502084, 30110803, 47545895, 47617085, 48087899, 54345546, 64571339, 64984123, 65051604, 71733376, 72494846, 72763165, 82645381, 84167603, 94685994, 103297900, 104328402, 105153943, 111823293, 113998979, 118529352, 126747199, 128521183, 135973339, 158755954, 159571144, 162096085, 163884034, 167403114, 167720107, 176964725, 189841821, 189996188, 198243950, 204907082, 210715397, 221047178, 223805726, 228824290, 234893651, 238188320, 243455459, 264846760, 268016355, 270518804, 281466902, 284021975, 286681657, 300789237, 315737786, 316266985, 316842811, 318929493, 324730998, 325541997, 326134223, 326219219, 330067048, 347680557, 348107549, 356791227] [1105420, 4044057, 8630912, 22127180, 25837680, 27701285, 27946376, 29169029, 43992204, 52302911, 57516458, 61643051, 64182307, 65151218, 66550856, 67273320, 67615834, 69269946, 75192723, 78541115, 82610966, 89362508, 95678065, 102859077, 115137604, 123368976, 124273371, 137877339, 139897548, 154130398, 162158098, 163605277, 165377492, 165768141, 166601071, 167177757, 170582125, 174631670, 182126841, 182611780, 184009291, 185748646, 191138260, 195662206, 221814748, 225792188, 227159530, 228525447, 230702381, 234957023, 242658998, 252730009, 255561334, 266549076, 281555005, 282974308, 283708726, 292738584, 296253221, 296452284, 297245463, 299062426, 302607262, 303773409, 305780559, 306911066, 311599333, 312863707, 322409664, 322904148, 326480333, 328466490, 333910294, 336128668, 339246192, 339623380, 341166057, 342449389, 350741848, 351345909, 356277864, 360840019, 369213988, 374040779, 375613431, 385253070, 400932178, 410063788, 410124851, 412709754, 412948402, 419490314, 425943348, 425957843, 427922342, 450474869, 451981789])," 4 (maximizeSquareHoleArea 359468690 454270785 [9255764, 24817170, 25231024, 27200073, 28502084, 30110803, 47545895, 47617085, 48087899, 54345546, 64571339, 64984123, 65051604, 71733376, 72494846, 72763165, 82645381, 84167603, 94685994, 103297900, 104328402, 105153943, 111823293, 113998979, 118529352, 126747199, 128521183, 135973339, 158755954, 159571144, 162096085, 163884034, 167403114, 167720107, 176964725, 189841821, 189996188, 198243950, 204907082, 210715397, 221047178, 223805726, 228824290, 234893651, 238188320, 243455459, 264846760, 268016355, 270518804, 281466902, 284021975, 286681657, 300789237, 315737786, 316266985, 316842811, 318929493, 324730998, 325541997, 326134223, 326219219, 330067048, 347680557, 348107549, 356791227] [1105420, 4044057, 8630912, 22127180, 25837680, 27701285, 27946376, 29169029, 43992204, 52302911, 57516458, 61643051, 64182307, 65151218, 66550856, 67273320, 67615834, 69269946, 75192723, 78541115, 82610966, 89362508, 95678065, 102859077, 115137604, 123368976, 124273371, 137877339, 139897548, 154130398, 162158098, 163605277, 165377492, 165768141, 166601071, 167177757, 170582125, 174631670, 182126841, 182611780, 184009291, 185748646, 191138260, 195662206, 221814748, 225792188, 227159530, 228525447, 230702381, 234957023, 242658998, 252730009, 255561334, 266549076, 281555005, 282974308, 283708726, 292738584, 296253221, 296452284, 297245463, 299062426, 302607262, 303773409, 305780559, 306911066, 311599333, 312863707, 322409664, 322904148, 326480333, 328466490, 333910294, 336128668, 339246192, 339623380, 341166057, 342449389, 350741848, 351345909, 356277864, 360840019, 369213988, 374040779, 375613431, 385253070, 400932178, 410063788, 410124851, 412709754, 412948402, 419490314, 425943348, 425957843, 427922342, 450474869, 451981789]))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (maximizeSquareHoleArea 513845407 404729930 [9498806, 24352148, 26405388, 27651898, 29120890, 35580523, 35935007, 40101019, 41878929, 43875275, 47492182, 48765489, 49947516, 57203412, 70691276, 84689459, 93044660, 93240277, 116478336, 117804161, 121374583, 126526290, 127250131, 128954259, 140270029, 144382281, 151411099, 162023831, 169333919, 176901198, 177477309, 178153918, 200329379, 219309632, 222215304, 237300715, 238051959, 239700914, 244909518, 245695307, 256516573, 264532508, 274540881, 275257189, 275409284, 296767318, 299294449, 310014321, 310311984, 328990919, 332181119, 334885781, 336122402, 336540450, 343272953, 347359863, 357763119, 360735233, 361829604, 363988889, 364297422, 370095593, 372431502, 379878259, 395231596, 397228371, 432486147, 439270075, 451931045, 457121274, 461011188, 462758866, 471790725, 488482448, 502796998] [7671344, 42918529, 51213337, 53077756, 68507963, 79720886, 88498372, 94878359, 94989617, 96947040, 104440141, 120481914, 129237944, 129263763, 132196848, 132855888, 138269318, 140843085, 142137325, 144215133, 146746379, 149060324, 149754883, 153353075, 175860592, 185487225, 185623139, 188465466, 192858754, 193099577, 224300323, 226031151, 229378231, 229492038, 237501591, 245632691, 256378619, 263450073, 273647763, 280845842, 297022618, 298382686, 299668390, 307900589, 308020315, 334951794, 339915399, 351620655, 356959767, 366914867, 386510686, 386724344, 388224650, 390589082, 392646173, 394447827])," 4 (maximizeSquareHoleArea 513845407 404729930 [9498806, 24352148, 26405388, 27651898, 29120890, 35580523, 35935007, 40101019, 41878929, 43875275, 47492182, 48765489, 49947516, 57203412, 70691276, 84689459, 93044660, 93240277, 116478336, 117804161, 121374583, 126526290, 127250131, 128954259, 140270029, 144382281, 151411099, 162023831, 169333919, 176901198, 177477309, 178153918, 200329379, 219309632, 222215304, 237300715, 238051959, 239700914, 244909518, 245695307, 256516573, 264532508, 274540881, 275257189, 275409284, 296767318, 299294449, 310014321, 310311984, 328990919, 332181119, 334885781, 336122402, 336540450, 343272953, 347359863, 357763119, 360735233, 361829604, 363988889, 364297422, 370095593, 372431502, 379878259, 395231596, 397228371, 432486147, 439270075, 451931045, 457121274, 461011188, 462758866, 471790725, 488482448, 502796998] [7671344, 42918529, 51213337, 53077756, 68507963, 79720886, 88498372, 94878359, 94989617, 96947040, 104440141, 120481914, 129237944, 129263763, 132196848, 132855888, 138269318, 140843085, 142137325, 144215133, 146746379, 149060324, 149754883, 153353075, 175860592, 185487225, 185623139, 188465466, 192858754, 193099577, 224300323, 226031151, 229378231, 229492038, 237501591, 245632691, 256378619, 263450073, 273647763, 280845842, 297022618, 298382686, 299668390, 307900589, 308020315, 334951794, 339915399, 351620655, 356959767, 366914867, 386510686, 386724344, 388224650, 390589082, 392646173, 394447827]))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (maximizeSquareHoleArea 540203719 864386158 [18159674, 54458115, 62778378, 105777903, 131818737, 194080940, 244038247, 262050056, 286206787, 337137656, 367602942, 423073030, 448920818, 497900945, 501590248] [35697500, 40873154, 55587178, 70212840, 83049615, 104605908, 117210403, 142204973, 164821392, 170338629, 178466862, 225008410, 249713156, 274641087, 367085254, 437026354, 443960721, 469543004, 484630123, 495488252, 550562101, 568598551, 582853569, 606216360, 631280423, 660866337, 664702679, 665739751, 673375438, 689103748, 706193654, 709677611, 718350801, 735649368, 738289218, 788099121, 816988546, 855161537])," 4 (maximizeSquareHoleArea 540203719 864386158 [18159674, 54458115, 62778378, 105777903, 131818737, 194080940, 244038247, 262050056, 286206787, 337137656, 367602942, 423073030, 448920818, 497900945, 501590248] [35697500, 40873154, 55587178, 70212840, 83049615, 104605908, 117210403, 142204973, 164821392, 170338629, 178466862, 225008410, 249713156, 274641087, 367085254, 437026354, 443960721, 469543004, 484630123, 495488252, 550562101, 568598551, 582853569, 606216360, 631280423, 660866337, 664702679, 665739751, 673375438, 689103748, 706193654, 709677611, 718350801, 735649368, 738289218, 788099121, 816988546, 855161537]))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (maximizeSquareHoleArea 306351915 170728625 [5247734, 6079061, 9237115, 10210344, 18735942, 18801043, 31704472, 34374350, 37786580, 41329920, 52952414, 57841187, 59142238, 62765260, 69131402, 70371442, 70968505, 80531876, 80618403, 81987540, 83198640, 83451609, 86899465, 90117298, 94888971, 95000438, 108057111, 127535258, 128667837, 138755740, 142209698, 143701434, 147781485, 151796694, 153181137, 154457854, 154515138, 154578684, 157238033, 158110818, 158240020, 161801225, 162627294, 164088970, 164878347, 165278789, 169186408, 190248161, 192440465, 204436985, 207904201, 209956636, 211796619, 214406669, 219811640, 219975623, 220408551, 220653169, 220679563, 226638124, 228225203, 231397055, 233246494, 238298802, 239433853, 241737251, 241889954, 243026394, 243570863, 254465607, 254953716, 259241983, 260615116, 267478250, 267590678, 272683721, 274618475, 276297393, 279494171, 280297886, 287172606, 288190298, 292236599, 292902931, 300414435, 303413932, 304593687] [20269528, 26663327, 48521999, 124096886])," 4 (maximizeSquareHoleArea 306351915 170728625 [5247734, 6079061, 9237115, 10210344, 18735942, 18801043, 31704472, 34374350, 37786580, 41329920, 52952414, 57841187, 59142238, 62765260, 69131402, 70371442, 70968505, 80531876, 80618403, 81987540, 83198640, 83451609, 86899465, 90117298, 94888971, 95000438, 108057111, 127535258, 128667837, 138755740, 142209698, 143701434, 147781485, 151796694, 153181137, 154457854, 154515138, 154578684, 157238033, 158110818, 158240020, 161801225, 162627294, 164088970, 164878347, 165278789, 169186408, 190248161, 192440465, 204436985, 207904201, 209956636, 211796619, 214406669, 219811640, 219975623, 220408551, 220653169, 220679563, 226638124, 228225203, 231397055, 233246494, 238298802, 239433853, 241737251, 241889954, 243026394, 243570863, 254465607, 254953716, 259241983, 260615116, 267478250, 267590678, 272683721, 274618475, 276297393, 279494171, 280297886, 287172606, 288190298, 292236599, 292902931, 300414435, 303413932, 304593687] [20269528, 26663327, 48521999, 124096886]))
37
+
38
+
39
+ -- Grouping test cases
40
+ tests :: Test
41
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
maximize_area_of_square_hole_in_grid/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(4, maximizeSquareHoleArea(2, 1, new ArrayList<>(Arrays.asList(2,3)), new ArrayList<>(Arrays.asList(2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, maximizeSquareHoleArea(1, 1, new ArrayList<>(Arrays.asList(2)), new ArrayList<>(Arrays.asList(2))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(4, maximizeSquareHoleArea(2, 3, new ArrayList<>(Arrays.asList(2,3)), new ArrayList<>(Arrays.asList(2,4))));
23
+ }
24
+
25
+ }
maximize_area_of_square_hole_in_grid/meta.json ADDED
@@ -0,0 +1,819 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3214,
3
+ "name": "maximize_area_of_square_hole_in_grid",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/maximize-area-of-square-hole-in-grid/",
6
+ "date": "2023-11-11 00:00:00",
7
+ "task_description": "You are given the two integers, `n` and `m` and two integer arrays, `hBars` and `vBars`. The grid has `n + 2` horizontal and `m + 2` vertical bars, creating 1 x 1 unit cells. The bars are indexed starting from `1`. You can **remove** some of the bars in `hBars` from horizontal bars and some of the bars in `vBars` from vertical bars. Note that other bars are fixed and cannot be removed. Return an integer denoting the **maximum area** of a _square-shaped_ hole in the grid, after removing some bars (possibly none). **Example 1:** **Input: **n = 2, m = 1, hBars = [2,3], vBars = [2] **Output: **4 **Explanation:** The left image shows the initial grid formed by the bars. The horizontal bars are `[1,2,3,4]`, and the vertical bars are `[1,2,3]`. One way to get the maximum square-shaped hole is by removing horizontal bar 2 and vertical bar 2. **Example 2:** **Input: **n = 1, m = 1, hBars = [2], vBars = [2] **Output: **4 **Explanation:** To get the maximum square-shaped hole, we remove horizontal bar 2 and vertical bar 2. **Example 3:** **Input: **n = 2, m = 3, hBars = [2,3], vBars = [2,4] **Output: **4 **Explanation:** One way to get the maximum square-shaped hole is by removing horizontal bar 3, and vertical bar 4. **Constraints:** `1 <= n <= 109` `1 <= m <= 109` `1 <= hBars.length <= 100` `2 <= hBars[i] <= n + 1` `1 <= vBars.length <= 100` `2 <= vBars[i] <= m + 1` All values in `hBars` are distinct. All values in `vBars` are distinct.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "n = 2, m = 1, hBars = [2,3], vBars = [2]",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "n = 1, m = 1, hBars = [2], vBars = [2]",
17
+ "output": "4 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "n = 2, m = 3, hBars = [2,3], vBars = [2,4]",
22
+ "output": "4 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 824467728,
29
+ 221817438,
30
+ [
31
+ 56096705,
32
+ 57870720,
33
+ 69469937,
34
+ 111791310,
35
+ 129788017,
36
+ 224924663,
37
+ 244126653,
38
+ 373088654,
39
+ 478648892,
40
+ 479737344,
41
+ 484027317,
42
+ 577078428,
43
+ 613845263,
44
+ 623404704,
45
+ 652011224,
46
+ 693982805,
47
+ 726122581,
48
+ 757518028,
49
+ 774930667,
50
+ 788601394
51
+ ],
52
+ [
53
+ 2188056,
54
+ 45814255,
55
+ 51635174,
56
+ 95034604,
57
+ 121130097,
58
+ 126531814,
59
+ 179968387,
60
+ 186279251,
61
+ 193100682,
62
+ 204173076
63
+ ]
64
+ ],
65
+ "output": 4
66
+ },
67
+ {
68
+ "input": [
69
+ 648154527,
70
+ 195491926,
71
+ [
72
+ 6430521,
73
+ 7662717,
74
+ 14849099,
75
+ 26729809,
76
+ 34176525,
77
+ 41416403,
78
+ 43987631,
79
+ 48927292,
80
+ 59693806,
81
+ 62867826,
82
+ 63453627,
83
+ 64973441,
84
+ 73601229,
85
+ 79276448,
86
+ 84680728,
87
+ 85005753,
88
+ 89143319,
89
+ 104246247,
90
+ 112714767,
91
+ 122033194,
92
+ 134082507,
93
+ 138491454,
94
+ 150121923,
95
+ 153922492,
96
+ 177333276,
97
+ 182168611,
98
+ 186177986,
99
+ 187117991,
100
+ 193176285,
101
+ 213168822,
102
+ 217262633,
103
+ 247009037,
104
+ 252072557,
105
+ 277050717,
106
+ 277682614,
107
+ 279480841,
108
+ 295854348,
109
+ 297703110,
110
+ 302050964,
111
+ 307032990,
112
+ 308251895,
113
+ 318537633,
114
+ 329614972,
115
+ 333618784,
116
+ 334944731,
117
+ 357626935,
118
+ 360357188,
119
+ 364551661,
120
+ 400905292,
121
+ 425738119,
122
+ 427251943,
123
+ 427438495,
124
+ 430124900,
125
+ 437443272,
126
+ 452394867,
127
+ 454476726,
128
+ 456980047,
129
+ 496329465,
130
+ 503394056,
131
+ 504896085,
132
+ 508835065,
133
+ 515695951,
134
+ 522010615,
135
+ 545056106,
136
+ 550060412,
137
+ 557832075,
138
+ 566679909,
139
+ 572459454,
140
+ 579926387,
141
+ 583147436,
142
+ 585416538,
143
+ 598188067,
144
+ 600334621,
145
+ 605754453,
146
+ 619694351,
147
+ 622515687,
148
+ 625846917,
149
+ 626010943,
150
+ 638107878
151
+ ],
152
+ [
153
+ 2321378,
154
+ 4728768,
155
+ 11190795,
156
+ 22081869,
157
+ 25588634,
158
+ 25895890,
159
+ 26934109,
160
+ 27020593,
161
+ 28711634,
162
+ 36829047,
163
+ 37341986,
164
+ 43605991,
165
+ 52537708,
166
+ 54499808,
167
+ 55275646,
168
+ 55565717,
169
+ 60970108,
170
+ 66532120,
171
+ 67215985,
172
+ 67255256,
173
+ 82268913,
174
+ 86949955,
175
+ 94715373,
176
+ 100371042,
177
+ 106605467,
178
+ 108763282,
179
+ 113409434,
180
+ 127318992,
181
+ 131467381,
182
+ 134614906,
183
+ 135710242,
184
+ 137155445,
185
+ 146012774,
186
+ 151819645,
187
+ 156567230,
188
+ 158046183,
189
+ 165292480,
190
+ 174238526,
191
+ 174665425,
192
+ 182107718,
193
+ 187191249,
194
+ 190269183,
195
+ 191586393,
196
+ 195268811
197
+ ]
198
+ ],
199
+ "output": 4
200
+ },
201
+ {
202
+ "input": [
203
+ 359468690,
204
+ 454270785,
205
+ [
206
+ 9255764,
207
+ 24817170,
208
+ 25231024,
209
+ 27200073,
210
+ 28502084,
211
+ 30110803,
212
+ 47545895,
213
+ 47617085,
214
+ 48087899,
215
+ 54345546,
216
+ 64571339,
217
+ 64984123,
218
+ 65051604,
219
+ 71733376,
220
+ 72494846,
221
+ 72763165,
222
+ 82645381,
223
+ 84167603,
224
+ 94685994,
225
+ 103297900,
226
+ 104328402,
227
+ 105153943,
228
+ 111823293,
229
+ 113998979,
230
+ 118529352,
231
+ 126747199,
232
+ 128521183,
233
+ 135973339,
234
+ 158755954,
235
+ 159571144,
236
+ 162096085,
237
+ 163884034,
238
+ 167403114,
239
+ 167720107,
240
+ 176964725,
241
+ 189841821,
242
+ 189996188,
243
+ 198243950,
244
+ 204907082,
245
+ 210715397,
246
+ 221047178,
247
+ 223805726,
248
+ 228824290,
249
+ 234893651,
250
+ 238188320,
251
+ 243455459,
252
+ 264846760,
253
+ 268016355,
254
+ 270518804,
255
+ 281466902,
256
+ 284021975,
257
+ 286681657,
258
+ 300789237,
259
+ 315737786,
260
+ 316266985,
261
+ 316842811,
262
+ 318929493,
263
+ 324730998,
264
+ 325541997,
265
+ 326134223,
266
+ 326219219,
267
+ 330067048,
268
+ 347680557,
269
+ 348107549,
270
+ 356791227
271
+ ],
272
+ [
273
+ 1105420,
274
+ 4044057,
275
+ 8630912,
276
+ 22127180,
277
+ 25837680,
278
+ 27701285,
279
+ 27946376,
280
+ 29169029,
281
+ 43992204,
282
+ 52302911,
283
+ 57516458,
284
+ 61643051,
285
+ 64182307,
286
+ 65151218,
287
+ 66550856,
288
+ 67273320,
289
+ 67615834,
290
+ 69269946,
291
+ 75192723,
292
+ 78541115,
293
+ 82610966,
294
+ 89362508,
295
+ 95678065,
296
+ 102859077,
297
+ 115137604,
298
+ 123368976,
299
+ 124273371,
300
+ 137877339,
301
+ 139897548,
302
+ 154130398,
303
+ 162158098,
304
+ 163605277,
305
+ 165377492,
306
+ 165768141,
307
+ 166601071,
308
+ 167177757,
309
+ 170582125,
310
+ 174631670,
311
+ 182126841,
312
+ 182611780,
313
+ 184009291,
314
+ 185748646,
315
+ 191138260,
316
+ 195662206,
317
+ 221814748,
318
+ 225792188,
319
+ 227159530,
320
+ 228525447,
321
+ 230702381,
322
+ 234957023,
323
+ 242658998,
324
+ 252730009,
325
+ 255561334,
326
+ 266549076,
327
+ 281555005,
328
+ 282974308,
329
+ 283708726,
330
+ 292738584,
331
+ 296253221,
332
+ 296452284,
333
+ 297245463,
334
+ 299062426,
335
+ 302607262,
336
+ 303773409,
337
+ 305780559,
338
+ 306911066,
339
+ 311599333,
340
+ 312863707,
341
+ 322409664,
342
+ 322904148,
343
+ 326480333,
344
+ 328466490,
345
+ 333910294,
346
+ 336128668,
347
+ 339246192,
348
+ 339623380,
349
+ 341166057,
350
+ 342449389,
351
+ 350741848,
352
+ 351345909,
353
+ 356277864,
354
+ 360840019,
355
+ 369213988,
356
+ 374040779,
357
+ 375613431,
358
+ 385253070,
359
+ 400932178,
360
+ 410063788,
361
+ 410124851,
362
+ 412709754,
363
+ 412948402,
364
+ 419490314,
365
+ 425943348,
366
+ 425957843,
367
+ 427922342,
368
+ 450474869,
369
+ 451981789
370
+ ]
371
+ ],
372
+ "output": 4
373
+ },
374
+ {
375
+ "input": [
376
+ 513845407,
377
+ 404729930,
378
+ [
379
+ 9498806,
380
+ 24352148,
381
+ 26405388,
382
+ 27651898,
383
+ 29120890,
384
+ 35580523,
385
+ 35935007,
386
+ 40101019,
387
+ 41878929,
388
+ 43875275,
389
+ 47492182,
390
+ 48765489,
391
+ 49947516,
392
+ 57203412,
393
+ 70691276,
394
+ 84689459,
395
+ 93044660,
396
+ 93240277,
397
+ 116478336,
398
+ 117804161,
399
+ 121374583,
400
+ 126526290,
401
+ 127250131,
402
+ 128954259,
403
+ 140270029,
404
+ 144382281,
405
+ 151411099,
406
+ 162023831,
407
+ 169333919,
408
+ 176901198,
409
+ 177477309,
410
+ 178153918,
411
+ 200329379,
412
+ 219309632,
413
+ 222215304,
414
+ 237300715,
415
+ 238051959,
416
+ 239700914,
417
+ 244909518,
418
+ 245695307,
419
+ 256516573,
420
+ 264532508,
421
+ 274540881,
422
+ 275257189,
423
+ 275409284,
424
+ 296767318,
425
+ 299294449,
426
+ 310014321,
427
+ 310311984,
428
+ 328990919,
429
+ 332181119,
430
+ 334885781,
431
+ 336122402,
432
+ 336540450,
433
+ 343272953,
434
+ 347359863,
435
+ 357763119,
436
+ 360735233,
437
+ 361829604,
438
+ 363988889,
439
+ 364297422,
440
+ 370095593,
441
+ 372431502,
442
+ 379878259,
443
+ 395231596,
444
+ 397228371,
445
+ 432486147,
446
+ 439270075,
447
+ 451931045,
448
+ 457121274,
449
+ 461011188,
450
+ 462758866,
451
+ 471790725,
452
+ 488482448,
453
+ 502796998
454
+ ],
455
+ [
456
+ 7671344,
457
+ 42918529,
458
+ 51213337,
459
+ 53077756,
460
+ 68507963,
461
+ 79720886,
462
+ 88498372,
463
+ 94878359,
464
+ 94989617,
465
+ 96947040,
466
+ 104440141,
467
+ 120481914,
468
+ 129237944,
469
+ 129263763,
470
+ 132196848,
471
+ 132855888,
472
+ 138269318,
473
+ 140843085,
474
+ 142137325,
475
+ 144215133,
476
+ 146746379,
477
+ 149060324,
478
+ 149754883,
479
+ 153353075,
480
+ 175860592,
481
+ 185487225,
482
+ 185623139,
483
+ 188465466,
484
+ 192858754,
485
+ 193099577,
486
+ 224300323,
487
+ 226031151,
488
+ 229378231,
489
+ 229492038,
490
+ 237501591,
491
+ 245632691,
492
+ 256378619,
493
+ 263450073,
494
+ 273647763,
495
+ 280845842,
496
+ 297022618,
497
+ 298382686,
498
+ 299668390,
499
+ 307900589,
500
+ 308020315,
501
+ 334951794,
502
+ 339915399,
503
+ 351620655,
504
+ 356959767,
505
+ 366914867,
506
+ 386510686,
507
+ 386724344,
508
+ 388224650,
509
+ 390589082,
510
+ 392646173,
511
+ 394447827
512
+ ]
513
+ ],
514
+ "output": 4
515
+ },
516
+ {
517
+ "input": [
518
+ 540203719,
519
+ 864386158,
520
+ [
521
+ 18159674,
522
+ 54458115,
523
+ 62778378,
524
+ 105777903,
525
+ 131818737,
526
+ 194080940,
527
+ 244038247,
528
+ 262050056,
529
+ 286206787,
530
+ 337137656,
531
+ 367602942,
532
+ 423073030,
533
+ 448920818,
534
+ 497900945,
535
+ 501590248
536
+ ],
537
+ [
538
+ 35697500,
539
+ 40873154,
540
+ 55587178,
541
+ 70212840,
542
+ 83049615,
543
+ 104605908,
544
+ 117210403,
545
+ 142204973,
546
+ 164821392,
547
+ 170338629,
548
+ 178466862,
549
+ 225008410,
550
+ 249713156,
551
+ 274641087,
552
+ 367085254,
553
+ 437026354,
554
+ 443960721,
555
+ 469543004,
556
+ 484630123,
557
+ 495488252,
558
+ 550562101,
559
+ 568598551,
560
+ 582853569,
561
+ 606216360,
562
+ 631280423,
563
+ 660866337,
564
+ 664702679,
565
+ 665739751,
566
+ 673375438,
567
+ 689103748,
568
+ 706193654,
569
+ 709677611,
570
+ 718350801,
571
+ 735649368,
572
+ 738289218,
573
+ 788099121,
574
+ 816988546,
575
+ 855161537
576
+ ]
577
+ ],
578
+ "output": 4
579
+ },
580
+ {
581
+ "input": [
582
+ 306351915,
583
+ 170728625,
584
+ [
585
+ 5247734,
586
+ 6079061,
587
+ 9237115,
588
+ 10210344,
589
+ 18735942,
590
+ 18801043,
591
+ 31704472,
592
+ 34374350,
593
+ 37786580,
594
+ 41329920,
595
+ 52952414,
596
+ 57841187,
597
+ 59142238,
598
+ 62765260,
599
+ 69131402,
600
+ 70371442,
601
+ 70968505,
602
+ 80531876,
603
+ 80618403,
604
+ 81987540,
605
+ 83198640,
606
+ 83451609,
607
+ 86899465,
608
+ 90117298,
609
+ 94888971,
610
+ 95000438,
611
+ 108057111,
612
+ 127535258,
613
+ 128667837,
614
+ 138755740,
615
+ 142209698,
616
+ 143701434,
617
+ 147781485,
618
+ 151796694,
619
+ 153181137,
620
+ 154457854,
621
+ 154515138,
622
+ 154578684,
623
+ 157238033,
624
+ 158110818,
625
+ 158240020,
626
+ 161801225,
627
+ 162627294,
628
+ 164088970,
629
+ 164878347,
630
+ 165278789,
631
+ 169186408,
632
+ 190248161,
633
+ 192440465,
634
+ 204436985,
635
+ 207904201,
636
+ 209956636,
637
+ 211796619,
638
+ 214406669,
639
+ 219811640,
640
+ 219975623,
641
+ 220408551,
642
+ 220653169,
643
+ 220679563,
644
+ 226638124,
645
+ 228225203,
646
+ 231397055,
647
+ 233246494,
648
+ 238298802,
649
+ 239433853,
650
+ 241737251,
651
+ 241889954,
652
+ 243026394,
653
+ 243570863,
654
+ 254465607,
655
+ 254953716,
656
+ 259241983,
657
+ 260615116,
658
+ 267478250,
659
+ 267590678,
660
+ 272683721,
661
+ 274618475,
662
+ 276297393,
663
+ 279494171,
664
+ 280297886,
665
+ 287172606,
666
+ 288190298,
667
+ 292236599,
668
+ 292902931,
669
+ 300414435,
670
+ 303413932,
671
+ 304593687
672
+ ],
673
+ [
674
+ 20269528,
675
+ 26663327,
676
+ 48521999,
677
+ 124096886
678
+ ]
679
+ ],
680
+ "output": 4
681
+ },
682
+ {
683
+ "input": [
684
+ 805192008,
685
+ 165109117,
686
+ [
687
+ 20057484,
688
+ 28290147,
689
+ 32933723,
690
+ 34305321,
691
+ 50789706,
692
+ 50823443,
693
+ 68848320,
694
+ 92688044,
695
+ 106621839,
696
+ 116486269,
697
+ 118588482,
698
+ 124114394,
699
+ 130816098,
700
+ 132593082,
701
+ 154465792,
702
+ 167306766,
703
+ 182772969,
704
+ 185170570,
705
+ 198382016,
706
+ 199918217,
707
+ 225996706,
708
+ 228188108,
709
+ 233647455,
710
+ 247694290,
711
+ 258887511,
712
+ 275141064,
713
+ 275306640,
714
+ 283077890,
715
+ 284743921,
716
+ 306083375,
717
+ 308850285,
718
+ 313735400,
719
+ 323006815,
720
+ 324297852,
721
+ 325945505,
722
+ 326842761,
723
+ 331277253,
724
+ 336994732,
725
+ 350039008,
726
+ 355339911,
727
+ 369811096,
728
+ 377052576,
729
+ 385885146,
730
+ 392166100,
731
+ 398773942,
732
+ 399753059,
733
+ 401964979,
734
+ 405977146,
735
+ 410165865,
736
+ 414040233,
737
+ 415174842,
738
+ 429289798,
739
+ 444277839,
740
+ 448558613,
741
+ 457343914,
742
+ 463599676,
743
+ 466799017,
744
+ 473488531,
745
+ 479421481,
746
+ 483636956,
747
+ 501550619,
748
+ 507514260,
749
+ 521386312,
750
+ 522587724,
751
+ 526211576,
752
+ 534206604,
753
+ 551723393,
754
+ 556415670,
755
+ 558270328,
756
+ 577844992,
757
+ 578054043,
758
+ 580847724,
759
+ 585076921,
760
+ 593002912,
761
+ 612516677,
762
+ 623590745,
763
+ 631589721,
764
+ 647124371,
765
+ 662553525,
766
+ 664079167,
767
+ 681662487,
768
+ 682773978,
769
+ 683716203,
770
+ 688162739,
771
+ 694216445,
772
+ 699086583,
773
+ 701412509,
774
+ 722219403,
775
+ 746154582,
776
+ 765304876,
777
+ 776851631,
778
+ 785660967,
779
+ 794734581,
780
+ 803863116
781
+ ],
782
+ [
783
+ 2946789,
784
+ 5627036,
785
+ 7965376,
786
+ 8996838,
787
+ 15424016,
788
+ 26854011,
789
+ 33278201,
790
+ 42502586,
791
+ 47895262,
792
+ 63629772,
793
+ 78012281,
794
+ 81896630,
795
+ 87118991,
796
+ 91043692,
797
+ 96773289,
798
+ 102053048,
799
+ 103649158,
800
+ 105033297,
801
+ 117665219,
802
+ 130616843,
803
+ 135109615,
804
+ 137494076,
805
+ 144742924,
806
+ 151984224,
807
+ 154296782,
808
+ 158086599
809
+ ]
810
+ ],
811
+ "output": 4
812
+ }
813
+ ],
814
+ "haskell_template": "maximizeSquareHoleArea :: Int -> Int -> [Int] -> [Int] -> Int\nmaximizeSquareHoleArea n m hBars vBars ",
815
+ "ocaml_template": "let maximizeSquareHoleArea (n: int) (m: int) (hBars: int list) (vBars: int list) : int = ",
816
+ "scala_template": "def maximizeSquareHoleArea(n: Int,m: Int,hBars: List[Int],vBars: List[Int]): Int = { \n \n}",
817
+ "java_template": "class Solution {\n public int maximizeSquareHoleArea(int n, int m, int[] hBars, int[] vBars) {\n \n }\n}",
818
+ "python_template": "class Solution(object):\n def maximizeSquareHoleArea(self, n, m, hBars, vBars):\n \"\"\"\n :type n: int\n :type m: int\n :type hBars: List[int]\n :type vBars: List[int]\n :rtype: int\n \"\"\"\n "
819
+ }
maximize_area_of_square_hole_in_grid/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 4 (maximizeSquareHoleArea 2 1 [2;3] [2])
12
+
13
+ let test2 _ = assert_equal 4 (maximizeSquareHoleArea 1 1 [2] [2])
14
+
15
+ let test3 _ = assert_equal 4 (maximizeSquareHoleArea 2 3 [2;3] [2;4])
16
+
17
+ let test4 _ = assert_equal 4 (maximizeSquareHoleArea 824467728 221817438 [56096705; 57870720; 69469937; 111791310; 129788017; 224924663; 244126653; 373088654; 478648892; 479737344; 484027317; 577078428; 613845263; 623404704; 652011224; 693982805; 726122581; 757518028; 774930667; 788601394] [2188056; 45814255; 51635174; 95034604; 121130097; 126531814; 179968387; 186279251; 193100682; 204173076])
18
+
19
+ let test5 _ = assert_equal 4 (maximizeSquareHoleArea 648154527 195491926 [6430521; 7662717; 14849099; 26729809; 34176525; 41416403; 43987631; 48927292; 59693806; 62867826; 63453627; 64973441; 73601229; 79276448; 84680728; 85005753; 89143319; 104246247; 112714767; 122033194; 134082507; 138491454; 150121923; 153922492; 177333276; 182168611; 186177986; 187117991; 193176285; 213168822; 217262633; 247009037; 252072557; 277050717; 277682614; 279480841; 295854348; 297703110; 302050964; 307032990; 308251895; 318537633; 329614972; 333618784; 334944731; 357626935; 360357188; 364551661; 400905292; 425738119; 427251943; 427438495; 430124900; 437443272; 452394867; 454476726; 456980047; 496329465; 503394056; 504896085; 508835065; 515695951; 522010615; 545056106; 550060412; 557832075; 566679909; 572459454; 579926387; 583147436; 585416538; 598188067; 600334621; 605754453; 619694351; 622515687; 625846917; 626010943; 638107878] [2321378; 4728768; 11190795; 22081869; 25588634; 25895890; 26934109; 27020593; 28711634; 36829047; 37341986; 43605991; 52537708; 54499808; 55275646; 55565717; 60970108; 66532120; 67215985; 67255256; 82268913; 86949955; 94715373; 100371042; 106605467; 108763282; 113409434; 127318992; 131467381; 134614906; 135710242; 137155445; 146012774; 151819645; 156567230; 158046183; 165292480; 174238526; 174665425; 182107718; 187191249; 190269183; 191586393; 195268811])
20
+
21
+ let test6 _ = assert_equal 4 (maximizeSquareHoleArea 359468690 454270785 [9255764; 24817170; 25231024; 27200073; 28502084; 30110803; 47545895; 47617085; 48087899; 54345546; 64571339; 64984123; 65051604; 71733376; 72494846; 72763165; 82645381; 84167603; 94685994; 103297900; 104328402; 105153943; 111823293; 113998979; 118529352; 126747199; 128521183; 135973339; 158755954; 159571144; 162096085; 163884034; 167403114; 167720107; 176964725; 189841821; 189996188; 198243950; 204907082; 210715397; 221047178; 223805726; 228824290; 234893651; 238188320; 243455459; 264846760; 268016355; 270518804; 281466902; 284021975; 286681657; 300789237; 315737786; 316266985; 316842811; 318929493; 324730998; 325541997; 326134223; 326219219; 330067048; 347680557; 348107549; 356791227] [1105420; 4044057; 8630912; 22127180; 25837680; 27701285; 27946376; 29169029; 43992204; 52302911; 57516458; 61643051; 64182307; 65151218; 66550856; 67273320; 67615834; 69269946; 75192723; 78541115; 82610966; 89362508; 95678065; 102859077; 115137604; 123368976; 124273371; 137877339; 139897548; 154130398; 162158098; 163605277; 165377492; 165768141; 166601071; 167177757; 170582125; 174631670; 182126841; 182611780; 184009291; 185748646; 191138260; 195662206; 221814748; 225792188; 227159530; 228525447; 230702381; 234957023; 242658998; 252730009; 255561334; 266549076; 281555005; 282974308; 283708726; 292738584; 296253221; 296452284; 297245463; 299062426; 302607262; 303773409; 305780559; 306911066; 311599333; 312863707; 322409664; 322904148; 326480333; 328466490; 333910294; 336128668; 339246192; 339623380; 341166057; 342449389; 350741848; 351345909; 356277864; 360840019; 369213988; 374040779; 375613431; 385253070; 400932178; 410063788; 410124851; 412709754; 412948402; 419490314; 425943348; 425957843; 427922342; 450474869; 451981789])
22
+
23
+ let test7 _ = assert_equal 4 (maximizeSquareHoleArea 513845407 404729930 [9498806; 24352148; 26405388; 27651898; 29120890; 35580523; 35935007; 40101019; 41878929; 43875275; 47492182; 48765489; 49947516; 57203412; 70691276; 84689459; 93044660; 93240277; 116478336; 117804161; 121374583; 126526290; 127250131; 128954259; 140270029; 144382281; 151411099; 162023831; 169333919; 176901198; 177477309; 178153918; 200329379; 219309632; 222215304; 237300715; 238051959; 239700914; 244909518; 245695307; 256516573; 264532508; 274540881; 275257189; 275409284; 296767318; 299294449; 310014321; 310311984; 328990919; 332181119; 334885781; 336122402; 336540450; 343272953; 347359863; 357763119; 360735233; 361829604; 363988889; 364297422; 370095593; 372431502; 379878259; 395231596; 397228371; 432486147; 439270075; 451931045; 457121274; 461011188; 462758866; 471790725; 488482448; 502796998] [7671344; 42918529; 51213337; 53077756; 68507963; 79720886; 88498372; 94878359; 94989617; 96947040; 104440141; 120481914; 129237944; 129263763; 132196848; 132855888; 138269318; 140843085; 142137325; 144215133; 146746379; 149060324; 149754883; 153353075; 175860592; 185487225; 185623139; 188465466; 192858754; 193099577; 224300323; 226031151; 229378231; 229492038; 237501591; 245632691; 256378619; 263450073; 273647763; 280845842; 297022618; 298382686; 299668390; 307900589; 308020315; 334951794; 339915399; 351620655; 356959767; 366914867; 386510686; 386724344; 388224650; 390589082; 392646173; 394447827])
24
+
25
+ let test8 _ = assert_equal 4 (maximizeSquareHoleArea 540203719 864386158 [18159674; 54458115; 62778378; 105777903; 131818737; 194080940; 244038247; 262050056; 286206787; 337137656; 367602942; 423073030; 448920818; 497900945; 501590248] [35697500; 40873154; 55587178; 70212840; 83049615; 104605908; 117210403; 142204973; 164821392; 170338629; 178466862; 225008410; 249713156; 274641087; 367085254; 437026354; 443960721; 469543004; 484630123; 495488252; 550562101; 568598551; 582853569; 606216360; 631280423; 660866337; 664702679; 665739751; 673375438; 689103748; 706193654; 709677611; 718350801; 735649368; 738289218; 788099121; 816988546; 855161537])
26
+
27
+ let test9 _ = assert_equal 4 (maximizeSquareHoleArea 306351915 170728625 [5247734; 6079061; 9237115; 10210344; 18735942; 18801043; 31704472; 34374350; 37786580; 41329920; 52952414; 57841187; 59142238; 62765260; 69131402; 70371442; 70968505; 80531876; 80618403; 81987540; 83198640; 83451609; 86899465; 90117298; 94888971; 95000438; 108057111; 127535258; 128667837; 138755740; 142209698; 143701434; 147781485; 151796694; 153181137; 154457854; 154515138; 154578684; 157238033; 158110818; 158240020; 161801225; 162627294; 164088970; 164878347; 165278789; 169186408; 190248161; 192440465; 204436985; 207904201; 209956636; 211796619; 214406669; 219811640; 219975623; 220408551; 220653169; 220679563; 226638124; 228225203; 231397055; 233246494; 238298802; 239433853; 241737251; 241889954; 243026394; 243570863; 254465607; 254953716; 259241983; 260615116; 267478250; 267590678; 272683721; 274618475; 276297393; 279494171; 280297886; 287172606; 288190298; 292236599; 292902931; 300414435; 303413932; 304593687] [20269528; 26663327; 48521999; 124096886])
28
+
29
+ let test10 _ = assert_equal 4 (maximizeSquareHoleArea 805192008 165109117 [20057484; 28290147; 32933723; 34305321; 50789706; 50823443; 68848320; 92688044; 106621839; 116486269; 118588482; 124114394; 130816098; 132593082; 154465792; 167306766; 182772969; 185170570; 198382016; 199918217; 225996706; 228188108; 233647455; 247694290; 258887511; 275141064; 275306640; 283077890; 284743921; 306083375; 308850285; 313735400; 323006815; 324297852; 325945505; 326842761; 331277253; 336994732; 350039008; 355339911; 369811096; 377052576; 385885146; 392166100; 398773942; 399753059; 401964979; 405977146; 410165865; 414040233; 415174842; 429289798; 444277839; 448558613; 457343914; 463599676; 466799017; 473488531; 479421481; 483636956; 501550619; 507514260; 521386312; 522587724; 526211576; 534206604; 551723393; 556415670; 558270328; 577844992; 578054043; 580847724; 585076921; 593002912; 612516677; 623590745; 631589721; 647124371; 662553525; 664079167; 681662487; 682773978; 683716203; 688162739; 694216445; 699086583; 701412509; 722219403; 746154582; 765304876; 776851631; 785660967; 794734581; 803863116] [2946789; 5627036; 7965376; 8996838; 15424016; 26854011; 33278201; 42502586; 47895262; 63629772; 78012281; 81896630; 87118991; 91043692; 96773289; 102053048; 103649158; 105033297; 117665219; 130616843; 135109615; 137494076; 144742924; 151984224; 154296782; 158086599])
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for maximizeSquareHoleArea" >::: [
34
+
35
+ "test1" >:: test1;
36
+ "test2" >:: test2;
37
+ "test3" >:: test3;
38
+ "test4" >:: test4;
39
+ "test5" >:: test5;
40
+ "test6" >:: test6;
41
+ "test7" >:: test7;
42
+ "test8" >:: test8;
43
+ "test9" >:: test9;
44
+ "test10" >:: test10;
45
+ ]
46
+
47
+
48
+ (* Running the tests *)
49
+ let () = run_test_tt_main suite
50
+ end
maximize_area_of_square_hole_in_grid/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximizeSquareHoleArea(2,1,List(2,3),List(2)), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximizeSquareHoleArea(1,1,List(2),List(2)), 4)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maximizeSquareHoleArea(2,3,List(2,3),List(2,4)), 4)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.maximizeSquareHoleArea(824467728,221817438,List(56096705, 57870720, 69469937, 111791310, 129788017, 224924663, 244126653, 373088654, 478648892, 479737344, 484027317, 577078428, 613845263, 623404704, 652011224, 693982805, 726122581, 757518028, 774930667, 788601394),List(2188056, 45814255, 51635174, 95034604, 121130097, 126531814, 179968387, 186279251, 193100682, 204173076)), 4)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.maximizeSquareHoleArea(648154527,195491926,List(6430521, 7662717, 14849099, 26729809, 34176525, 41416403, 43987631, 48927292, 59693806, 62867826, 63453627, 64973441, 73601229, 79276448, 84680728, 85005753, 89143319, 104246247, 112714767, 122033194, 134082507, 138491454, 150121923, 153922492, 177333276, 182168611, 186177986, 187117991, 193176285, 213168822, 217262633, 247009037, 252072557, 277050717, 277682614, 279480841, 295854348, 297703110, 302050964, 307032990, 308251895, 318537633, 329614972, 333618784, 334944731, 357626935, 360357188, 364551661, 400905292, 425738119, 427251943, 427438495, 430124900, 437443272, 452394867, 454476726, 456980047, 496329465, 503394056, 504896085, 508835065, 515695951, 522010615, 545056106, 550060412, 557832075, 566679909, 572459454, 579926387, 583147436, 585416538, 598188067, 600334621, 605754453, 619694351, 622515687, 625846917, 626010943, 638107878),List(2321378, 4728768, 11190795, 22081869, 25588634, 25895890, 26934109, 27020593, 28711634, 36829047, 37341986, 43605991, 52537708, 54499808, 55275646, 55565717, 60970108, 66532120, 67215985, 67255256, 82268913, 86949955, 94715373, 100371042, 106605467, 108763282, 113409434, 127318992, 131467381, 134614906, 135710242, 137155445, 146012774, 151819645, 156567230, 158046183, 165292480, 174238526, 174665425, 182107718, 187191249, 190269183, 191586393, 195268811)), 4)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.maximizeSquareHoleArea(359468690,454270785,List(9255764, 24817170, 25231024, 27200073, 28502084, 30110803, 47545895, 47617085, 48087899, 54345546, 64571339, 64984123, 65051604, 71733376, 72494846, 72763165, 82645381, 84167603, 94685994, 103297900, 104328402, 105153943, 111823293, 113998979, 118529352, 126747199, 128521183, 135973339, 158755954, 159571144, 162096085, 163884034, 167403114, 167720107, 176964725, 189841821, 189996188, 198243950, 204907082, 210715397, 221047178, 223805726, 228824290, 234893651, 238188320, 243455459, 264846760, 268016355, 270518804, 281466902, 284021975, 286681657, 300789237, 315737786, 316266985, 316842811, 318929493, 324730998, 325541997, 326134223, 326219219, 330067048, 347680557, 348107549, 356791227),List(1105420, 4044057, 8630912, 22127180, 25837680, 27701285, 27946376, 29169029, 43992204, 52302911, 57516458, 61643051, 64182307, 65151218, 66550856, 67273320, 67615834, 69269946, 75192723, 78541115, 82610966, 89362508, 95678065, 102859077, 115137604, 123368976, 124273371, 137877339, 139897548, 154130398, 162158098, 163605277, 165377492, 165768141, 166601071, 167177757, 170582125, 174631670, 182126841, 182611780, 184009291, 185748646, 191138260, 195662206, 221814748, 225792188, 227159530, 228525447, 230702381, 234957023, 242658998, 252730009, 255561334, 266549076, 281555005, 282974308, 283708726, 292738584, 296253221, 296452284, 297245463, 299062426, 302607262, 303773409, 305780559, 306911066, 311599333, 312863707, 322409664, 322904148, 326480333, 328466490, 333910294, 336128668, 339246192, 339623380, 341166057, 342449389, 350741848, 351345909, 356277864, 360840019, 369213988, 374040779, 375613431, 385253070, 400932178, 410063788, 410124851, 412709754, 412948402, 419490314, 425943348, 425957843, 427922342, 450474869, 451981789)), 4)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.maximizeSquareHoleArea(513845407,404729930,List(9498806, 24352148, 26405388, 27651898, 29120890, 35580523, 35935007, 40101019, 41878929, 43875275, 47492182, 48765489, 49947516, 57203412, 70691276, 84689459, 93044660, 93240277, 116478336, 117804161, 121374583, 126526290, 127250131, 128954259, 140270029, 144382281, 151411099, 162023831, 169333919, 176901198, 177477309, 178153918, 200329379, 219309632, 222215304, 237300715, 238051959, 239700914, 244909518, 245695307, 256516573, 264532508, 274540881, 275257189, 275409284, 296767318, 299294449, 310014321, 310311984, 328990919, 332181119, 334885781, 336122402, 336540450, 343272953, 347359863, 357763119, 360735233, 361829604, 363988889, 364297422, 370095593, 372431502, 379878259, 395231596, 397228371, 432486147, 439270075, 451931045, 457121274, 461011188, 462758866, 471790725, 488482448, 502796998),List(7671344, 42918529, 51213337, 53077756, 68507963, 79720886, 88498372, 94878359, 94989617, 96947040, 104440141, 120481914, 129237944, 129263763, 132196848, 132855888, 138269318, 140843085, 142137325, 144215133, 146746379, 149060324, 149754883, 153353075, 175860592, 185487225, 185623139, 188465466, 192858754, 193099577, 224300323, 226031151, 229378231, 229492038, 237501591, 245632691, 256378619, 263450073, 273647763, 280845842, 297022618, 298382686, 299668390, 307900589, 308020315, 334951794, 339915399, 351620655, 356959767, 366914867, 386510686, 386724344, 388224650, 390589082, 392646173, 394447827)), 4)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.maximizeSquareHoleArea(540203719,864386158,List(18159674, 54458115, 62778378, 105777903, 131818737, 194080940, 244038247, 262050056, 286206787, 337137656, 367602942, 423073030, 448920818, 497900945, 501590248),List(35697500, 40873154, 55587178, 70212840, 83049615, 104605908, 117210403, 142204973, 164821392, 170338629, 178466862, 225008410, 249713156, 274641087, 367085254, 437026354, 443960721, 469543004, 484630123, 495488252, 550562101, 568598551, 582853569, 606216360, 631280423, 660866337, 664702679, 665739751, 673375438, 689103748, 706193654, 709677611, 718350801, 735649368, 738289218, 788099121, 816988546, 855161537)), 4)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.maximizeSquareHoleArea(306351915,170728625,List(5247734, 6079061, 9237115, 10210344, 18735942, 18801043, 31704472, 34374350, 37786580, 41329920, 52952414, 57841187, 59142238, 62765260, 69131402, 70371442, 70968505, 80531876, 80618403, 81987540, 83198640, 83451609, 86899465, 90117298, 94888971, 95000438, 108057111, 127535258, 128667837, 138755740, 142209698, 143701434, 147781485, 151796694, 153181137, 154457854, 154515138, 154578684, 157238033, 158110818, 158240020, 161801225, 162627294, 164088970, 164878347, 165278789, 169186408, 190248161, 192440465, 204436985, 207904201, 209956636, 211796619, 214406669, 219811640, 219975623, 220408551, 220653169, 220679563, 226638124, 228225203, 231397055, 233246494, 238298802, 239433853, 241737251, 241889954, 243026394, 243570863, 254465607, 254953716, 259241983, 260615116, 267478250, 267590678, 272683721, 274618475, 276297393, 279494171, 280297886, 287172606, 288190298, 292236599, 292902931, 300414435, 303413932, 304593687),List(20269528, 26663327, 48521999, 124096886)), 4)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.maximizeSquareHoleArea(805192008,165109117,List(20057484, 28290147, 32933723, 34305321, 50789706, 50823443, 68848320, 92688044, 106621839, 116486269, 118588482, 124114394, 130816098, 132593082, 154465792, 167306766, 182772969, 185170570, 198382016, 199918217, 225996706, 228188108, 233647455, 247694290, 258887511, 275141064, 275306640, 283077890, 284743921, 306083375, 308850285, 313735400, 323006815, 324297852, 325945505, 326842761, 331277253, 336994732, 350039008, 355339911, 369811096, 377052576, 385885146, 392166100, 398773942, 399753059, 401964979, 405977146, 410165865, 414040233, 415174842, 429289798, 444277839, 448558613, 457343914, 463599676, 466799017, 473488531, 479421481, 483636956, 501550619, 507514260, 521386312, 522587724, 526211576, 534206604, 551723393, 556415670, 558270328, 577844992, 578054043, 580847724, 585076921, 593002912, 612516677, 623590745, 631589721, 647124371, 662553525, 664079167, 681662487, 682773978, 683716203, 688162739, 694216445, 699086583, 701412509, 722219403, 746154582, 765304876, 776851631, 785660967, 794734581, 803863116),List(2946789, 5627036, 7965376, 8996838, 15424016, 26854011, 33278201, 42502586, 47895262, 63629772, 78012281, 81896630, 87118991, 91043692, 96773289, 102053048, 103649158, 105033297, 117665219, 130616843, 135109615, 137494076, 144742924, 151984224, 154296782, 158086599)), 4)
42
+ }
43
+
44
+ }
maximize_consecutive_elements_in_an_array_after_modification/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
maximize_consecutive_elements_in_an_array_after_modification/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(3, maxSelectedElements(Arrays.asList(2,1,5,1,1)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(1, maxSelectedElements(Arrays.asList(1,4,7,10)));
18
+ }
19
+
20
+ }