CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
main.ml43 linesDownload Raw Back to ocaml_tests
1 2module Main = struct3    open OUnit24 5    (* Program start *)6    let alternatingSubarray (nums: int list) : int =   failwith "Not implemented"7 8    (* Program end *)9 10    (* Test cases *)11    12let test1 _ = assert_equal 4 (alternatingSubarray [2;3;4;3;4])13 14let test2 _ = assert_equal 2 (alternatingSubarray [4;5;6])15 16let test3 _ = assert_equal 2 (alternatingSubarray [54; 16; 32; 95; 67; 55; 86; 56; 31; 70; 16; 68; 90; 20; 43; 33; 67; 50; 75; 12; 55; 63; 26; 45; 31; 55; 17; 20; 83; 34; 63; 51; 82; 103; 88; 88; 8; 66; 76; 85; 93; 24; 4; 70; 5; 40; 46; 99; 88; 88; 8; 40; 58; 22; 39; 37; 39; 92; 29; 26; 44; 90; 38; 15; 48; 77; 76; 10; 96; 7; 26; 7; 95; 93])17 18let test4 _ = assert_equal 2 (alternatingSubarray [62; 77; 25; 40; 7; 16; 33; 76; 103; 72; 89; 50; 18; 58; 45; 28; 50; 88; 43; 65; 46; 100; 29; 65; 27; 29; 25; 8; 2; 33; 62; 34; 14; 20; 20; 40; 87; 75; 49; 53; 65; 87; 30; 100; 38; 9; 72; 86; 44; 10; 41; 53; 92; 99; 102; 14; 47; 34])19 20let test5 _ = assert_equal 2 (alternatingSubarray [50; 30; 88; 101; 99; 23; 27; 91; 21])21 22let test6 _ = assert_equal 2 (alternatingSubarray [3; 23; 16; 46])23 24let test7 _ = assert_equal 2 (alternatingSubarray [38; 73; 92; 36; 95; 99; 83; 14; 95; 4; 91; 89; 82; 62; 22; 40; 102; 25; 45; 88; 60; 80; 36; 104; 71; 28; 39; 44; 44; 38; 65; 14; 29; 43; 17; 18; 22; 79; 39; 98; 102; 55; 81; 25; 104; 60; 6])25 26 27    (* Grouping test cases *)28    let suite = "Test Suite for alternatingSubarray" >::: [29        30  "test1" >:: test1;31  "test2" >:: test2;32  "test3" >:: test3;33  "test4" >:: test4;34  "test5" >:: test5;35  "test6" >:: test6;36  "test7" >:: test7;37    ]38 39 40    (* Running the tests *)41    let () = run_test_tt_main suite42end43