Prompt:
(**Given an array of non-negative integers, return a copy of the given array after sorting,
 * you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
 * or sort it in descending order if the sum( first index value, last index value) is even.
 * Note:
 * * don't change the given array.
 * Examples:
 * >>> sort_array []
 * []
 * >>> sort_array [5]
 * [5]
 * >>> sort_array [2; 4; 3; 0; 1; 5]
 * [0; 1; 2; 3; 4; 5]
 * >>> sort_array [2; 4; 3; 0; 1; 5; 6]
 * [6; 5; 4; 3; 2; 1; 0]
*)
let sort_array (array : int list) : int list =


Prompt:
(**Create a function encrypt that takes a string as an argument and
 * returns a string encrypted with the alphabet being rotated.
 * The alphabet should be rotated in a manner such that the letters
 * shift down by two multiplied to two places.
 * For example:
 * >>> encrypt "hi"
 * "lm"
 * >>> encrypt "asdfghjkl"
 * "ewhjklnop"
 * >>> encrypt "gf"
 * "kj"
 * >>> encrypt "et"
 * "ix"
*)
let encrypt (s : string) : string =

let assertions =
 let candidate = encrypt in
  (assert ((candidate "hi") = "lm"));
  (assert ((candidate "asdfghjkl") = "ewhjklnop"));
  (assert ((candidate "gf") = "kj"));
  (assert ((candidate "et") = "ix"));
  (assert ((candidate "faewfawefaewg") = "jeiajeaijeiak"));
  (assert ((candidate "hellomyfriend") = "lippsqcjvmirh"));
  (assert ((candidate "dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh") = "hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl"));
  (assert ((candidate "a") = "e"));
  ()


Prompt:
(**For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
 * Empty sum should be equal to 0 and empty product should be equal to 1.
 * >>> sum_product []
 * (0, 1)
 * >>> sum_product [1; 2; 3; 4]
 * (10, 24)
*)
let sum_product (numbers : int list) :  int * int =

let assertions =
 let candidate = sum_product in
  (assert ((candidate []) = (0, 1)));
  (assert ((candidate [1; 1; 1]) = (3, 1)));
  (assert ((candidate [100; 0]) = (100, 0)));
  (assert ((candidate [3; 5; 7]) = (15, 105)));
  (assert ((candidate [10]) = (10, 10)));
  ()


Prompt:
(**You are given a list of integers.
 * Write a function next_smallest() that returns the 2nd smallest element of the list.
 * Return None if there is no such element.
 * >>> next_smallest [1; 2; 3; 4; 5]
 * Some(2)
 * >>> next_smallest [5; 1; 4; 3; 2]
 * Some(2)
 * >>> next_smallest []
 * Some(None)
 * >>> next_smallest [1; 1]
 * Some(None)
*)
let next_smallest (lst : int list) : int option =

let assertions =
 let candidate = next_smallest in
  (assert ((candidate [1; 2; 3; 4; 5]) = Some(2)));
  (assert ((candidate [5; 1; 4; 3; 2]) = Some(2)));
  (assert ((candidate []) = Some(None)));
  (assert ((candidate [1; 1]) = Some(None)));
  (assert ((candidate [1; 1; 1; 1; 0]) = Some(1)));
  (assert ((candidate [1; 1]) = Some(None)));
  (assert ((candidate [(~35); 34; 12; (~45)]) = Some((~35))));
  ()


Prompt:
(**You'll be given a string of words, and your task is to count the number
 * of boredoms. A boredom is a sentence that starts with the word "I".
 * Sentences are delimited by '.', '?' or '!'.
 * For example:
 * >>> is_bored "Hello world"
 * 0
 * >>> is_bored "The sky is blue. The sun is shining. I love this weather"
 * 1
*)
let is_bored (S : string) : int =

let assertions =
 let candidate = is_bored in
  (assert ((candidate "Hello world") = 0));
  (assert ((candidate "Is the sky blue?") = 0));
  (assert ((candidate "I love It !") = 1));
  (assert ((candidate "bIt") = 0));
  (assert ((candidate "I feel good today. I will be productive. will kill It") = 2));
  (assert ((candidate "You and I are going for a walk") = 0));
  ()


Prompt:
(**Create a function that takes 3 numbers.
 * Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
 * Returns false in any other cases.
 * Examples
 * >>> any_int 5 2 7
 * true
 * >>> any_int 3 2 2
 * false
 * >>> any_int 3 (~2) 1
 * true
 * >>> any_int 3.6 -2.2 2
 * false
*)
let any_int (x : float) (y : float) (z : float) : bool =

let assertions =
 let candidate = any_int in
  (assert ((candidate 2.0 3.0 1.0) = true));
  (assert ((candidate 2.5 2.0 3.0) = false));
  (assert ((candidate 1.5 5.0 3.5) = false));
  (assert ((candidate 2.0 6.0 2.0) = false));
  (assert ((candidate 4.0 2.0 2.0) = true));
  (assert ((candidate 2.2 2.2 2.2) = false));
  (assert ((candidate (~4).0 6.0 2.0) = true));
  (assert ((candidate 2.0 1.0 1.0) = true));
  (assert ((candidate 3.0 4.0 7.0) = true));
  (assert ((candidate 3.0 4.0 7.0) = false));
  ()


Prompt:
(**Write a function that takes a message, and encodes in such a
 * way that it swaps case of all letters, replaces all vowels in
 * the message with the letter that appears 2 places ahead of that
 * vowel in the english alphabet.
 * Assume only letters.
 * Examples:
 * >>> encode "test"
 * "TGST"
 * >>> encode "This is a message"
 * "tHKS KS C MGSSCGG"
*)
let encode (message : string) : string =

let assertions =
 let candidate = encode in
  (assert ((candidate "TEST") = "tgst"));
  (assert ((candidate "Mudasir") = "mWDCSKR"));
  (assert ((candidate "YES") = "ygs"));
  (assert ((candidate "This is a message") = "tHKS KS C MGSSCGG"));
  (assert ((candidate "I DoNt KnOw WhAt tO WrItE") = "k dQnT kNqW wHcT Tq wRkTg"));
  ()


Prompt:
(**You are given a list of integers.
 * You need to find the largest prime value and return the sum of its digits.
 * Examples:
 * >>> skjkasdkd [0; 3; 2; 1; 3; 5; 7; 4; 5; 5; 5; 2; 181; 32; 4; 32; 3; 2; 32; 324; 4; 3]
 * 10
 * >>> skjkasdkd [1; 0; 1; 8; 2; 4597; 2; 1; 3; 40; 1; 2; 1; 2; 4; 2; 5; 1]
 * 25
 * >>> skjkasdkd [1; 3; 1; 32; 5107; 34; 83278; 109; 163; 23; 2323; 32; 30; 1; 9; 3]
 * 13
 * >>> skjkasdkd [0; 724; 32; 71; 99; 32; 6; 0; 5; 91; 83; 0; 5; 6]
 * 11
 * >>> skjkasdkd [0; 81; 12; 3; 1; 21]
 * 3
 * >>> skjkasdkd [0; 8; 1; 2; 1; 7]
 * 7
*)
let skjkasdkd (lst : int list) : int =


Prompt:
(**Given a dictionary, return True if all keys are strings in lower
 * case or all keys are strings in upper case, else return False.
 * The function should return False is the given dictionary is empty.
 * Examples:
 * >>> check_dict_case [("a", "apple"); ("b", "banana")]
 * true
 * >>> check_dict_case [("a", "apple"); ("A", "banana"); ("B", "banana")]
 * false
 * >>> check_dict_case [("a", "apple"); (8, "banana"); ("a", "apple")]
 * false
 * >>> check_dict_case [("Name", "John"); ("Age", "36"); ("City", "Houston")]
 * false
 * >>> check_dict_case [("STATE", "NC"); ("ZIP", "12345")]
 * true
*)
let check_dict_case (dict : (string, string) list) : bool =

let assertions =
 let candidate = check_dict_case in
  (assert ((candidate [("p", "pineapple"); ("b", "banana")]) = true));
  (assert ((candidate [("p", "pineapple"); ("A", "banana"); ("B", "banana")]) = false));
  (assert ((candidate [("p", "pineapple"); ("5", "banana"); ("a", "apple")]) = false));
  (assert ((candidate [("Name", "John"); ("Age", "36"); ("City", "Houston")]) = false));
  (assert ((candidate [("STATE", "NC"); ("ZIP", "12345")]) = true));
  (assert ((candidate [("fruit", "Orange"); ("taste", "Sweet")]) = true));
  (assert ((candidate []) = false));
  ()


Prompt:
(**Implement a function that takes an non-negative integer and returns an array of the first n
 * integers that are prime numbers and less than n.
 * for example:
 * >>> count_up_to 5
 * [2; 3]
 * >>> count_up_to 11
 * [2; 3; 5; 7]
 * >>> count_up_to 0
 * []
 * >>> count_up_to 20
 * [2; 3; 5; 7; 11; 13; 17; 19]
 * >>> count_up_to 1
 * []
 * >>> count_up_to 18
 * [2; 3; 5; 7; 11; 13; 17]
*)
let count_up_to (n : int) : int list =


Prompt:
(**Complete the function that takes two integers and returns
 * the product of their unit digits.
 * Assume the input is always valid.
 * Examples:
 * >>> multiply 148 412
 * 16
 * >>> multiply 19 28
 * 72
 * >>> multiply 2020 1851
 * 0
 * >>> multiply 14 (~15)
 * 20
*)
let multiply (a : int) (b : int) : int =

let assertions =
 let candidate = multiply in
  (assert ((candidate 148 412) = 16));
  (assert ((candidate 19 28) = 72));
  (assert ((candidate 2020 1851) = 0));
  (assert ((candidate 14 (~15)) = 20));
  (assert ((candidate 76 67) = 42));
  (assert ((candidate 17 27) = 49));
  (assert ((candidate 0 1) = 0));
  (assert ((candidate 0 0) = 0));
  ()


Prompt:
(**Given a string s, count the number of uppercase vowels in even indices.
 * For example:
 * >>> count_upper "aBCdEf"
 * 1
 * >>> count_upper "abcdefg"
 * 0
 * >>> count_upper "dBBE"
 * 0
*)
let count_upper (s : string) : int =

let assertions =
 let candidate = count_upper in
  (assert ((candidate "aBCdEf") = 1));
  (assert ((candidate "abcdefg") = 0));
  (assert ((candidate "dBBE") = 0));
  (assert ((candidate "B") = 0));
  (assert ((candidate "U") = 1));
  (assert ((candidate "") = 0));
  (assert ((candidate "EEEE") = 2));
  ()


Prompt:
(**Create a function that takes a value (string) representing a number
 * and returns the closest integer to it. If the number is equidistant
 * from two integers, round it away from zero.
 * Examples
 * >>> closest_integer "10"
 * 10
 * >>> closest_integer "15.3"
 * 15
 * Note:
 * Rounding away from zero means that if the given number is equidistant
 * from two integers, the one you should return is the one that is the
 * farthest from zero. For example closest_integer("14.5") should
 * return 15 and closest_integer("-14.5") should return -15.
*)
let closest_integer (value : string) : int =

let assertions =
 let candidate = closest_integer in
  (assert ((candidate "10") = 10));
  (assert ((candidate "14.5") = 15));
  (assert ((candidate "-15.5") = (~16)));
  (assert ((candidate "15.3") = 15));
  (assert ((candidate "0") = 0));
  ()


Prompt:
(**From a given list of integers, generate a list of rolling maximum element found until given moment
 * in the sequence.
 * >>> rolling_max [1; 2; 3; 2; 3; 4; 2]
 * [1; 2; 3; 3; 3; 4; 4]
*)
let rolling_max (numbers : int list) : int list =