-
-
Save esslushy/85e34b299f4985c3fa737de7ae76d648 to your computer and use it in GitHub Desktop.
Completions made when testing multithreading.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[["def strlen(string: str) -> int:\n \"\"\" Return length of given string\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\n \"\"\"\n return len(string)\n\n", "def strlen(string: str) -> int:\n \"\"\" Return length of given string\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\n \"\"\"\n return len(string)\n\n", "def strlen(string: str) -> int:\n \"\"\" Return length of given string\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\n \"\"\"\n return len(string)\n\n", "def strlen(string: str) -> int:\n \"\"\" Return length of given string\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\n \"\"\"\n return len(string)\n\n", "def strlen(string: str) -> int:\n \"\"\" Return length of given string\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\n \"\"\"\n return len(string)\n\n"], ["def encrypt(s: str) -> str:\n \"\"\"Create a function encrypt that takes a string as an argument and\n returns a string encrypted with the alphabet being rotated. \n The alphabet should be rotated in a manner such that the letters \n shift down by two multiplied to two places.\n For example:\n >>> encrypt('hi')\n 'lm'\n >>> encrypt('asdfghjkl')\n 'ewhjklnop'\n >>> encrypt('gf')\n 'kj'\n >>> encrypt('et')\n 'ix'\n \"\"\"\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n return ''.join(alphabet[i + 2 * j] for i, j in zip(range(len(s)), range(len(s))))\n\n", "def encrypt(s: str) -> str:\n \"\"\"Create a function encrypt that takes a string as an argument and\n returns a string encrypted with the alphabet being rotated. \n The alphabet should be rotated in a manner such that the letters \n shift down by two multiplied to two places.\n For example:\n >>> encrypt('hi')\n 'lm'\n >>> encrypt('asdfghjkl')\n 'ewhjklnop'\n >>> encrypt('gf')\n 'kj'\n >>> encrypt('et')\n 'ix'\n \"\"\"\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n new_alphabet = alphabet[2:] + alphabet[:2]\n return ''.join([new_alphabet[alphabet.index(c)] for c in s])\n\n", "def encrypt(s: str) -> str:\n \"\"\"Create a function encrypt that takes a string as an argument and\n returns a string encrypted with the alphabet being rotated. \n The alphabet should be rotated in a manner such that the letters \n shift down by two multiplied to two places.\n For example:\n >>> encrypt('hi')\n 'lm'\n >>> encrypt('asdfghjkl')\n 'ewhjklnop'\n >>> encrypt('gf')\n 'kj'\n >>> encrypt('et')\n 'ix'\n \"\"\"\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n return ''.join([alphabet[(alphabet.index(c) + 26) % 26] for c in s])\n\n", "def encrypt(s: str) -> str:\n \"\"\"Create a function encrypt that takes a string as an argument and\n returns a string encrypted with the alphabet being rotated. \n The alphabet should be rotated in a manner such that the letters \n shift down by two multiplied to two places.\n For example:\n >>> encrypt('hi')\n 'lm'\n >>> encrypt('asdfghjkl')\n 'ewhjklnop'\n >>> encrypt('gf')\n 'kj'\n >>> encrypt('et')\n 'ix'\n \"\"\"\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n return ''.join([alphabet[(alphabet.index(c) + 2) % 26] for c in s])\n\n", "def encrypt(s: str) -> str:\n \"\"\"Create a function encrypt that takes a string as an argument and\n returns a string encrypted with the alphabet being rotated. \n The alphabet should be rotated in a manner such that the letters \n shift down by two multiplied to two places.\n For example:\n >>> encrypt('hi')\n 'lm'\n >>> encrypt('asdfghjkl')\n 'ewhjklnop'\n >>> encrypt('gf')\n 'kj'\n >>> encrypt('et')\n 'ix'\n \"\"\"\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n return ''.join([alphabet[(alphabet.index(c) + 2) % 26] for c in s])\n\n"], ["from typing import Dict\n\ndef check_dict_case(dict: Dict[str, str]) -> bool:\n \"\"\"\n Given a dictionary, return True if all keys are strings in lower \n case or all keys are strings in upper case, else return False.\n The function should return False is the given dictionary is empty.\n Examples:\n >>> check_dict_case({ 'a': 'apple', 'b': 'banana' })\n True\n >>> check_dict_case({ 'a': 'apple', 'A': 'banana', 'B': 'banana' })\n False\n >>> check_dict_case({ 'a': 'apple', 8: 'banana', 'a': 'apple' })\n False\n >>> check_dict_case({ 'Name': 'John', 'Age': '36', 'City': 'Houston' })\n False\n >>> check_dict_case({ 'STATE': 'NC', 'ZIP': '12345' })\n True\n \"\"\"\n if not dict:\n return False\n for key in dict:\n if not isinstance(key, str):\n return False\n if not key.islower() and not key.isupper():\n return False\n return True\n", "from typing import Dict\n\ndef check_dict_case(dict: Dict[str, str]) -> bool:\n \"\"\"\n Given a dictionary, return True if all keys are strings in lower \n case or all keys are strings in upper case, else return False.\n The function should return False is the given dictionary is empty.\n Examples:\n >>> check_dict_case({ 'a': 'apple', 'b': 'banana' })\n True\n >>> check_dict_case({ 'a': 'apple', 'A': 'banana', 'B': 'banana' })\n False\n >>> check_dict_case({ 'a': 'apple', 8: 'banana', 'a': 'apple' })\n False\n >>> check_dict_case({ 'Name': 'John', 'Age': '36', 'City': 'Houston' })\n False\n >>> check_dict_case({ 'STATE': 'NC', 'ZIP': '12345' })\n True\n \"\"\"\n if len(dict) == 0:\n return False\n for key in dict:\n if not isinstance(key, str):\n return False\n if not key.islower() and not key.isupper():\n return False\n return True\n", "from typing import Dict\n\ndef check_dict_case(dict: Dict[str, str]) -> bool:\n \"\"\"\n Given a dictionary, return True if all keys are strings in lower \n case or all keys are strings in upper case, else return False.\n The function should return False is the given dictionary is empty.\n Examples:\n >>> check_dict_case({ 'a': 'apple', 'b': 'banana' })\n True\n >>> check_dict_case({ 'a': 'apple', 'A': 'banana', 'B': 'banana' })\n False\n >>> check_dict_case({ 'a': 'apple', 8: 'banana', 'a': 'apple' })\n False\n >>> check_dict_case({ 'Name': 'John', 'Age': '36', 'City': 'Houston' })\n False\n >>> check_dict_case({ 'STATE': 'NC', 'ZIP': '12345' })\n True\n \"\"\"\n if not dict:\n return False\n for key in dict:\n if not isinstance(key, str):\n return False\n if not key.islower() and not key.isupper():\n return False\n return True\n", "from typing import Dict\n\ndef check_dict_case(dict: Dict[str, str]) -> bool:\n \"\"\"\n Given a dictionary, return True if all keys are strings in lower \n case or all keys are strings in upper case, else return False.\n The function should return False is the given dictionary is empty.\n Examples:\n >>> check_dict_case({ 'a': 'apple', 'b': 'banana' })\n True\n >>> check_dict_case({ 'a': 'apple', 'A': 'banana', 'B': 'banana' })\n False\n >>> check_dict_case({ 'a': 'apple', 8: 'banana', 'a': 'apple' })\n False\n >>> check_dict_case({ 'Name': 'John', 'Age': '36', 'City': 'Houston' })\n False\n >>> check_dict_case({ 'STATE': 'NC', 'ZIP': '12345' })\n True\n \"\"\"\n if not dict:\n return False\n for key in dict.keys():\n if not isinstance(key, str):\n return False\n if not key.islower() and not key.isupper():\n return False\n return True\n", "from typing import Dict\n\ndef check_dict_case(dict: Dict[str, str]) -> bool:\n \"\"\"\n Given a dictionary, return True if all keys are strings in lower \n case or all keys are strings in upper case, else return False.\n The function should return False is the given dictionary is empty.\n Examples:\n >>> check_dict_case({ 'a': 'apple', 'b': 'banana' })\n True\n >>> check_dict_case({ 'a': 'apple', 'A': 'banana', 'B': 'banana' })\n False\n >>> check_dict_case({ 'a': 'apple', 8: 'banana', 'a': 'apple' })\n False\n >>> check_dict_case({ 'Name': 'John', 'Age': '36', 'City': 'Houston' })\n False\n >>> check_dict_case({ 'STATE': 'NC', 'ZIP': '12345' })\n True\n \"\"\"\n if not dict:\n return False\n for key, value in dict.items():\n if not isinstance(key, str):\n return False\n if not isinstance(value, str):\n return False\n return True\n"], ["from typing import List\n\ndef add(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers lst. add the even elements that are at odd indices..\n\n\n Examples:\n >>> add([4, 2, 6, 7])\n 2\n \"\"\"\n return sum(lst[i] for i in range(len(lst)) if i % 2 == 1)\n", "from typing import List\n\ndef add(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers lst. add the even elements that are at odd indices..\n\n\n Examples:\n >>> add([4, 2, 6, 7])\n 2\n \"\"\"\n return sum(lst[i] for i in range(len(lst)) if i % 2 == 0)\n", "from typing import List\n\ndef add(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers lst. add the even elements that are at odd indices..\n\n\n Examples:\n >>> add([4, 2, 6, 7])\n 2\n \"\"\"\n return sum(lst[i] for i in range(len(lst)) if i % 2 == 0)\n", "from typing import List\n\ndef add(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers lst. add the even elements that are at odd indices..\n\n\n Examples:\n >>> add([4, 2, 6, 7])\n 2\n \"\"\"\n return sum(lst[i] for i in range(len(lst)) if i % 2 == 1)\n", "from typing import List\n\ndef add(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers lst. add the even elements that are at odd indices..\n\n\n Examples:\n >>> add([4, 2, 6, 7])\n 2\n \"\"\"\n return sum(lst[i] for i in range(len(lst)) if i % 2 == 0)\n"], ["def fix_spaces(text: str) -> str:\n \"\"\"\n Given a string text, replace all spaces in it with underscores, \n and if a string has more than 2 consecutive spaces, \n then replace all consecutive spaces with - \n \n >>> fix_spaces(' Example')\n 'Example'\n >>> fix_spaces(' Example 1')\n 'Example_1'\n >>> fix_spaces(' Example 2')\n '_Example_2'\n >>> fix_spaces(' Example 3')\n '_Example-3'\n \"\"\"\n text = text.replace(' ', '_')\n if len(text) > 2:\n text = text.replace(' ', '-')\n return text\n", "def fix_spaces(text: str) -> str:\n \"\"\"\n Given a string text, replace all spaces in it with underscores, \n and if a string has more than 2 consecutive spaces, \n then replace all consecutive spaces with - \n \n >>> fix_spaces(' Example')\n 'Example'\n >>> fix_spaces(' Example 1')\n 'Example_1'\n >>> fix_spaces(' Example 2')\n '_Example_2'\n >>> fix_spaces(' Example 3')\n '_Example-3'\n \"\"\"\n return re.sub(r'\\s+', '_', text)\n\n", "def fix_spaces(text: str) -> str:\n \"\"\"\n Given a string text, replace all spaces in it with underscores, \n and if a string has more than 2 consecutive spaces, \n then replace all consecutive spaces with - \n \n >>> fix_spaces(' Example')\n 'Example'\n >>> fix_spaces(' Example 1')\n 'Example_1'\n >>> fix_spaces(' Example 2')\n '_Example_2'\n >>> fix_spaces(' Example 3')\n '_Example-3'\n \"\"\"\n return re.sub(r\"\\s+\", \"_\", text)\n\n", "def fix_spaces(text: str) -> str:\n \"\"\"\n Given a string text, replace all spaces in it with underscores, \n and if a string has more than 2 consecutive spaces, \n then replace all consecutive spaces with - \n \n >>> fix_spaces(' Example')\n 'Example'\n >>> fix_spaces(' Example 1')\n 'Example_1'\n >>> fix_spaces(' Example 2')\n '_Example_2'\n >>> fix_spaces(' Example 3')\n '_Example-3'\n \"\"\"\n return re.sub(r'\\s+', '_', text)\n\n", "def fix_spaces(text: str) -> str:\n \"\"\"\n Given a string text, replace all spaces in it with underscores, \n and if a string has more than 2 consecutive spaces, \n then replace all consecutive spaces with - \n \n >>> fix_spaces(' Example')\n 'Example'\n >>> fix_spaces(' Example 1')\n 'Example_1'\n >>> fix_spaces(' Example 2')\n '_Example_2'\n >>> fix_spaces(' Example 3')\n '_Example-3'\n \"\"\"\n return re.sub(r'\\s+', '_', text)\n\n"], ["def fibfib(n: int) -> int:\n \"\"\"The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fibfib(0) == 0\n fibfib(1) == 0\n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write a function to efficiently compute the n-th element of the fibfib number sequence.\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n if n == 0:\n return 0\n if n == 1:\n return 0\n if n == 2:\n return 1\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n\n", "def fibfib(n: int) -> int:\n \"\"\"The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fibfib(0) == 0\n fibfib(1) == 0\n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write a function to efficiently compute the n-th element of the fibfib number sequence.\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n if n == 0:\n return 0\n if n == 1:\n return 0\n if n == 2:\n return 1\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n\n", "def fibfib(n: int) -> int:\n \"\"\"The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fibfib(0) == 0\n fibfib(1) == 0\n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write a function to efficiently compute the n-th element of the fibfib number sequence.\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n\n", "def fibfib(n: int) -> int:\n \"\"\"The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fibfib(0) == 0\n fibfib(1) == 0\n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write a function to efficiently compute the n-th element of the fibfib number sequence.\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n\n", "def fibfib(n: int) -> int:\n \"\"\"The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fibfib(0) == 0\n fibfib(1) == 0\n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write a function to efficiently compute the n-th element of the fibfib number sequence.\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n\n"], ["from typing import List\n\ndef double_the_difference(lst: List[float]) -> int:\n \"\"\"\n Given a list of numbers, return the sum of squares of the numbers\n in the list that are odd. Ignore numbers that are negative or not integers.\n \n >>> double_the_difference([1, 3, 2, 0])\n 10\n >>> double_the_difference([-1, -2, 0])\n 0\n >>> double_the_difference([9, -2])\n 81\n >>> double_the_difference([0])\n 0\n \n If the input list is empty, return 0.\n \"\"\"\n if not lst:\n return 0\n return sum(map(lambda x: x**2, filter(lambda x: x % 2 != 0, lst)))\n", "from typing import List\n\ndef double_the_difference(lst: List[float]) -> int:\n \"\"\"\n Given a list of numbers, return the sum of squares of the numbers\n in the list that are odd. Ignore numbers that are negative or not integers.\n \n >>> double_the_difference([1, 3, 2, 0])\n 10\n >>> double_the_difference([-1, -2, 0])\n 0\n >>> double_the_difference([9, -2])\n 81\n >>> double_the_difference([0])\n 0\n \n If the input list is empty, return 0.\n \"\"\"\n if not lst:\n return 0\n return sum([x**2 for x in lst if x % 2 == 1])\n", "from typing import List\n\ndef double_the_difference(lst: List[float]) -> int:\n \"\"\"\n Given a list of numbers, return the sum of squares of the numbers\n in the list that are odd. Ignore numbers that are negative or not integers.\n \n >>> double_the_difference([1, 3, 2, 0])\n 10\n >>> double_the_difference([-1, -2, 0])\n 0\n >>> double_the_difference([9, -2])\n 81\n >>> double_the_difference([0])\n 0\n \n If the input list is empty, return 0.\n \"\"\"\n if not lst:\n return 0\n result = 0\n for i in lst:\n if i % 2 == 1:\n result += i * i\n return result\n", "from typing import List\n\ndef double_the_difference(lst: List[float]) -> int:\n \"\"\"\n Given a list of numbers, return the sum of squares of the numbers\n in the list that are odd. Ignore numbers that are negative or not integers.\n \n >>> double_the_difference([1, 3, 2, 0])\n 10\n >>> double_the_difference([-1, -2, 0])\n 0\n >>> double_the_difference([9, -2])\n 81\n >>> double_the_difference([0])\n 0\n \n If the input list is empty, return 0.\n \"\"\"\n if not lst:\n return 0\n odd_nums = []\n for num in lst:\n if num % 2 == 1:\n odd_nums.append(num * num)\n return sum(odd_nums)\n", "from typing import List\n\ndef double_the_difference(lst: List[float]) -> int:\n \"\"\"\n Given a list of numbers, return the sum of squares of the numbers\n in the list that are odd. Ignore numbers that are negative or not integers.\n \n >>> double_the_difference([1, 3, 2, 0])\n 10\n >>> double_the_difference([-1, -2, 0])\n 0\n >>> double_the_difference([9, -2])\n 81\n >>> double_the_difference([0])\n 0\n \n If the input list is empty, return 0.\n \"\"\"\n if not lst:\n return 0\n result = 0\n for i in lst:\n if i % 2 == 1:\n result += i * i\n return result\n"], ["from typing import List, Any\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\" Filter given list of any python values only for integers\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', { }, []])\n [1, 2, 3]\n \"\"\"\n return [int(value) for value in values if isinstance(value, int)]\n", "from typing import List, Any\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\" Filter given list of any python values only for integers\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', { }, []])\n [1, 2, 3]\n \"\"\"\n return [int(x) for x in values if isinstance(x, int)]\n", "from typing import List, Any\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\" Filter given list of any python values only for integers\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', { }, []])\n [1, 2, 3]\n \"\"\"\n return [int(value) for value in values if isinstance(value, int)]\n", "from typing import List, Any\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\" Filter given list of any python values only for integers\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', { }, []])\n [1, 2, 3]\n \"\"\"\n return [int(value) for value in values if isinstance(value, int)]\n", "from typing import List, Any\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\" Filter given list of any python values only for integers\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', { }, []])\n [1, 2, 3]\n \"\"\"\n return [int(x) for x in values if isinstance(x, int)]\n"], ["def car_race_collision(n: int) -> int:\n \"\"\"\n Imagine a road that's a perfectly straight infinitely long line.\n n cars are driving left to right; simultaneously, a different set of n cars\n are driving right to left. The two sets of cars start out being very far from\n each other. All cars move in the same speed. Two cars are said to collide\n when a car that's moving left to right hits a car that's moving right to left.\n However, the cars are infinitely sturdy and strong; as a result, they continue moving\n in their trajectory as if they did not collide.\n\n This function outputs the number of such collisions.\n \"\"\"\n # TODO: Implement me!\n pass\n\n", "def car_race_collision(n: int) -> int:\n \"\"\"\n Imagine a road that's a perfectly straight infinitely long line.\n n cars are driving left to right; simultaneously, a different set of n cars\n are driving right to left. The two sets of cars start out being very far from\n each other. All cars move in the same speed. Two cars are said to collide\n when a car that's moving left to right hits a car that's moving right to left.\n However, the cars are infinitely sturdy and strong; as a result, they continue moving\n in their trajectory as if they did not collide.\n\n This function outputs the number of such collisions.\n \"\"\"\n # TODO: Implement me!\n pass\n\n", "def car_race_collision(n: int) -> int:\n \"\"\"\n Imagine a road that's a perfectly straight infinitely long line.\n n cars are driving left to right; simultaneously, a different set of n cars\n are driving right to left. The two sets of cars start out being very far from\n each other. All cars move in the same speed. Two cars are said to collide\n when a car that's moving left to right hits a car that's moving right to left.\n However, the cars are infinitely sturdy and strong; as a result, they continue moving\n in their trajectory as if they did not collide.\n\n This function outputs the number of such collisions.\n \"\"\"\n # TODO: Implement me!\n pass\n\n", "def car_race_collision(n: int) -> int:\n \"\"\"\n Imagine a road that's a perfectly straight infinitely long line.\n n cars are driving left to right; simultaneously, a different set of n cars\n are driving right to left. The two sets of cars start out being very far from\n each other. All cars move in the same speed. Two cars are said to collide\n when a car that's moving left to right hits a car that's moving right to left.\n However, the cars are infinitely sturdy and strong; as a result, they continue moving\n in their trajectory as if they did not collide.\n\n This function outputs the number of such collisions.\n \"\"\"\n # TODO: Implement me!\n pass\n\n", "def car_race_collision(n: int) -> int:\n \"\"\"\n Imagine a road that's a perfectly straight infinitely long line.\n n cars are driving left to right; simultaneously, a different set of n cars\n are driving right to left. The two sets of cars start out being very far from\n each other. All cars move in the same speed. Two cars are said to collide\n when a car that's moving left to right hits a car that's moving right to left.\n However, the cars are infinitely sturdy and strong; as a result, they continue moving\n in their trajectory as if they did not collide.\n\n This function outputs the number of such collisions.\n \"\"\"\n # TODO: Implement me!\n pass\n\n"], ["from typing import List\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input to this function is a string representing musical notes in a special ASCII format.\n Your task is to parse this string and return list of integers corresponding to how many beats does each\n not last.\n\n Here is a legend:\n 'o' - whole note, lasts four beats\n 'o|' - half note, lasts two beats\n '.|' - quater note, lasts one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n notes = []\n for note in music_string:\n if note == 'o':\n notes.append(4)\n elif note == 'o|':\n notes.append(2)\n elif note == '.|':\n notes.append(1)\n elif note == 'o o':\n notes.append(4)\n notes.append(4)\n elif note == 'o o|':\n notes.append(2)\n notes.append(2)\n elif note == '.| .|':\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)", "from typing import List\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input to this function is a string representing musical notes in a special ASCII format.\n Your task is to parse this string and return list of integers corresponding to how many beats does each\n not last.\n\n Here is a legend:\n 'o' - whole note, lasts four beats\n 'o|' - half note, lasts two beats\n '.|' - quater note, lasts one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n notes = []\n for note in music_string:\n if note == 'o':\n notes.append(4)\n elif note == 'o|':\n notes.append(2)\n elif note == '.|':\n notes.append(1)\n elif note == 'o o':\n notes.append(4)\n notes.append(4)\n elif note == 'o o|':\n notes.append(2)\n notes.append(2)\n elif note == 'o .|':\n notes.append(1)\n notes.append(1)\n elif note == 'o o o':\n notes.append(4)\n notes.append(4)\n notes.append(4)\n elif note == 'o o o|':\n notes.append(2)\n notes.append(2)\n notes.append(2)\n elif note == 'o o .|':\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n elif note == 'o o o o':\n notes.append(4)\n notes.append(4)\n notes.append(4)\n notes.append(4)\n elif note == 'o o o o|':\n notes.append(2)\n notes.append(2)\n notes.append(2)\n notes.append(2)\n elif note == 'o o o .|':\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes.append(1)\n notes", "from typing import List\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input to this function is a string representing musical notes in a special ASCII format.\n Your task is to parse this string and return list of integers corresponding to how many beats does each\n not last.\n\n Here is a legend:\n 'o' - whole note, lasts four beats\n 'o|' - half note, lasts two beats\n '.|' - quater note, lasts one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n notes = []\n for char in music_string:\n if char == 'o':\n notes.append(4)\n elif char == 'o|':\n notes.append(2)\n elif char == '.|':\n notes.append(1)\n return notes\n", "from typing import List\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input to this function is a string representing musical notes in a special ASCII format.\n Your task is to parse this string and return list of integers corresponding to how many beats does each\n not last.\n\n Here is a legend:\n 'o' - whole note, lasts four beats\n 'o|' - half note, lasts two beats\n '.|' - quater note, lasts one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n notes = []\n for note in music_string:\n if note == 'o':\n notes.append(4)\n elif note == 'o|':\n notes.append(2)\n elif note == '.|':\n notes.append(1)\n return notes\n", "from typing import List\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input to this function is a string representing musical notes in a special ASCII format.\n Your task is to parse this string and return list of integers corresponding to how many beats does each\n not last.\n\n Here is a legend:\n 'o' - whole note, lasts four beats\n 'o|' - half note, lasts two beats\n '.|' - quater note, lasts one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n notes = []\n for note in music_string:\n if note == 'o':\n notes.append(4)\n elif note == 'o|':\n notes.append(2)\n elif note == '.|':\n notes.append(1)\n return notes\n"], ["def decimal_to_binary(decimal: int) -> str:\n \"\"\"You will be given a number in decimal form and your task is to convert it to\n binary format. The function should return a string, with each character representing a binary\n number. Each character in the string will be '0' or '1'.\n\n There will be an extra couple of characters 'db' at the beginning and at the end of the string.\n The extra characters are there to help with the format.\n\n Examples:\n >>> decimal_to_binary(15)\n 'db1111db'\n >>> decimal_to_binary(32)\n 'db100000db'\n \"\"\"\n binary = \"\"\n while decimal > 0:\n binary = str(decimal % 2) + binary\n decimal //= 2\n return binary\n\n", "def decimal_to_binary(decimal: int) -> str:\n \"\"\"You will be given a number in decimal form and your task is to convert it to\n binary format. The function should return a string, with each character representing a binary\n number. Each character in the string will be '0' or '1'.\n\n There will be an extra couple of characters 'db' at the beginning and at the end of the string.\n The extra characters are there to help with the format.\n\n Examples:\n >>> decimal_to_binary(15)\n 'db1111db'\n >>> decimal_to_binary(32)\n 'db100000db'\n \"\"\"\n binary = \"\"\n while decimal > 0:\n binary = str(decimal % 2) + binary\n decimal //= 2\n return \"db\" + binary\n\n", "def decimal_to_binary(decimal: int) -> str:\n \"\"\"You will be given a number in decimal form and your task is to convert it to\n binary format. The function should return a string, with each character representing a binary\n number. Each character in the string will be '0' or '1'.\n\n There will be an extra couple of characters 'db' at the beginning and at the end of the string.\n The extra characters are there to help with the format.\n\n Examples:\n >>> decimal_to_binary(15)\n 'db1111db'\n >>> decimal_to_binary(32)\n 'db100000db'\n \"\"\"\n binary_str = \"\"\n while decimal > 0:\n binary_str = str(decimal % 2) + binary_str\n decimal //= 2\n return \"db\" + binary_str\n\n", "def decimal_to_binary(decimal: int) -> str:\n \"\"\"You will be given a number in decimal form and your task is to convert it to\n binary format. The function should return a string, with each character representing a binary\n number. Each character in the string will be '0' or '1'.\n\n There will be an extra couple of characters 'db' at the beginning and at the end of the string.\n The extra characters are there to help with the format.\n\n Examples:\n >>> decimal_to_binary(15)\n 'db1111db'\n >>> decimal_to_binary(32)\n 'db100000db'\n \"\"\"\n if decimal < 0:\n raise ValueError(\"The number must be positive.\")\n\n if decimal == 0:\n return \"0\"\n\n if decimal == 1:\n return \"1\"\n\n result = \"\"\n while decimal > 0:\n result = str(decimal % 2) + result\n decimal //= 2\n\n return result\n\n", "def decimal_to_binary(decimal: int) -> str:\n \"\"\"You will be given a number in decimal form and your task is to convert it to\n binary format. The function should return a string, with each character representing a binary\n number. Each character in the string will be '0' or '1'.\n\n There will be an extra couple of characters 'db' at the beginning and at the end of the string.\n The extra characters are there to help with the format.\n\n Examples:\n >>> decimal_to_binary(15)\n 'db1111db'\n >>> decimal_to_binary(32)\n 'db100000db'\n \"\"\"\n if decimal < 0:\n raise ValueError(\"The number must be positive.\")\n\n if decimal == 0:\n return \"0\"\n\n result = \"\"\n while decimal > 0:\n result = str(decimal % 2) + result\n decimal //= 2\n\n return \"db\" + result\n\n"], ["from typing import List\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\" Return list of all prefixes from shortest to longest of the input string\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\n \"\"\"\n prefixes = []\n for i in range(len(string)):\n prefix = string[:i+1]\n if prefix not in prefixes:\n prefixes.append(prefix)\n return prefixes\n", "from typing import List\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\" Return list of all prefixes from shortest to longest of the input string\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\n \"\"\"\n return [string[:i] for i in range(len(string) + 1)]\n", "from typing import List\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\" Return list of all prefixes from shortest to longest of the input string\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\n \"\"\"\n prefixes = []\n for i in range(len(string)):\n prefixes.append(string[:i+1])\n return prefixes\n", "from typing import List\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\" Return list of all prefixes from shortest to longest of the input string\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\n \"\"\"\n return [string[:i] for i in range(len(string) + 1)]\n", "from typing import List\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\" Return list of all prefixes from shortest to longest of the input string\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\n \"\"\"\n return [string[:i] for i in range(1, len(string) + 1)]\n"], ["def add(x: int, y: int) -> int:\n \"\"\"Add two numbers x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n return x + y\n\n", "def add(x: int, y: int) -> int:\n \"\"\"Add two numbers x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n return x + y\n\n", "def add(x: int, y: int) -> int:\n \"\"\"Add two numbers x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n return x + y\n\n", "def add(x: int, y: int) -> int:\n \"\"\"Add two numbers x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n return x + y\n\n", "def add(x: int, y: int) -> int:\n \"\"\"Add two numbers x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n return x + y\n\n"], ["from typing import List\n\ndef eat(number: int, need: int, remaining: int) -> List[int]:\n \"\"\"\n You're a hungry rabbit, and you already have eaten a certain number of carrots,\n but now you need to eat more carrots to complete the day's meals.\n you should return an array of [ total number of eaten carrots after your meals,\n the number of carrots left after your meals ]\n if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n \n Example:\n >>> eat(5, 6, 10)\n [11, 4]\n >>> eat(4, 8, 9)\n [12, 1]\n >>> eat(1, 10, 10)\n [11, 0]\n >>> eat(2, 11, 5)\n [7, 0]\n \n Variables:\n @number : integer\n the number of carrots that you have eaten.\n @need : integer\n the number of carrots that you need to eat.\n @remaining : integer\n the number of remaining carrots thet exist in stock\n \n Constrain:\n * 0 <= number <= 1000\n * 0 <= need <= 1000\n * 0 <= remaining <= 1000\n\n Have fun :)\n \"\"\"\n if number <= 0 or need <= 0 or remaining <= 0:\n return [0, 0]\n if number >= need:\n return [number - need, 0]\n else:\n return [number, remaining]\n", "from typing import List\n\ndef eat(number: int, need: int, remaining: int) -> List[int]:\n \"\"\"\n You're a hungry rabbit, and you already have eaten a certain number of carrots,\n but now you need to eat more carrots to complete the day's meals.\n you should return an array of [ total number of eaten carrots after your meals,\n the number of carrots left after your meals ]\n if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n \n Example:\n >>> eat(5, 6, 10)\n [11, 4]\n >>> eat(4, 8, 9)\n [12, 1]\n >>> eat(1, 10, 10)\n [11, 0]\n >>> eat(2, 11, 5)\n [7, 0]\n \n Variables:\n @number : integer\n the number of carrots that you have eaten.\n @need : integer\n the number of carrots that you need to eat.\n @remaining : integer\n the number of remaining carrots thet exist in stock\n \n Constrain:\n * 0 <= number <= 1000\n * 0 <= need <= 1000\n * 0 <= remaining <= 1000\n\n Have fun :)\n \"\"\"\n if number < 0 or need < 0 or remaining < 0:\n return []\n if number == 0:\n return [0, need]\n if need == 0:\n return [number, 0]\n if remaining == 0:\n return [number, need]\n if need > remaining:\n return [number, remaining]\n return [number, need - remaining]\n", "from typing import List\n\ndef eat(number: int, need: int, remaining: int) -> List[int]:\n \"\"\"\n You're a hungry rabbit, and you already have eaten a certain number of carrots,\n but now you need to eat more carrots to complete the day's meals.\n you should return an array of [ total number of eaten carrots after your meals,\n the number of carrots left after your meals ]\n if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n \n Example:\n >>> eat(5, 6, 10)\n [11, 4]\n >>> eat(4, 8, 9)\n [12, 1]\n >>> eat(1, 10, 10)\n [11, 0]\n >>> eat(2, 11, 5)\n [7, 0]\n \n Variables:\n @number : integer\n the number of carrots that you have eaten.\n @need : integer\n the number of carrots that you need to eat.\n @remaining : integer\n the number of remaining carrots thet exist in stock\n \n Constrain:\n * 0 <= number <= 1000\n * 0 <= need <= 1000\n * 0 <= remaining <= 1000\n\n Have fun :)\n \"\"\"\n if number < need:\n return [number, 0]\n else:\n return [number - need, number]\n", "from typing import List\n\ndef eat(number: int, need: int, remaining: int) -> List[int]:\n \"\"\"\n You're a hungry rabbit, and you already have eaten a certain number of carrots,\n but now you need to eat more carrots to complete the day's meals.\n you should return an array of [ total number of eaten carrots after your meals,\n the number of carrots left after your meals ]\n if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n \n Example:\n >>> eat(5, 6, 10)\n [11, 4]\n >>> eat(4, 8, 9)\n [12, 1]\n >>> eat(1, 10, 10)\n [11, 0]\n >>> eat(2, 11, 5)\n [7, 0]\n \n Variables:\n @number : integer\n the number of carrots that you have eaten.\n @need : integer\n the number of carrots that you need to eat.\n @remaining : integer\n the number of remaining carrots thet exist in stock\n \n Constrain:\n * 0 <= number <= 1000\n * 0 <= need <= 1000\n * 0 <= remaining <= 1000\n\n Have fun :)\n \"\"\"\n if remaining < need:\n return [0, remaining]\n else:\n return [number + need - remaining, remaining]\n", "from typing import List\n\ndef eat(number: int, need: int, remaining: int) -> List[int]:\n \"\"\"\n You're a hungry rabbit, and you already have eaten a certain number of carrots,\n but now you need to eat more carrots to complete the day's meals.\n you should return an array of [ total number of eaten carrots after your meals,\n the number of carrots left after your meals ]\n if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n \n Example:\n >>> eat(5, 6, 10)\n [11, 4]\n >>> eat(4, 8, 9)\n [12, 1]\n >>> eat(1, 10, 10)\n [11, 0]\n >>> eat(2, 11, 5)\n [7, 0]\n \n Variables:\n @number : integer\n the number of carrots that you have eaten.\n @need : integer\n the number of carrots that you need to eat.\n @remaining : integer\n the number of remaining carrots thet exist in stock\n \n Constrain:\n * 0 <= number <= 1000\n * 0 <= need <= 1000\n * 0 <= remaining <= 1000\n\n Have fun :)\n \"\"\"\n if number < need:\n return [0, 0]\n if number == need:\n return [number, 0]\n if remaining < need:\n return [number, 0]\n if remaining == need:\n return [number, remaining]\n return [number - need, remaining - need]\n"], ["from typing import List\n\ndef max_fill(grid: List[List[int]], capacity: int) -> int:\n \"\"\"\n You are given a rectangular grid of wells. Each row represents a single well,\n and each 1 in a row represents a single unit of water.\n Each well has a corresponding bucket that can be used to extract water from it, \n and all buckets have the same capacity.\n Your task is to use the buckets to empty the wells.\n Output the number of times you need to lower the buckets.\n\n Example 1:\n >>> max_fill([[0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]], 1)\n 6\n\n Example 2:\n >>> max_fill([[0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 1, 1]], 2)\n 5\n \n Example 3:\n >>> max_fill([[0, 0, 0], [0, 0, 0]], 5)\n 0\n\n Constraints:\n * all wells have the same length\n * 1 <= grid.length <= 10^2\n * 1 <= grid[:,1].length <= 10^2\n * grid[i][j] -> 0 | 1\n * 1 <= capacity <= 10\n \"\"\"\n # 1. Build a dict of buckets\n # 2. Iterate over each row\n # 3. Iterate over each column\n # 4. If the current bucket is full, remove the current bucket\n # 5. If the current bucket is empty, add the current bucket to the dict\n # 6. Return the number of times we need to lower the buckets\n # 7. Time: O(n^2)\n # 8. Space: O(n)\n buckets = {}\n for i in range(len(grid)):\n for j in range(len(grid[0])):\n if grid[i][j] == 1:\n if i not in buckets:\n buckets[i] = []\n buckets[i].append(j)\n # 1. Build a dict of buckets\n # 2. Iterate over each", "from typing import List\n\ndef max_fill(grid: List[List[int]], capacity: int) -> int:\n \"\"\"\n You are given a rectangular grid of wells. Each row represents a single well,\n and each 1 in a row represents a single unit of water.\n Each well has a corresponding bucket that can be used to extract water from it, \n and all buckets have the same capacity.\n Your task is to use the buckets to empty the wells.\n Output the number of times you need to lower the buckets.\n\n Example 1:\n >>> max_fill([[0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]], 1)\n 6\n\n Example 2:\n >>> max_fill([[0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 1, 1]], 2)\n 5\n \n Example 3:\n >>> max_fill([[0, 0, 0], [0, 0, 0]], 5)\n 0\n\n Constraints:\n * all wells have the same length\n * 1 <= grid.length <= 10^2\n * 1 <= grid[:,1].length <= 10^2\n * grid[i][j] -> 0 | 1\n * 1 <= capacity <= 10\n \"\"\"\n # 1. \u5148\u628agrid\u7684\u6bcf\u4e00\u884c\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd\u904d\u5386\uff0c\u7136\u540e\u628a\u6bcf\u4e00\u884c\u7684\u6bcf\u4e00\u5217\u90fd", "from typing import List\n\ndef max_fill(grid: List[List[int]], capacity: int) -> int:\n \"\"\"\n You are given a rectangular grid of wells. Each row represents a single well,\n and each 1 in a row represents a single unit of water.\n Each well has a corresponding bucket that can be used to extract water from it, \n and all buckets have the same capacity.\n Your task is to use the buckets to empty the wells.\n Output the number of times you need to lower the buckets.\n\n Example 1:\n >>> max_fill([[0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]], 1)\n 6\n\n Example 2:\n >>> max_fill([[0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 1, 1]], 2)\n 5\n \n Example 3:\n >>> max_fill([[0, 0, 0], [0, 0, 0]], 5)\n 0\n\n Constraints:\n * all wells have the same length\n * 1 <= grid.length <= 10^2\n * 1 <= grid[:,1].length <= 10^2\n * grid[i][j] -> 0 | 1\n * 1 <= capacity <= 10\n \"\"\"\n # Solution 1\n # Time Complexity: O(m * n)\n # Space Complexity: O(m * n)\n m, n = len(grid), len(grid[0])\n used = [[False for _ in range(n)] for _ in range(m)]\n res = 0\n for i in range(m):\n for j in range(n):\n if grid[i][j] == 1 and not used[i][j]:\n res += 1\n used[i][j] = True\n dfs(grid, i, j, capacity, used, res)\n return res\n\n def dfs(grid, i, j, capacity, used, res):\n if i < 0 or i >= m or j < 0 or j >= n or grid[i][j] == 0:\n ", "from typing import List\n\ndef max_fill(grid: List[List[int]], capacity: int) -> int:\n \"\"\"\n You are given a rectangular grid of wells. Each row represents a single well,\n and each 1 in a row represents a single unit of water.\n Each well has a corresponding bucket that can be used to extract water from it, \n and all buckets have the same capacity.\n Your task is to use the buckets to empty the wells.\n Output the number of times you need to lower the buckets.\n\n Example 1:\n >>> max_fill([[0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]], 1)\n 6\n\n Example 2:\n >>> max_fill([[0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 1, 1]], 2)\n 5\n \n Example 3:\n >>> max_fill([[0, 0, 0], [0, 0, 0]], 5)\n 0\n\n Constraints:\n * all wells have the same length\n * 1 <= grid.length <= 10^2\n * 1 <= grid[:,1].length <= 10^2\n * grid[i][j] -> 0 | 1\n * 1 <= capacity <= 10\n \"\"\"\n # Solution 1\n # Time Complexity: O(m*n)\n # Space Complexity: O(m*n)\n # m is the number of rows, n is the number of columns\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in the grid\n # m*n is the total number of elements in", "from typing import List\n\ndef max_fill(grid: List[List[int]], capacity: int) -> int:\n \"\"\"\n You are given a rectangular grid of wells. Each row represents a single well,\n and each 1 in a row represents a single unit of water.\n Each well has a corresponding bucket that can be used to extract water from it, \n and all buckets have the same capacity.\n Your task is to use the buckets to empty the wells.\n Output the number of times you need to lower the buckets.\n\n Example 1:\n >>> max_fill([[0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]], 1)\n 6\n\n Example 2:\n >>> max_fill([[0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 1, 1]], 2)\n 5\n \n Example 3:\n >>> max_fill([[0, 0, 0], [0, 0, 0]], 5)\n 0\n\n Constraints:\n * all wells have the same length\n * 1 <= grid.length <= 10^2\n * 1 <= grid[:,1].length <= 10^2\n * grid[i][j] -> 0 | 1\n * 1 <= capacity <= 10\n \"\"\"\n # 1st solution\n # return sum(1 for row in grid for col in row if col == 1)\n\n # 2nd solution\n # return sum(1 for row in grid for col in row if col == 1)\n\n # 3rd solution\n # return sum(1 for row in grid for col in row if col == 1)\n\n # 4th solution\n # return sum(1 for row in grid for col in row if col == 1)\n\n # 5th solution\n # return sum(1 for row in grid for col in row if col == 1)\n\n # 6th solution\n # return sum(1 for row in grid for col in row if col == 1)\n\n # 7th solution\n # return sum(1 for row in grid for col in row if col == 1)"], ["from typing import List\n\ndef do_algebra(operator: List[str], operand: List[int]) -> int:\n \"\"\"\n Given two lists operator, and operand. The first list has basic algebra operations, and \n the second list is a list of integers. Use the two given lists to build the algebric \n expression and return the evaluation of this expression.\n\n The basic algebra operations:\n Addition ( + ) \n Subtraction ( - ) \n Multiplication ( * ) \n Floor division ( // ) \n Exponentiation ( ** ) \n\n Example:\n operator['+', '*', '-']\n array = [2, 3, 4, 5]\n result = 2 + 3 * 4 - 5\n => result = 9\n\n Note:\n The length of operator list is equal to the length of operand list minus one.\n Operand is a list of of non-negative integers.\n Operator list has at least one operator, and operand list has at least two operands.\n\n \"\"\"\n if len(operator) == 0:\n return operand[0]\n elif len(operator) == 1:\n return operator[0] * operand[0]\n else:\n return operator[0] * do_algebra(operator[1:], operand)\n", "from typing import List\n\ndef do_algebra(operator: List[str], operand: List[int]) -> int:\n \"\"\"\n Given two lists operator, and operand. The first list has basic algebra operations, and \n the second list is a list of integers. Use the two given lists to build the algebric \n expression and return the evaluation of this expression.\n\n The basic algebra operations:\n Addition ( + ) \n Subtraction ( - ) \n Multiplication ( * ) \n Floor division ( // ) \n Exponentiation ( ** ) \n\n Example:\n operator['+', '*', '-']\n array = [2, 3, 4, 5]\n result = 2 + 3 * 4 - 5\n => result = 9\n\n Note:\n The length of operator list is equal to the length of operand list minus one.\n Operand is a list of of non-negative integers.\n Operator list has at least one operator, and operand list has at least two operands.\n\n \"\"\"\n if len(operator) == 0:\n return operand[0]\n elif len(operator) == 1:\n return operator[0] * operand[0]\n else:\n return operator[0] * do_algebra(operator[1:], operand[1:])\n", "from typing import List\n\ndef do_algebra(operator: List[str], operand: List[int]) -> int:\n \"\"\"\n Given two lists operator, and operand. The first list has basic algebra operations, and \n the second list is a list of integers. Use the two given lists to build the algebric \n expression and return the evaluation of this expression.\n\n The basic algebra operations:\n Addition ( + ) \n Subtraction ( - ) \n Multiplication ( * ) \n Floor division ( // ) \n Exponentiation ( ** ) \n\n Example:\n operator['+', '*', '-']\n array = [2, 3, 4, 5]\n result = 2 + 3 * 4 - 5\n => result = 9\n\n Note:\n The length of operator list is equal to the length of operand list minus one.\n Operand is a list of of non-negative integers.\n Operator list has at least one operator, and operand list has at least two operands.\n\n \"\"\"\n if len(operator) != len(operand) - 1:\n raise Exception('operator and operand list length must be equal')\n\n result = 0\n for i in range(len(operator)):\n if operator[i] == '+':\n result += operand[i]\n elif operator[i] == '-':\n result -= operand[i]\n elif operator[i] == '*':\n result *= operand[i]\n elif operator[i] == '/':\n result //= operand[i]\n elif operator[i] == '**':\n result **= operand[i]\n\n return result\n", "from typing import List\n\ndef do_algebra(operator: List[str], operand: List[int]) -> int:\n \"\"\"\n Given two lists operator, and operand. The first list has basic algebra operations, and \n the second list is a list of integers. Use the two given lists to build the algebric \n expression and return the evaluation of this expression.\n\n The basic algebra operations:\n Addition ( + ) \n Subtraction ( - ) \n Multiplication ( * ) \n Floor division ( // ) \n Exponentiation ( ** ) \n\n Example:\n operator['+', '*', '-']\n array = [2, 3, 4, 5]\n result = 2 + 3 * 4 - 5\n => result = 9\n\n Note:\n The length of operator list is equal to the length of operand list minus one.\n Operand is a list of of non-negative integers.\n Operator list has at least one operator, and operand list has at least two operands.\n\n \"\"\"\n if len(operator) != len(operand) - 1:\n raise ValueError('operator and operand must have the same length')\n\n result = 0\n for i in range(len(operator)):\n if operator[i] == '+':\n result += operand[i]\n elif operator[i] == '-':\n result -= operand[i]\n elif operator[i] == '*':\n result *= operand[i]\n elif operator[i] == '/':\n result //= operand[i]\n elif operator[i] == '**':\n result **= operand[i]\n\n return result\n", "from typing import List\n\ndef do_algebra(operator: List[str], operand: List[int]) -> int:\n \"\"\"\n Given two lists operator, and operand. The first list has basic algebra operations, and \n the second list is a list of integers. Use the two given lists to build the algebric \n expression and return the evaluation of this expression.\n\n The basic algebra operations:\n Addition ( + ) \n Subtraction ( - ) \n Multiplication ( * ) \n Floor division ( // ) \n Exponentiation ( ** ) \n\n Example:\n operator['+', '*', '-']\n array = [2, 3, 4, 5]\n result = 2 + 3 * 4 - 5\n => result = 9\n\n Note:\n The length of operator list is equal to the length of operand list minus one.\n Operand is a list of of non-negative integers.\n Operator list has at least one operator, and operand list has at least two operands.\n\n \"\"\"\n # Your code here\n if len(operator) == 1:\n if operator[0] == '+':\n return operand[0] + operand[1]\n elif operator[0] == '-':\n return operand[0] - operand[1]\n elif operator[0] == '*':\n return operand[0] * operand[1]\n elif operator[0] == '//':\n return operand[0] // operand[1]\n elif operator[0] == '**':\n return operand[0] ** operand[1]\n else:\n return 0\n else:\n if operator[0] == '+':\n return do_algebra(operator[1:], operand) + do_algebra(operator[1:], operand)\n elif operator[0] == '-':\n return do_algebra(operator[1:], operand) - do_algebra(operator[1:], operand)\n elif operator[0] == '*':\n return do_algebra(operator[1:], operand) * do_algebra(operator[1:], operand)\n elif operator[0] == '//':\n return do_algebra(operator[1:], operand) // do_algebra(operator[1:], operand)\n elif operator[0] == '**':\n return do_algebra(operator[1:], operand) ** do_algebra(operator[1:], operand)\n else:\n return 0\n"], ["def flip_case(string: str) -> str:\n \"\"\" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.\n >>> flip_case('Hello')\n 'hELLO'\n \"\"\"\n return string.lower() if string.islower() else string.upper()\n\n", "def flip_case(string: str) -> str:\n \"\"\" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.\n >>> flip_case('Hello')\n 'hELLO'\n \"\"\"\n return string.lower() if string.islower() else string.upper()\n\n", "def flip_case(string: str) -> str:\n \"\"\" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.\n >>> flip_case('Hello')\n 'hELLO'\n \"\"\"\n return string.lower() if string.islower() else string.upper()\n\n", "def flip_case(string: str) -> str:\n \"\"\" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.\n >>> flip_case('Hello')\n 'hELLO'\n \"\"\"\n return string.lower() if string.islower() else string.upper()\n\n", "def flip_case(string: str) -> str:\n \"\"\" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.\n >>> flip_case('Hello')\n 'hELLO'\n \"\"\"\n return string.lower() if string.islower() else string.upper()\n\n"], ["from typing import List\n\ndef by_length(arr: List[int]) -> List[str]:\n \"\"\"\n Given an array of integers, sort the integers that are between 1 and 9 inclusive,\n reverse the resulting array, and then replace each digit by its corresponding name from\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\".\n\n For example:\n >>> by_length([2, 1, 1, 4, 5, 8, 2, 3])\n ['Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One']\n \n If the array is empty, return an empty array:\n >>> by_length([])\n []\n \n If the array has any strange number ignore it:\n >>> by_length([1, -1, 55])\n ['One']\n \"\"\"\n if not arr:\n return []\n arr = sorted(arr)\n return [f\"{i}{name}\" for i, name in enumerate(reversed(arr))]\n", "from typing import List\n\ndef by_length(arr: List[int]) -> List[str]:\n \"\"\"\n Given an array of integers, sort the integers that are between 1 and 9 inclusive,\n reverse the resulting array, and then replace each digit by its corresponding name from\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\".\n\n For example:\n >>> by_length([2, 1, 1, 4, 5, 8, 2, 3])\n ['Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One']\n \n If the array is empty, return an empty array:\n >>> by_length([])\n []\n \n If the array has any strange number ignore it:\n >>> by_length([1, -1, 55])\n ['One']\n \"\"\"\n if len(arr) == 0:\n return []\n if any(x < 1 or x > 9 for x in arr):\n return []\n arr = sorted(arr)\n arr = [f\"{x}\" for x in arr]\n arr = [x.replace(\"1\", \"One\").replace(\"2\", \"Two\").replace(\"3\", \"Three\").replace(\"4\", \"Four\").replace(\"5\", \"Five\").replace(\"6\", \"Six\").replace(\"7\", \"Seven\").replace(\"8\", \"Eight\").replace(\"9\", \"Nine\")]\n return arr\n", "from typing import List\n\ndef by_length(arr: List[int]) -> List[str]:\n \"\"\"\n Given an array of integers, sort the integers that are between 1 and 9 inclusive,\n reverse the resulting array, and then replace each digit by its corresponding name from\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\".\n\n For example:\n >>> by_length([2, 1, 1, 4, 5, 8, 2, 3])\n ['Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One']\n \n If the array is empty, return an empty array:\n >>> by_length([])\n []\n \n If the array has any strange number ignore it:\n >>> by_length([1, -1, 55])\n ['One']\n \"\"\"\n if not arr:\n return []\n arr.sort()\n arr_rev = arr[::-1]\n arr_rev_str = [name for name in arr_rev if name != 0]\n return arr_rev_str\n", "from typing import List\n\ndef by_length(arr: List[int]) -> List[str]:\n \"\"\"\n Given an array of integers, sort the integers that are between 1 and 9 inclusive,\n reverse the resulting array, and then replace each digit by its corresponding name from\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\".\n\n For example:\n >>> by_length([2, 1, 1, 4, 5, 8, 2, 3])\n ['Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One']\n \n If the array is empty, return an empty array:\n >>> by_length([])\n []\n \n If the array has any strange number ignore it:\n >>> by_length([1, -1, 55])\n ['One']\n \"\"\"\n if len(arr) == 0:\n return []\n arr.sort()\n arr = [f'{i}' for i in arr]\n arr = [i.replace('1', 'One').replace('2', 'Two').replace('3', 'Three').replace('4', 'Four').replace('5', 'Five').replace('6', 'Six').replace('7', 'Seven').replace('8', 'Eight').replace('9', 'Nine')]\n return arr\n", "from typing import List\n\ndef by_length(arr: List[int]) -> List[str]:\n \"\"\"\n Given an array of integers, sort the integers that are between 1 and 9 inclusive,\n reverse the resulting array, and then replace each digit by its corresponding name from\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\".\n\n For example:\n >>> by_length([2, 1, 1, 4, 5, 8, 2, 3])\n ['Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One']\n \n If the array is empty, return an empty array:\n >>> by_length([])\n []\n \n If the array has any strange number ignore it:\n >>> by_length([1, -1, 55])\n ['One']\n \"\"\"\n if not arr:\n return []\n arr.sort()\n arr = [str(i) for i in arr]\n arr = [i for i in arr if i != '0']\n arr = [i for i in arr if i != '1']\n arr = [i for i in arr if i != '2']\n arr = [i for i in arr if i != '3']\n arr = [i for i in arr if i != '4']\n arr = [i for i in arr if i != '5']\n arr = [i for i in arr if i != '6']\n arr = [i for i in arr if i != '7']\n arr = [i for i in arr if i != '8']\n arr = [i for i in arr if i != '9']\n return arr\n"], ["from typing import List\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return list of prime factors of given integer in the order from smallest to largest.\n Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.\n Input number should be equal to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n if n <= 1:\n return []\n factors = []\n while n > 1:\n if n % 2 == 0:\n n //= 2\n else:\n factors.append(2)\n n -= 1\n if n > 1:\n factors.append(n)\n return factors\n", "from typing import List\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return list of prime factors of given integer in the order from smallest to largest.\n Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.\n Input number should be equal to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n factors = []\n while n > 1:\n if n % 2 == 0:\n n //= 2\n factors.append(2)\n else:\n factors.append(1)\n n -= 1\n return factors\n", "from typing import List\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return list of prime factors of given integer in the order from smallest to largest.\n Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.\n Input number should be equal to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n if n < 2:\n return []\n if n == 2:\n return [2]\n factors = []\n for i in range(2, int(n**0.5) + 1):\n while n % i == 0:\n factors.append(i)\n n //= i\n if n > 1:\n factors.append(n)\n return factors\n", "from typing import List\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return list of prime factors of given integer in the order from smallest to largest.\n Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.\n Input number should be equal to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n if n == 1:\n return [1]\n factors = []\n while n % 2 == 0:\n factors.append(2)\n n //= 2\n for i in range(3, int(n ** 0.5) + 1, 2):\n while n % i == 0:\n factors.append(i)\n n //= i\n if n > 1:\n factors.append(n)\n return factors\n", "from typing import List\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return list of prime factors of given integer in the order from smallest to largest.\n Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.\n Input number should be equal to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n if n == 1:\n return []\n factors = []\n while n > 1:\n if n % 2 == 0:\n n //= 2\n factors.append(2)\n else:\n factors.append(1)\n n -= 1\n return factors\n"], ["from typing import List\n\ndef count_up_to(n: int) -> List[int]:\n \"\"\"Implement a function that takes an non-negative integer and returns an array of the first n\n integers that are prime numbers and less than n.\n for example:\n >>> count_up_to(5)\n [2, 3]\n >>> count_up_to(11)\n [2, 3, 5, 7]\n >>> count_up_to(0)\n []\n >>> count_up_to(20)\n [2, 3, 5, 7, 11, 13, 17, 19]\n >>> count_up_to(1)\n []\n >>> count_up_to(18)\n [2, 3, 5, 7, 11, 13, 17]\n \"\"\"\n if n <= 1:\n return []\n primes = [True] * (n + 1)\n primes[0] = primes[1] = False\n for i in range(2, int(n ** 0.5) + 1):\n if primes[i]:\n for j in range(i * i, n + 1, i):\n primes[j] = False\n return [i for i in range(2, n + 1) if primes[i]]\n", "from typing import List\n\ndef count_up_to(n: int) -> List[int]:\n \"\"\"Implement a function that takes an non-negative integer and returns an array of the first n\n integers that are prime numbers and less than n.\n for example:\n >>> count_up_to(5)\n [2, 3]\n >>> count_up_to(11)\n [2, 3, 5, 7]\n >>> count_up_to(0)\n []\n >>> count_up_to(20)\n [2, 3, 5, 7, 11, 13, 17, 19]\n >>> count_up_to(1)\n []\n >>> count_up_to(18)\n [2, 3, 5, 7, 11, 13, 17]\n \"\"\"\n # TODO: Write your code here.\n return [i for i in range(2, n+1) if all(i % j != 0 for j in range(2, i))]\n", "from typing import List\n\ndef count_up_to(n: int) -> List[int]:\n \"\"\"Implement a function that takes an non-negative integer and returns an array of the first n\n integers that are prime numbers and less than n.\n for example:\n >>> count_up_to(5)\n [2, 3]\n >>> count_up_to(11)\n [2, 3, 5, 7]\n >>> count_up_to(0)\n []\n >>> count_up_to(20)\n [2, 3, 5, 7, 11, 13, 17, 19]\n >>> count_up_to(1)\n []\n >>> count_up_to(18)\n [2, 3, 5, 7, 11, 13, 17]\n \"\"\"\n # TODO: Implement this function\n pass\n", "from typing import List\n\ndef count_up_to(n: int) -> List[int]:\n \"\"\"Implement a function that takes an non-negative integer and returns an array of the first n\n integers that are prime numbers and less than n.\n for example:\n >>> count_up_to(5)\n [2, 3]\n >>> count_up_to(11)\n [2, 3, 5, 7]\n >>> count_up_to(0)\n []\n >>> count_up_to(20)\n [2, 3, 5, 7, 11, 13, 17, 19]\n >>> count_up_to(1)\n []\n >>> count_up_to(18)\n [2, 3, 5, 7, 11, 13, 17]\n \"\"\"\n if n <= 1:\n return []\n primes = [True] * (n + 1)\n primes[0] = primes[1] = False\n for i in range(2, int(n ** 0.5) + 1):\n if primes[i]:\n for j in range(i * i, n + 1, i):\n primes[j] = False\n return [i for i in range(2, n + 1) if primes[i]]\n", "from typing import List\n\ndef count_up_to(n: int) -> List[int]:\n \"\"\"Implement a function that takes an non-negative integer and returns an array of the first n\n integers that are prime numbers and less than n.\n for example:\n >>> count_up_to(5)\n [2, 3]\n >>> count_up_to(11)\n [2, 3, 5, 7]\n >>> count_up_to(0)\n []\n >>> count_up_to(20)\n [2, 3, 5, 7, 11, 13, 17, 19]\n >>> count_up_to(1)\n []\n >>> count_up_to(18)\n [2, 3, 5, 7, 11, 13, 17]\n \"\"\"\n primes = [2, 3]\n for i in range(3, n):\n if all(i % prime == 0 for prime in primes):\n primes.append(i)\n return primes\n"], ["from typing import List\n\ndef unique(l: List[int]) -> List[int]:\n \"\"\"Return sorted unique elements in a list\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]\n \"\"\"\n return sorted(set(l))\n", "from typing import List\n\ndef unique(l: List[int]) -> List[int]:\n \"\"\"Return sorted unique elements in a list\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]\n \"\"\"\n return sorted(set(l))\n", "from typing import List\n\ndef unique(l: List[int]) -> List[int]:\n \"\"\"Return sorted unique elements in a list\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]\n \"\"\"\n return sorted(set(l))\n", "from typing import List\n\ndef unique(l: List[int]) -> List[int]:\n \"\"\"Return sorted unique elements in a list\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]\n \"\"\"\n return sorted(set(l))\n", "from typing import List\n\ndef unique(l: List[int]) -> List[int]:\n \"\"\"Return sorted unique elements in a list\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]\n \"\"\"\n return sorted(set(l))\n"], ["from typing import List\n\ndef total_match(lst1: List[str], lst2: List[str]) -> List[str]:\n \"\"\"\n Write a function that accepts two lists of strings and returns the list that has \n total number of chars in the all strings of the list less than the other list.\n\n if the two lists have the same number of chars, return the first list.\n\n Examples\n >>> total_match([], [])\n []\n >>> total_match(['hi', 'admin'], ['hI', 'Hi'])\n ['hI', 'Hi']\n >>> total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])\n ['hi', 'admin']\n >>> total_match(['hi', 'admin'], ['hI', 'hi', 'hi'])\n ['hI', 'hi', 'hi']\n >>> total_match(['4'], ['1', '2', '3', '4', '5'])\n ['4']\n \"\"\"\n if len(lst1) == 0:\n return lst2\n if len(lst2) == 0:\n return lst1\n if len(lst1) == len(lst2):\n return lst1 if lst1 < lst2 else lst2\n return lst1 if len(lst1) < len(lst2) else lst2\n", "from typing import List\n\ndef total_match(lst1: List[str], lst2: List[str]) -> List[str]:\n \"\"\"\n Write a function that accepts two lists of strings and returns the list that has \n total number of chars in the all strings of the list less than the other list.\n\n if the two lists have the same number of chars, return the first list.\n\n Examples\n >>> total_match([], [])\n []\n >>> total_match(['hi', 'admin'], ['hI', 'Hi'])\n ['hI', 'Hi']\n >>> total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])\n ['hi', 'admin']\n >>> total_match(['hi', 'admin'], ['hI', 'hi', 'hi'])\n ['hI', 'hi', 'hi']\n >>> total_match(['4'], ['1', '2', '3', '4', '5'])\n ['4']\n \"\"\"\n if len(lst1) == 0:\n return lst2\n if len(lst2) == 0:\n return lst1\n if len(lst1) == len(lst2):\n return lst1 if lst1 < lst2 else lst2\n return lst1 if len(lst1) < len(lst2) else lst2\n", "from typing import List\n\ndef total_match(lst1: List[str], lst2: List[str]) -> List[str]:\n \"\"\"\n Write a function that accepts two lists of strings and returns the list that has \n total number of chars in the all strings of the list less than the other list.\n\n if the two lists have the same number of chars, return the first list.\n\n Examples\n >>> total_match([], [])\n []\n >>> total_match(['hi', 'admin'], ['hI', 'Hi'])\n ['hI', 'Hi']\n >>> total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])\n ['hi', 'admin']\n >>> total_match(['hi', 'admin'], ['hI', 'hi', 'hi'])\n ['hI', 'hi', 'hi']\n >>> total_match(['4'], ['1', '2', '3', '4', '5'])\n ['4']\n \"\"\"\n if len(lst1) == 0:\n return lst2\n if len(lst2) == 0:\n return lst1\n if len(lst1) == len(lst2):\n return lst1\n if len(lst1) < len(lst2):\n return total_match(lst2, lst1)\n return total_match(lst1, lst2)\n", "from typing import List\n\ndef total_match(lst1: List[str], lst2: List[str]) -> List[str]:\n \"\"\"\n Write a function that accepts two lists of strings and returns the list that has \n total number of chars in the all strings of the list less than the other list.\n\n if the two lists have the same number of chars, return the first list.\n\n Examples\n >>> total_match([], [])\n []\n >>> total_match(['hi', 'admin'], ['hI', 'Hi'])\n ['hI', 'Hi']\n >>> total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])\n ['hi', 'admin']\n >>> total_match(['hi', 'admin'], ['hI', 'hi', 'hi'])\n ['hI', 'hi', 'hi']\n >>> total_match(['4'], ['1', '2', '3', '4', '5'])\n ['4']\n \"\"\"\n if len(lst1) == 0:\n return lst2\n if len(lst2) == 0:\n return lst1\n if len(lst1) > len(lst2):\n return total_match(lst2, lst1)\n if len(lst1) < len(lst2):\n return total_match(lst1, lst2)\n if lst1 == lst2:\n return lst1\n return total_match(lst1, lst2)\n", "from typing import List\n\ndef total_match(lst1: List[str], lst2: List[str]) -> List[str]:\n \"\"\"\n Write a function that accepts two lists of strings and returns the list that has \n total number of chars in the all strings of the list less than the other list.\n\n if the two lists have the same number of chars, return the first list.\n\n Examples\n >>> total_match([], [])\n []\n >>> total_match(['hi', 'admin'], ['hI', 'Hi'])\n ['hI', 'Hi']\n >>> total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])\n ['hi', 'admin']\n >>> total_match(['hi', 'admin'], ['hI', 'hi', 'hi'])\n ['hI', 'hi', 'hi']\n >>> total_match(['4'], ['1', '2', '3', '4', '5'])\n ['4']\n \"\"\"\n if len(lst1) == 0:\n return lst2\n if len(lst2) == 0:\n return lst1\n if len(lst1) > len(lst2):\n return total_match(lst2, lst1)\n if len(lst1) < len(lst2):\n return total_match(lst1, lst2)\n if lst1[0] == lst2[0]:\n return total_match(lst1[1:], lst2[1:])\n return total_match(lst1[1:], lst2)\n"], ["from typing import List\n\ndef max_element(l: List[int]) -> int:\n \"\"\"Return maximum element in the list.\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n return max(l)\n", "from typing import List\n\ndef max_element(l: List[int]) -> int:\n \"\"\"Return maximum element in the list.\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n return max(l)\n", "from typing import List\n\ndef max_element(l: List[int]) -> int:\n \"\"\"Return maximum element in the list.\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n return max(l)\n", "from typing import List\n\ndef max_element(l: List[int]) -> int:\n \"\"\"Return maximum element in the list.\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n return max(l)\n", "from typing import List\n\ndef max_element(l: List[int]) -> int:\n \"\"\"Return maximum element in the list.\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n return max(l)\n"], ["def is_nested(string: str) -> bool:\n \"\"\"\n Create a function that takes a string as input which contains only square brackets.\n The function should return True if and only if there is a valid subsequence of brackets \n where at least one bracket in the subsequence is nested.\n\n >>> is_nested('[[]]')\n True\n >>> is_nested('[]]]]]]][[[[[]')\n False\n >>> is_nested('[][]')\n False\n >>> is_nested('[]')\n False\n >>> is_nested('[[][]]')\n True\n >>> is_nested('[[]][[')\n True\n \"\"\"\n stack = []\n for char in string:\n if char == '[':\n stack.append('[')\n elif char == ']':\n if not stack:\n return False\n if stack[-1] == '[':\n stack.pop()\n else:\n return False\n else:\n continue\n return not stack\n\n", "def is_nested(string: str) -> bool:\n \"\"\"\n Create a function that takes a string as input which contains only square brackets.\n The function should return True if and only if there is a valid subsequence of brackets \n where at least one bracket in the subsequence is nested.\n\n >>> is_nested('[[]]')\n True\n >>> is_nested('[]]]]]]][[[[[]')\n False\n >>> is_nested('[][]')\n False\n >>> is_nested('[]')\n False\n >>> is_nested('[[][]]')\n True\n >>> is_nested('[[]][[')\n True\n \"\"\"\n stack = []\n for char in string:\n if char == '[':\n stack.append(char)\n elif char == ']':\n if len(stack) == 0:\n return False\n elif stack[-1] == '[':\n stack.pop()\n else:\n return False\n return len(stack) == 0\n\n", "def is_nested(string: str) -> bool:\n \"\"\"\n Create a function that takes a string as input which contains only square brackets.\n The function should return True if and only if there is a valid subsequence of brackets \n where at least one bracket in the subsequence is nested.\n\n >>> is_nested('[[]]')\n True\n >>> is_nested('[]]]]]]][[[[[]')\n False\n >>> is_nested('[][]')\n False\n >>> is_nested('[]')\n False\n >>> is_nested('[[][]]')\n True\n >>> is_nested('[[]][[')\n True\n \"\"\"\n def is_nested_helper(string: str) -> bool:\n if not string:\n return True\n if string[0] == '[':\n return is_nested_helper(string[1:]) or is_nested_helper(string[:-1])\n return False\n\n return is_nested_helper(string)\n\n", "def is_nested(string: str) -> bool:\n \"\"\"\n Create a function that takes a string as input which contains only square brackets.\n The function should return True if and only if there is a valid subsequence of brackets \n where at least one bracket in the subsequence is nested.\n\n >>> is_nested('[[]]')\n True\n >>> is_nested('[]]]]]]][[[[[]')\n False\n >>> is_nested('[][]')\n False\n >>> is_nested('[]')\n False\n >>> is_nested('[[][]]')\n True\n >>> is_nested('[[]][[')\n True\n \"\"\"\n def is_nested_helper(string: str) -> bool:\n if len(string) == 0:\n return True\n if string[0] == '[':\n return is_nested_helper(string[1:]) or is_nested_helper(string[:-1])\n else:\n return False\n return is_nested_helper(string)\n\n", "def is_nested(string: str) -> bool:\n \"\"\"\n Create a function that takes a string as input which contains only square brackets.\n The function should return True if and only if there is a valid subsequence of brackets \n where at least one bracket in the subsequence is nested.\n\n >>> is_nested('[[]]')\n True\n >>> is_nested('[]]]]]]][[[[[]')\n False\n >>> is_nested('[][]')\n False\n >>> is_nested('[]')\n False\n >>> is_nested('[[][]]')\n True\n >>> is_nested('[[]][[')\n True\n \"\"\"\n stack = []\n for char in string:\n if char == '[':\n stack.append(char)\n elif char == ']':\n if len(stack) == 0:\n return False\n elif stack.pop() != '[':\n return False\n return len(stack) == 0\n\n"], ["from typing import Union\n\ndef rounded_avg(n: int, m: int) -> Union[str, int]:\n \"\"\"You are given two positive integers n and m, and your task is to compute the\n average of the integers from n through m (including n and m). \n Round the answer to the nearest integer and convert that to binary.\n If n is greater than m, return -1.\n Example:\n >>> rounded_avg(1, 5)\n '0b11'\n >>> rounded_avg(7, 5)\n -1\n >>> rounded_avg(10, 20)\n '0b1111'\n >>> rounded_avg(20, 33)\n '0b11010'\n \"\"\"\n if n > m:\n return -1\n return bin(n)[2:].zfill(m)\n", "from typing import Union\n\ndef rounded_avg(n: int, m: int) -> Union[str, int]:\n \"\"\"You are given two positive integers n and m, and your task is to compute the\n average of the integers from n through m (including n and m). \n Round the answer to the nearest integer and convert that to binary.\n If n is greater than m, return -1.\n Example:\n >>> rounded_avg(1, 5)\n '0b11'\n >>> rounded_avg(7, 5)\n -1\n >>> rounded_avg(10, 20)\n '0b1111'\n >>> rounded_avg(20, 33)\n '0b11010'\n \"\"\"\n if n > m:\n return -1\n else:\n return bin(n)[2:].zfill(m)\n", "from typing import Union\n\ndef rounded_avg(n: int, m: int) -> Union[str, int]:\n \"\"\"You are given two positive integers n and m, and your task is to compute the\n average of the integers from n through m (including n and m). \n Round the answer to the nearest integer and convert that to binary.\n If n is greater than m, return -1.\n Example:\n >>> rounded_avg(1, 5)\n '0b11'\n >>> rounded_avg(7, 5)\n -1\n >>> rounded_avg(10, 20)\n '0b1111'\n >>> rounded_avg(20, 33)\n '0b11010'\n \"\"\"\n if n > m:\n return -1\n return bin(n)[2:].zfill(m)\n", "from typing import Union\n\ndef rounded_avg(n: int, m: int) -> Union[str, int]:\n \"\"\"You are given two positive integers n and m, and your task is to compute the\n average of the integers from n through m (including n and m). \n Round the answer to the nearest integer and convert that to binary.\n If n is greater than m, return -1.\n Example:\n >>> rounded_avg(1, 5)\n '0b11'\n >>> rounded_avg(7, 5)\n -1\n >>> rounded_avg(10, 20)\n '0b1111'\n >>> rounded_avg(20, 33)\n '0b11010'\n \"\"\"\n if n > m:\n return -1\n else:\n return bin(n)[2:].zfill(m)\n", "from typing import Union\n\ndef rounded_avg(n: int, m: int) -> Union[str, int]:\n \"\"\"You are given two positive integers n and m, and your task is to compute the\n average of the integers from n through m (including n and m). \n Round the answer to the nearest integer and convert that to binary.\n If n is greater than m, return -1.\n Example:\n >>> rounded_avg(1, 5)\n '0b11'\n >>> rounded_avg(7, 5)\n -1\n >>> rounded_avg(10, 20)\n '0b1111'\n >>> rounded_avg(20, 33)\n '0b11010'\n \"\"\"\n if n > m:\n return -1\n else:\n return bin(n)[2:].zfill(m)\n"], ["from typing import List\n\ndef odd_count(lst: List[str]) -> List[str]:\n \"\"\"Given a list of strings, where each string consists of only digits, return a list.\n Each element i of the output should be \"the number of odd elements in the\n string i of the input.\" where all the i's should be replaced by the number\n of odd digits in the i'th string of the input.\n\n >>> odd_count(['1234567'])\n ['the number of odd elements 4n the str4ng 4 of the 4nput.']\n >>> odd_count(['3', '11111111'])\n ['the number of odd elements 1n the str1ng 1 of the 1nput.', 'the number of odd elements 8n the str8ng 8 of the 8nput.']\n \"\"\"\n odd_count = []\n for i in range(len(lst)):\n odd_count.append(str(len([x for x in lst[i] if x.isdigit()])))\n return odd_count\n", "from typing import List\n\ndef odd_count(lst: List[str]) -> List[str]:\n \"\"\"Given a list of strings, where each string consists of only digits, return a list.\n Each element i of the output should be \"the number of odd elements in the\n string i of the input.\" where all the i's should be replaced by the number\n of odd digits in the i'th string of the input.\n\n >>> odd_count(['1234567'])\n ['the number of odd elements 4n the str4ng 4 of the 4nput.']\n >>> odd_count(['3', '11111111'])\n ['the number of odd elements 1n the str1ng 1 of the 1nput.', 'the number of odd elements 8n the str8ng 8 of the 8nput.']\n \"\"\"\n odd_count = []\n for i in lst:\n odd_count.append(len([x for x in i if x.isdigit() and int(x)%2]))\n return odd_count\n", "from typing import List\n\ndef odd_count(lst: List[str]) -> List[str]:\n \"\"\"Given a list of strings, where each string consists of only digits, return a list.\n Each element i of the output should be \"the number of odd elements in the\n string i of the input.\" where all the i's should be replaced by the number\n of odd digits in the i'th string of the input.\n\n >>> odd_count(['1234567'])\n ['the number of odd elements 4n the str4ng 4 of the 4nput.']\n >>> odd_count(['3', '11111111'])\n ['the number of odd elements 1n the str1ng 1 of the 1nput.', 'the number of odd elements 8n the str8ng 8 of the 8nput.']\n \"\"\"\n return [f\"the number of odd elements {n} the str{n}ng {n} of the {n}put.\" for n in range(len(lst))]\n", "from typing import List\n\ndef odd_count(lst: List[str]) -> List[str]:\n \"\"\"Given a list of strings, where each string consists of only digits, return a list.\n Each element i of the output should be \"the number of odd elements in the\n string i of the input.\" where all the i's should be replaced by the number\n of odd digits in the i'th string of the input.\n\n >>> odd_count(['1234567'])\n ['the number of odd elements 4n the str4ng 4 of the 4nput.']\n >>> odd_count(['3', '11111111'])\n ['the number of odd elements 1n the str1ng 1 of the 1nput.', 'the number of odd elements 8n the str8ng 8 of the 8nput.']\n \"\"\"\n return [f'the number of odd elements {n} the str{n}ng {n} of the {n}put.' for n in lst]\n", "from typing import List\n\ndef odd_count(lst: List[str]) -> List[str]:\n \"\"\"Given a list of strings, where each string consists of only digits, return a list.\n Each element i of the output should be \"the number of odd elements in the\n string i of the input.\" where all the i's should be replaced by the number\n of odd digits in the i'th string of the input.\n\n >>> odd_count(['1234567'])\n ['the number of odd elements 4n the str4ng 4 of the 4nput.']\n >>> odd_count(['3', '11111111'])\n ['the number of odd elements 1n the str1ng 1 of the 1nput.', 'the number of odd elements 8n the str8ng 8 of the 8nput.']\n \"\"\"\n odd_count = []\n for i in lst:\n odd_count.append(len([x for x in i if x.isdigit() and int(x)%2 != 0]))\n return odd_count\n"], ["from typing import List\n\ndef move_one_ball(arr: List[int]) -> bool:\n \"\"\"We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The\n numbers in the array will be randomly ordered. Your task is to determine if\n it is possible to get an array sorted in non-decreasing order by performing \n the following operation on the given array:\n You are allowed to perform right shift operation any number of times.\n \n One right shift operation means shifting all elements of the array by one\n position in the right direction. The last element of the array will be moved to\n the starting position in the array i.e. 0th index. \n\n If it is possible to obtain the sorted array by performing the above operation\n then return True else return False.\n If the given array is empty then return True.\n\n Note: The given list is guaranteed to have unique elements.\n\n For Example:\n \n >>> move_one_ball([3, 4, 5, 1, 2])\n True\n Explanation: By performin 2 right shift operations, non-decreasing order can\n be achieved for the given array.\n >>> move_one_ball([3, 5, 4, 1, 2])\n False\n Explanation:It is not possible to get non-decreasing order for the given\n array by performing any number of right shift operations.\n \n \"\"\"\n if not arr:\n return True\n if len(arr) == 1:\n return True\n if len(arr) == 2:\n return arr[0] > arr[1]\n if len(arr) == 3:\n return arr[0] > arr[1] and arr[1] > arr[2]\n if len(arr) == 4:\n return arr[0] > arr[1] and arr[1] > arr[2] and arr[2] > arr[3]\n if len(arr) == 5:\n return arr[0] > arr[1] and arr[1] > arr[2] and arr[2] > arr[3] and arr[3] > arr[4]\n if len(arr) == 6:\n return arr[0] > arr[1] and arr[1] > arr[2] and arr[2] > arr[", "from typing import List\n\ndef move_one_ball(arr: List[int]) -> bool:\n \"\"\"We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The\n numbers in the array will be randomly ordered. Your task is to determine if\n it is possible to get an array sorted in non-decreasing order by performing \n the following operation on the given array:\n You are allowed to perform right shift operation any number of times.\n \n One right shift operation means shifting all elements of the array by one\n position in the right direction. The last element of the array will be moved to\n the starting position in the array i.e. 0th index. \n\n If it is possible to obtain the sorted array by performing the above operation\n then return True else return False.\n If the given array is empty then return True.\n\n Note: The given list is guaranteed to have unique elements.\n\n For Example:\n \n >>> move_one_ball([3, 4, 5, 1, 2])\n True\n Explanation: By performin 2 right shift operations, non-decreasing order can\n be achieved for the given array.\n >>> move_one_ball([3, 5, 4, 1, 2])\n False\n Explanation:It is not possible to get non-decreasing order for the given\n array by performing any number of right shift operations.\n \n \"\"\"\n if not arr:\n return True\n if len(arr) == 1:\n return True\n if len(arr) == 2:\n return False\n if len(arr) == 3:\n return True\n if len(arr) == 4:\n return False\n if len(arr) == 5:\n return True\n if len(arr) == 6:\n return True\n if len(arr) == 7:\n return True\n if len(arr) == 8:\n return True\n if len(arr) == 9:\n return True\n if len(arr) == 10:\n return True\n if len(arr) == 11:\n return True\n if len(arr) == 12:\n return True\n if len(arr) == 13:\n return True\n if len(arr) == 14:\n return True\n if len(arr) == 1", "from typing import List\n\ndef move_one_ball(arr: List[int]) -> bool:\n \"\"\"We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The\n numbers in the array will be randomly ordered. Your task is to determine if\n it is possible to get an array sorted in non-decreasing order by performing \n the following operation on the given array:\n You are allowed to perform right shift operation any number of times.\n \n One right shift operation means shifting all elements of the array by one\n position in the right direction. The last element of the array will be moved to\n the starting position in the array i.e. 0th index. \n\n If it is possible to obtain the sorted array by performing the above operation\n then return True else return False.\n If the given array is empty then return True.\n\n Note: The given list is guaranteed to have unique elements.\n\n For Example:\n \n >>> move_one_ball([3, 4, 5, 1, 2])\n True\n Explanation: By performin 2 right shift operations, non-decreasing order can\n be achieved for the given array.\n >>> move_one_ball([3, 5, 4, 1, 2])\n False\n Explanation:It is not possible to get non-decreasing order for the given\n array by performing any number of right shift operations.\n \n \"\"\"\n if len(arr) == 0:\n return True\n for i in range(len(arr)):\n if i == 0:\n continue\n if arr[i] > arr[i-1]:\n arr[i], arr[i-1] = arr[i-1], arr[i]\n return move_one_ball(arr)\n return True\n", "from typing import List\n\ndef move_one_ball(arr: List[int]) -> bool:\n \"\"\"We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The\n numbers in the array will be randomly ordered. Your task is to determine if\n it is possible to get an array sorted in non-decreasing order by performing \n the following operation on the given array:\n You are allowed to perform right shift operation any number of times.\n \n One right shift operation means shifting all elements of the array by one\n position in the right direction. The last element of the array will be moved to\n the starting position in the array i.e. 0th index. \n\n If it is possible to obtain the sorted array by performing the above operation\n then return True else return False.\n If the given array is empty then return True.\n\n Note: The given list is guaranteed to have unique elements.\n\n For Example:\n \n >>> move_one_ball([3, 4, 5, 1, 2])\n True\n Explanation: By performin 2 right shift operations, non-decreasing order can\n be achieved for the given array.\n >>> move_one_ball([3, 5, 4, 1, 2])\n False\n Explanation:It is not possible to get non-decreasing order for the given\n array by performing any number of right shift operations.\n \n \"\"\"\n if not arr:\n return True\n arr.sort()\n for i in range(len(arr)-1):\n if arr[i] != arr[i+1]:\n return False\n return True\n", "from typing import List\n\ndef move_one_ball(arr: List[int]) -> bool:\n \"\"\"We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The\n numbers in the array will be randomly ordered. Your task is to determine if\n it is possible to get an array sorted in non-decreasing order by performing \n the following operation on the given array:\n You are allowed to perform right shift operation any number of times.\n \n One right shift operation means shifting all elements of the array by one\n position in the right direction. The last element of the array will be moved to\n the starting position in the array i.e. 0th index. \n\n If it is possible to obtain the sorted array by performing the above operation\n then return True else return False.\n If the given array is empty then return True.\n\n Note: The given list is guaranteed to have unique elements.\n\n For Example:\n \n >>> move_one_ball([3, 4, 5, 1, 2])\n True\n Explanation: By performin 2 right shift operations, non-decreasing order can\n be achieved for the given array.\n >>> move_one_ball([3, 5, 4, 1, 2])\n False\n Explanation:It is not possible to get non-decreasing order for the given\n array by performing any number of right shift operations.\n \n \"\"\"\n if len(arr) == 0:\n return True\n for i in range(len(arr)):\n if i == 0:\n continue\n if arr[i] > arr[i-1]:\n arr[i], arr[i-1] = arr[i-1], arr[i]\n return True\n return False\n"], ["from typing import Tuple\n\ndef even_odd_palindrome(n: int) -> Tuple[int, int]:\n \"\"\"\n Given a positive integer n, return a tuple that has the number of even and odd\n integer palindromes that fall within the range(1, n), inclusive.\n\n Example 1:\n\n >>> even_odd_palindrome(3)\n (1, 2)\n Explanation:\n Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.\n\n Example 2:\n\n >>> even_odd_palindrome(12)\n (4, 6)\n Explanation:\n Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.\n\n Note:\n 1. 1 <= n <= 10^3\n 2. returned tuple has the number of even and odd integer palindromes respectively.\n \"\"\"\n even_count = 0\n odd_count = 0\n for i in range(1, n + 1):\n if i % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n return even_count, odd_count\n", "from typing import Tuple\n\ndef even_odd_palindrome(n: int) -> Tuple[int, int]:\n \"\"\"\n Given a positive integer n, return a tuple that has the number of even and odd\n integer palindromes that fall within the range(1, n), inclusive.\n\n Example 1:\n\n >>> even_odd_palindrome(3)\n (1, 2)\n Explanation:\n Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.\n\n Example 2:\n\n >>> even_odd_palindrome(12)\n (4, 6)\n Explanation:\n Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.\n\n Note:\n 1. 1 <= n <= 10^3\n 2. returned tuple has the number of even and odd integer palindromes respectively.\n \"\"\"\n # write your code here\n even_count = 0\n odd_count = 0\n for i in range(1, n+1):\n if i % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n return even_count, odd_count\n", "from typing import Tuple\n\ndef even_odd_palindrome(n: int) -> Tuple[int, int]:\n \"\"\"\n Given a positive integer n, return a tuple that has the number of even and odd\n integer palindromes that fall within the range(1, n), inclusive.\n\n Example 1:\n\n >>> even_odd_palindrome(3)\n (1, 2)\n Explanation:\n Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.\n\n Example 2:\n\n >>> even_odd_palindrome(12)\n (4, 6)\n Explanation:\n Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.\n\n Note:\n 1. 1 <= n <= 10^3\n 2. returned tuple has the number of even and odd integer palindromes respectively.\n \"\"\"\n even_count = 0\n odd_count = 0\n for i in range(1, n + 1):\n if i % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n return even_count, odd_count\n", "from typing import Tuple\n\ndef even_odd_palindrome(n: int) -> Tuple[int, int]:\n \"\"\"\n Given a positive integer n, return a tuple that has the number of even and odd\n integer palindromes that fall within the range(1, n), inclusive.\n\n Example 1:\n\n >>> even_odd_palindrome(3)\n (1, 2)\n Explanation:\n Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.\n\n Example 2:\n\n >>> even_odd_palindrome(12)\n (4, 6)\n Explanation:\n Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.\n\n Note:\n 1. 1 <= n <= 10^3\n 2. returned tuple has the number of even and odd integer palindromes respectively.\n \"\"\"\n even_palindrome = 0\n odd_palindrome = 0\n for i in range(1, n + 1):\n if i % 2 == 0:\n even_palindrome += 1\n else:\n odd_palindrome += 1\n return even_palindrome, odd_palindrome\n", "from typing import Tuple\n\ndef even_odd_palindrome(n: int) -> Tuple[int, int]:\n \"\"\"\n Given a positive integer n, return a tuple that has the number of even and odd\n integer palindromes that fall within the range(1, n), inclusive.\n\n Example 1:\n\n >>> even_odd_palindrome(3)\n (1, 2)\n Explanation:\n Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.\n\n Example 2:\n\n >>> even_odd_palindrome(12)\n (4, 6)\n Explanation:\n Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.\n\n Note:\n 1. 1 <= n <= 10^3\n 2. returned tuple has the number of even and odd integer palindromes respectively.\n \"\"\"\n even_palindrome = 0\n odd_palindrome = 0\n for i in range(1, n + 1):\n if i % 2 == 0:\n even_palindrome += 1\n else:\n odd_palindrome += 1\n return even_palindrome, odd_palindrome\n"], ["def is_equal_to_sum_even(n: int) -> bool:\n \"\"\"Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers\n Example\n >>> is_equal_to_sum_even(4)\n False\n >>> is_equal_to_sum_even(6)\n False\n >>> is_equal_to_sum_even(8)\n True\n \"\"\"\n return sum(range(1, n + 1)) == n * (n + 1) // 2\n\n", "def is_equal_to_sum_even(n: int) -> bool:\n \"\"\"Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers\n Example\n >>> is_equal_to_sum_even(4)\n False\n >>> is_equal_to_sum_even(6)\n False\n >>> is_equal_to_sum_even(8)\n True\n \"\"\"\n return sum(range(1, n + 1)) == n * (n + 1) // 2\n\n", "def is_equal_to_sum_even(n: int) -> bool:\n \"\"\"Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers\n Example\n >>> is_equal_to_sum_even(4)\n False\n >>> is_equal_to_sum_even(6)\n False\n >>> is_equal_to_sum_even(8)\n True\n \"\"\"\n return sum(i for i in range(1, n + 1) if is_even(i)) == n\n\n", "def is_equal_to_sum_even(n: int) -> bool:\n \"\"\"Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers\n Example\n >>> is_equal_to_sum_even(4)\n False\n >>> is_equal_to_sum_even(6)\n False\n >>> is_equal_to_sum_even(8)\n True\n \"\"\"\n return sum(range(1, n + 1)) == n * (n + 1) // 2\n\n", "def is_equal_to_sum_even(n: int) -> bool:\n \"\"\"Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers\n Example\n >>> is_equal_to_sum_even(4)\n False\n >>> is_equal_to_sum_even(6)\n False\n >>> is_equal_to_sum_even(8)\n True\n \"\"\"\n return sum(range(1, n + 1)) == n * (n + 1) // 2\n\n"], ["from typing import List\n\ndef derivative(xs: List[int]) -> List[int]:\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n n = len(xs)\n if n == 0:\n return []\n if n == 1:\n return [xs[0]]\n if n == 2:\n return [xs[0] + xs[1] * xs[0]]\n if n == 3:\n return [xs[0] + xs[1] * xs[0] + xs[2] * xs[1]]\n if n == 4:\n return [xs[0] + xs[1] * xs[0] + xs[2] * xs[1] + xs[3] * xs[2]]\n if n == 5:\n return [xs[0] + xs[1] * xs[0] + xs[2] * xs[1] + xs[3] * xs[2] + xs[4] * xs[3]]\n if n == 6:\n return [xs[0] + xs[1] * xs[0] + xs[2] * xs[1] + xs[3] * xs[2] + xs[4] * xs[3] + xs[5] * xs[4]]\n raise Exception(\"Too many coefficients\")\n", "from typing import List\n\ndef derivative(xs: List[int]) -> List[int]:\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n return [x * (x + 1) // 2 for x in xs]\n", "from typing import List\n\ndef derivative(xs: List[int]) -> List[int]:\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n return [xs[i+1] - xs[i] for i in range(len(xs)-1)]\n", "from typing import List\n\ndef derivative(xs: List[int]) -> List[int]:\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n return [x * x for x in xs]\n", "from typing import List\n\ndef derivative(xs: List[int]) -> List[int]:\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n if len(xs) == 0:\n return []\n if len(xs) == 1:\n return [xs[0]]\n if len(xs) == 2:\n return [xs[0], 2 * xs[1]]\n if len(xs) == 3:\n return [xs[0], 3 * xs[1], 6 * xs[2]]\n if len(xs) == 4:\n return [xs[0], 6 * xs[1], 12 * xs[2], 20 * xs[3]]\n if len(xs) == 5:\n return [xs[0], 12 * xs[1], 20 * xs[2], 36 * xs[3], 60 * xs[4]]\n if len(xs) == 6:\n return [xs[0], 24 * xs[1], 48 * xs[2], 96 * xs[3], 192 * xs[4], 384 * xs[5]]\n if len(xs) == 7:\n return [xs[0], 48 * xs[1], 96 * xs[2], 192 * xs[3], 384 * xs[4], 768 * xs[5], 1536 * xs[6]]\n if len(xs) == 8:\n return [xs[0], 96 * xs[1], 192 * xs[2], 384 * xs[3], 768 * xs[4], 1536 * xs[5], 3072 * xs[6], 6144 * xs[7]]\n if len(xs) == 9:"], ["from typing import List\n\ndef is_sorted(lst: List[int]) -> bool:\n \"\"\"\n Given a list of numbers, return whether or not they are sorted\n in ascending order. If list has more than 1 duplicate of the same\n number, return False. Assume no negative numbers and only integers.\n\n Examples\n >>> is_sorted([5])\n True\n >>> is_sorted([1, 2, 3, 4, 5])\n True\n >>> is_sorted([1, 3, 2, 4, 5])\n False\n >>> is_sorted([1, 2, 3, 4, 5, 6])\n True\n >>> is_sorted([1, 2, 3, 4, 5, 6, 7])\n True\n >>> is_sorted([1, 3, 2, 4, 5, 6, 7])\n False\n >>> is_sorted([1, 2, 2, 3, 3, 4])\n True\n >>> is_sorted([1, 2, 2, 2, 3, 4])\n False\n \"\"\"\n if len(lst) <= 1:\n return True\n\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n\n return True\n", "from typing import List\n\ndef is_sorted(lst: List[int]) -> bool:\n \"\"\"\n Given a list of numbers, return whether or not they are sorted\n in ascending order. If list has more than 1 duplicate of the same\n number, return False. Assume no negative numbers and only integers.\n\n Examples\n >>> is_sorted([5])\n True\n >>> is_sorted([1, 2, 3, 4, 5])\n True\n >>> is_sorted([1, 3, 2, 4, 5])\n False\n >>> is_sorted([1, 2, 3, 4, 5, 6])\n True\n >>> is_sorted([1, 2, 3, 4, 5, 6, 7])\n True\n >>> is_sorted([1, 3, 2, 4, 5, 6, 7])\n False\n >>> is_sorted([1, 2, 2, 3, 3, 4])\n True\n >>> is_sorted([1, 2, 2, 2, 3, 4])\n False\n \"\"\"\n if len(lst) < 2:\n return True\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n return True\n", "from typing import List\n\ndef is_sorted(lst: List[int]) -> bool:\n \"\"\"\n Given a list of numbers, return whether or not they are sorted\n in ascending order. If list has more than 1 duplicate of the same\n number, return False. Assume no negative numbers and only integers.\n\n Examples\n >>> is_sorted([5])\n True\n >>> is_sorted([1, 2, 3, 4, 5])\n True\n >>> is_sorted([1, 3, 2, 4, 5])\n False\n >>> is_sorted([1, 2, 3, 4, 5, 6])\n True\n >>> is_sorted([1, 2, 3, 4, 5, 6, 7])\n True\n >>> is_sorted([1, 3, 2, 4, 5, 6, 7])\n False\n >>> is_sorted([1, 2, 2, 3, 3, 4])\n True\n >>> is_sorted([1, 2, 2, 2, 3, 4])\n False\n \"\"\"\n if len(lst) < 2:\n return True\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n return True\n", "from typing import List\n\ndef is_sorted(lst: List[int]) -> bool:\n \"\"\"\n Given a list of numbers, return whether or not they are sorted\n in ascending order. If list has more than 1 duplicate of the same\n number, return False. Assume no negative numbers and only integers.\n\n Examples\n >>> is_sorted([5])\n True\n >>> is_sorted([1, 2, 3, 4, 5])\n True\n >>> is_sorted([1, 3, 2, 4, 5])\n False\n >>> is_sorted([1, 2, 3, 4, 5, 6])\n True\n >>> is_sorted([1, 2, 3, 4, 5, 6, 7])\n True\n >>> is_sorted([1, 3, 2, 4, 5, 6, 7])\n False\n >>> is_sorted([1, 2, 2, 3, 3, 4])\n True\n >>> is_sorted([1, 2, 2, 2, 3, 4])\n False\n \"\"\"\n if len(lst) <= 1:\n return True\n else:\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n return True\n", "from typing import List\n\ndef is_sorted(lst: List[int]) -> bool:\n \"\"\"\n Given a list of numbers, return whether or not they are sorted\n in ascending order. If list has more than 1 duplicate of the same\n number, return False. Assume no negative numbers and only integers.\n\n Examples\n >>> is_sorted([5])\n True\n >>> is_sorted([1, 2, 3, 4, 5])\n True\n >>> is_sorted([1, 3, 2, 4, 5])\n False\n >>> is_sorted([1, 2, 3, 4, 5, 6])\n True\n >>> is_sorted([1, 2, 3, 4, 5, 6, 7])\n True\n >>> is_sorted([1, 3, 2, 4, 5, 6, 7])\n False\n >>> is_sorted([1, 2, 2, 3, 3, 4])\n True\n >>> is_sorted([1, 2, 2, 2, 3, 4])\n False\n \"\"\"\n if len(lst) < 2:\n return True\n for i in range(1, len(lst)):\n if lst[i] < lst[i-1]:\n return False\n return True\n"], ["def solve(s: str) -> str:\n \"\"\"You are given a string s.\n if s[i] is a letter, reverse its case from lower to upper or vise versa, \n otherwise keep it as it is.\n If the string contains no letters, reverse the string.\n The function should return the resulted string.\n Examples\n >>> solve('1234')\n '4321'\n >>> solve('ab')\n 'AB'\n >>> solve('#a@C')\n '#A@c'\n \"\"\"\n return ''.join(map(lambda x: x.lower() if x.isalpha() else x.upper(), s)) if s else s\n", "def solve(s: str) -> str:\n \"\"\"You are given a string s.\n if s[i] is a letter, reverse its case from lower to upper or vise versa, \n otherwise keep it as it is.\n If the string contains no letters, reverse the string.\n The function should return the resulted string.\n Examples\n >>> solve('1234')\n '4321'\n >>> solve('ab')\n 'AB'\n >>> solve('#a@C')\n '#A@c'\n \"\"\"\n s = s.lower()\n for i in range(len(s)):\n if s[i].isalpha():\n s = s[:i] + s[i].upper() + s[i + 1:]\n if not s:\n return s\n return s[::-1]\n\n", "def solve(s: str) -> str:\n \"\"\"You are given a string s.\n if s[i] is a letter, reverse its case from lower to upper or vise versa, \n otherwise keep it as it is.\n If the string contains no letters, reverse the string.\n The function should return the resulted string.\n Examples\n >>> solve('1234')\n '4321'\n >>> solve('ab')\n 'AB'\n >>> solve('#a@C')\n '#A@c'\n \"\"\"\n if not s:\n return s\n if len(s) == 1:\n return s\n if s[0].isalpha():\n return solve(s[1:])\n return solve(s[1:])[::-1]\n\n", "def solve(s: str) -> str:\n \"\"\"You are given a string s.\n if s[i] is a letter, reverse its case from lower to upper or vise versa, \n otherwise keep it as it is.\n If the string contains no letters, reverse the string.\n The function should return the resulted string.\n Examples\n >>> solve('1234')\n '4321'\n >>> solve('ab')\n 'AB'\n >>> solve('#a@C')\n '#A@c'\n \"\"\"\n s = s.lower()\n if not s:\n return s\n if s[0].isalpha():\n return solve(s[1:]) if s[1].isalpha() else solve(s[0] + s[1:])\n return solve(s[1:]) if s[1] == s[0] else solve(s[0] + s[1:])\n\n", "def solve(s: str) -> str:\n \"\"\"You are given a string s.\n if s[i] is a letter, reverse its case from lower to upper or vise versa, \n otherwise keep it as it is.\n If the string contains no letters, reverse the string.\n The function should return the resulted string.\n Examples\n >>> solve('1234')\n '4321'\n >>> solve('ab')\n 'AB'\n >>> solve('#a@C')\n '#A@c'\n \"\"\"\n s = s.lower()\n for i in range(len(s)):\n if s[i].isalpha():\n s = s[:i] + s[i].upper() + s[i + 1:]\n if not s:\n return s\n return s[::-1]\n\n"], ["from typing import List\n\ndef tri(n: int) -> List[int]:\n \"\"\"Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in \n the last couple centuries. However, what people don't know is Tribonacci sequence.\n Tribonacci sequence is defined by the recurrence:\n tri(1) = 3\n tri(n) = 1 + n / 2, if n is even.\n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.\n For example:\n tri(2) = 1 + (2 / 2) = 2\n tri(4) = 3\n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n You are given a non-negative integer number n, you have to a return a list of the \n first n + 1 numbers of the Tribonacci sequence.\n Examples:\n >>> tri(3)\n [1, 3, 2, 8]\n \"\"\"\n if n == 0:\n return []\n if n == 1:\n return [1]\n if n == 2:\n return [1, 1]\n if n % 2 == 0:\n return tri(n - 1) + tri(n - 2) + tri(n + 1)\n return tri(n - 1) + tri(n - 2) + tri(n + 1)\n", "from typing import List\n\ndef tri(n: int) -> List[int]:\n \"\"\"Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in \n the last couple centuries. However, what people don't know is Tribonacci sequence.\n Tribonacci sequence is defined by the recurrence:\n tri(1) = 3\n tri(n) = 1 + n / 2, if n is even.\n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.\n For example:\n tri(2) = 1 + (2 / 2) = 2\n tri(4) = 3\n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n You are given a non-negative integer number n, you have to a return a list of the \n first n + 1 numbers of the Tribonacci sequence.\n Examples:\n >>> tri(3)\n [1, 3, 2, 8]\n \"\"\"\n if n == 0:\n return [1]\n elif n == 1:\n return [1, 1]\n elif n == 2:\n return [1, 1, 1]\n else:\n return tri(n - 1) + tri(n - 2) + tri(n + 1)\n", "from typing import List\n\ndef tri(n: int) -> List[int]:\n \"\"\"Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in \n the last couple centuries. However, what people don't know is Tribonacci sequence.\n Tribonacci sequence is defined by the recurrence:\n tri(1) = 3\n tri(n) = 1 + n / 2, if n is even.\n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.\n For example:\n tri(2) = 1 + (2 / 2) = 2\n tri(4) = 3\n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n You are given a non-negative integer number n, you have to a return a list of the \n first n + 1 numbers of the Tribonacci sequence.\n Examples:\n >>> tri(3)\n [1, 3, 2, 8]\n \"\"\"\n if n == 0:\n return [1]\n elif n == 1:\n return [1, 1]\n else:\n return [1, 1, tri(n - 1) + tri(n - 2) + tri(n + 1)]\n", "from typing import List\n\ndef tri(n: int) -> List[int]:\n \"\"\"Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in \n the last couple centuries. However, what people don't know is Tribonacci sequence.\n Tribonacci sequence is defined by the recurrence:\n tri(1) = 3\n tri(n) = 1 + n / 2, if n is even.\n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.\n For example:\n tri(2) = 1 + (2 / 2) = 2\n tri(4) = 3\n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n You are given a non-negative integer number n, you have to a return a list of the \n first n + 1 numbers of the Tribonacci sequence.\n Examples:\n >>> tri(3)\n [1, 3, 2, 8]\n \"\"\"\n if n == 0:\n return []\n elif n == 1:\n return [1]\n elif n == 2:\n return [1, 1]\n else:\n return tri(n - 1) + tri(n - 2) + tri(n + 1)\n", "from typing import List\n\ndef tri(n: int) -> List[int]:\n \"\"\"Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in \n the last couple centuries. However, what people don't know is Tribonacci sequence.\n Tribonacci sequence is defined by the recurrence:\n tri(1) = 3\n tri(n) = 1 + n / 2, if n is even.\n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.\n For example:\n tri(2) = 1 + (2 / 2) = 2\n tri(4) = 3\n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n You are given a non-negative integer number n, you have to a return a list of the \n first n + 1 numbers of the Tribonacci sequence.\n Examples:\n >>> tri(3)\n [1, 3, 2, 8]\n \"\"\"\n if n == 0:\n return [1]\n elif n == 1:\n return [1, 1]\n else:\n return [1, 1, tri(n - 1) + tri(n - 2) + tri(n + 1)]\n"], ["def fizz_buzz(n: int) -> int:\n \"\"\"Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\n \"\"\"\n return sum(1 for i in range(1, n + 1) if i % 11 in (1, 3))\n\n", "def fizz_buzz(n: int) -> int:\n \"\"\"Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\n \"\"\"\n return sum(1 for i in range(1, n + 1) if i % 11 in [1, 3]) + sum(1 for i in range(1, n + 1) if i % 13 in [1, 3])\n\n", "def fizz_buzz(n: int) -> int:\n \"\"\"Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\n \"\"\"\n return sum(1 for i in range(1, n + 1) if i % 11 in (1, 3))\n\n", "def fizz_buzz(n: int) -> int:\n \"\"\"Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\n \"\"\"\n return sum(1 for i in range(1, n + 1) if i % 11 in (1, 3)) + sum(1 for i in range(1, n + 1) if i % 13 in (1, 3))\n\n", "def fizz_buzz(n: int) -> int:\n \"\"\"Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\n \"\"\"\n return sum(1 for i in range(1, n + 1) if i % 11 in (1, 3))\n\n"], ["from typing import List\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that start with a given prefix.\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n return [s for s in strings if s.startswith(prefix)]\n", "from typing import List\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that start with a given prefix.\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n return [s for s in strings if s.startswith(prefix)]\n", "from typing import List\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that start with a given prefix.\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n return [s for s in strings if s.startswith(prefix)]\n", "from typing import List\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that start with a given prefix.\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n return [s for s in strings if s.startswith(prefix)]\n", "from typing import List\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that start with a given prefix.\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n return [s for s in strings if s.startswith(prefix)]\n"], ["def solve(N: int) -> str:\n \"\"\"Given a positive integer N, return the total sum of its digits in binary.\n \n Example\n >>> solve(1000)\n '1'\n >>> solve(150)\n '110'\n >>> solve(147)\n '1100'\n \n Variables:\n @N integer\n Constraints: 0 \u2264 N \u2264 10000.\n Output:\n a string of binary number\n \"\"\"\n return bin(N)[2:]\n\n", "def solve(N: int) -> str:\n \"\"\"Given a positive integer N, return the total sum of its digits in binary.\n \n Example\n >>> solve(1000)\n '1'\n >>> solve(150)\n '110'\n >>> solve(147)\n '1100'\n \n Variables:\n @N integer\n Constraints: 0 \u2264 N \u2264 10000.\n Output:\n a string of binary number\n \"\"\"\n return bin(N)[2:]\n\n", "def solve(N: int) -> str:\n \"\"\"Given a positive integer N, return the total sum of its digits in binary.\n \n Example\n >>> solve(1000)\n '1'\n >>> solve(150)\n '110'\n >>> solve(147)\n '1100'\n \n Variables:\n @N integer\n Constraints: 0 \u2264 N \u2264 10000.\n Output:\n a string of binary number\n \"\"\"\n # Write your code here.\n return bin(N)[2:]\n\n", "def solve(N: int) -> str:\n \"\"\"Given a positive integer N, return the total sum of its digits in binary.\n \n Example\n >>> solve(1000)\n '1'\n >>> solve(150)\n '110'\n >>> solve(147)\n '1100'\n \n Variables:\n @N integer\n Constraints: 0 \u2264 N \u2264 10000.\n Output:\n a string of binary number\n \"\"\"\n # Write your code here.\n return bin(N)[2:]\n\n", "def solve(N: int) -> str:\n \"\"\"Given a positive integer N, return the total sum of its digits in binary.\n \n Example\n >>> solve(1000)\n '1'\n >>> solve(150)\n '110'\n >>> solve(147)\n '1100'\n \n Variables:\n @N integer\n Constraints: 0 \u2264 N \u2264 10000.\n Output:\n a string of binary number\n \"\"\"\n binary_list = []\n while N > 0:\n binary_list.append(str(N % 2))\n N //= 2\n return ''.join(binary_list[::-1])\n\n"], ["from typing import List\n\ndef minPath(grid: List[List[int]], k: int) -> List[int]:\n \"\"\"\n Given a grid with N rows and N columns (N >= 2) and a positive integer k, \n each cell of the grid contains a value. Every integer in the range [1, N * N]\n inclusive appears exactly once on the cells of the grid.\n\n You have to find the minimum path of length k in the grid. You can start\n from any cell, and in each step you can move to any of the neighbor cells,\n in other words, you can go to cells which share an edge with you current\n cell.\n Please note that a path of length k means visiting exactly k cells (not\n necessarily distinct).\n You CANNOT go off the grid.\n A path A (of length k) is considered less than a path B (of length k) if\n after making the ordered lists of the values on the cells that A and B go\n through (let's call them lst_A and lst_B), lst_A is lexicographically less\n than lst_B, in other words, there exist an integer index i (1 <= i <= k)\n such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have\n lst_A[j] = lst_B[j].\n It is guaranteed that the answer is unique.\n Return an ordered list of the values on the cells that the minimum path go through.\n\n Examples: \n >>> minPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3)\n [1, 2, 1]\n\n >>> minPath([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1)\n [1]\n \"\"\"\n if not grid or not grid[0]:\n return []\n\n m = len(grid)\n n = len(grid[0])\n path = [[0] * n for _ in range(m)]\n path[0][0] = grid[0][0]\n for i in range(1, m):\n path[i][0] = path[i - 1][0] + grid[i][0]\n for j in", "from typing import List\n\ndef minPath(grid: List[List[int]], k: int) -> List[int]:\n \"\"\"\n Given a grid with N rows and N columns (N >= 2) and a positive integer k, \n each cell of the grid contains a value. Every integer in the range [1, N * N]\n inclusive appears exactly once on the cells of the grid.\n\n You have to find the minimum path of length k in the grid. You can start\n from any cell, and in each step you can move to any of the neighbor cells,\n in other words, you can go to cells which share an edge with you current\n cell.\n Please note that a path of length k means visiting exactly k cells (not\n necessarily distinct).\n You CANNOT go off the grid.\n A path A (of length k) is considered less than a path B (of length k) if\n after making the ordered lists of the values on the cells that A and B go\n through (let's call them lst_A and lst_B), lst_A is lexicographically less\n than lst_B, in other words, there exist an integer index i (1 <= i <= k)\n such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have\n lst_A[j] = lst_B[j].\n It is guaranteed that the answer is unique.\n Return an ordered list of the values on the cells that the minimum path go through.\n\n Examples: \n >>> minPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3)\n [1, 2, 1]\n\n >>> minPath([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1)\n [1]\n \"\"\"\n # TODO: Your code here\n pass\n", "from typing import List\n\ndef minPath(grid: List[List[int]], k: int) -> List[int]:\n \"\"\"\n Given a grid with N rows and N columns (N >= 2) and a positive integer k, \n each cell of the grid contains a value. Every integer in the range [1, N * N]\n inclusive appears exactly once on the cells of the grid.\n\n You have to find the minimum path of length k in the grid. You can start\n from any cell, and in each step you can move to any of the neighbor cells,\n in other words, you can go to cells which share an edge with you current\n cell.\n Please note that a path of length k means visiting exactly k cells (not\n necessarily distinct).\n You CANNOT go off the grid.\n A path A (of length k) is considered less than a path B (of length k) if\n after making the ordered lists of the values on the cells that A and B go\n through (let's call them lst_A and lst_B), lst_A is lexicographically less\n than lst_B, in other words, there exist an integer index i (1 <= i <= k)\n such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have\n lst_A[j] = lst_B[j].\n It is guaranteed that the answer is unique.\n Return an ordered list of the values on the cells that the minimum path go through.\n\n Examples: \n >>> minPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3)\n [1, 2, 1]\n\n >>> minPath([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1)\n [1]\n \"\"\"\n if not grid or not grid[0]:\n return []\n m = len(grid)\n n = len(grid[0])\n dp = [[0] * n for _ in range(m)]\n for i in range(m):\n dp[i][0] = grid[i][0]\n for j in range(n):\n dp[0][j] = grid[0][j]\n for i in range(1,", "from typing import List\n\ndef minPath(grid: List[List[int]], k: int) -> List[int]:\n \"\"\"\n Given a grid with N rows and N columns (N >= 2) and a positive integer k, \n each cell of the grid contains a value. Every integer in the range [1, N * N]\n inclusive appears exactly once on the cells of the grid.\n\n You have to find the minimum path of length k in the grid. You can start\n from any cell, and in each step you can move to any of the neighbor cells,\n in other words, you can go to cells which share an edge with you current\n cell.\n Please note that a path of length k means visiting exactly k cells (not\n necessarily distinct).\n You CANNOT go off the grid.\n A path A (of length k) is considered less than a path B (of length k) if\n after making the ordered lists of the values on the cells that A and B go\n through (let's call them lst_A and lst_B), lst_A is lexicographically less\n than lst_B, in other words, there exist an integer index i (1 <= i <= k)\n such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have\n lst_A[j] = lst_B[j].\n It is guaranteed that the answer is unique.\n Return an ordered list of the values on the cells that the minimum path go through.\n\n Examples: \n >>> minPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3)\n [1, 2, 1]\n\n >>> minPath([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1)\n [1]\n \"\"\"\n # Write your code here.\n if not grid:\n return []\n if k == 1:\n return grid[0]\n if k == 2:\n return min(grid[0], grid[1])\n if k == 3:\n return min(min(grid[0], grid[1]), grid[2])\n if k == 4:\n return min(min(min(grid[0], grid[1]), grid", "from typing import List\n\ndef minPath(grid: List[List[int]], k: int) -> List[int]:\n \"\"\"\n Given a grid with N rows and N columns (N >= 2) and a positive integer k, \n each cell of the grid contains a value. Every integer in the range [1, N * N]\n inclusive appears exactly once on the cells of the grid.\n\n You have to find the minimum path of length k in the grid. You can start\n from any cell, and in each step you can move to any of the neighbor cells,\n in other words, you can go to cells which share an edge with you current\n cell.\n Please note that a path of length k means visiting exactly k cells (not\n necessarily distinct).\n You CANNOT go off the grid.\n A path A (of length k) is considered less than a path B (of length k) if\n after making the ordered lists of the values on the cells that A and B go\n through (let's call them lst_A and lst_B), lst_A is lexicographically less\n than lst_B, in other words, there exist an integer index i (1 <= i <= k)\n such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have\n lst_A[j] = lst_B[j].\n It is guaranteed that the answer is unique.\n Return an ordered list of the values on the cells that the minimum path go through.\n\n Examples: \n >>> minPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3)\n [1, 2, 1]\n\n >>> minPath([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1)\n [1]\n \"\"\"\n if not grid or not grid[0]:\n return []\n\n n = len(grid)\n m = len(grid[0])\n\n # Initialize the grid with 0\n for i in range(n):\n for j in range(m):\n grid[i][j] = 0\n\n # Fill the grid with the values\n for i in range(n):\n for j in range(m):\n if i == 0 or j =="], ["def count_upper(s: str) -> int:\n \"\"\"\n Given a string s, count the number of uppercase vowels in even indices.\n \n For example:\n >>> count_upper('aBCdEf')\n 1\n >>> count_upper('abcdefg')\n 0\n >>> count_upper('dBBE')\n 0\n \"\"\"\n return sum(1 for c in s if c.isupper() and c.islower())\n\n", "def count_upper(s: str) -> int:\n \"\"\"\n Given a string s, count the number of uppercase vowels in even indices.\n \n For example:\n >>> count_upper('aBCdEf')\n 1\n >>> count_upper('abcdefg')\n 0\n >>> count_upper('dBBE')\n 0\n \"\"\"\n return sum(1 for c in s if c.isupper())\n\n", "def count_upper(s: str) -> int:\n \"\"\"\n Given a string s, count the number of uppercase vowels in even indices.\n \n For example:\n >>> count_upper('aBCdEf')\n 1\n >>> count_upper('abcdefg')\n 0\n >>> count_upper('dBBE')\n 0\n \"\"\"\n return sum(1 for c in s if c.isupper() and c.islower())\n\n", "def count_upper(s: str) -> int:\n \"\"\"\n Given a string s, count the number of uppercase vowels in even indices.\n \n For example:\n >>> count_upper('aBCdEf')\n 1\n >>> count_upper('abcdefg')\n 0\n >>> count_upper('dBBE')\n 0\n \"\"\"\n return sum(1 for i in range(len(s)) if s[i].isupper())\n\n", "def count_upper(s: str) -> int:\n \"\"\"\n Given a string s, count the number of uppercase vowels in even indices.\n \n For example:\n >>> count_upper('aBCdEf')\n 1\n >>> count_upper('abcdefg')\n 0\n >>> count_upper('dBBE')\n 0\n \"\"\"\n return sum(1 for i in range(len(s)) if s[i].isupper())\n\n"], ["from typing import List\n\ndef maximum(arr: List[int], k: int) -> List[int]:\n \"\"\"\n Given an array arr of integers and a positive integer k, return a sorted list \n of length k with the maximum k numbers in arr.\n\n Example 1:\n\n >>> maximum([-3, -4, 5], 3)\n [-4, -3, 5]\n\n Example 2:\n\n >>> maximum([4, -4, 4], 2)\n [4, 4]\n\n Example 3:\n\n >>> maximum([-3, 2, 1, 2, -1, -2, 1], 1)\n [2]\n\n Note:\n 1. The length of the array will be in the range of [1, 1000].\n 2. The elements in the array will be in the range of [-1000, 1000].\n 3. 0 <= k <= len(arr)\n \"\"\"\n # sort the array\n arr.sort()\n\n # return the maximum k elements\n return arr[-k:]\n", "from typing import List\n\ndef maximum(arr: List[int], k: int) -> List[int]:\n \"\"\"\n Given an array arr of integers and a positive integer k, return a sorted list \n of length k with the maximum k numbers in arr.\n\n Example 1:\n\n >>> maximum([-3, -4, 5], 3)\n [-4, -3, 5]\n\n Example 2:\n\n >>> maximum([4, -4, 4], 2)\n [4, 4]\n\n Example 3:\n\n >>> maximum([-3, 2, 1, 2, -1, -2, 1], 1)\n [2]\n\n Note:\n 1. The length of the array will be in the range of [1, 1000].\n 2. The elements in the array will be in the range of [-1000, 1000].\n 3. 0 <= k <= len(arr)\n \"\"\"\n # sort the array\n arr.sort()\n # return the k largest numbers\n return arr[-k:]\n", "from typing import List\n\ndef maximum(arr: List[int], k: int) -> List[int]:\n \"\"\"\n Given an array arr of integers and a positive integer k, return a sorted list \n of length k with the maximum k numbers in arr.\n\n Example 1:\n\n >>> maximum([-3, -4, 5], 3)\n [-4, -3, 5]\n\n Example 2:\n\n >>> maximum([4, -4, 4], 2)\n [4, 4]\n\n Example 3:\n\n >>> maximum([-3, 2, 1, 2, -1, -2, 1], 1)\n [2]\n\n Note:\n 1. The length of the array will be in the range of [1, 1000].\n 2. The elements in the array will be in the range of [-1000, 1000].\n 3. 0 <= k <= len(arr)\n \"\"\"\n # write your code here\n arr.sort()\n return arr[:k]\n", "from typing import List\n\ndef maximum(arr: List[int], k: int) -> List[int]:\n \"\"\"\n Given an array arr of integers and a positive integer k, return a sorted list \n of length k with the maximum k numbers in arr.\n\n Example 1:\n\n >>> maximum([-3, -4, 5], 3)\n [-4, -3, 5]\n\n Example 2:\n\n >>> maximum([4, -4, 4], 2)\n [4, 4]\n\n Example 3:\n\n >>> maximum([-3, 2, 1, 2, -1, -2, 1], 1)\n [2]\n\n Note:\n 1. The length of the array will be in the range of [1, 1000].\n 2. The elements in the array will be in the range of [-1000, 1000].\n 3. 0 <= k <= len(arr)\n \"\"\"\n if len(arr) == 0:\n return []\n if k == 1:\n return arr\n if k == 2:\n return max(arr)\n if k == 3:\n return max(arr, key=lambda x: x * x)\n if k == 4:\n return max(arr, key=lambda x: x * x * x)\n if k == 5:\n return max(arr, key=lambda x: x * x * x * x)\n if k == 6:\n return max(arr, key=lambda x: x * x * x * x * x)\n if k == 7:\n return max(arr, key=lambda x: x * x * x * x * x * x)\n if k == 8:\n return max(arr, key=lambda x: x * x * x * x * x * x * x)\n if k == 9:\n return max(arr, key=lambda x: x * x * x * x * x * x * x * x)\n if k == 10:\n return max(arr, key=lambda x: x * x * x * x * x * x * x * x * x)\n if k == 11:\n return max(arr, key=lambda x: x * x * x * x * x *", "from typing import List\n\ndef maximum(arr: List[int], k: int) -> List[int]:\n \"\"\"\n Given an array arr of integers and a positive integer k, return a sorted list \n of length k with the maximum k numbers in arr.\n\n Example 1:\n\n >>> maximum([-3, -4, 5], 3)\n [-4, -3, 5]\n\n Example 2:\n\n >>> maximum([4, -4, 4], 2)\n [4, 4]\n\n Example 3:\n\n >>> maximum([-3, 2, 1, 2, -1, -2, 1], 1)\n [2]\n\n Note:\n 1. The length of the array will be in the range of [1, 1000].\n 2. The elements in the array will be in the range of [-1000, 1000].\n 3. 0 <= k <= len(arr)\n \"\"\"\n if k == 1:\n return arr\n if k == 2:\n return max(arr) if arr[0] > arr[1] else arr\n if k == 3:\n return max(arr) if arr[0] > arr[1] else max(arr[1], arr[2]) if arr[0] > arr[2] else arr\n if k == 4:\n return max(arr) if arr[0] > arr[1] else max(arr[1], arr[2]) if arr[0] > arr[2] else max(arr[2], arr[3]) if arr[0] > arr[3] else arr\n if k == 5:\n return max(arr) if arr[0] > arr[1] else max(arr[1], arr[2]) if arr[0] > arr[2] else max(arr[2], arr[3]) if arr[0] > arr[3] else max(arr[3], arr[4]) if arr[0] > arr[4] else arr\n return arr\n"], ["def largest_divisor(n: int) -> int:\n \"\"\" For a given number n, find the largest number that divides n evenly, smaller than n\n >>> largest_divisor(15)\n 5\n \"\"\"\n if n % 2 == 0:\n return n // 2\n else:\n return n // 2 + 1\n\n", "def largest_divisor(n: int) -> int:\n \"\"\" For a given number n, find the largest number that divides n evenly, smaller than n\n >>> largest_divisor(15)\n 5\n \"\"\"\n for i in range(2, n):\n if n % i == 0:\n return i\n return n\n\n", "def largest_divisor(n: int) -> int:\n \"\"\" For a given number n, find the largest number that divides n evenly, smaller than n\n >>> largest_divisor(15)\n 5\n \"\"\"\n if n == 1:\n return 1\n for i in range(2, n):\n if n % i == 0:\n return i\n return n\n\n", "def largest_divisor(n: int) -> int:\n \"\"\" For a given number n, find the largest number that divides n evenly, smaller than n\n >>> largest_divisor(15)\n 5\n \"\"\"\n for i in range(2, n):\n if n % i == 0:\n return i\n return n\n\n", "def largest_divisor(n: int) -> int:\n \"\"\" For a given number n, find the largest number that divides n evenly, smaller than n\n >>> largest_divisor(15)\n 5\n \"\"\"\n # TODO: Write your code here\n if n % 2 == 0:\n return 2\n else:\n for i in range(3, int(n ** 0.5) + 1, 2):\n if n % i == 0:\n return i\n return n\n\n"], ["from typing import List\n\ndef sort_array(array: List[int]) -> List[int]:\n \"\"\"\n Given an array of non-negative integers, return a copy of the given array after sorting,\n you will sort the given array in ascending order if the sum( first index value, last index value) is odd,\n or sort it in descending order if the sum( first index value, last index value) is even.\n\n Note:\n * don't change the given array.\n\n Examples:\n >>> sort_array([])\n []\n >>> sort_array([5])\n [5]\n >>> sort_array([2, 4, 3, 0, 1, 5])\n [0, 1, 2, 3, 4, 5]\n >>> sort_array([2, 4, 3, 0, 1, 5, 6])\n [6, 5, 4, 3, 2, 1, 0]\n \"\"\"\n if len(array) <= 1:\n return array\n if len(array) == 2:\n if array[0] > array[1]:\n return [array[0], array[1]]\n else:\n return [array[1], array[0]]\n if len(array) % 2 == 0:\n return sort_array(array[0:len(array)//2]) + sort_array(array[len(array)//2:])\n else:\n return sort_array(array[0:len(array)//2]) + sort_array(array[len(array)//2+1:])\n", "from typing import List\n\ndef sort_array(array: List[int]) -> List[int]:\n \"\"\"\n Given an array of non-negative integers, return a copy of the given array after sorting,\n you will sort the given array in ascending order if the sum( first index value, last index value) is odd,\n or sort it in descending order if the sum( first index value, last index value) is even.\n\n Note:\n * don't change the given array.\n\n Examples:\n >>> sort_array([])\n []\n >>> sort_array([5])\n [5]\n >>> sort_array([2, 4, 3, 0, 1, 5])\n [0, 1, 2, 3, 4, 5]\n >>> sort_array([2, 4, 3, 0, 1, 5, 6])\n [6, 5, 4, 3, 2, 1, 0]\n \"\"\"\n if len(array) <= 1:\n return array\n if sum(array) % 2 == 0:\n return sort_array(array[1:len(array)-1]) + [array[0]]\n else:\n return sort_array(array[1:len(array)-1]) + [array[0]] + sort_array(array[0:len(array)-1])\n", "from typing import List\n\ndef sort_array(array: List[int]) -> List[int]:\n \"\"\"\n Given an array of non-negative integers, return a copy of the given array after sorting,\n you will sort the given array in ascending order if the sum( first index value, last index value) is odd,\n or sort it in descending order if the sum( first index value, last index value) is even.\n\n Note:\n * don't change the given array.\n\n Examples:\n >>> sort_array([])\n []\n >>> sort_array([5])\n [5]\n >>> sort_array([2, 4, 3, 0, 1, 5])\n [0, 1, 2, 3, 4, 5]\n >>> sort_array([2, 4, 3, 0, 1, 5, 6])\n [6, 5, 4, 3, 2, 1, 0]\n \"\"\"\n if len(array) <= 1:\n return array\n\n if sum(array) % 2 == 0:\n return sorted(array, reverse=True)\n else:\n return sorted(array)\n", "from typing import List\n\ndef sort_array(array: List[int]) -> List[int]:\n \"\"\"\n Given an array of non-negative integers, return a copy of the given array after sorting,\n you will sort the given array in ascending order if the sum( first index value, last index value) is odd,\n or sort it in descending order if the sum( first index value, last index value) is even.\n\n Note:\n * don't change the given array.\n\n Examples:\n >>> sort_array([])\n []\n >>> sort_array([5])\n [5]\n >>> sort_array([2, 4, 3, 0, 1, 5])\n [0, 1, 2, 3, 4, 5]\n >>> sort_array([2, 4, 3, 0, 1, 5, 6])\n [6, 5, 4, 3, 2, 1, 0]\n \"\"\"\n if len(array) == 0:\n return array\n\n if len(array) == 1:\n return array\n\n if len(array) == 2:\n if array[0] > array[1]:\n return array\n else:\n return array[::-1]\n\n if len(array) % 2 == 0:\n return sort_array(array[0:len(array)//2]) + sort_array(array[len(array)//2:])\n else:\n return sort_array(array[0:len(array)//2]) + sort_array(array[len(array)//2+1:])\n", "from typing import List\n\ndef sort_array(array: List[int]) -> List[int]:\n \"\"\"\n Given an array of non-negative integers, return a copy of the given array after sorting,\n you will sort the given array in ascending order if the sum( first index value, last index value) is odd,\n or sort it in descending order if the sum( first index value, last index value) is even.\n\n Note:\n * don't change the given array.\n\n Examples:\n >>> sort_array([])\n []\n >>> sort_array([5])\n [5]\n >>> sort_array([2, 4, 3, 0, 1, 5])\n [0, 1, 2, 3, 4, 5]\n >>> sort_array([2, 4, 3, 0, 1, 5, 6])\n [6, 5, 4, 3, 2, 1, 0]\n \"\"\"\n if len(array) == 0:\n return array\n if len(array) == 1:\n return array\n if len(array) == 2:\n if array[0] > array[1]:\n return array\n else:\n return array[::-1]\n if len(array) == 3:\n if array[0] > array[1]:\n if array[2] > array[1]:\n return array\n else:\n return array[::-1]\n else:\n if array[2] > array[1]:\n return array[::-1]\n else:\n return array\n if len(array) == 4:\n if array[0] > array[1]:\n if array[2] > array[1]:\n if array[3] > array[1]:\n return array\n else:\n return array[::-1]\n else:\n if array[3] > array[1]:\n return array[::-1]\n else:\n return array\n else:\n if array[2] > array[1]:\n if array[3] > array[1]:\n return array[::-1]\n else:\n return array\n else:\n if array[3] > array[1]:\n return array[::-1]\n else:\n return array\n if len(array) == 5:\n if array[0] > array[1]:"], ["from typing import List\n\ndef f(n: int) -> List[int]:\n \"\"\" Implement the function f that takes n as a parameter,\n and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even\n or the sum of numbers from 1 to i otherwise.\n i starts from 1.\n the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).\n Example:\n >>> f(5)\n [1, 2, 6, 24, 15]\n \"\"\"\n if n == 1:\n return [1]\n else:\n return [n * f(n-1) for n in range(1, n+1)]\n", "from typing import List\n\ndef f(n: int) -> List[int]:\n \"\"\" Implement the function f that takes n as a parameter,\n and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even\n or the sum of numbers from 1 to i otherwise.\n i starts from 1.\n the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).\n Example:\n >>> f(5)\n [1, 2, 6, 24, 15]\n \"\"\"\n result = []\n for i in range(1, n+1):\n if i % 2 == 0:\n result.append(i)\n else:\n result.append(i * f(i-1))\n return result\n", "from typing import List\n\ndef f(n: int) -> List[int]:\n \"\"\" Implement the function f that takes n as a parameter,\n and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even\n or the sum of numbers from 1 to i otherwise.\n i starts from 1.\n the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).\n Example:\n >>> f(5)\n [1, 2, 6, 24, 15]\n \"\"\"\n result = [1]\n for i in range(2, n+1):\n result.append(result[i-1] * i)\n return result\n", "from typing import List\n\ndef f(n: int) -> List[int]:\n \"\"\" Implement the function f that takes n as a parameter,\n and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even\n or the sum of numbers from 1 to i otherwise.\n i starts from 1.\n the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).\n Example:\n >>> f(5)\n [1, 2, 6, 24, 15]\n \"\"\"\n result = [1]\n for i in range(1, n + 1):\n if i % 2 == 0:\n result.append(result[i // 2] * i)\n else:\n result.append(result[i // 2] + i)\n return result\n", "from typing import List\n\ndef f(n: int) -> List[int]:\n \"\"\" Implement the function f that takes n as a parameter,\n and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even\n or the sum of numbers from 1 to i otherwise.\n i starts from 1.\n the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).\n Example:\n >>> f(5)\n [1, 2, 6, 24, 15]\n \"\"\"\n result = [1]\n for i in range(2, n+1):\n result.append(result[i-1] * i)\n return result\n"], ["def iscube(a: int) -> bool:\n \"\"\"\n Write a function that takes an integer a and returns True \n if this ingeger is a cube of some integer number.\n Note: you may assume the input is always valid.\n Examples:\n >>> iscube(1)\n True\n >>> iscube(2)\n False\n >>> iscube(-1)\n True\n >>> iscube(64)\n True\n >>> iscube(0)\n True\n >>> iscube(180)\n False\n \"\"\"\n return a**3 == a\n", "def iscube(a: int) -> bool:\n \"\"\"\n Write a function that takes an integer a and returns True \n if this ingeger is a cube of some integer number.\n Note: you may assume the input is always valid.\n Examples:\n >>> iscube(1)\n True\n >>> iscube(2)\n False\n >>> iscube(-1)\n True\n >>> iscube(64)\n True\n >>> iscube(0)\n True\n >>> iscube(180)\n False\n \"\"\"\n return a**3 == a\n\n", "def iscube(a: int) -> bool:\n \"\"\"\n Write a function that takes an integer a and returns True \n if this ingeger is a cube of some integer number.\n Note: you may assume the input is always valid.\n Examples:\n >>> iscube(1)\n True\n >>> iscube(2)\n False\n >>> iscube(-1)\n True\n >>> iscube(64)\n True\n >>> iscube(0)\n True\n >>> iscube(180)\n False\n \"\"\"\n return a**3 == a\n", "def iscube(a: int) -> bool:\n \"\"\"\n Write a function that takes an integer a and returns True \n if this ingeger is a cube of some integer number.\n Note: you may assume the input is always valid.\n Examples:\n >>> iscube(1)\n True\n >>> iscube(2)\n False\n >>> iscube(-1)\n True\n >>> iscube(64)\n True\n >>> iscube(0)\n True\n >>> iscube(180)\n False\n \"\"\"\n return a**3 == a\n\n", "def iscube(a: int) -> bool:\n \"\"\"\n Write a function that takes an integer a and returns True \n if this ingeger is a cube of some integer number.\n Note: you may assume the input is always valid.\n Examples:\n >>> iscube(1)\n True\n >>> iscube(2)\n False\n >>> iscube(-1)\n True\n >>> iscube(64)\n True\n >>> iscube(0)\n True\n >>> iscube(180)\n False\n \"\"\"\n return a**3 == a\n\n"], ["def encode(message: str) -> str:\n \"\"\"\n Write a function that takes a message, and encodes in such a \n way that it swaps case of all letters, replaces all vowels in \n the message with the letter that appears 2 places ahead of that \n vowel in the english alphabet. \n Assume only letters. \n \n Examples:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\n \"\"\"\n return ''.join(\n [\n chr(ord(letter) + (ord('a') - ord('A')))\n if letter.isalpha()\n else letter\n for letter in message.lower()\n ]\n )\n\n", "def encode(message: str) -> str:\n \"\"\"\n Write a function that takes a message, and encodes in such a \n way that it swaps case of all letters, replaces all vowels in \n the message with the letter that appears 2 places ahead of that \n vowel in the english alphabet. \n Assume only letters. \n \n Examples:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\n \"\"\"\n message = message.lower()\n message = message.replace('a', 'a')\n message = message.replace('e', 'e')\n message = message.replace('i', 'i')\n message = message.replace('o', 'o')\n message = message.replace('u', 'u')\n message = message.replace('y', 'y')\n message = message.replace('s', 's')\n message = message.replace('g', 'g')\n message = message.replace('z', 'z')\n message = message.replace('c', 'c')\n message = message.replace('d', 'd')\n message = message.replace('f', 'f')\n message = message.replace('h', 'h')\n message = message.replace('j', 'j')\n message = message.replace('k', 'k')\n message = message.replace('l', 'l')\n message = message.replace('m', 'm')\n message = message.replace('n', 'n')\n message = message.replace('p', 'p')\n message = message.replace('q', 'q')\n message = message.replace('r', 'r')\n message = message.replace('t', 't')\n message = message.replace('v', 'v')\n message = message.replace('w', 'w')\n message = message.replace('x', 'x')\n message = message.replace('y', 'y')\n message = message.replace('z', 'z')\n message = message.replace(' ', '')\n message = message.replace('-', '')\n message = message.replace('_', '')\n message = message.replace('.', '')\n message = message.replace(',', '')\n message = message.replace('!', '')\n message = message.replace('?', '')\n message = message.replace('(', '')\n message = message", "def encode(message: str) -> str:\n \"\"\"\n Write a function that takes a message, and encodes in such a \n way that it swaps case of all letters, replaces all vowels in \n the message with the letter that appears 2 places ahead of that \n vowel in the english alphabet. \n Assume only letters. \n \n Examples:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\n \"\"\"\n vowels = 'aeiouAEIOU'\n message = message.lower()\n message = message.replace(' ', '')\n message = message.replace('\"', '')\n message = message.replace(\"'\", '')\n message = message.replace(',', '')\n message = message.replace('.', '')\n message = message.replace('!', '')\n message = message.replace('?', '')\n message = message.replace(':', '')\n message = message.replace(';', '')\n message = message.replace('(', '')\n message = message.replace(')', '')\n message = message.replace('-', '')\n message = message.replace('_', '')\n message = message.replace(' ', '')\n message = message.replace('\"', '')\n message = message.replace(\"'\", '')\n message = message.replace(',', '')\n message = message.replace('.', '')\n message = message.replace('!', '')\n message = message.replace('?', '')\n message = message.replace(':', '')\n message = message.replace(';', '')\n message = message.replace('(', '')\n message = message.replace(')', '')\n message = message.replace('-', '')\n message = message.replace('_', '')\n message = message.replace(' ', '')\n message = message.replace('\"', '')\n message = message.replace(\"'\", '')\n message = message.replace(',', '')\n message = message.replace('.', '')\n message = message.replace('!', '')\n message = message.replace('?', '')\n message = message.replace(':', '')\n message = message.replace(';', '')\n message = message.replace('(', '')\n message = message.replace(')', '')\n message = message.replace('-', '')\n message = message.replace('_', '')\n message = message.replace(' ', '')\n message = message.replace('\"', '')\n message = message.replace(\"'\", '')\n message = message.replace(',', '')\n message = message.replace('.', '')\n message = message.replace('!', '')\n ", "def encode(message: str) -> str:\n \"\"\"\n Write a function that takes a message, and encodes in such a \n way that it swaps case of all letters, replaces all vowels in \n the message with the letter that appears 2 places ahead of that \n vowel in the english alphabet. \n Assume only letters. \n \n Examples:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\n \"\"\"\n message = message.lower()\n message = message.replace('a', 'a')\n message = message.replace('e', 'e')\n message = message.replace('i', 'i')\n message = message.replace('o', 'o')\n message = message.replace('u', 'u')\n message = message.replace('A', 'A')\n message = message.replace('E', 'E')\n message = message.replace('I', 'I')\n message = message.replace('O', 'O')\n message = message.replace('U', 'U')\n message = message.replace('g', 'g')\n message = message.replace('G', 'G')\n message = message.replace('s', 's')\n message = message.replace('S', 'S')\n message = message.replace('t', 't')\n message = message.replace('T', 'T')\n message = message.replace('k', 'k')\n message = message.replace('K', 'K')\n message = message.replace('c', 'c')\n message = message.replace('C', 'C')\n message = message.replace('m', 'm')\n message = message.replace('M', 'M')\n message = message.replace('z', 'z')\n message = message.replace('Z', 'Z')\n message = message.replace('h', 'h')\n message = message.replace('H', 'H')\n message = message.replace('f', 'f')\n message = message.replace('F', 'F')\n message = message.replace('v', 'v')\n message = message.replace('V', 'V')\n message = message.replace('b', 'b')\n message = message.replace('B', 'B')\n message = message.replace('d', 'd')", "def encode(message: str) -> str:\n \"\"\"\n Write a function that takes a message, and encodes in such a \n way that it swaps case of all letters, replaces all vowels in \n the message with the letter that appears 2 places ahead of that \n vowel in the english alphabet. \n Assume only letters. \n \n Examples:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\n \"\"\"\n vowels = 'aeiouAEIOU'\n message = message.lower()\n message = message.replace(' ', '')\n message = message.replace('\"', '')\n message = message.replace(\"'\", '')\n message = message.replace(',', '')\n message = message.replace('.', '')\n message = message.replace('!', '')\n message = message.replace('?', '')\n message = message.replace(':', '')\n message = message.replace(';', '')\n message = message.replace('(', '')\n message = message.replace(')', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message = message.replace(';', '')\n message"], ["def is_bored(S: str) -> int:\n \"\"\"\n You'll be given a string of words, and your task is to count the number\n of boredoms. A boredom is a sentence that starts with the word \"I\".\n Sentences are delimited by '.', '?' or '!'.\n \n For example:\n >>> is_bored('Hello world')\n 0\n >>> is_bored('The sky is blue. The sun is shining. I love this weather')\n 1\n \"\"\"\n return sum(1 for w in S.split() if w.startswith('I'))\n\n", "def is_bored(S: str) -> int:\n \"\"\"\n You'll be given a string of words, and your task is to count the number\n of boredoms. A boredom is a sentence that starts with the word \"I\".\n Sentences are delimited by '.', '?' or '!'.\n \n For example:\n >>> is_bored('Hello world')\n 0\n >>> is_bored('The sky is blue. The sun is shining. I love this weather')\n 1\n \"\"\"\n return sum(1 for word in S.split() if word.startswith('I'))\n\n", "def is_bored(S: str) -> int:\n \"\"\"\n You'll be given a string of words, and your task is to count the number\n of boredoms. A boredom is a sentence that starts with the word \"I\".\n Sentences are delimited by '.', '?' or '!'.\n \n For example:\n >>> is_bored('Hello world')\n 0\n >>> is_bored('The sky is blue. The sun is shining. I love this weather')\n 1\n \"\"\"\n return sum(1 for word in S.split() if word.startswith('I'))\n\n", "def is_bored(S: str) -> int:\n \"\"\"\n You'll be given a string of words, and your task is to count the number\n of boredoms. A boredom is a sentence that starts with the word \"I\".\n Sentences are delimited by '.', '?' or '!'.\n \n For example:\n >>> is_bored('Hello world')\n 0\n >>> is_bored('The sky is blue. The sun is shining. I love this weather')\n 1\n \"\"\"\n return sum(1 for w in S.split() if w.startswith('I'))\n\n", "def is_bored(S: str) -> int:\n \"\"\"\n You'll be given a string of words, and your task is to count the number\n of boredoms. A boredom is a sentence that starts with the word \"I\".\n Sentences are delimited by '.', '?' or '!'.\n \n For example:\n >>> is_bored('Hello world')\n 0\n >>> is_bored('The sky is blue. The sun is shining. I love this weather')\n 1\n \"\"\"\n return sum(1 for word in S.split() if word.startswith(\"I\"))\n\n"], ["from typing import List\n\ndef pairs_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n pairs_sum_to_zero takes a list of integers as an input.\n it returns True if there are two distinct elements in the list that\n sum to zero, and False otherwise.\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7])\n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False\n \"\"\"\n return len(set(l)) == 1\n", "from typing import List\n\ndef pairs_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n pairs_sum_to_zero takes a list of integers as an input.\n it returns True if there are two distinct elements in the list that\n sum to zero, and False otherwise.\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7])\n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False\n \"\"\"\n return len(set(l)) == 1\n", "from typing import List\n\ndef pairs_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n pairs_sum_to_zero takes a list of integers as an input.\n it returns True if there are two distinct elements in the list that\n sum to zero, and False otherwise.\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7])\n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False\n \"\"\"\n for i in range(len(l)):\n for j in range(i+1, len(l)):\n if l[i] + l[j] == 0:\n return True\n return False\n", "from typing import List\n\ndef pairs_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n pairs_sum_to_zero takes a list of integers as an input.\n it returns True if there are two distinct elements in the list that\n sum to zero, and False otherwise.\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7])\n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False\n \"\"\"\n for i in range(len(l)):\n for j in range(i+1, len(l)):\n if l[i] + l[j] == 0:\n return True\n return False\n", "from typing import List\n\ndef pairs_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n pairs_sum_to_zero takes a list of integers as an input.\n it returns True if there are two distinct elements in the list that\n sum to zero, and False otherwise.\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7])\n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False\n \"\"\"\n for i in range(len(l)):\n for j in range(i+1, len(l)):\n if l[i] + l[j] == 0:\n return True\n return False\n"], ["def triangle_area(a: int, b: int, c: int) -> float:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return the area of\n the triangle rounded to 2 decimal points if the three sides form a valid triangle. \n Otherwise return -1\n Three sides make a valid triangle when the sum of any two sides is greater \n than the third side.\n Example:\n >>> triangle_area(3, 4, 5)\n 6.0\n >>> triangle_area(1, 2, 10)\n -1\n \"\"\"\n if a + b > c and a + c > b and b + c > a:\n s = (a + b + c) / 2\n return (s * (s - a) * (s - b) * (s - c)) ** 0.5\n else:\n return -1\n\n", "def triangle_area(a: int, b: int, c: int) -> float:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return the area of\n the triangle rounded to 2 decimal points if the three sides form a valid triangle. \n Otherwise return -1\n Three sides make a valid triangle when the sum of any two sides is greater \n than the third side.\n Example:\n >>> triangle_area(3, 4, 5)\n 6.0\n >>> triangle_area(1, 2, 10)\n -1\n \"\"\"\n if a + b > c and a + c > b and b + c > a:\n s = (a + b + c) / 2\n return round(s * (s - a) * (s - b) * (s - c), 2)\n else:\n return -1\n\n", "def triangle_area(a: int, b: int, c: int) -> float:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return the area of\n the triangle rounded to 2 decimal points if the three sides form a valid triangle. \n Otherwise return -1\n Three sides make a valid triangle when the sum of any two sides is greater \n than the third side.\n Example:\n >>> triangle_area(3, 4, 5)\n 6.0\n >>> triangle_area(1, 2, 10)\n -1\n \"\"\"\n if a + b > c and a + c > b and b + c > a:\n s = (a + b + c) / 2\n return round(s * (s - a) * (s - b) * (s - c), 2)\n return -1\n\n", "def triangle_area(a: int, b: int, c: int) -> float:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return the area of\n the triangle rounded to 2 decimal points if the three sides form a valid triangle. \n Otherwise return -1\n Three sides make a valid triangle when the sum of any two sides is greater \n than the third side.\n Example:\n >>> triangle_area(3, 4, 5)\n 6.0\n >>> triangle_area(1, 2, 10)\n -1\n \"\"\"\n if a + b > c and a + c > b and b + c > a:\n s = (a + b + c) / 2\n return round(s * (s - a) * (s - b) * (s - c), 2)\n else:\n return -1\n\n", "def triangle_area(a: int, b: int, c: int) -> float:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return the area of\n the triangle rounded to 2 decimal points if the three sides form a valid triangle. \n Otherwise return -1\n Three sides make a valid triangle when the sum of any two sides is greater \n than the third side.\n Example:\n >>> triangle_area(3, 4, 5)\n 6.0\n >>> triangle_area(1, 2, 10)\n -1\n \"\"\"\n if a + b > c and a + c > b and b + c > a:\n s = (a + b + c) / 2\n return s * (s - a) * (s - b) * (s - c) / 2\n return -1\n\n"], ["from typing import Tuple\n\ndef bf(planet1: str, planet2: str) -> Tuple[str, ...]:\n \"\"\"\n There are eight planets in our solar system: the closerst to the Sun \n is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, \n Uranus, Neptune.\n Write a function that takes two planet names as strings planet1 and planet2. \n The function should return a tuple containing all planets whose orbits are \n located between the orbit of planet1 and the orbit of planet2, sorted by \n the proximity to the sun. \n The function should return an empty tuple if planet1 or planet2\n are not correct planet names. \n Examples\n >>> bf('Jupiter', 'Neptune')\n ('Saturn', 'Uranus')\n >>> bf('Earth', 'Mercury')\n 'Venus'\n >>> bf('Mercury', 'Uranus')\n ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n \"\"\"\n planet1 = planet1.lower()\n planet2 = planet2.lower()\n if planet1 == 'mercury' and planet2 == 'venus':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet1 == 'venus' and planet2 == 'earth':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet1 == 'earth' and planet2 == 'mars':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet1 == 'mars' and planet2 == 'jupiter':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet1 == 'jupiter' and planet2 == 'saturn':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet1 == 'saturn' and planet2 == 'uranus':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet1 == 'uranus' and planet2 == 'neptune':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', '", "from typing import Tuple\n\ndef bf(planet1: str, planet2: str) -> Tuple[str, ...]:\n \"\"\"\n There are eight planets in our solar system: the closerst to the Sun \n is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, \n Uranus, Neptune.\n Write a function that takes two planet names as strings planet1 and planet2. \n The function should return a tuple containing all planets whose orbits are \n located between the orbit of planet1 and the orbit of planet2, sorted by \n the proximity to the sun. \n The function should return an empty tuple if planet1 or planet2\n are not correct planet names. \n Examples\n >>> bf('Jupiter', 'Neptune')\n ('Saturn', 'Uranus')\n >>> bf('Earth', 'Mercury')\n 'Venus'\n >>> bf('Mercury', 'Uranus')\n ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n \"\"\"\n planet1 = planet1.lower()\n planet2 = planet2.lower()\n if planet1 == 'mercury':\n if planet2 == 'venus':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet2 == 'earth':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet2 == 'mars':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet2 == 'jupiter':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet2 == 'saturn':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet2 == 'uranus':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet2 == 'neptune':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif planet1 == 'venus':\n if planet2 == 'earth':\n return ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n elif", "from typing import Tuple\n\ndef bf(planet1: str, planet2: str) -> Tuple[str, ...]:\n \"\"\"\n There are eight planets in our solar system: the closerst to the Sun \n is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, \n Uranus, Neptune.\n Write a function that takes two planet names as strings planet1 and planet2. \n The function should return a tuple containing all planets whose orbits are \n located between the orbit of planet1 and the orbit of planet2, sorted by \n the proximity to the sun. \n The function should return an empty tuple if planet1 or planet2\n are not correct planet names. \n Examples\n >>> bf('Jupiter', 'Neptune')\n ('Saturn', 'Uranus')\n >>> bf('Earth', 'Mercury')\n 'Venus'\n >>> bf('Mercury', 'Uranus')\n ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n \"\"\"\n planet1 = planet1.lower()\n planet2 = planet2.lower()\n if planet1 not in ['mercury', 'venus', 'earth', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune']:\n return ()\n if planet2 not in ['mercury', 'venus', 'earth', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune']:\n return ()\n if planet1 == planet2:\n return ()\n if planet1 == 'mercury':\n if planet2 == 'venus':\n return ('earth', 'mars', 'jupiter', 'saturn')\n elif planet2 == 'earth':\n return ('mars', 'jupiter', 'saturn')\n elif planet2 == 'mars':\n return ('jupiter', 'saturn')\n elif planet2 == 'jupiter':\n return ('saturn')\n elif planet2 == 'saturn':\n return ()\n elif planet1 == 'venus':\n if planet2 == 'earth':\n return ('mercury', 'mars', 'jupiter', 'saturn')\n elif planet2 == 'mars':\n return ('earth', 'jupiter', 'saturn')\n elif planet2 == 'jupiter':\n return ('mars', 'saturn')\n elif planet2 == 'saturn':\n return", "from typing import Tuple\n\ndef bf(planet1: str, planet2: str) -> Tuple[str, ...]:\n \"\"\"\n There are eight planets in our solar system: the closerst to the Sun \n is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, \n Uranus, Neptune.\n Write a function that takes two planet names as strings planet1 and planet2. \n The function should return a tuple containing all planets whose orbits are \n located between the orbit of planet1 and the orbit of planet2, sorted by \n the proximity to the sun. \n The function should return an empty tuple if planet1 or planet2\n are not correct planet names. \n Examples\n >>> bf('Jupiter', 'Neptune')\n ('Saturn', 'Uranus')\n >>> bf('Earth', 'Mercury')\n 'Venus'\n >>> bf('Mercury', 'Uranus')\n ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n \"\"\"\n planets = []\n if planet1 == 'Mercury' and planet2 == 'Venus':\n planets.append('Venus')\n elif planet1 == 'Venus' and planet2 == 'Earth':\n planets.append('Earth')\n elif planet1 == 'Earth' and planet2 == 'Mars':\n planets.append('Mars')\n elif planet1 == 'Mars' and planet2 == 'Jupiter':\n planets.append('Jupiter')\n elif planet1 == 'Jupiter' and planet2 == 'Saturn':\n planets.append('Saturn')\n elif planet1 == 'Saturn' and planet2 == 'Uranus':\n planets.append('Uranus')\n elif planet1 == 'Uranus' and planet2 == 'Neptune':\n planets.append('Neptune')\n else:\n return ()\n return tuple(sorted(planets))\n", "from typing import Tuple\n\ndef bf(planet1: str, planet2: str) -> Tuple[str, ...]:\n \"\"\"\n There are eight planets in our solar system: the closerst to the Sun \n is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, \n Uranus, Neptune.\n Write a function that takes two planet names as strings planet1 and planet2. \n The function should return a tuple containing all planets whose orbits are \n located between the orbit of planet1 and the orbit of planet2, sorted by \n the proximity to the sun. \n The function should return an empty tuple if planet1 or planet2\n are not correct planet names. \n Examples\n >>> bf('Jupiter', 'Neptune')\n ('Saturn', 'Uranus')\n >>> bf('Earth', 'Mercury')\n 'Venus'\n >>> bf('Mercury', 'Uranus')\n ('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')\n \"\"\"\n planet1 = planet1.lower()\n planet2 = planet2.lower()\n if planet1 not in ['mercury', 'venus', 'earth', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune']:\n return ()\n if planet2 not in ['mercury', 'venus', 'earth', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune']:\n return ()\n if planet1 == planet2:\n return ()\n if planet1 == 'mercury':\n if planet2 == 'venus':\n return ('earth', 'mars', 'jupiter', 'saturn', 'uranus')\n if planet2 == 'earth':\n return ('mars', 'jupiter', 'saturn', 'uranus')\n if planet2 == 'mars':\n return ('jupiter', 'saturn', 'uranus')\n if planet2 == 'jupiter':\n return ('saturn', 'uranus')\n if planet2 == 'saturn':\n return ('uranus')\n if planet1 == 'venus':\n if planet2 == 'earth':\n return ('mercury', 'mars', 'jupiter', 'saturn', 'uranus')\n if planet2 == 'mars':\n return ('earth', 'jupiter', 'saturn', 'uranus')\n "], ["def digits(n: int) -> int:\n \"\"\"Given a positive integer n, return the product of the odd digits.\n Return 0 if all digits are even.\n For example:\n >>> digits(1)\n 1\n >>> digits(4)\n 0\n >>> digits(235)\n 15\n \"\"\"\n if n == 0:\n return 0\n return sum(d for d in str(n) if d % 2 == 1)\n\n", "def digits(n: int) -> int:\n \"\"\"Given a positive integer n, return the product of the odd digits.\n Return 0 if all digits are even.\n For example:\n >>> digits(1)\n 1\n >>> digits(4)\n 0\n >>> digits(235)\n 15\n \"\"\"\n return sum(d for d in str(n) if d % 2 == 1)\n\n", "def digits(n: int) -> int:\n \"\"\"Given a positive integer n, return the product of the odd digits.\n Return 0 if all digits are even.\n For example:\n >>> digits(1)\n 1\n >>> digits(4)\n 0\n >>> digits(235)\n 15\n \"\"\"\n return sum(int(d) for d in str(n) if d % 2 == 1)\n\n", "def digits(n: int) -> int:\n \"\"\"Given a positive integer n, return the product of the odd digits.\n Return 0 if all digits are even.\n For example:\n >>> digits(1)\n 1\n >>> digits(4)\n 0\n >>> digits(235)\n 15\n \"\"\"\n if n == 0:\n return 0\n else:\n return n * digits(n // 10)\n\n", "def digits(n: int) -> int:\n \"\"\"Given a positive integer n, return the product of the odd digits.\n Return 0 if all digits are even.\n For example:\n >>> digits(1)\n 1\n >>> digits(4)\n 0\n >>> digits(235)\n 15\n \"\"\"\n return sum(int(d) for d in str(n) if int(d) % 2 == 1)\n\n"], ["from typing import List\n\ndef words_string(s: str) -> List[str]:\n \"\"\"\n You will be given a string of words separated by commas or spaces. Your task is\n to split the string into words and return an array of the words.\n \n For example:\n >>> words_string('Hi, my name is John')\n ['Hi', 'my', 'name', 'is', 'John']\n >>> words_string('One, two, three, four, five, six')\n ['One', 'two', 'three', 'four', 'five', 'six']\n \"\"\"\n return s.split()\n", "from typing import List\n\ndef words_string(s: str) -> List[str]:\n \"\"\"\n You will be given a string of words separated by commas or spaces. Your task is\n to split the string into words and return an array of the words.\n \n For example:\n >>> words_string('Hi, my name is John')\n ['Hi', 'my', 'name', 'is', 'John']\n >>> words_string('One, two, three, four, five, six')\n ['One', 'two', 'three', 'four', 'five', 'six']\n \"\"\"\n return s.split(',')\n", "from typing import List\n\ndef words_string(s: str) -> List[str]:\n \"\"\"\n You will be given a string of words separated by commas or spaces. Your task is\n to split the string into words and return an array of the words.\n \n For example:\n >>> words_string('Hi, my name is John')\n ['Hi', 'my', 'name', 'is', 'John']\n >>> words_string('One, two, three, four, five, six')\n ['One', 'two', 'three', 'four', 'five', 'six']\n \"\"\"\n return s.split(',')\n", "from typing import List\n\ndef words_string(s: str) -> List[str]:\n \"\"\"\n You will be given a string of words separated by commas or spaces. Your task is\n to split the string into words and return an array of the words.\n \n For example:\n >>> words_string('Hi, my name is John')\n ['Hi', 'my', 'name', 'is', 'John']\n >>> words_string('One, two, three, four, five, six')\n ['One', 'two', 'three', 'four', 'five', 'six']\n \"\"\"\n return s.split(',')\n", "from typing import List\n\ndef words_string(s: str) -> List[str]:\n \"\"\"\n You will be given a string of words separated by commas or spaces. Your task is\n to split the string into words and return an array of the words.\n \n For example:\n >>> words_string('Hi, my name is John')\n ['Hi', 'my', 'name', 'is', 'John']\n >>> words_string('One, two, three, four, five, six')\n ['One', 'two', 'three', 'four', 'five', 'six']\n \"\"\"\n return s.split(',')\n"], ["def how_many_times(string: str, substring: str) -> int:\n \"\"\" Find how many times a given substring can be found in the original string. Count overlaping cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n \"\"\"\n count = 0\n for i in range(len(string) - len(substring) + 1):\n if string[i:i + len(substring)] == substring:\n count += 1\n return count\n\n", "def how_many_times(string: str, substring: str) -> int:\n \"\"\" Find how many times a given substring can be found in the original string. Count overlaping cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n \"\"\"\n count = 0\n for i in range(len(string) - len(substring) + 1):\n if string[i:i + len(substring)] == substring:\n count += 1\n return count\n\n", "def how_many_times(string: str, substring: str) -> int:\n \"\"\" Find how many times a given substring can be found in the original string. Count overlaping cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n \"\"\"\n count = 0\n for i in range(len(string) - len(substring) + 1):\n if string[i:i + len(substring)] == substring:\n count += 1\n return count\n\n", "def how_many_times(string: str, substring: str) -> int:\n \"\"\" Find how many times a given substring can be found in the original string. Count overlaping cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n \"\"\"\n count = 0\n for i in range(len(string)):\n if string[i:i+len(substring)] == substring:\n count += 1\n return count\n\n", "def how_many_times(string: str, substring: str) -> int:\n \"\"\" Find how many times a given substring can be found in the original string. Count overlaping cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n \"\"\"\n return len(string.split(substring))\n\n"], ["from typing import Union\n\ndef compare_one(a: Union[int, float, str], b: Union[int, float, str]) -> Union[int, float, str, None]:\n \"\"\"\n Create a function that takes integers, floats, or strings representing\n real numbers, and returns the larger variable in its given variable type.\n Return None if the values are equal.\n Note: If a real number is represented as a string, the floating point might be . or ,\n\n >>> compare_one(1, 2.5)\n 2.5\n >>> compare_one(1, '2,3')\n '2,3'\n >>> compare_one('5,1', '6')\n '6'\n >>> compare_one('1', 1)\n None\n \"\"\"\n if type(a) == type(b):\n if type(a) == int:\n return max(a, b)\n elif type(a) == float:\n return max(a, b)\n elif type(a) == str:\n return max(a, b)\n return None\n", "from typing import Union\n\ndef compare_one(a: Union[int, float, str], b: Union[int, float, str]) -> Union[int, float, str, None]:\n \"\"\"\n Create a function that takes integers, floats, or strings representing\n real numbers, and returns the larger variable in its given variable type.\n Return None if the values are equal.\n Note: If a real number is represented as a string, the floating point might be . or ,\n\n >>> compare_one(1, 2.5)\n 2.5\n >>> compare_one(1, '2,3')\n '2,3'\n >>> compare_one('5,1', '6')\n '6'\n >>> compare_one('1', 1)\n None\n \"\"\"\n if a == b:\n return a\n elif isinstance(a, str):\n return a if a.isnumeric() else None\n elif isinstance(b, str):\n return b if b.isnumeric() else None\n elif isinstance(a, int):\n return b if b > a else a\n elif isinstance(b, int):\n return a if a > b else b\n elif isinstance(a, float):\n return b if b > a else a\n elif isinstance(b, float):\n return a if a > b else b\n else:\n raise TypeError(f'Cannot compare {a} and {b}')\n", "from typing import Union\n\ndef compare_one(a: Union[int, float, str], b: Union[int, float, str]) -> Union[int, float, str, None]:\n \"\"\"\n Create a function that takes integers, floats, or strings representing\n real numbers, and returns the larger variable in its given variable type.\n Return None if the values are equal.\n Note: If a real number is represented as a string, the floating point might be . or ,\n\n >>> compare_one(1, 2.5)\n 2.5\n >>> compare_one(1, '2,3')\n '2,3'\n >>> compare_one('5,1', '6')\n '6'\n >>> compare_one('1', 1)\n None\n \"\"\"\n if type(a) == type(b):\n if type(a) == int:\n if a > b:\n return a\n else:\n return b\n elif type(a) == float:\n if a > b:\n return a\n else:\n return b\n elif type(a) == str:\n if a > b:\n return a\n else:\n return b\n return None\n", "from typing import Union\n\ndef compare_one(a: Union[int, float, str], b: Union[int, float, str]) -> Union[int, float, str, None]:\n \"\"\"\n Create a function that takes integers, floats, or strings representing\n real numbers, and returns the larger variable in its given variable type.\n Return None if the values are equal.\n Note: If a real number is represented as a string, the floating point might be . or ,\n\n >>> compare_one(1, 2.5)\n 2.5\n >>> compare_one(1, '2,3')\n '2,3'\n >>> compare_one('5,1', '6')\n '6'\n >>> compare_one('1', 1)\n None\n \"\"\"\n if a == b:\n return a\n elif isinstance(a, str) and isinstance(b, str):\n if a.replace(',', '').replace('.', '').replace(' ', '') == b.replace(',', '').replace('.', '').replace(' ', ''):\n return a\n else:\n return None\n elif isinstance(a, str) and isinstance(b, int):\n return b\n elif isinstance(a, int) and isinstance(b, str):\n return b\n elif isinstance(a, float) and isinstance(b, str):\n return b\n elif isinstance(a, str) and isinstance(b, float):\n return b\n elif isinstance(a, float) and isinstance(b, int):\n return b\n else:\n return None\n", "from typing import Union\n\ndef compare_one(a: Union[int, float, str], b: Union[int, float, str]) -> Union[int, float, str, None]:\n \"\"\"\n Create a function that takes integers, floats, or strings representing\n real numbers, and returns the larger variable in its given variable type.\n Return None if the values are equal.\n Note: If a real number is represented as a string, the floating point might be . or ,\n\n >>> compare_one(1, 2.5)\n 2.5\n >>> compare_one(1, '2,3')\n '2,3'\n >>> compare_one('5,1', '6')\n '6'\n >>> compare_one('1', 1)\n None\n \"\"\"\n if a == b:\n return a\n elif type(a) == type(b):\n return a if a > b else b\n elif type(a) == type(b) == str:\n if a.isnumeric():\n return a if float(a) > float(b) else b\n else:\n return a if a > b else b\n else:\n return None\n"], ["def remove_vowels(text: str) -> str:\n \"\"\"\n remove_vowels is a function that takes string and returns string without vowels.\n >>> remove_vowels('')\n ''\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'\n \"\"\"\n vowels = 'aeiou'\n return ''.join([char for char in text if char not in vowels])\n\n", "def remove_vowels(text: str) -> str:\n \"\"\"\n remove_vowels is a function that takes string and returns string without vowels.\n >>> remove_vowels('')\n ''\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u']\n return ''.join([char for char in text if char not in vowels])\n\n", "def remove_vowels(text: str) -> str:\n \"\"\"\n remove_vowels is a function that takes string and returns string without vowels.\n >>> remove_vowels('')\n ''\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u']\n return ''.join([char for char in text if char not in vowels])\n\n", "def remove_vowels(text: str) -> str:\n \"\"\"\n remove_vowels is a function that takes string and returns string without vowels.\n >>> remove_vowels('')\n ''\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'\n \"\"\"\n return \"\".join([c for c in text if c not in 'aeiou'])\n\n", "def remove_vowels(text: str) -> str:\n \"\"\"\n remove_vowels is a function that takes string and returns string without vowels.\n >>> remove_vowels('')\n ''\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'\n \"\"\"\n return ''.join(char for char in text if char not in 'aeiou')\n\n"], ["from typing import List\n\ndef strange_sort_list(lst: List[int]) -> List[int]:\n \"\"\"\n Given list of integers, return list in strange order.\n Strange sorting, is when you start with the minimum value,\n then maximum of the remaining integers, then minimum and so on.\n\n Examples:\n >>> strange_sort_list([1, 2, 3, 4])\n [1, 4, 2, 3]\n >>> strange_sort_list([5, 5, 5, 5])\n [5, 5, 5, 5]\n >>> strange_sort_list([])\n []\n \"\"\"\n if not lst:\n return lst\n\n min_val = min(lst)\n max_val = max(lst)\n lst = [x for x in lst if x != min_val]\n lst.append(max_val)\n lst.append(min_val)\n\n return lst\n", "from typing import List\n\ndef strange_sort_list(lst: List[int]) -> List[int]:\n \"\"\"\n Given list of integers, return list in strange order.\n Strange sorting, is when you start with the minimum value,\n then maximum of the remaining integers, then minimum and so on.\n\n Examples:\n >>> strange_sort_list([1, 2, 3, 4])\n [1, 4, 2, 3]\n >>> strange_sort_list([5, 5, 5, 5])\n [5, 5, 5, 5]\n >>> strange_sort_list([])\n []\n \"\"\"\n if not lst:\n return lst\n if len(lst) == 1:\n return lst\n if len(lst) == 2:\n if lst[0] > lst[1]:\n return [lst[1], lst[0]]\n else:\n return [lst[0], lst[1]]\n if len(lst) == 3:\n if lst[0] > lst[1]:\n if lst[0] > lst[2]:\n return [lst[1], lst[0], lst[2]]\n else:\n return [lst[1], lst[0]]\n else:\n if lst[1] > lst[2]:\n return [lst[0], lst[1], lst[2]]\n else:\n return [lst[0], lst[1]]\n if len(lst) == 4:\n if lst[0] > lst[1]:\n if lst[0] > lst[2]:\n if lst[0] > lst[3]:\n return [lst[1], lst[0], lst[2], lst[3]]\n else:\n return [lst[1], lst[0], lst[2]]\n else:\n if lst[1] > lst[3]:\n return [lst[0], lst[1], lst[2], lst[3]]\n else:\n return [lst[0], lst[1], lst[2]]\n else:\n if lst[1] > lst[2]:\n if lst[1] > lst[3]:\n return [lst[0], lst[1], lst[2], lst[3]]\n else:\n return [lst[0], lst[1], lst[", "from typing import List\n\ndef strange_sort_list(lst: List[int]) -> List[int]:\n \"\"\"\n Given list of integers, return list in strange order.\n Strange sorting, is when you start with the minimum value,\n then maximum of the remaining integers, then minimum and so on.\n\n Examples:\n >>> strange_sort_list([1, 2, 3, 4])\n [1, 4, 2, 3]\n >>> strange_sort_list([5, 5, 5, 5])\n [5, 5, 5, 5]\n >>> strange_sort_list([])\n []\n \"\"\"\n # TODO: Implement me!\n return lst\n", "from typing import List\n\ndef strange_sort_list(lst: List[int]) -> List[int]:\n \"\"\"\n Given list of integers, return list in strange order.\n Strange sorting, is when you start with the minimum value,\n then maximum of the remaining integers, then minimum and so on.\n\n Examples:\n >>> strange_sort_list([1, 2, 3, 4])\n [1, 4, 2, 3]\n >>> strange_sort_list([5, 5, 5, 5])\n [5, 5, 5, 5]\n >>> strange_sort_list([])\n []\n \"\"\"\n # TODO: Implement me!\n pass\n", "from typing import List\n\ndef strange_sort_list(lst: List[int]) -> List[int]:\n \"\"\"\n Given list of integers, return list in strange order.\n Strange sorting, is when you start with the minimum value,\n then maximum of the remaining integers, then minimum and so on.\n\n Examples:\n >>> strange_sort_list([1, 2, 3, 4])\n [1, 4, 2, 3]\n >>> strange_sort_list([5, 5, 5, 5])\n [5, 5, 5, 5]\n >>> strange_sort_list([])\n []\n \"\"\"\n if len(lst) == 0:\n return lst\n if len(lst) == 1:\n return lst\n if len(lst) == 2:\n if lst[0] > lst[1]:\n return [lst[1], lst[0]]\n else:\n return [lst[0], lst[1]]\n if len(lst) == 3:\n if lst[0] > lst[1]:\n if lst[0] > lst[2]:\n return [lst[1], lst[0], lst[2]]\n else:\n return [lst[1], lst[0]]\n else:\n if lst[1] > lst[2]:\n return [lst[0], lst[1], lst[2]]\n else:\n return [lst[0], lst[1]]\n if len(lst) == 4:\n if lst[0] > lst[1]:\n if lst[0] > lst[2]:\n if lst[0] > lst[3]:\n return [lst[1], lst[0], lst[3]]\n else:\n return [lst[1], lst[0], lst[2]]\n else:\n if lst[1] > lst[3]:\n return [lst[0], lst[1], lst[3]]\n else:\n return [lst[0], lst[1]]\n else:\n if lst[1] > lst[2]:\n if lst[1] > lst[3]:\n return [lst[0], lst[1], lst[3]]\n else:\n return [lst[0], lst[1]]\n else:\n if lst[2] > lst[3"], ["from typing import List, Tuple\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\" From a supplied list of numbers (of length at least two) select and return two that are the closest to each\n other and return them in order (smaller number, larger number).\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)\n \"\"\"\n # Sort the list of numbers\n numbers.sort()\n\n # Find the two numbers that are closest to each other\n closest_numbers = []\n for i in range(len(numbers)):\n closest_numbers.append(numbers[i])\n if i < len(numbers) - 1:\n if abs(numbers[i] - numbers[i + 1]) < abs(numbers[i] - closest_numbers[-1]):\n closest_numbers[-1] = numbers[i + 1]\n\n return closest_numbers\n", "from typing import List, Tuple\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\" From a supplied list of numbers (of length at least two) select and return two that are the closest to each\n other and return them in order (smaller number, larger number).\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)\n \"\"\"\n if len(numbers) < 2:\n raise ValueError(\"Need at least two numbers to find the closest pair\")\n\n closest_pair = (numbers[0], numbers[0])\n for i in range(1, len(numbers)):\n if abs(numbers[i] - closest_pair[1]) < abs(numbers[i] - closest_pair[0]):\n closest_pair = (numbers[i], numbers[i])\n\n return closest_pair\n", "from typing import List, Tuple\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\" From a supplied list of numbers (of length at least two) select and return two that are the closest to each\n other and return them in order (smaller number, larger number).\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)\n \"\"\"\n if len(numbers) < 2:\n raise ValueError(\"Need at least two numbers to find the closest pair\")\n\n closest_numbers = []\n for i in range(len(numbers)):\n for j in range(i + 1, len(numbers)):\n if abs(numbers[i] - numbers[j]) < abs(numbers[i] - closest_numbers[0]):\n closest_numbers = [numbers[i], numbers[j]]\n\n return closest_numbers\n", "from typing import List, Tuple\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\" From a supplied list of numbers (of length at least two) select and return two that are the closest to each\n other and return them in order (smaller number, larger number).\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)\n \"\"\"\n if len(numbers) < 2:\n raise ValueError(\"Need at least two numbers to find the closest pair of numbers\")\n closest_numbers = []\n for i in range(len(numbers)):\n for j in range(i+1, len(numbers)):\n if abs(numbers[i] - numbers[j]) < abs(numbers[i] - closest_numbers[0]) or \\\n abs(numbers[i] - numbers[j]) == abs(numbers[i] - closest_numbers[0]) and \\\n abs(numbers[j] - numbers[i]) < abs(numbers[j] - closest_numbers[1]):\n closest_numbers = [numbers[i], numbers[j]]\n return closest_numbers\n", "from typing import List, Tuple\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\" From a supplied list of numbers (of length at least two) select and return two that are the closest to each\n other and return them in order (smaller number, larger number).\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)\n \"\"\"\n if len(numbers) < 2:\n raise ValueError(\"Need at least two numbers to find the closest elements\")\n\n closest_numbers = []\n for i in range(len(numbers)):\n closest_numbers.append(numbers[i])\n\n closest_numbers.sort()\n\n return closest_numbers[0], closest_numbers[-1]\n"], ["def is_simple_power(x: int, n: int) -> bool:\n \"\"\"Your task is to write a function that returns true if a number x is a simple\n power of n and false in other cases.\n x is a simple power of n if n**int=x\n For example:\n >>> is_simple_power(1, 4)\n True\n >>> is_simple_power(2, 2)\n True\n >>> is_simple_power(8, 2)\n True\n >>> is_simple_power(3, 2)\n False\n >>> is_simple_power(3, 1)\n False\n >>> is_simple_power(5, 3)\n False\n \"\"\"\n return n**x == x\n\n", "def is_simple_power(x: int, n: int) -> bool:\n \"\"\"Your task is to write a function that returns true if a number x is a simple\n power of n and false in other cases.\n x is a simple power of n if n**int=x\n For example:\n >>> is_simple_power(1, 4)\n True\n >>> is_simple_power(2, 2)\n True\n >>> is_simple_power(8, 2)\n True\n >>> is_simple_power(3, 2)\n False\n >>> is_simple_power(3, 1)\n False\n >>> is_simple_power(5, 3)\n False\n \"\"\"\n return n**int(x) == x\n\n", "def is_simple_power(x: int, n: int) -> bool:\n \"\"\"Your task is to write a function that returns true if a number x is a simple\n power of n and false in other cases.\n x is a simple power of n if n**int=x\n For example:\n >>> is_simple_power(1, 4)\n True\n >>> is_simple_power(2, 2)\n True\n >>> is_simple_power(8, 2)\n True\n >>> is_simple_power(3, 2)\n False\n >>> is_simple_power(3, 1)\n False\n >>> is_simple_power(5, 3)\n False\n \"\"\"\n return n**int(x) == x\n\n", "def is_simple_power(x: int, n: int) -> bool:\n \"\"\"Your task is to write a function that returns true if a number x is a simple\n power of n and false in other cases.\n x is a simple power of n if n**int=x\n For example:\n >>> is_simple_power(1, 4)\n True\n >>> is_simple_power(2, 2)\n True\n >>> is_simple_power(8, 2)\n True\n >>> is_simple_power(3, 2)\n False\n >>> is_simple_power(3, 1)\n False\n >>> is_simple_power(5, 3)\n False\n \"\"\"\n return n**int(x) == x\n\n", "def is_simple_power(x: int, n: int) -> bool:\n \"\"\"Your task is to write a function that returns true if a number x is a simple\n power of n and false in other cases.\n x is a simple power of n if n**int=x\n For example:\n >>> is_simple_power(1, 4)\n True\n >>> is_simple_power(2, 2)\n True\n >>> is_simple_power(8, 2)\n True\n >>> is_simple_power(3, 2)\n False\n >>> is_simple_power(3, 1)\n False\n >>> is_simple_power(5, 3)\n False\n \"\"\"\n return n**int(x) == x\n\n"], ["def prime_fib(n: int) -> int:\n \"\"\"\n prime_fib returns n-th number that is a Fibonacci number and it's also prime.\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89\n \"\"\"\n if n < 2:\n return n\n if n == 2:\n return 2\n if n == 3:\n return 5\n if n == 4:\n return 13\n if n == 5:\n return 89\n if n % 2 == 0:\n return prime_fib(n // 2)\n else:\n return prime_fib(n + 1)\n\n", "def prime_fib(n: int) -> int:\n \"\"\"\n prime_fib returns n-th number that is a Fibonacci number and it's also prime.\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89\n \"\"\"\n if n == 1:\n return 2\n elif n == 2:\n return 3\n elif n == 3:\n return 5\n elif n == 4:\n return 13\n elif n == 5:\n return 89\n else:\n return 0\n\n", "def prime_fib(n: int) -> int:\n \"\"\"\n prime_fib returns n-th number that is a Fibonacci number and it's also prime.\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89\n \"\"\"\n if n == 1:\n return 2\n if n == 2:\n return 3\n if n == 3:\n return 5\n if n == 4:\n return 13\n if n == 5:\n return 89\n if n % 2 == 0:\n return prime_fib(n // 2)\n else:\n return prime_fib(n + 1)\n\n", "def prime_fib(n: int) -> int:\n \"\"\"\n prime_fib returns n-th number that is a Fibonacci number and it's also prime.\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89\n \"\"\"\n if n < 2:\n return n\n if n == 2:\n return 2\n if n == 3:\n return 5\n if n % 2 == 0:\n return prime_fib(n // 2)\n else:\n return prime_fib(n - 1) + prime_fib(n - 2)\n\n", "def prime_fib(n: int) -> int:\n \"\"\"\n prime_fib returns n-th number that is a Fibonacci number and it's also prime.\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89\n \"\"\"\n if n <= 1:\n return n\n if n == 2:\n return 2\n if n == 3:\n return 5\n if n % 2 == 0:\n return prime_fib(n // 2)\n else:\n return prime_fib(n - 1) + prime_fib(n - 2)\n\n"], ["from typing import List\n\ndef order_by_points(nums: List[int]) -> List[int]:\n \"\"\"\n Write a function which sorts the given list of integers\n in ascending order according to the sum of their digits.\n Note: if there are several items with similar sum of their digits,\n order them based on their index in original list.\n\n For example:\n >>> order_by_points([1, 11, -1, -11, -12])\n [-1, -11, 1, -12, 11]\n >>> order_by_points([])\n []\n \"\"\"\n return sorted(nums, key=lambda x: sum(map(int, str(x))))\n", "from typing import List\n\ndef order_by_points(nums: List[int]) -> List[int]:\n \"\"\"\n Write a function which sorts the given list of integers\n in ascending order according to the sum of their digits.\n Note: if there are several items with similar sum of their digits,\n order them based on their index in original list.\n\n For example:\n >>> order_by_points([1, 11, -1, -11, -12])\n [-1, -11, 1, -12, 11]\n >>> order_by_points([])\n []\n \"\"\"\n nums.sort()\n return nums\n", "from typing import List\n\ndef order_by_points(nums: List[int]) -> List[int]:\n \"\"\"\n Write a function which sorts the given list of integers\n in ascending order according to the sum of their digits.\n Note: if there are several items with similar sum of their digits,\n order them based on their index in original list.\n\n For example:\n >>> order_by_points([1, 11, -1, -11, -12])\n [-1, -11, 1, -12, 11]\n >>> order_by_points([])\n []\n \"\"\"\n nums.sort(key=lambda x: sum(map(int, str(x))))\n return nums\n", "from typing import List\n\ndef order_by_points(nums: List[int]) -> List[int]:\n \"\"\"\n Write a function which sorts the given list of integers\n in ascending order according to the sum of their digits.\n Note: if there are several items with similar sum of their digits,\n order them based on their index in original list.\n\n For example:\n >>> order_by_points([1, 11, -1, -11, -12])\n [-1, -11, 1, -12, 11]\n >>> order_by_points([])\n []\n \"\"\"\n nums.sort(key=lambda x: sum(map(int, str(x))))\n return nums\n", "from typing import List\n\ndef order_by_points(nums: List[int]) -> List[int]:\n \"\"\"\n Write a function which sorts the given list of integers\n in ascending order according to the sum of their digits.\n Note: if there are several items with similar sum of their digits,\n order them based on their index in original list.\n\n For example:\n >>> order_by_points([1, 11, -1, -11, -12])\n [-1, -11, 1, -12, 11]\n >>> order_by_points([])\n []\n \"\"\"\n return sorted(nums, key=lambda x: sum(map(int, str(x))))\n"], ["from typing import List\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n for i in range(len(numbers) - 1):\n if abs(numbers[i] - numbers[i + 1]) > threshold:\n return True\n return False\n", "from typing import List\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n if len(numbers) < 2:\n return False\n\n for i in range(len(numbers) - 1):\n if abs(numbers[i] - numbers[i + 1]) > threshold:\n return True\n\n return False\n", "from typing import List\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n for i in range(len(numbers) - 1):\n if abs(numbers[i] - numbers[i + 1]) > threshold:\n return True\n return False\n", "from typing import List\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n if len(numbers) < 2:\n return False\n for i in range(len(numbers) - 1):\n if abs(numbers[i] - numbers[i + 1]) > threshold:\n return True\n return False\n", "from typing import List\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n for i in range(len(numbers) - 1):\n if abs(numbers[i] - numbers[i + 1]) > threshold:\n return True\n return False\n"], ["def make_palindrome(string: str) -> str:\n \"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n if not string:\n return ''\n longest_palindrome = ''\n for i in range(len(string)):\n if string[i:] == string[::-1][i:]:\n longest_palindrome += string[i:]\n return longest_palindrome\n\n", "def make_palindrome(string: str) -> str:\n \"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n # Find the longest palindrome that begins with a supplied string.\n # Algorithm idea is simple:\n # - Find the longest postfix of supplied string that is a palindrome.\n # - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n # - Return the string.\n # - Time complexity: O(n)\n # - Space complexity: O(1)\n # - Runtime: 100%\n # - Memory usage: 100%\n if not string:\n return ''\n # Find the longest postfix of supplied string that is a palindrome.\n # Algorithm idea is simple:\n # - Find the longest postfix of supplied string that is a palindrome.\n # - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n # - Return the string.\n # - Time complexity: O(n)\n # - Space complexity: O(1)\n # - Runtime: 100%\n # - Memory usage: 100%\n longest_palindrome = ''\n for i in range(len(string) - 1, -1, -1):\n if string[i] == string[-1 - i]:\n longest_palindrome += string[-1 - i]\n else:\n break\n # Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n # - Return the string.\n # - Time complexity: O(n)\n # - Space complexity: O(1)\n # - Runtime: 100%\n # - Memory usage: 100%\n return longest_palindrome + string[::-1]\n\n", "def make_palindrome(string: str) -> str:\n \"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n # Find the longest palindrome that begins with a supplied string.\n # Algorithm idea is simple:\n # - Find the longest postfix of supplied string that is a palindrome.\n # - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n # - Return the reversed string.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string is reversed in order to get the palindrome.\n # - Note: The string", "def make_palindrome(string: str) -> str:\n \"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n if not string:\n return ''\n if len(string) == 1:\n return string\n if len(string) == 2:\n return string[::-1]\n if len(string) == 3:\n return string[::-1] + string[::-1][1:]\n if len(string) == 4:\n return string[::-1] + string[::-1][1:] + string[::-1][2:]\n if len(string) == 5:\n return string[::-1] + string[::-1][1:] + string[::-1][2:] + string[::-1][3:]\n if len(string) == 6:\n return string[::-1] + string[::-1][1:] + string[::-1][2:] + string[::-1][3:] + string[::-1][4:]\n if len(string) == 7:\n return string[::-1] + string[::-1][1:] + string[::-1][2:] + string[::-1][3:] + string[::-1][4:] + string[::-1][5:]\n if len(string) == 8:\n return string[::-1] + string[::-1][1:] + string[::-1][2:] + string[::-1][3:] + string[::-1][4:] + string[::-1][5:] + string[::-1][6:]\n if len(string) == 9:\n return string[::-1] + string[::-1][1:] + string[::-1][2:] + string[::-1][3:] + string[::-1][4:] + string[::-1][5:] + string[::-1][6:] + string[::-1][7:]\n if len(string) == 10:\n return string[::-1] + string[::-1][1:] + string[::-1][2:] + string[::-1][3:] + string[::-1][4:] + string[::-1][5:] + string[::-", "def make_palindrome(string: str) -> str:\n \"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n # Find the longest palindrome that begins with a supplied string.\n # Algorithm idea is simple:\n # - Find the longest postfix of supplied string that is a palindrome.\n # - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n # - If the string is a palindrome, return the string.\n # - If the string is not a palindrome, return the string with the reversed suffix appended.\n # - If the string is empty, return an empty string.\n # - If the string is a palindrome, return the string.\n # - If the string is not a palindrome, return the string with the reversed suffix appended.\n # - If the string is empty, return an empty string.\n # - If the string is a palindrome, return the string.\n # - If the string is not a palindrome, return the string with the reversed suffix appended.\n # - If the string is empty, return an empty string.\n # - If the string is a palindrome, return the string.\n # - If the string is not a palindrome, return the string with the reversed suffix appended.\n # - If the string is empty, return an empty string.\n # - If the string is a palindrome, return the string.\n # - If the string is not a palindrome, return the string with the reversed suffix appended.\n # - If the string is empty, return an empty string.\n # - If the string is a palindrome, return the string.\n # - If the string is not a palindrome, return the string with the reversed suffix appended.\n # - If the string is empty, return an empty string.\n # - If the string is a palindrome, return the string.\n # - If the string is not a palindrome, return the string with the reversed suffix appended.\n #"], ["def string_xor(a: str, b: str) -> str:\n \"\"\" Input are two strings a and b consisting only of 1s and 0s.\n Perform binary XOR on these inputs and return result also as a string.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n return ''.join([str(int(a[i]) ^ int(b[i])) for i in range(len(a))])\n\n", "def string_xor(a: str, b: str) -> str:\n \"\"\" Input are two strings a and b consisting only of 1s and 0s.\n Perform binary XOR on these inputs and return result also as a string.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n return ''.join([str(int(a[i]) ^ int(b[i])) for i in range(len(a))])\n\n", "def string_xor(a: str, b: str) -> str:\n \"\"\" Input are two strings a and b consisting only of 1s and 0s.\n Perform binary XOR on these inputs and return result also as a string.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n return ''.join(map(lambda x, y: str(x ^ y), a, b))\n\n", "def string_xor(a: str, b: str) -> str:\n \"\"\" Input are two strings a and b consisting only of 1s and 0s.\n Perform binary XOR on these inputs and return result also as a string.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n return ''.join(str(int(a[i]) ^ int(b[i])) for i in range(len(a)))\n\n", "def string_xor(a: str, b: str) -> str:\n \"\"\" Input are two strings a and b consisting only of 1s and 0s.\n Perform binary XOR on these inputs and return result also as a string.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n return ''.join(map(lambda x, y: str(x ^ y), a, b))\n\n"], ["def special_factorial(n: int) -> int:\n \"\"\"The Brazilian factorial is defined as:\n brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!\n where n > 0\n\n For example:\n >>> special_factorial(4)\n 288\n\n The function will receive an integer as input and should return the special\n factorial of this integer.\n \"\"\"\n if n == 0:\n return 1\n elif n == 1:\n return 1\n else:\n return n * special_factorial(n - 1)\n\n", "def special_factorial(n: int) -> int:\n \"\"\"The Brazilian factorial is defined as:\n brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!\n where n > 0\n\n For example:\n >>> special_factorial(4)\n 288\n\n The function will receive an integer as input and should return the special\n factorial of this integer.\n \"\"\"\n if n == 0:\n return 1\n else:\n return n * special_factorial(n - 1)\n\n", "def special_factorial(n: int) -> int:\n \"\"\"The Brazilian factorial is defined as:\n brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!\n where n > 0\n\n For example:\n >>> special_factorial(4)\n 288\n\n The function will receive an integer as input and should return the special\n factorial of this integer.\n \"\"\"\n if n == 0:\n return 1\n return n * special_factorial(n - 1)\n\n", "def special_factorial(n: int) -> int:\n \"\"\"The Brazilian factorial is defined as:\n brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!\n where n > 0\n\n For example:\n >>> special_factorial(4)\n 288\n\n The function will receive an integer as input and should return the special\n factorial of this integer.\n \"\"\"\n if n < 0:\n raise ValueError(\"The factorial of a negative number is undefined.\")\n if n == 0:\n return 1\n return n * special_factorial(n - 1)\n\n", "def special_factorial(n: int) -> int:\n \"\"\"The Brazilian factorial is defined as:\n brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!\n where n > 0\n\n For example:\n >>> special_factorial(4)\n 288\n\n The function will receive an integer as input and should return the special\n factorial of this integer.\n \"\"\"\n if n == 0:\n return 1\n elif n == 1:\n return 1\n else:\n return n * special_factorial(n - 1)\n\n"], ["from typing import List\n\ndef add_elements(arr: List[int], k: int) -> int:\n \"\"\"\n Given a non-empty array of integers arr and an integer k, return\n the sum of the elements with at most two digits from the first k elements of arr.\n\n Example:\n\n >>> add_elements([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4)\n 24\n\n Constraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n \"\"\"\n if k == 0:\n return 0\n if k == 1:\n return arr[0]\n if k == 2:\n return arr[0] + arr[1]\n if k == 3:\n return arr[0] + arr[1] + arr[2]\n if k == 4:\n return arr[0] + arr[1] + arr[2] + arr[3]\n if k == 5:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4]\n if k == 6:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5]\n if k == 7:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6]\n if k == 8:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7]\n if k == 9:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8]\n return 0\n", "from typing import List\n\ndef add_elements(arr: List[int], k: int) -> int:\n \"\"\"\n Given a non-empty array of integers arr and an integer k, return\n the sum of the elements with at most two digits from the first k elements of arr.\n\n Example:\n\n >>> add_elements([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4)\n 24\n\n Constraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n \"\"\"\n if len(arr) < k:\n return 0\n if k == 1:\n return arr[0]\n if k == 2:\n return arr[0] + arr[1]\n if k == 3:\n return arr[0] + arr[1] + arr[2]\n if k == 4:\n return arr[0] + arr[1] + arr[2] + arr[3]\n if k == 5:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4]\n if k == 6:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5]\n if k == 7:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6]\n if k == 8:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7]\n if k == 9:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8]\n return 0\n", "from typing import List\n\ndef add_elements(arr: List[int], k: int) -> int:\n \"\"\"\n Given a non-empty array of integers arr and an integer k, return\n the sum of the elements with at most two digits from the first k elements of arr.\n\n Example:\n\n >>> add_elements([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4)\n 24\n\n Constraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n \"\"\"\n # Your code here\n arr = sorted(arr)\n return sum(arr[:k]) + sum(arr[-k:])\n", "from typing import List\n\ndef add_elements(arr: List[int], k: int) -> int:\n \"\"\"\n Given a non-empty array of integers arr and an integer k, return\n the sum of the elements with at most two digits from the first k elements of arr.\n\n Example:\n\n >>> add_elements([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4)\n 24\n\n Constraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n \"\"\"\n return sum(arr[:k]) + sum(arr[k:])\n", "from typing import List\n\ndef add_elements(arr: List[int], k: int) -> int:\n \"\"\"\n Given a non-empty array of integers arr and an integer k, return\n the sum of the elements with at most two digits from the first k elements of arr.\n\n Example:\n\n >>> add_elements([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4)\n 24\n\n Constraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n \"\"\"\n if k == 0:\n return 0\n if k == 1:\n return arr[0]\n if k == 2:\n return arr[0] + arr[1]\n if k == 3:\n return arr[0] + arr[1] + arr[2]\n if k == 4:\n return arr[0] + arr[1] + arr[2] + arr[3]\n if k == 5:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4]\n if k == 6:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5]\n if k == 7:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6]\n if k == 8:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7]\n if k == 9:\n return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8]\n return 0\n"], ["def fib4(n: int) -> int:\n \"\"\"The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fib4(0) -> 0\n fib4(1) -> 0\n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)\n\n", "def fib4(n: int) -> int:\n \"\"\"The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fib4(0) -> 0\n fib4(1) -> 0\n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)\n\n", "def fib4(n: int) -> int:\n \"\"\"The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fib4(0) -> 0\n fib4(1) -> 0\n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 2\n elif n == 3:\n return 0\n else:\n return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)\n\n", "def fib4(n: int) -> int:\n \"\"\"The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fib4(0) -> 0\n fib4(1) -> 0\n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)\n\n", "def fib4(n: int) -> int:\n \"\"\"The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:\n fib4(0) -> 0\n fib4(1) -> 0\n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)\n\n"], ["from typing import List\n\ndef unique_digits(x: List[int]) -> List[int]:\n \"\"\"Given a list of positive integers x. return a sorted list of all \n elements that hasn't any even digit.\n\n Note: Returned list should be sorted in increasing order.\n \n For example:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []\n \"\"\"\n # Your code here\n return sorted(set(x) - set(map(lambda x: x % 10, x)))\n", "from typing import List\n\ndef unique_digits(x: List[int]) -> List[int]:\n \"\"\"Given a list of positive integers x. return a sorted list of all \n elements that hasn't any even digit.\n\n Note: Returned list should be sorted in increasing order.\n \n For example:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []\n \"\"\"\n # Write your code here.\n return sorted(set(x) - set(map(lambda x: x % 10, x)))\n", "from typing import List\n\ndef unique_digits(x: List[int]) -> List[int]:\n \"\"\"Given a list of positive integers x. return a sorted list of all \n elements that hasn't any even digit.\n\n Note: Returned list should be sorted in increasing order.\n \n For example:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []\n \"\"\"\n return sorted(set(x) - set(filter(lambda x: x % 2 == 0, x)))\n", "from typing import List\n\ndef unique_digits(x: List[int]) -> List[int]:\n \"\"\"Given a list of positive integers x. return a sorted list of all \n elements that hasn't any even digit.\n\n Note: Returned list should be sorted in increasing order.\n \n For example:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []\n \"\"\"\n return sorted(list(set(x) - set(filter(lambda x: x % 2 == 0, x))))\n", "from typing import List\n\ndef unique_digits(x: List[int]) -> List[int]:\n \"\"\"Given a list of positive integers x. return a sorted list of all \n elements that hasn't any even digit.\n\n Note: Returned list should be sorted in increasing order.\n \n For example:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []\n \"\"\"\n return sorted(set(x) - set(map(lambda x: x % 10, x)))\n"], ["from typing import List\n\ndef select_words(s: str, n: int) -> List[str]:\n \"\"\"Given a string s and a natural number n, you have been tasked to implement \n a function that returns a list of all words from string s that contain exactly \n n consonants, in order these words appear in the string s.\n If the string s is empty then the function should return an empty list.\n Note: you may assume the input string contains only letters and spaces.\n Examples:\n >>> select_words('Mary had a little lamb', 4)\n ['little']\n >>> select_words('Mary had a little lamb', 3)\n ['Mary', 'lamb']\n >>> select_words('simple white space', 2)\n []\n >>> select_words('Hello world', 4)\n ['world']\n >>> select_words('Uncle sam', 3)\n ['Uncle']\n \"\"\"\n # Your code here\n if len(s) == 0:\n return []\n else:\n return [word for word in s.split() if len(word) == n and all(c.isalpha() for c in word)]\n", "from typing import List\n\ndef select_words(s: str, n: int) -> List[str]:\n \"\"\"Given a string s and a natural number n, you have been tasked to implement \n a function that returns a list of all words from string s that contain exactly \n n consonants, in order these words appear in the string s.\n If the string s is empty then the function should return an empty list.\n Note: you may assume the input string contains only letters and spaces.\n Examples:\n >>> select_words('Mary had a little lamb', 4)\n ['little']\n >>> select_words('Mary had a little lamb', 3)\n ['Mary', 'lamb']\n >>> select_words('simple white space', 2)\n []\n >>> select_words('Hello world', 4)\n ['world']\n >>> select_words('Uncle sam', 3)\n ['Uncle']\n \"\"\"\n # Your code here\n return [word for word in s.split() if len(word) == n and all(c.isalpha() for c in word)]\n", "from typing import List\n\ndef select_words(s: str, n: int) -> List[str]:\n \"\"\"Given a string s and a natural number n, you have been tasked to implement \n a function that returns a list of all words from string s that contain exactly \n n consonants, in order these words appear in the string s.\n If the string s is empty then the function should return an empty list.\n Note: you may assume the input string contains only letters and spaces.\n Examples:\n >>> select_words('Mary had a little lamb', 4)\n ['little']\n >>> select_words('Mary had a little lamb', 3)\n ['Mary', 'lamb']\n >>> select_words('simple white space', 2)\n []\n >>> select_words('Hello world', 4)\n ['world']\n >>> select_words('Uncle sam', 3)\n ['Uncle']\n \"\"\"\n if len(s) == 0:\n return []\n if len(s) < n:\n return []\n if s[0].isupper():\n return [s[0]]\n if s[0].islower():\n return [s[0]]\n if s[0].isspace():\n return [s[0]]\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[0] == ' ':\n return select_words(s[1:], n)\n if s[", "from typing import List\n\ndef select_words(s: str, n: int) -> List[str]:\n \"\"\"Given a string s and a natural number n, you have been tasked to implement \n a function that returns a list of all words from string s that contain exactly \n n consonants, in order these words appear in the string s.\n If the string s is empty then the function should return an empty list.\n Note: you may assume the input string contains only letters and spaces.\n Examples:\n >>> select_words('Mary had a little lamb', 4)\n ['little']\n >>> select_words('Mary had a little lamb', 3)\n ['Mary', 'lamb']\n >>> select_words('simple white space', 2)\n []\n >>> select_words('Hello world', 4)\n ['world']\n >>> select_words('Uncle sam', 3)\n ['Uncle']\n \"\"\"\n # Write your code here.\n words = []\n for i in range(len(s)):\n if s[i] == 'a' or s[i] == 'e' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u':\n words.append(s[i])\n if len(words) == 0:\n return []\n else:\n return words[:n]\n", "from typing import List\n\ndef select_words(s: str, n: int) -> List[str]:\n \"\"\"Given a string s and a natural number n, you have been tasked to implement \n a function that returns a list of all words from string s that contain exactly \n n consonants, in order these words appear in the string s.\n If the string s is empty then the function should return an empty list.\n Note: you may assume the input string contains only letters and spaces.\n Examples:\n >>> select_words('Mary had a little lamb', 4)\n ['little']\n >>> select_words('Mary had a little lamb', 3)\n ['Mary', 'lamb']\n >>> select_words('simple white space', 2)\n []\n >>> select_words('Hello world', 4)\n ['world']\n >>> select_words('Uncle sam', 3)\n ['Uncle']\n \"\"\"\n words = []\n for i in range(len(s)):\n if s[i] in 'aeiouAEIOU':\n words.append(s[i:i+n])\n return words\n"], ["from typing import List\n\ndef will_it_fly(q: List[int], w: int) -> bool:\n \"\"\"\n Write a function that returns True if the object q will fly, and False otherwise.\n The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.\n\n Example:\n >>> will_it_fly([1, 2], 5)\n False\n # 1+2 is less than the maximum possible weight, but it's unbalanced.\n\n >>> will_it_fly([3, 2, 3], 1)\n False\n # it's balanced, but 3+2+3 is more than the maximum possible weight.\n\n >>> will_it_fly([3, 2, 3], 9)\n True\n # 3+2+3 is less than the maximum possible weight, and it's balanced.\n\n >>> will_it_fly([3], 5)\n True\n # 3 is less than the maximum possible weight, and it's balanced.\n \"\"\"\n # TODO: Write your code here.\n if len(q) == 1:\n return True\n if len(q) == 2:\n return q[0] == q[1]\n if len(q) == 3:\n return q[0] == q[1] and q[1] == q[2]\n if len(q) == 4:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3]\n if len(q) == 5:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4]\n return False\n", "from typing import List\n\ndef will_it_fly(q: List[int], w: int) -> bool:\n \"\"\"\n Write a function that returns True if the object q will fly, and False otherwise.\n The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.\n\n Example:\n >>> will_it_fly([1, 2], 5)\n False\n # 1+2 is less than the maximum possible weight, but it's unbalanced.\n\n >>> will_it_fly([3, 2, 3], 1)\n False\n # it's balanced, but 3+2+3 is more than the maximum possible weight.\n\n >>> will_it_fly([3, 2, 3], 9)\n True\n # 3+2+3 is less than the maximum possible weight, and it's balanced.\n\n >>> will_it_fly([3], 5)\n True\n # 3 is less than the maximum possible weight, and it's balanced.\n \"\"\"\n if len(q) == 1:\n return True\n if len(q) == 2:\n return q[0] == q[1]\n if len(q) == 3:\n return q[0] == q[1] and q[1] == q[2]\n if len(q) == 4:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3]\n if len(q) == 5:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4]\n if len(q) == 6:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4] and q[4] == q[5]\n if len(q) == 7:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4] and", "from typing import List\n\ndef will_it_fly(q: List[int], w: int) -> bool:\n \"\"\"\n Write a function that returns True if the object q will fly, and False otherwise.\n The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.\n\n Example:\n >>> will_it_fly([1, 2], 5)\n False\n # 1+2 is less than the maximum possible weight, but it's unbalanced.\n\n >>> will_it_fly([3, 2, 3], 1)\n False\n # it's balanced, but 3+2+3 is more than the maximum possible weight.\n\n >>> will_it_fly([3, 2, 3], 9)\n True\n # 3+2+3 is less than the maximum possible weight, and it's balanced.\n\n >>> will_it_fly([3], 5)\n True\n # 3 is less than the maximum possible weight, and it's balanced.\n \"\"\"\n if len(q) == 1:\n return True\n if len(q) == 2:\n return q[0] == q[1]\n if len(q) == 3:\n return q[0] == q[1] and q[1] == q[2]\n if len(q) == 4:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3]\n if len(q) == 5:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4]\n if len(q) == 6:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4] and q[4] == q[5]\n if len(q) == 7:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4] and", "from typing import List\n\ndef will_it_fly(q: List[int], w: int) -> bool:\n \"\"\"\n Write a function that returns True if the object q will fly, and False otherwise.\n The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.\n\n Example:\n >>> will_it_fly([1, 2], 5)\n False\n # 1+2 is less than the maximum possible weight, but it's unbalanced.\n\n >>> will_it_fly([3, 2, 3], 1)\n False\n # it's balanced, but 3+2+3 is more than the maximum possible weight.\n\n >>> will_it_fly([3, 2, 3], 9)\n True\n # 3+2+3 is less than the maximum possible weight, and it's balanced.\n\n >>> will_it_fly([3], 5)\n True\n # 3 is less than the maximum possible weight, and it's balanced.\n \"\"\"\n # check if the list is balanced\n if len(q) == 1:\n return True\n if len(q) == 2:\n return q[0] == q[1]\n\n # check if the sum of the elements is less than or equal the maximum possible weight\n if sum(q) <= w:\n return True\n\n # check if the sum of the elements is greater than the maximum possible weight\n return sum(q) > w\n\n", "from typing import List\n\ndef will_it_fly(q: List[int], w: int) -> bool:\n \"\"\"\n Write a function that returns True if the object q will fly, and False otherwise.\n The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.\n\n Example:\n >>> will_it_fly([1, 2], 5)\n False\n # 1+2 is less than the maximum possible weight, but it's unbalanced.\n\n >>> will_it_fly([3, 2, 3], 1)\n False\n # it's balanced, but 3+2+3 is more than the maximum possible weight.\n\n >>> will_it_fly([3, 2, 3], 9)\n True\n # 3+2+3 is less than the maximum possible weight, and it's balanced.\n\n >>> will_it_fly([3], 5)\n True\n # 3 is less than the maximum possible weight, and it's balanced.\n \"\"\"\n if len(q) == 1:\n return True\n if len(q) == 2:\n return q[0] == q[1]\n if len(q) == 3:\n return q[0] == q[1] and q[1] == q[2]\n if len(q) == 4:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3]\n if len(q) == 5:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4]\n if len(q) == 6:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4] and q[4] == q[5]\n if len(q) == 7:\n return q[0] == q[1] and q[1] == q[2] and q[2] == q[3] and q[3] == q[4] and"], ["def fib(n: int) -> int:\n \"\"\"Return n-th Fibonacci number.\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\n \"\"\"\n if n <= 1:\n return n\n return fib(n - 1) + fib(n - 2)\n\n", "def fib(n: int) -> int:\n \"\"\"Return n-th Fibonacci number.\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\n \"\"\"\n if n <= 1:\n return n\n return fib(n - 1) + fib(n - 2)\n\n", "def fib(n: int) -> int:\n \"\"\"Return n-th Fibonacci number.\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\n \"\"\"\n if n < 2:\n return n\n return fib(n - 1) + fib(n - 2)\n\n", "def fib(n: int) -> int:\n \"\"\"Return n-th Fibonacci number.\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\n \"\"\"\n if n == 1:\n return 1\n elif n == 2:\n return 1\n else:\n return fib(n - 1) + fib(n - 2)\n\n", "def fib(n: int) -> int:\n \"\"\"Return n-th Fibonacci number.\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fib(n - 1) + fib(n - 2)\n\n"], ["from typing import List\n\ndef Strongest_Extension(class_name: str, extensions: List[str]) -> str:\n \"\"\"You will be given the name of a class (a string) and a list of extensions.\n The extensions are to be used to load additional classes to the class. The\n strength of the extension is as follows: Let CAP be the number of the uppercase\n letters in the extension's name, and let SM be the number of lowercase letters \n in the extension's name, the strength is given by the fraction CAP - SM. \n You should find the strongest extension and return a string in this \n format: ClassName.StrongestExtensionName.\n If there are two or more extensions with the same strength, you should\n choose the one that comes first in the list.\n For example, if you are given \"Slices\" as the class and a list of the\n extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should\n return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension \n (its strength is -1).\n Example:\n >>> Strongest_Extension('my_class', ['AA', 'Be', 'CC'])\n 'my_class.AA'\n \"\"\"\n # Write your code here.\n return class_name + '.' + max(extensions, key=len)\n", "from typing import List\n\ndef Strongest_Extension(class_name: str, extensions: List[str]) -> str:\n \"\"\"You will be given the name of a class (a string) and a list of extensions.\n The extensions are to be used to load additional classes to the class. The\n strength of the extension is as follows: Let CAP be the number of the uppercase\n letters in the extension's name, and let SM be the number of lowercase letters \n in the extension's name, the strength is given by the fraction CAP - SM. \n You should find the strongest extension and return a string in this \n format: ClassName.StrongestExtensionName.\n If there are two or more extensions with the same strength, you should\n choose the one that comes first in the list.\n For example, if you are given \"Slices\" as the class and a list of the\n extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should\n return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension \n (its strength is -1).\n Example:\n >>> Strongest_Extension('my_class', ['AA', 'Be', 'CC'])\n 'my_class.AA'\n \"\"\"\n # Your code here\n return class_name + '.' + max(extensions, key=len)\n", "from typing import List\n\ndef Strongest_Extension(class_name: str, extensions: List[str]) -> str:\n \"\"\"You will be given the name of a class (a string) and a list of extensions.\n The extensions are to be used to load additional classes to the class. The\n strength of the extension is as follows: Let CAP be the number of the uppercase\n letters in the extension's name, and let SM be the number of lowercase letters \n in the extension's name, the strength is given by the fraction CAP - SM. \n You should find the strongest extension and return a string in this \n format: ClassName.StrongestExtensionName.\n If there are two or more extensions with the same strength, you should\n choose the one that comes first in the list.\n For example, if you are given \"Slices\" as the class and a list of the\n extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should\n return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension \n (its strength is -1).\n Example:\n >>> Strongest_Extension('my_class', ['AA', 'Be', 'CC'])\n 'my_class.AA'\n \"\"\"\n # Your code here\n return class_name + '.' + max(extensions, key=len)\n", "from typing import List\n\ndef Strongest_Extension(class_name: str, extensions: List[str]) -> str:\n \"\"\"You will be given the name of a class (a string) and a list of extensions.\n The extensions are to be used to load additional classes to the class. The\n strength of the extension is as follows: Let CAP be the number of the uppercase\n letters in the extension's name, and let SM be the number of lowercase letters \n in the extension's name, the strength is given by the fraction CAP - SM. \n You should find the strongest extension and return a string in this \n format: ClassName.StrongestExtensionName.\n If there are two or more extensions with the same strength, you should\n choose the one that comes first in the list.\n For example, if you are given \"Slices\" as the class and a list of the\n extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should\n return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension \n (its strength is -1).\n Example:\n >>> Strongest_Extension('my_class', ['AA', 'Be', 'CC'])\n 'my_class.AA'\n \"\"\"\n # Write your code here\n if len(extensions) == 0:\n return class_name\n else:\n max_strength = 0\n max_extension = ''\n for extension in extensions:\n if len(extension) > len(max_extension):\n max_extension = extension\n max_strength = len(extension) - len(max_extension)\n return class_name + '.' + max_extension[:max_strength]\n", "from typing import List\n\ndef Strongest_Extension(class_name: str, extensions: List[str]) -> str:\n \"\"\"You will be given the name of a class (a string) and a list of extensions.\n The extensions are to be used to load additional classes to the class. The\n strength of the extension is as follows: Let CAP be the number of the uppercase\n letters in the extension's name, and let SM be the number of lowercase letters \n in the extension's name, the strength is given by the fraction CAP - SM. \n You should find the strongest extension and return a string in this \n format: ClassName.StrongestExtensionName.\n If there are two or more extensions with the same strength, you should\n choose the one that comes first in the list.\n For example, if you are given \"Slices\" as the class and a list of the\n extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should\n return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension \n (its strength is -1).\n Example:\n >>> Strongest_Extension('my_class', ['AA', 'Be', 'CC'])\n 'my_class.AA'\n \"\"\"\n # Your code here\n return class_name + '.' + max(extensions, key=len)\n"], ["from typing import List\n\ndef match_parens(lst: List[str]) -> str:\n \"\"\"\n You are given a list of two strings, both strings consist of open\n parentheses '(' or close parentheses ')' only.\n Your job is to check if it is possible to concatenate the two strings in\n some order, that the resulting string will be good.\n A string S is considered to be good if and only if all parentheses in S\n are balanced. For example: the string '(())()' is good, while the string\n '())' is not.\n Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.\n\n Examples:\n >>> match_parens(['()(', ')'])\n 'Yes'\n >>> match_parens([')', ')'])\n 'No'\n \"\"\"\n if len(lst) % 2 != 0:\n return 'No'\n stack = []\n for i in range(len(lst)//2):\n if lst[i] == '(':\n stack.append(lst[i])\n elif lst[i] == ')':\n if len(stack) == 0:\n return 'No'\n elif stack.pop() != '(':\n return 'No'\n return 'Yes'\n", "from typing import List\n\ndef match_parens(lst: List[str]) -> str:\n \"\"\"\n You are given a list of two strings, both strings consist of open\n parentheses '(' or close parentheses ')' only.\n Your job is to check if it is possible to concatenate the two strings in\n some order, that the resulting string will be good.\n A string S is considered to be good if and only if all parentheses in S\n are balanced. For example: the string '(())()' is good, while the string\n '())' is not.\n Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.\n\n Examples:\n >>> match_parens(['()(', ')'])\n 'Yes'\n >>> match_parens([')', ')'])\n 'No'\n \"\"\"\n stack = []\n for s in lst:\n if s == '(':\n stack.append(s)\n elif s == ')':\n if len(stack) == 0:\n return 'No'\n if stack.pop() != '(':\n return 'No'\n if len(stack) != 0:\n return 'No'\n return 'Yes'\n", "from typing import List\n\ndef match_parens(lst: List[str]) -> str:\n \"\"\"\n You are given a list of two strings, both strings consist of open\n parentheses '(' or close parentheses ')' only.\n Your job is to check if it is possible to concatenate the two strings in\n some order, that the resulting string will be good.\n A string S is considered to be good if and only if all parentheses in S\n are balanced. For example: the string '(())()' is good, while the string\n '())' is not.\n Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.\n\n Examples:\n >>> match_parens(['()(', ')'])\n 'Yes'\n >>> match_parens([')', ')'])\n 'No'\n \"\"\"\n stack = []\n for s in lst:\n if s == '(':\n stack.append(s)\n elif s == ')':\n if len(stack) == 0:\n return 'No'\n if stack[-1] == '(':\n stack.pop()\n else:\n return 'No'\n if len(stack) == 0:\n return 'Yes'\n return 'No'\n", "from typing import List\n\ndef match_parens(lst: List[str]) -> str:\n \"\"\"\n You are given a list of two strings, both strings consist of open\n parentheses '(' or close parentheses ')' only.\n Your job is to check if it is possible to concatenate the two strings in\n some order, that the resulting string will be good.\n A string S is considered to be good if and only if all parentheses in S\n are balanced. For example: the string '(())()' is good, while the string\n '())' is not.\n Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.\n\n Examples:\n >>> match_parens(['()(', ')'])\n 'Yes'\n >>> match_parens([')', ')'])\n 'No'\n \"\"\"\n if len(lst) % 2 != 0:\n return 'No'\n stack = []\n for i in range(len(lst)):\n if lst[i] == '(':\n stack.append(lst[i])\n elif lst[i] == ')':\n if len(stack) == 0:\n return 'No'\n if stack[-1] == '(':\n stack.pop()\n else:\n return 'No'\n if len(stack) == 0:\n return 'Yes'\n else:\n return 'No'\n", "from typing import List\n\ndef match_parens(lst: List[str]) -> str:\n \"\"\"\n You are given a list of two strings, both strings consist of open\n parentheses '(' or close parentheses ')' only.\n Your job is to check if it is possible to concatenate the two strings in\n some order, that the resulting string will be good.\n A string S is considered to be good if and only if all parentheses in S\n are balanced. For example: the string '(())()' is good, while the string\n '())' is not.\n Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.\n\n Examples:\n >>> match_parens(['()(', ')'])\n 'Yes'\n >>> match_parens([')', ')'])\n 'No'\n \"\"\"\n stack = []\n for i in lst:\n if i == '(':\n stack.append(i)\n elif i == ')':\n if stack:\n if stack[-1] == '(':\n stack.pop()\n else:\n return 'No'\n else:\n return 'No'\n if stack:\n return 'No'\n else:\n return 'Yes'\n"], ["from typing import List, Optional\n\ndef next_smallest(lst: List[int]) -> Optional[int]:\n \"\"\"\n You are given a list of integers.\n Write a function next_smallest() that returns the 2nd smallest element of the list.\n Return None if there is no such element.\n >>> next_smallest([1, 2, 3, 4, 5])\n 2\n >>> next_smallest([5, 1, 4, 3, 2])\n 2\n >>> next_smallest([])\n None\n >>> next_smallest([1, 1])\n None\n \"\"\"\n if len(lst) == 0:\n return None\n if len(lst) == 1:\n return lst[0]\n if len(lst) == 2:\n return min(lst) if lst[0] < lst[1] else max(lst)\n if len(lst) == 3:\n return min(lst) if lst[0] < lst[1] < lst[2] else max(lst)\n if len(lst) == 4:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] else max(lst)\n if len(lst) == 5:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] else max(lst)\n if len(lst) == 6:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] < lst[5] else max(lst)\n if len(lst) == 7:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] < lst[5] < lst[6] else max(lst)\n if len(lst) == 8:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] < lst[5] < lst[6] < lst[7] else max(lst)\n if len(lst) == 9:\n return min(lst) if lst[0] < lst[1] < lst[", "from typing import List, Optional\n\ndef next_smallest(lst: List[int]) -> Optional[int]:\n \"\"\"\n You are given a list of integers.\n Write a function next_smallest() that returns the 2nd smallest element of the list.\n Return None if there is no such element.\n >>> next_smallest([1, 2, 3, 4, 5])\n 2\n >>> next_smallest([5, 1, 4, 3, 2])\n 2\n >>> next_smallest([])\n None\n >>> next_smallest([1, 1])\n None\n \"\"\"\n if len(lst) == 0:\n return None\n if len(lst) == 1:\n return lst[0]\n if len(lst) == 2:\n return min(lst) if lst[0] < lst[1] else max(lst)\n if len(lst) == 3:\n return min(lst) if lst[0] < lst[1] < lst[2] else max(lst)\n if len(lst) == 4:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] else max(lst)\n if len(lst) == 5:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] else max(lst)\n return None\n", "from typing import List, Optional\n\ndef next_smallest(lst: List[int]) -> Optional[int]:\n \"\"\"\n You are given a list of integers.\n Write a function next_smallest() that returns the 2nd smallest element of the list.\n Return None if there is no such element.\n >>> next_smallest([1, 2, 3, 4, 5])\n 2\n >>> next_smallest([5, 1, 4, 3, 2])\n 2\n >>> next_smallest([])\n None\n >>> next_smallest([1, 1])\n None\n \"\"\"\n if len(lst) == 1:\n return lst[0]\n if len(lst) == 2:\n return lst[1]\n if len(lst) == 3:\n return min(lst[1:]) if lst[0] < lst[1] else lst[0]\n if len(lst) == 4:\n return min(lst[1:]) if lst[0] < lst[1] else min(lst[2:]) if lst[0] < lst[2] else lst[0]\n if len(lst) == 5:\n return min(lst[1:]) if lst[0] < lst[1] else min(lst[2:]) if lst[0] < lst[2] else min(lst[3:]) if lst[0] < lst[3] else min(lst[4:]) if lst[0] < lst[4] else lst[0]\n return min(lst[1:]) if lst[0] < lst[1] else min(lst[2:]) if lst[0] < lst[2] else min(lst[3:]) if lst[0] < lst[3] else min(lst[4:]) if lst[0] < lst[4] else min(lst[5:]) if lst[0] < lst[5] else lst[0]\n", "from typing import List, Optional\n\ndef next_smallest(lst: List[int]) -> Optional[int]:\n \"\"\"\n You are given a list of integers.\n Write a function next_smallest() that returns the 2nd smallest element of the list.\n Return None if there is no such element.\n >>> next_smallest([1, 2, 3, 4, 5])\n 2\n >>> next_smallest([5, 1, 4, 3, 2])\n 2\n >>> next_smallest([])\n None\n >>> next_smallest([1, 1])\n None\n \"\"\"\n if len(lst) == 1:\n return lst[0]\n if len(lst) == 2:\n return min(lst) if lst[0] < lst[1] else max(lst)\n if len(lst) == 3:\n return min(lst) if lst[0] < lst[1] < lst[2] else max(lst)\n if len(lst) == 4:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] else max(lst)\n if len(lst) == 5:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] else max(lst)\n return None\n", "from typing import List, Optional\n\ndef next_smallest(lst: List[int]) -> Optional[int]:\n \"\"\"\n You are given a list of integers.\n Write a function next_smallest() that returns the 2nd smallest element of the list.\n Return None if there is no such element.\n >>> next_smallest([1, 2, 3, 4, 5])\n 2\n >>> next_smallest([5, 1, 4, 3, 2])\n 2\n >>> next_smallest([])\n None\n >>> next_smallest([1, 1])\n None\n \"\"\"\n if len(lst) == 0:\n return None\n if len(lst) == 1:\n return lst[0]\n if len(lst) == 2:\n return min(lst) if lst[0] < lst[1] else max(lst)\n if len(lst) == 3:\n return min(lst) if lst[0] < lst[1] < lst[2] else max(lst)\n if len(lst) == 4:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] else max(lst)\n if len(lst) == 5:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] else max(lst)\n if len(lst) == 6:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] < lst[5] else max(lst)\n if len(lst) == 7:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] < lst[5] < lst[6] else max(lst)\n if len(lst) == 8:\n return min(lst) if lst[0] < lst[1] < lst[2] < lst[3] < lst[4] < lst[5] < lst[6] < lst[7] else max(lst)\n if len(lst) == 9:\n return min(lst) if lst[0] < lst[1] < lst["], ["def any_int(x: float, y: float, z: float) -> bool:\n \"\"\"\n Create a function that takes 3 numbers.\n Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.\n Returns false in any other cases.\n \n Examples\n >>> any_int(5, 2, 7)\n True\n \n >>> any_int(3, 2, 2)\n False\n\n >>> any_int(3, -2, 1)\n True\n \n >>> any_int(3.6, -2.2, 2)\n False\n \n\n \n \"\"\"\n return x + y + z == sum(x, y, z) and all(isinstance(x, int) for x in (x, y, z))\n\n", "def any_int(x: float, y: float, z: float) -> bool:\n \"\"\"\n Create a function that takes 3 numbers.\n Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.\n Returns false in any other cases.\n \n Examples\n >>> any_int(5, 2, 7)\n True\n \n >>> any_int(3, 2, 2)\n False\n\n >>> any_int(3, -2, 1)\n True\n \n >>> any_int(3.6, -2.2, 2)\n False\n \n\n \n \"\"\"\n return x + y == z and isinstance(x, int) and isinstance(y, int) and isinstance(z, int)\n\n", "def any_int(x: float, y: float, z: float) -> bool:\n \"\"\"\n Create a function that takes 3 numbers.\n Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.\n Returns false in any other cases.\n \n Examples\n >>> any_int(5, 2, 7)\n True\n \n >>> any_int(3, 2, 2)\n False\n\n >>> any_int(3, -2, 1)\n True\n \n >>> any_int(3.6, -2.2, 2)\n False\n \n\n \n \"\"\"\n return x + y == z and isinstance(x, int) and isinstance(y, int) and isinstance(z, int)\n\n", "def any_int(x: float, y: float, z: float) -> bool:\n \"\"\"\n Create a function that takes 3 numbers.\n Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.\n Returns false in any other cases.\n \n Examples\n >>> any_int(5, 2, 7)\n True\n \n >>> any_int(3, 2, 2)\n False\n\n >>> any_int(3, -2, 1)\n True\n \n >>> any_int(3.6, -2.2, 2)\n False\n \n\n \n \"\"\"\n return x + y + z == sum(map(int, [x, y, z]))\n\n", "def any_int(x: float, y: float, z: float) -> bool:\n \"\"\"\n Create a function that takes 3 numbers.\n Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.\n Returns false in any other cases.\n \n Examples\n >>> any_int(5, 2, 7)\n True\n \n >>> any_int(3, 2, 2)\n False\n\n >>> any_int(3, -2, 1)\n True\n \n >>> any_int(3.6, -2.2, 2)\n False\n \n\n \n \"\"\"\n return (x + y) == z and all(isinstance(x, int) for x in (x, y, z))\n\n"], ["def truncate_number(number: float) -> float:\n \"\"\" Given a positive floating point number, it can be decomposed into\n and integer part (largest integer smaller than given number) and decimals\n (leftover part always smaller than 1).\n\n Return the decimal part of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n return float(f\"{number:.1f}\")\n\n", "def truncate_number(number: float) -> float:\n \"\"\" Given a positive floating point number, it can be decomposed into\n and integer part (largest integer smaller than given number) and decimals\n (leftover part always smaller than 1).\n\n Return the decimal part of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n if number == 0:\n return 0\n if number < 0:\n raise ValueError(\"Number must be positive\")\n if number == 1:\n return 1\n if number == 2:\n return 2\n if number == 3:\n return 3\n if number == 4:\n return 4\n if number == 5:\n return 5\n if number == 6:\n return 6\n if number == 7:\n return 7\n if number == 8:\n return 8\n if number == 9:\n return 9\n if number == 10:\n return 10\n if number == 11:\n return 11\n if number == 12:\n return 12\n if number == 13:\n return 13\n if number == 14:\n return 14\n if number == 15:\n return 15\n if number == 16:\n return 16\n if number == 17:\n return 17\n if number == 18:\n return 18\n if number == 19:\n return 19\n if number == 20:\n return 20\n if number == 21:\n return 21\n if number == 22:\n return 22\n if number == 23:\n return 23\n if number == 24:\n return 24\n if number == 25:\n return 25\n if number == 26:\n return 26\n if number == 27:\n return 27\n if number == 28:\n return 28\n if number == 29:\n return 29\n if number == 30:\n return 30\n if number == 31:\n return 31\n if number == 32:\n return 32\n if number == 33:\n ", "def truncate_number(number: float) -> float:\n \"\"\" Given a positive floating point number, it can be decomposed into\n and integer part (largest integer smaller than given number) and decimals\n (leftover part always smaller than 1).\n\n Return the decimal part of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n return round(number, 1)\n\n", "def truncate_number(number: float) -> float:\n \"\"\" Given a positive floating point number, it can be decomposed into\n and integer part (largest integer smaller than given number) and decimals\n (leftover part always smaller than 1).\n\n Return the decimal part of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n if number < 0:\n raise ValueError(\"Number must be positive\")\n if number == 0:\n return 0\n integer_part = math.floor(number)\n decimal_part = number - integer_part\n return decimal_part\n\n", "def truncate_number(number: float) -> float:\n \"\"\" Given a positive floating point number, it can be decomposed into\n and integer part (largest integer smaller than given number) and decimals\n (leftover part always smaller than 1).\n\n Return the decimal part of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n if number == 0:\n return 0\n elif number < 0:\n raise ValueError(\"Number must be positive\")\n else:\n return float(number) % 1\n\n"], ["from typing import List\n\ndef incr_list(l: List[int]) -> List[int]:\n \"\"\"Return list with elements incremented by 1.\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n return [x + 1 for x in l]\n", "from typing import List\n\ndef incr_list(l: List[int]) -> List[int]:\n \"\"\"Return list with elements incremented by 1.\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n return [x + 1 for x in l]\n", "from typing import List\n\ndef incr_list(l: List[int]) -> List[int]:\n \"\"\"Return list with elements incremented by 1.\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n return [x + 1 for x in l]\n", "from typing import List\n\ndef incr_list(l: List[int]) -> List[int]:\n \"\"\"Return list with elements incremented by 1.\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n return [x + 1 for x in l]\n", "from typing import List\n\ndef incr_list(l: List[int]) -> List[int]:\n \"\"\"Return list with elements incremented by 1.\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n return [x+1 for x in l]\n"], ["def x_or_y(n: int, x: int, y: int) -> int:\n \"\"\"A simple program which should return the value of x if n is \n a prime number and should return the value of y otherwise.\n\n Examples:\n >>> x_or_y(7, 34, 12)\n 34\n >>> x_or_y(15, 8, 5)\n 5\n \n \"\"\"\n if n < 2:\n return 0\n elif n == 2:\n return 1\n elif n % 2 == 0:\n return x_or_y(n // 2, x, y)\n else:\n return x_or_y(n // 2, x, y) + y\n\n", "def x_or_y(n: int, x: int, y: int) -> int:\n \"\"\"A simple program which should return the value of x if n is \n a prime number and should return the value of y otherwise.\n\n Examples:\n >>> x_or_y(7, 34, 12)\n 34\n >>> x_or_y(15, 8, 5)\n 5\n \n \"\"\"\n if n < 2:\n return 0\n if n == 2:\n return 2\n if n % 2 == 0:\n return x_or_y(n // 2, x, y)\n else:\n return x_or_y(n // 2, y, x)\n\n", "def x_or_y(n: int, x: int, y: int) -> int:\n \"\"\"A simple program which should return the value of x if n is \n a prime number and should return the value of y otherwise.\n\n Examples:\n >>> x_or_y(7, 34, 12)\n 34\n >>> x_or_y(15, 8, 5)\n 5\n \n \"\"\"\n if n < 2:\n return 0\n if n == 2:\n return 2\n if n % 2 == 0:\n return x_or_y(n // 2, x, y)\n return x_or_y(n // 2, y, x)\n\n", "def x_or_y(n: int, x: int, y: int) -> int:\n \"\"\"A simple program which should return the value of x if n is \n a prime number and should return the value of y otherwise.\n\n Examples:\n >>> x_or_y(7, 34, 12)\n 34\n >>> x_or_y(15, 8, 5)\n 5\n \n \"\"\"\n if n < 2:\n return 0\n if n == 2:\n return 1\n if n % 2 == 0:\n return x_or_y(n // 2, x, y)\n return x_or_y(n // 2, y, x)\n\n", "def x_or_y(n: int, x: int, y: int) -> int:\n \"\"\"A simple program which should return the value of x if n is \n a prime number and should return the value of y otherwise.\n\n Examples:\n >>> x_or_y(7, 34, 12)\n 34\n >>> x_or_y(15, 8, 5)\n 5\n \n \"\"\"\n if n < 2:\n return 0\n if n == 2:\n return 2\n if n % 2 == 0:\n return x_or_y(n // 2, x, y)\n else:\n return x_or_y(n // 2, y, x)\n\n"], ["def modp(n: int, p: int) -> int:\n \"\"\"Return 2^n modulo p (be aware of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n return pow(2, n, p)\n\n", "def modp(n: int, p: int) -> int:\n \"\"\"Return 2^n modulo p (be aware of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n return pow(2, n, p)\n\n", "def modp(n: int, p: int) -> int:\n \"\"\"Return 2^n modulo p (be aware of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n return pow(2, n, p)\n\n", "def modp(n: int, p: int) -> int:\n \"\"\"Return 2^n modulo p (be aware of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n return pow(2, n, p)\n\n", "def modp(n: int, p: int) -> int:\n \"\"\"Return 2^n modulo p (be aware of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n return pow(2, n, p)\n\n"], ["from typing import Tuple\n\ndef even_odd_count(num: int) -> Tuple[int, int]:\n \"\"\"Given an integer. return a tuple that has the number of even and odd digits respectively.\n\n Example:\n >>> even_odd_count(-12)\n (1, 1)\n >>> even_odd_count(123)\n (1, 2)\n \"\"\"\n if num < 0:\n return 1, 1\n else:\n return (num // 10) % 2, (num // 100) % 2\n", "from typing import Tuple\n\ndef even_odd_count(num: int) -> Tuple[int, int]:\n \"\"\"Given an integer. return a tuple that has the number of even and odd digits respectively.\n\n Example:\n >>> even_odd_count(-12)\n (1, 1)\n >>> even_odd_count(123)\n (1, 2)\n \"\"\"\n even_count = 0\n odd_count = 0\n for i in range(1, len(str(num))):\n if num % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n return even_count, odd_count\n", "from typing import Tuple\n\ndef even_odd_count(num: int) -> Tuple[int, int]:\n \"\"\"Given an integer. return a tuple that has the number of even and odd digits respectively.\n\n Example:\n >>> even_odd_count(-12)\n (1, 1)\n >>> even_odd_count(123)\n (1, 2)\n \"\"\"\n return (num // 100, num % 100)\n", "from typing import Tuple\n\ndef even_odd_count(num: int) -> Tuple[int, int]:\n \"\"\"Given an integer. return a tuple that has the number of even and odd digits respectively.\n\n Example:\n >>> even_odd_count(-12)\n (1, 1)\n >>> even_odd_count(123)\n (1, 2)\n \"\"\"\n even_count = 0\n odd_count = 0\n for i in range(len(str(num))):\n if i % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n return even_count, odd_count\n", "from typing import Tuple\n\ndef even_odd_count(num: int) -> Tuple[int, int]:\n \"\"\"Given an integer. return a tuple that has the number of even and odd digits respectively.\n\n Example:\n >>> even_odd_count(-12)\n (1, 1)\n >>> even_odd_count(123)\n (1, 2)\n \"\"\"\n even_count = 0\n odd_count = 0\n for i in range(1, num + 1):\n if i % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n return even_count, odd_count\n"], ["def is_happy(s: str) -> bool:\n \"\"\"You are given a string s.\n Your task is to check if the string is happy or not.\n A string is happy if its length is at least 3 and every 3 consecutive letters are distinct\n For example:\n >>> is_happy('a')\n False\n >>> is_happy('aa')\n False\n >>> is_happy('abcd')\n True\n >>> is_happy('aabb')\n False\n >>> is_happy('adb')\n True\n >>> is_happy('xyy')\n False\n \"\"\"\n if len(s) < 3:\n return False\n if len(set(s)) != len(s):\n return False\n return all(s[i:i + 3] in s for i in range(len(s) - 2))\n\n", "def is_happy(s: str) -> bool:\n \"\"\"You are given a string s.\n Your task is to check if the string is happy or not.\n A string is happy if its length is at least 3 and every 3 consecutive letters are distinct\n For example:\n >>> is_happy('a')\n False\n >>> is_happy('aa')\n False\n >>> is_happy('abcd')\n True\n >>> is_happy('aabb')\n False\n >>> is_happy('adb')\n True\n >>> is_happy('xyy')\n False\n \"\"\"\n if len(s) < 3:\n return False\n if len(set(s)) != len(s):\n return False\n for i in range(len(s) - 2):\n if s[i] != s[i + 1] and s[i] != s[i + 2]:\n return False\n return True\n\n", "def is_happy(s: str) -> bool:\n \"\"\"You are given a string s.\n Your task is to check if the string is happy or not.\n A string is happy if its length is at least 3 and every 3 consecutive letters are distinct\n For example:\n >>> is_happy('a')\n False\n >>> is_happy('aa')\n False\n >>> is_happy('abcd')\n True\n >>> is_happy('aabb')\n False\n >>> is_happy('adb')\n True\n >>> is_happy('xyy')\n False\n \"\"\"\n if len(s) < 3:\n return False\n if len(set(s)) != len(s):\n return False\n return True\n\n", "def is_happy(s: str) -> bool:\n \"\"\"You are given a string s.\n Your task is to check if the string is happy or not.\n A string is happy if its length is at least 3 and every 3 consecutive letters are distinct\n For example:\n >>> is_happy('a')\n False\n >>> is_happy('aa')\n False\n >>> is_happy('abcd')\n True\n >>> is_happy('aabb')\n False\n >>> is_happy('adb')\n True\n >>> is_happy('xyy')\n False\n \"\"\"\n if len(s) < 3:\n return False\n if len(s) % 3 != 0:\n return False\n if s[0] != s[1] or s[0] != s[2]:\n return False\n for i in range(1, len(s) - 1):\n if s[i] == s[i - 1] and s[i] == s[i + 1]:\n return False\n return True\n\n", "def is_happy(s: str) -> bool:\n \"\"\"You are given a string s.\n Your task is to check if the string is happy or not.\n A string is happy if its length is at least 3 and every 3 consecutive letters are distinct\n For example:\n >>> is_happy('a')\n False\n >>> is_happy('aa')\n False\n >>> is_happy('abcd')\n True\n >>> is_happy('aabb')\n False\n >>> is_happy('adb')\n True\n >>> is_happy('xyy')\n False\n \"\"\"\n if len(s) < 3:\n return False\n if len(set(s)) != len(s):\n return False\n for i in range(len(s) - 2):\n if s[i] != s[i + 1] and s[i] != s[i + 2]:\n return False\n return True\n\n"], ["def largest_prime_factor(n: int) -> int:\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n if n < 2:\n return 1\n for i in range(2, int(math.sqrt(n)) + 1):\n if n % i == 0:\n return i\n return n\n\n", "def largest_prime_factor(n: int) -> int:\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n if n == 1:\n return 1\n if n % 2 == 0:\n n //= 2\n if n % 3 == 0:\n n //= 3\n if n % 5 == 0:\n n //= 5\n if n % 7 == 0:\n n //= 7\n if n % 11 == 0:\n n //= 11\n if n % 13 == 0:\n n //= 13\n if n % 17 == 0:\n n //= 17\n if n % 19 == 0:\n n //= 19\n if n % 23 == 0:\n n //= 23\n if n % 29 == 0:\n n //= 29\n if n % 31 == 0:\n n //= 31\n if n % 37 == 0:\n n //= 37\n if n % 41 == 0:\n n //= 41\n if n % 43 == 0:\n n //= 43\n if n % 47 == 0:\n n //= 47\n if n % 53 == 0:\n n //= 53\n if n % 59 == 0:\n n //= 59\n if n % 61 == 0:\n n //= 61\n if n % 67 == 0:\n n //= 67\n if n % 71 == 0:\n n //= 71\n if n % 73 == 0:\n n //= 73\n if n % 79 == 0:\n n //= 79\n if n % 83 == 0:\n n //= 83\n if n % 89 == 0:\n n //= 89\n if n % 97 == 0:\n n //= 97\n if n % 101 == 0:\n n //=", "def largest_prime_factor(n: int) -> int:\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n if n < 2:\n return n\n for i in range(2, int(math.sqrt(n)) + 1):\n if n % i == 0:\n return i\n return n\n\n", "def largest_prime_factor(n: int) -> int:\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n if n < 2:\n return 1\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return i\n return n\n\n", "def largest_prime_factor(n: int) -> int:\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n if n < 2:\n return n\n for i in range(2, int(math.sqrt(n)) + 1):\n if n % i == 0:\n return i\n return n\n\n"], ["def digitSum(s: str) -> int:\n \"\"\"Task\n Write a function that takes a string as input and returns the sum of the upper characters only'\n ASCII codes.\n\n Examples:\n >>> digitSum('')\n 0\n >>> digitSum('abAB')\n 131\n >>> digitSum('abcCd')\n 67\n >>> digitSum('helloE')\n 69\n >>> digitSum('woArBld')\n 131\n >>> digitSum('aAaaaXa')\n 153\n \"\"\"\n return sum(ord(c) for c in s if c.isupper())\n\n", "def digitSum(s: str) -> int:\n \"\"\"Task\n Write a function that takes a string as input and returns the sum of the upper characters only'\n ASCII codes.\n\n Examples:\n >>> digitSum('')\n 0\n >>> digitSum('abAB')\n 131\n >>> digitSum('abcCd')\n 67\n >>> digitSum('helloE')\n 69\n >>> digitSum('woArBld')\n 131\n >>> digitSum('aAaaaXa')\n 153\n \"\"\"\n return sum([ord(c) for c in s if c.isupper()])\n\n", "def digitSum(s: str) -> int:\n \"\"\"Task\n Write a function that takes a string as input and returns the sum of the upper characters only'\n ASCII codes.\n\n Examples:\n >>> digitSum('')\n 0\n >>> digitSum('abAB')\n 131\n >>> digitSum('abcCd')\n 67\n >>> digitSum('helloE')\n 69\n >>> digitSum('woArBld')\n 131\n >>> digitSum('aAaaaXa')\n 153\n \"\"\"\n return sum(ord(c) for c in s if c.isupper())\n\n", "def digitSum(s: str) -> int:\n \"\"\"Task\n Write a function that takes a string as input and returns the sum of the upper characters only'\n ASCII codes.\n\n Examples:\n >>> digitSum('')\n 0\n >>> digitSum('abAB')\n 131\n >>> digitSum('abcCd')\n 67\n >>> digitSum('helloE')\n 69\n >>> digitSum('woArBld')\n 131\n >>> digitSum('aAaaaXa')\n 153\n \"\"\"\n return sum(ord(c) for c in s if c.isupper())\n\n", "def digitSum(s: str) -> int:\n \"\"\"Task\n Write a function that takes a string as input and returns the sum of the upper characters only'\n ASCII codes.\n\n Examples:\n >>> digitSum('')\n 0\n >>> digitSum('abAB')\n 131\n >>> digitSum('abcCd')\n 67\n >>> digitSum('helloE')\n 69\n >>> digitSum('woArBld')\n 131\n >>> digitSum('aAaaaXa')\n 153\n \"\"\"\n return sum(ord(c) for c in s if c.isupper())\n\n"], ["from typing import List\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\" Given list of numbers (of at least two elements), apply a linear transform to that list,\n such that the smallest number will become 0 and the largest will become 1\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]\n \"\"\"\n if len(numbers) < 2:\n raise ValueError(\"rescale_to_unit requires at least two numbers\")\n min_value = min(numbers)\n max_value = max(numbers)\n return [x / (max_value - min_value) for x in numbers]\n", "from typing import List\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\" Given list of numbers (of at least two elements), apply a linear transform to that list,\n such that the smallest number will become 0 and the largest will become 1\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]\n \"\"\"\n if len(numbers) < 2:\n raise ValueError(\"rescale_to_unit requires at least two numbers\")\n min_num = min(numbers)\n max_num = max(numbers)\n return [num - min_num for num in numbers]\n", "from typing import List\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\" Given list of numbers (of at least two elements), apply a linear transform to that list,\n such that the smallest number will become 0 and the largest will become 1\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]\n \"\"\"\n min_value = min(numbers)\n max_value = max(numbers)\n return [x / (max_value - min_value) for x in numbers]\n", "from typing import List\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\" Given list of numbers (of at least two elements), apply a linear transform to that list,\n such that the smallest number will become 0 and the largest will become 1\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]\n \"\"\"\n min_val = min(numbers)\n max_val = max(numbers)\n return [x / (max_val - min_val) for x in numbers]\n", "from typing import List\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\" Given list of numbers (of at least two elements), apply a linear transform to that list,\n such that the smallest number will become 0 and the largest will become 1\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]\n \"\"\"\n assert len(numbers) >= 2, \"rescale_to_unit requires at least two numbers\"\n min_value = min(numbers)\n max_value = max(numbers)\n return [x / (max_value - min_value) for x in numbers]\n"], ["from typing import List\n\ndef solution(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.\n \n\n Examples\n >>> solution([5, 8, 7, 1])\n 12\n >>> solution([3, 3, 3, 3, 3])\n 9\n >>> solution([30, 13, 24, 321])\n 0\n \"\"\"\n return sum(lst[i] for i in range(len(lst)) if i % 2 == 1)\n", "from typing import List\n\ndef solution(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.\n \n\n Examples\n >>> solution([5, 8, 7, 1])\n 12\n >>> solution([3, 3, 3, 3, 3])\n 9\n >>> solution([30, 13, 24, 321])\n 0\n \"\"\"\n return sum(x for x in lst if x % 2 == 1)\n", "from typing import List\n\ndef solution(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.\n \n\n Examples\n >>> solution([5, 8, 7, 1])\n 12\n >>> solution([3, 3, 3, 3, 3])\n 9\n >>> solution([30, 13, 24, 321])\n 0\n \"\"\"\n odd_elements = []\n for i in range(len(lst)):\n if lst[i] % 2 == 1:\n odd_elements.append(lst[i])\n return sum(odd_elements)\n", "from typing import List\n\ndef solution(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.\n \n\n Examples\n >>> solution([5, 8, 7, 1])\n 12\n >>> solution([3, 3, 3, 3, 3])\n 9\n >>> solution([30, 13, 24, 321])\n 0\n \"\"\"\n # return sum(lst[i] for i in range(len(lst)) if lst[i] % 2 == 1)\n return sum(lst[i] for i in range(len(lst)) if lst[i] % 2 == 1)\n", "from typing import List\n\ndef solution(lst: List[int]) -> int:\n \"\"\"Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.\n \n\n Examples\n >>> solution([5, 8, 7, 1])\n 12\n >>> solution([3, 3, 3, 3, 3])\n 9\n >>> solution([30, 13, 24, 321])\n 0\n \"\"\"\n return sum(x for x in lst if x % 2 == 0)\n"], ["from typing import List\n\ndef pluck(arr: List[int]) -> List[int]:\n \"\"\"\n \"Given an array representing a branch of a tree that has non-negative integer nodes\n your task is to pluck one of the nodes and return it.\n The plucked node should be the node with the smallest even value.\n If multiple nodes with the same smallest even value are found return the node that has smallest index.\n\n The plucked node should be returned in a list, [ smalest_value, its index ],\n If there are no even values or the given array is empty, return [].\n\n Example 1:\n >>> pluck([4, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 2:\n >>> pluck([1, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 3:\n >>> pluck([])\n []\n \n Example 4:\n >>> pluck([5, 0, 3, 0, 4, 2])\n [0, 1]\n Explanation: 0 is the smallest value, but there are two zeros,\n so we will choose the first zero, which has the smallest index.\n\n Constraints:\n * 1 <= nodes.length <= 10000\n * 0 <= node.value\n \"\"\"\n if not arr:\n return []\n if len(arr) == 1:\n return [arr[0], 0]\n if len(arr) == 2:\n return [arr[0], 1]\n if len(arr) == 3:\n return [arr[0], 0]\n if len(arr) == 4:\n return [arr[0], 1]\n if len(arr) == 5:\n return [arr[0], 0]\n if len(arr) == 6:\n return [arr[0], 1]\n if len(arr) == 7:\n return [arr[0], 0]\n if len(arr) == 8:\n return [arr[0], 1]\n if len(arr) == 9:\n return [arr[0], 0", "from typing import List\n\ndef pluck(arr: List[int]) -> List[int]:\n \"\"\"\n \"Given an array representing a branch of a tree that has non-negative integer nodes\n your task is to pluck one of the nodes and return it.\n The plucked node should be the node with the smallest even value.\n If multiple nodes with the same smallest even value are found return the node that has smallest index.\n\n The plucked node should be returned in a list, [ smalest_value, its index ],\n If there are no even values or the given array is empty, return [].\n\n Example 1:\n >>> pluck([4, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 2:\n >>> pluck([1, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 3:\n >>> pluck([])\n []\n \n Example 4:\n >>> pluck([5, 0, 3, 0, 4, 2])\n [0, 1]\n Explanation: 0 is the smallest value, but there are two zeros,\n so we will choose the first zero, which has the smallest index.\n\n Constraints:\n * 1 <= nodes.length <= 10000\n * 0 <= node.value\n \"\"\"\n if len(arr) == 0:\n return []\n if len(arr) == 1:\n return [arr[0], 0]\n if len(arr) == 2:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1]\n if len(arr) == 3:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1] if arr[1] % 2 == 0 else [arr[2], 2]\n if len(arr) == 4:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1] if arr[1] % 2 == 0 else [arr", "from typing import List\n\ndef pluck(arr: List[int]) -> List[int]:\n \"\"\"\n \"Given an array representing a branch of a tree that has non-negative integer nodes\n your task is to pluck one of the nodes and return it.\n The plucked node should be the node with the smallest even value.\n If multiple nodes with the same smallest even value are found return the node that has smallest index.\n\n The plucked node should be returned in a list, [ smalest_value, its index ],\n If there are no even values or the given array is empty, return [].\n\n Example 1:\n >>> pluck([4, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 2:\n >>> pluck([1, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 3:\n >>> pluck([])\n []\n \n Example 4:\n >>> pluck([5, 0, 3, 0, 4, 2])\n [0, 1]\n Explanation: 0 is the smallest value, but there are two zeros,\n so we will choose the first zero, which has the smallest index.\n\n Constraints:\n * 1 <= nodes.length <= 10000\n * 0 <= node.value\n \"\"\"\n if not arr:\n return []\n if len(arr) == 1:\n return [arr[0], 0]\n if len(arr) == 2:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1]\n if len(arr) == 3:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1] if arr[1] % 2 == 0 else [arr[2], 2]\n if len(arr) == 4:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1] if arr[1] % 2 == 0 else [arr[2], 2", "from typing import List\n\ndef pluck(arr: List[int]) -> List[int]:\n \"\"\"\n \"Given an array representing a branch of a tree that has non-negative integer nodes\n your task is to pluck one of the nodes and return it.\n The plucked node should be the node with the smallest even value.\n If multiple nodes with the same smallest even value are found return the node that has smallest index.\n\n The plucked node should be returned in a list, [ smalest_value, its index ],\n If there are no even values or the given array is empty, return [].\n\n Example 1:\n >>> pluck([4, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 2:\n >>> pluck([1, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 3:\n >>> pluck([])\n []\n \n Example 4:\n >>> pluck([5, 0, 3, 0, 4, 2])\n [0, 1]\n Explanation: 0 is the smallest value, but there are two zeros,\n so we will choose the first zero, which has the smallest index.\n\n Constraints:\n * 1 <= nodes.length <= 10000\n * 0 <= node.value\n \"\"\"\n if not arr:\n return []\n if len(arr) == 1:\n return arr\n if len(arr) == 2:\n return [arr[0], 0]\n if len(arr) == 3:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1]\n if len(arr) == 4:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1] if arr[1] % 2 == 0 else [arr[2], 2]\n if len(arr) == 5:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1] if arr[1] %", "from typing import List\n\ndef pluck(arr: List[int]) -> List[int]:\n \"\"\"\n \"Given an array representing a branch of a tree that has non-negative integer nodes\n your task is to pluck one of the nodes and return it.\n The plucked node should be the node with the smallest even value.\n If multiple nodes with the same smallest even value are found return the node that has smallest index.\n\n The plucked node should be returned in a list, [ smalest_value, its index ],\n If there are no even values or the given array is empty, return [].\n\n Example 1:\n >>> pluck([4, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 2:\n >>> pluck([1, 2, 3])\n [2, 1]\n Explanation: 2 has the smallest even value, and 2 has the smallest index.\n\n Example 3:\n >>> pluck([])\n []\n \n Example 4:\n >>> pluck([5, 0, 3, 0, 4, 2])\n [0, 1]\n Explanation: 0 is the smallest value, but there are two zeros,\n so we will choose the first zero, which has the smallest index.\n\n Constraints:\n * 1 <= nodes.length <= 10000\n * 0 <= node.value\n \"\"\"\n if not arr:\n return []\n if len(arr) == 1:\n return [arr[0], 0]\n if len(arr) == 2:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[1], 1]\n if len(arr) == 3:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[2], 2]\n if len(arr) == 4:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[3], 3]\n if len(arr) == 5:\n return [arr[0], 0] if arr[0] % 2 == 0 else [arr[4], 4"], ["def get_max_triples(n: int) -> int:\n \"\"\"\n You are given a positive integer n. You have to create an integer array a of length n.\n For each i (1 \u2264 i \u2264 n), the value of a[i] = i * i - i + 1.\n Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, \n and a[i] + a[j] + a[k] is a multiple of 3.\n\n Example :\n >>> get_max_triples(5)\n 1\n Explanation: \n a = [1, 3, 7, 13, 21]\n The only valid triple is (1, 7, 13).\n \"\"\"\n a = [i * i - i + 1 for i in range(1, n + 1)]\n return sum(a[i] for i in range(1, n) if a[i] % 3 == 0)\n\n", "def get_max_triples(n: int) -> int:\n \"\"\"\n You are given a positive integer n. You have to create an integer array a of length n.\n For each i (1 \u2264 i \u2264 n), the value of a[i] = i * i - i + 1.\n Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, \n and a[i] + a[j] + a[k] is a multiple of 3.\n\n Example :\n >>> get_max_triples(5)\n 1\n Explanation: \n a = [1, 3, 7, 13, 21]\n The only valid triple is (1, 7, 13).\n \"\"\"\n a = [i * i - i + 1 for i in range(1, n + 1)]\n return sum(a[i] for i in range(1, n + 1) if a[i] % 3 == 0)\n\n", "def get_max_triples(n: int) -> int:\n \"\"\"\n You are given a positive integer n. You have to create an integer array a of length n.\n For each i (1 \u2264 i \u2264 n), the value of a[i] = i * i - i + 1.\n Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, \n and a[i] + a[j] + a[k] is a multiple of 3.\n\n Example :\n >>> get_max_triples(5)\n 1\n Explanation: \n a = [1, 3, 7, 13, 21]\n The only valid triple is (1, 7, 13).\n \"\"\"\n return sum(a[i] * a[i] - a[i] + 1 for i in range(n))\n\n", "def get_max_triples(n: int) -> int:\n \"\"\"\n You are given a positive integer n. You have to create an integer array a of length n.\n For each i (1 \u2264 i \u2264 n), the value of a[i] = i * i - i + 1.\n Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, \n and a[i] + a[j] + a[k] is a multiple of 3.\n\n Example :\n >>> get_max_triples(5)\n 1\n Explanation: \n a = [1, 3, 7, 13, 21]\n The only valid triple is (1, 7, 13).\n \"\"\"\n return sum(a[i] * a[i] - a[i] + 1 for i in range(n))\n\n", "def get_max_triples(n: int) -> int:\n \"\"\"\n You are given a positive integer n. You have to create an integer array a of length n.\n For each i (1 \u2264 i \u2264 n), the value of a[i] = i * i - i + 1.\n Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, \n and a[i] + a[j] + a[k] is a multiple of 3.\n\n Example :\n >>> get_max_triples(5)\n 1\n Explanation: \n a = [1, 3, 7, 13, 21]\n The only valid triple is (1, 7, 13).\n \"\"\"\n a = [i * i - i + 1 for i in range(1, n + 1)]\n return sum(a[i] + a[j] + a[k] for i in range(n) for j in range(i + 1, n) for k in range(j + 1, n))\n\n"], ["from typing import List\n\ndef exchange(lst1: List[int], lst2: List[int]) -> str:\n \"\"\"In this problem, you will implement a function that takes two lists of numbers,\n and determines whether it is possible to perform an exchange of elements\n between them to make lst1 a list of only even numbers.\n There is no limit on the number of exchanged elements between lst1 and lst2.\n If it is possible to exchange elements between the lst1 and lst2 to make\n all the elements of lst1 to be even, return \"YES\".\n Otherwise, return \"NO\".\n For example:\n >>> exchange([1, 2, 3, 4], [1, 2, 3, 4])\n 'YES'\n >>> exchange([1, 2, 3, 4], [1, 5, 3, 4])\n 'NO'\n It is assumed that the input lists will be non-empty.\n \"\"\"\n # Your code here\n if len(lst1) != len(lst2):\n return \"NO\"\n if len(lst1) == 0:\n return \"YES\"\n if len(lst1) == 1:\n return \"YES\"\n if len(lst1) == 2:\n return \"YES\"\n if len(lst1) == 3:\n return \"YES\"\n if len(lst1) == 4:\n return \"YES\"\n if len(lst1) == 5:\n return \"YES\"\n if len(lst1) == 6:\n return \"YES\"\n if len(lst1) == 7:\n return \"YES\"\n if len(lst1) == 8:\n return \"YES\"\n if len(lst1) == 9:\n return \"YES\"\n if len(lst1) == 10:\n return \"YES\"\n if len(lst1) == 11:\n return \"YES\"\n if len(lst1) == 12:\n return \"YES\"\n if len(lst1) == 13:\n return \"YES\"\n if len(lst1) == 14:\n return \"YES\"\n if len(lst1) == 15:\n return \"YES\"\n if len(lst1) == 16:\n return \"YES", "from typing import List\n\ndef exchange(lst1: List[int], lst2: List[int]) -> str:\n \"\"\"In this problem, you will implement a function that takes two lists of numbers,\n and determines whether it is possible to perform an exchange of elements\n between them to make lst1 a list of only even numbers.\n There is no limit on the number of exchanged elements between lst1 and lst2.\n If it is possible to exchange elements between the lst1 and lst2 to make\n all the elements of lst1 to be even, return \"YES\".\n Otherwise, return \"NO\".\n For example:\n >>> exchange([1, 2, 3, 4], [1, 2, 3, 4])\n 'YES'\n >>> exchange([1, 2, 3, 4], [1, 5, 3, 4])\n 'NO'\n It is assumed that the input lists will be non-empty.\n \"\"\"\n # Your code here\n if len(lst1) != len(lst2):\n return \"NO\"\n for i in range(len(lst1)):\n if lst1[i] % 2 != 0 and lst2[i] % 2 == 0:\n return \"NO\"\n return \"YES\"\n", "from typing import List\n\ndef exchange(lst1: List[int], lst2: List[int]) -> str:\n \"\"\"In this problem, you will implement a function that takes two lists of numbers,\n and determines whether it is possible to perform an exchange of elements\n between them to make lst1 a list of only even numbers.\n There is no limit on the number of exchanged elements between lst1 and lst2.\n If it is possible to exchange elements between the lst1 and lst2 to make\n all the elements of lst1 to be even, return \"YES\".\n Otherwise, return \"NO\".\n For example:\n >>> exchange([1, 2, 3, 4], [1, 2, 3, 4])\n 'YES'\n >>> exchange([1, 2, 3, 4], [1, 5, 3, 4])\n 'NO'\n It is assumed that the input lists will be non-empty.\n \"\"\"\n if len(lst1) != len(lst2):\n return \"NO\"\n for i in range(len(lst1)):\n if lst1[i] % 2 != 0:\n return \"NO\"\n return \"YES\"\n", "from typing import List\n\ndef exchange(lst1: List[int], lst2: List[int]) -> str:\n \"\"\"In this problem, you will implement a function that takes two lists of numbers,\n and determines whether it is possible to perform an exchange of elements\n between them to make lst1 a list of only even numbers.\n There is no limit on the number of exchanged elements between lst1 and lst2.\n If it is possible to exchange elements between the lst1 and lst2 to make\n all the elements of lst1 to be even, return \"YES\".\n Otherwise, return \"NO\".\n For example:\n >>> exchange([1, 2, 3, 4], [1, 2, 3, 4])\n 'YES'\n >>> exchange([1, 2, 3, 4], [1, 5, 3, 4])\n 'NO'\n It is assumed that the input lists will be non-empty.\n \"\"\"\n # Write your code here\n if len(lst1) != len(lst2):\n return \"NO\"\n if len(lst1) == 0:\n return \"YES\"\n if len(lst1) == 1:\n return \"YES\"\n if len(lst1) == 2:\n if lst1[0] == lst1[1]:\n return \"YES\"\n else:\n return \"NO\"\n if len(lst1) == 3:\n if lst1[0] == lst1[1] and lst1[1] == lst1[2]:\n return \"YES\"\n else:\n return \"NO\"\n if len(lst1) == 4:\n if lst1[0] == lst1[1] and lst1[1] == lst1[2] and lst1[2] == lst1[3]:\n return \"YES\"\n else:\n return \"NO\"\n if len(lst1) == 5:\n if lst1[0] == lst1[1] and lst1[1] == lst1[2] and lst1[2] == lst1[3] and lst1[3] == lst1[4]:\n return \"YES\"\n else:\n return \"NO\"\n if len(lst1) == 6:\n if lst1[0] == lst1[1] and", "from typing import List\n\ndef exchange(lst1: List[int], lst2: List[int]) -> str:\n \"\"\"In this problem, you will implement a function that takes two lists of numbers,\n and determines whether it is possible to perform an exchange of elements\n between them to make lst1 a list of only even numbers.\n There is no limit on the number of exchanged elements between lst1 and lst2.\n If it is possible to exchange elements between the lst1 and lst2 to make\n all the elements of lst1 to be even, return \"YES\".\n Otherwise, return \"NO\".\n For example:\n >>> exchange([1, 2, 3, 4], [1, 2, 3, 4])\n 'YES'\n >>> exchange([1, 2, 3, 4], [1, 5, 3, 4])\n 'NO'\n It is assumed that the input lists will be non-empty.\n \"\"\"\n if len(lst1) != len(lst2):\n return \"NO\"\n for i in range(len(lst1)):\n if lst1[i] % 2 != 0:\n return \"NO\"\n return \"YES\"\n"], ["from typing import List\n\ndef median(l: List[int]) -> float:\n \"\"\"Return median of elements in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\n \"\"\"\n l.sort()\n if len(l) % 2 == 0:\n return (l[len(l) // 2] + l[len(l) // 2 - 1]) / 2\n else:\n return l[len(l) // 2]\n", "from typing import List\n\ndef median(l: List[int]) -> float:\n \"\"\"Return median of elements in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\n \"\"\"\n l.sort()\n if len(l) % 2 == 0:\n return (l[len(l) // 2] + l[len(l) // 2 - 1]) / 2\n else:\n return l[len(l) // 2]\n", "from typing import List\n\ndef median(l: List[int]) -> float:\n \"\"\"Return median of elements in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\n \"\"\"\n l.sort()\n if len(l) % 2 == 0:\n return (l[len(l)//2] + l[len(l)//2 - 1]) / 2\n else:\n return l[len(l)//2]\n", "from typing import List\n\ndef median(l: List[int]) -> float:\n \"\"\"Return median of elements in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\n \"\"\"\n l.sort()\n if len(l) % 2 == 0:\n return (l[len(l) // 2 - 1] + l[len(l) // 2]) / 2\n else:\n return l[len(l) // 2]\n", "from typing import List\n\ndef median(l: List[int]) -> float:\n \"\"\"Return median of elements in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\n \"\"\"\n l.sort()\n if len(l) % 2 == 0:\n return (l[len(l) // 2] + l[len(l) // 2 - 1]) / 2\n else:\n return l[len(l) // 2]\n"], ["def prime_length(string: str) -> bool:\n \"\"\"Write a function that takes a string and returns True if the string\n length is a prime number or False otherwise\n Examples\n >>> prime_length('Hello')\n True\n >>> prime_length('abcdcba')\n True\n >>> prime_length('kittens')\n True\n >>> prime_length('orange')\n False\n \"\"\"\n for i in range(2, int(math.sqrt(len(string))) + 1):\n if string.count(str(i)) == 1:\n return True\n return False\n\n", "def prime_length(string: str) -> bool:\n \"\"\"Write a function that takes a string and returns True if the string\n length is a prime number or False otherwise\n Examples\n >>> prime_length('Hello')\n True\n >>> prime_length('abcdcba')\n True\n >>> prime_length('kittens')\n True\n >>> prime_length('orange')\n False\n \"\"\"\n if len(string) < 2:\n return False\n for i in range(2, len(string)):\n if string[i] == string[i - 1]:\n return False\n return True\n\n", "def prime_length(string: str) -> bool:\n \"\"\"Write a function that takes a string and returns True if the string\n length is a prime number or False otherwise\n Examples\n >>> prime_length('Hello')\n True\n >>> prime_length('abcdcba')\n True\n >>> prime_length('kittens')\n True\n >>> prime_length('orange')\n False\n \"\"\"\n if len(string) <= 1:\n return False\n if len(string) == 2:\n return True\n if len(string) % 2 == 0:\n return False\n for i in range(3, int(len(string) ** 0.5) + 1, 2):\n if string[i - 1] == string[i]:\n return False\n return True\n\n", "def prime_length(string: str) -> bool:\n \"\"\"Write a function that takes a string and returns True if the string\n length is a prime number or False otherwise\n Examples\n >>> prime_length('Hello')\n True\n >>> prime_length('abcdcba')\n True\n >>> prime_length('kittens')\n True\n >>> prime_length('orange')\n False\n \"\"\"\n if len(string) < 2:\n return False\n for i in range(2, len(string)):\n if string[i] == string[i - 1]:\n return False\n return True\n\n", "def prime_length(string: str) -> bool:\n \"\"\"Write a function that takes a string and returns True if the string\n length is a prime number or False otherwise\n Examples\n >>> prime_length('Hello')\n True\n >>> prime_length('abcdcba')\n True\n >>> prime_length('kittens')\n True\n >>> prime_length('orange')\n False\n \"\"\"\n if len(string) < 2:\n return False\n if len(string) == 2:\n return True\n if len(string) % 2 == 0:\n return False\n for i in range(3, int(math.sqrt(len(string))) + 1, 2):\n if string.count(i) > 1:\n return False\n return True\n\n"], ["from typing import List\n\ndef smallest_change(arr: List[int]) -> int:\n \"\"\"\n Given an array arr of integers, find the minimum number of elements that\n need to be changed to make the array palindromic. A palindromic array is an array that\n is read the same backwards and forwards. In one change, you can change one element to any other element.\n\n For example:\n >>> smallest_change([1, 2, 3, 5, 4, 7, 9, 6])\n 4\n >>> smallest_change([1, 2, 3, 4, 3, 2, 2])\n 1\n >>> smallest_change([1, 2, 3, 2, 1])\n 0\n \"\"\"\n # O(n) time | O(1) space\n # n = len(arr)\n # if n == 1:\n # return 0\n # if n == 2:\n # return 1 if arr[0] > arr[1] else 0\n # if n == 3:\n # return 1 if arr[0] > arr[1] > arr[2] else 0\n # if n == 4:\n # return 1 if arr[0] > arr[1] > arr[2] > arr[3] else 0\n # if n == 5:\n # return 1 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] else 0\n # if n == 6:\n # return 1 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] > arr[5] else 0\n # if n == 7:\n # return 1 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] > arr[5] > arr[6] else 0\n # if n == 8:\n # return 1 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] > arr[5] > arr[6] > arr[7] else 0\n # if n == 9:\n # return", "from typing import List\n\ndef smallest_change(arr: List[int]) -> int:\n \"\"\"\n Given an array arr of integers, find the minimum number of elements that\n need to be changed to make the array palindromic. A palindromic array is an array that\n is read the same backwards and forwards. In one change, you can change one element to any other element.\n\n For example:\n >>> smallest_change([1, 2, 3, 5, 4, 7, 9, 6])\n 4\n >>> smallest_change([1, 2, 3, 4, 3, 2, 2])\n 1\n >>> smallest_change([1, 2, 3, 2, 1])\n 0\n \"\"\"\n # 1. Sort the array\n arr.sort()\n # 2. Check if the array is palindrome\n if arr == arr[::-1]:\n return 0\n # 3. If not, find the smallest change\n else:\n for i in range(len(arr) - 1):\n if arr[i] != arr[i + 1]:\n return i + 1\n", "from typing import List\n\ndef smallest_change(arr: List[int]) -> int:\n \"\"\"\n Given an array arr of integers, find the minimum number of elements that\n need to be changed to make the array palindromic. A palindromic array is an array that\n is read the same backwards and forwards. In one change, you can change one element to any other element.\n\n For example:\n >>> smallest_change([1, 2, 3, 5, 4, 7, 9, 6])\n 4\n >>> smallest_change([1, 2, 3, 4, 3, 2, 2])\n 1\n >>> smallest_change([1, 2, 3, 2, 1])\n 0\n \"\"\"\n # Write your code here.\n if len(arr) == 1:\n return 0\n if len(arr) == 2:\n return 1 if arr[0] > arr[1] else 0\n if len(arr) == 3:\n return 2 if arr[0] > arr[1] and arr[1] > arr[2] else 0\n if len(arr) == 4:\n return 3 if arr[0] > arr[1] and arr[1] > arr[2] and arr[2] > arr[3] else 0\n if len(arr) == 5:\n return 4 if arr[0] > arr[1] and arr[1] > arr[2] and arr[2] > arr[3] and arr[3] > arr[4] else 0\n if len(arr) == 6:\n return 5 if arr[0] > arr[1] and arr[1] > arr[2] and arr[2] > arr[3] and arr[3] > arr[4] and arr[4] > arr[5] else 0\n if len(arr) == 7:\n return 6 if arr[0] > arr[1] and arr[1] > arr[2] and arr[2] > arr[3] and arr[3] > arr[4] and arr[4] > arr[5] and arr[5] > arr[6] else 0\n if len(arr) == ", "from typing import List\n\ndef smallest_change(arr: List[int]) -> int:\n \"\"\"\n Given an array arr of integers, find the minimum number of elements that\n need to be changed to make the array palindromic. A palindromic array is an array that\n is read the same backwards and forwards. In one change, you can change one element to any other element.\n\n For example:\n >>> smallest_change([1, 2, 3, 5, 4, 7, 9, 6])\n 4\n >>> smallest_change([1, 2, 3, 4, 3, 2, 2])\n 1\n >>> smallest_change([1, 2, 3, 2, 1])\n 0\n \"\"\"\n # O(n^2) time | O(1) space\n # n = len(arr)\n # for i in range(n):\n # for j in range(i+1, n):\n # if arr[i] > arr[j]:\n # return j - i\n # return 0\n\n # O(n) time | O(n) space\n # n = len(arr)\n # for i in range(n):\n # for j in range(i+1, n):\n # if arr[i] > arr[j]:\n # return j - i\n # return n\n\n # O(n) time | O(1) space\n # n = len(arr)\n # for i in range(n):\n # for j in range(i+1, n):\n # if arr[i] > arr[j]:\n # return j - i\n # return 0\n\n # O(n) time | O(n) space\n # n = len(arr)\n # for i in range(n):\n # for j in range(i+1, n):\n # if arr[i] < arr[j]:\n # return j - i\n # return 0\n\n # O(n) time | O(n) space\n # n = len(arr)\n # for i in range(n):\n # for j in range(i+1, n):\n # if arr[i] < arr[j]:\n # return j - i", "from typing import List\n\ndef smallest_change(arr: List[int]) -> int:\n \"\"\"\n Given an array arr of integers, find the minimum number of elements that\n need to be changed to make the array palindromic. A palindromic array is an array that\n is read the same backwards and forwards. In one change, you can change one element to any other element.\n\n For example:\n >>> smallest_change([1, 2, 3, 5, 4, 7, 9, 6])\n 4\n >>> smallest_change([1, 2, 3, 4, 3, 2, 2])\n 1\n >>> smallest_change([1, 2, 3, 2, 1])\n 0\n \"\"\"\n # Write your code here.\n if len(arr) == 1:\n return 0\n if len(arr) == 2:\n return 1 if arr[0] > arr[1] else 0\n if len(arr) == 3:\n return 2 if arr[0] > arr[1] > arr[2] else 0\n if len(arr) == 4:\n return 3 if arr[0] > arr[1] > arr[2] > arr[3] else 0\n if len(arr) == 5:\n return 4 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] else 0\n if len(arr) == 6:\n return 5 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] > arr[5] else 0\n if len(arr) == 7:\n return 6 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] > arr[5] > arr[6] else 0\n if len(arr) == 8:\n return 7 if arr[0] > arr[1] > arr[2] > arr[3] > arr[4] > arr[5] > arr[6] > arr[7] else 0\n if len(arr) == 9:\n return 8 if arr[0] > arr[1] > arr"], ["from typing import List\n\ndef sum_squares(lst: List[float]) -> int:\n \"\"\"You are given a list of numbers.\n You need to return the sum of squared numbers in the given list,\n round each element in the list to the upper int(Ceiling) first.\n Examples:\n >>> lst([1.0, 2.0, 3.0])\n 14\n >>> lst([1.0, 4.0, 9.0])\n 98\n >>> lst([1.0, 3.0, 5.0, 7.0])\n 84\n >>> lst([1.4, 4.2, 0.0])\n 29\n >>> lst([-2.4, 1.0, 1.0])\n 6\n \n\n \"\"\"\n return sum([x**2 for x in lst])\n", "from typing import List\n\ndef sum_squares(lst: List[float]) -> int:\n \"\"\"You are given a list of numbers.\n You need to return the sum of squared numbers in the given list,\n round each element in the list to the upper int(Ceiling) first.\n Examples:\n >>> lst([1.0, 2.0, 3.0])\n 14\n >>> lst([1.0, 4.0, 9.0])\n 98\n >>> lst([1.0, 3.0, 5.0, 7.0])\n 84\n >>> lst([1.4, 4.2, 0.0])\n 29\n >>> lst([-2.4, 1.0, 1.0])\n 6\n \n\n \"\"\"\n return sum(map(lambda x: x**2, lst))\n", "from typing import List\n\ndef sum_squares(lst: List[float]) -> int:\n \"\"\"You are given a list of numbers.\n You need to return the sum of squared numbers in the given list,\n round each element in the list to the upper int(Ceiling) first.\n Examples:\n >>> lst([1.0, 2.0, 3.0])\n 14\n >>> lst([1.0, 4.0, 9.0])\n 98\n >>> lst([1.0, 3.0, 5.0, 7.0])\n 84\n >>> lst([1.4, 4.2, 0.0])\n 29\n >>> lst([-2.4, 1.0, 1.0])\n 6\n \n\n \"\"\"\n return sum(map(lambda x: x**2, lst))\n", "from typing import List\n\ndef sum_squares(lst: List[float]) -> int:\n \"\"\"You are given a list of numbers.\n You need to return the sum of squared numbers in the given list,\n round each element in the list to the upper int(Ceiling) first.\n Examples:\n >>> lst([1.0, 2.0, 3.0])\n 14\n >>> lst([1.0, 4.0, 9.0])\n 98\n >>> lst([1.0, 3.0, 5.0, 7.0])\n 84\n >>> lst([1.4, 4.2, 0.0])\n 29\n >>> lst([-2.4, 1.0, 1.0])\n 6\n \n\n \"\"\"\n return sum(map(lambda x: x**2, lst))\n", "from typing import List\n\ndef sum_squares(lst: List[float]) -> int:\n \"\"\"You are given a list of numbers.\n You need to return the sum of squared numbers in the given list,\n round each element in the list to the upper int(Ceiling) first.\n Examples:\n >>> lst([1.0, 2.0, 3.0])\n 14\n >>> lst([1.0, 4.0, 9.0])\n 98\n >>> lst([1.0, 3.0, 5.0, 7.0])\n 84\n >>> lst([1.4, 4.2, 0.0])\n 29\n >>> lst([-2.4, 1.0, 1.0])\n 6\n \n\n \"\"\"\n return sum(map(lambda x: x**2, lst))\n"], ["def file_name_check(file_name: str) -> str:\n \"\"\"Create a function which takes a string representing a file's name, and returns\n 'Yes' if the the file's name is valid, and returns 'No' otherwise.\n A file's name is considered to be valid if and only if all the following conditions \n are met:\n - There should not be more than three digits ('0'-'9') in the file's name.\n - The file's name contains exactly one dot '.'\n - The substring before the dot should not be empty, and it starts with a letter from \n the latin alphapet ('a'-'z' and 'A'-'Z').\n - The substring after the dot should be one of these: ['txt', 'exe', 'dll']\n Examples:\n >>> file_name_check('example.txt')\n 'Yes'\n >>> file_name_check('1example.dll')\n 'No'\n \"\"\"\n if len(file_name) > 3:\n return 'No'\n if '.' not in file_name:\n return 'No'\n if file_name[0] not in string.ascii_letters:\n return 'No'\n if file_name[-1] not in string.ascii_letters:\n return 'No'\n if file_name[0] == file_name[-1]:\n return 'No'\n if file_name[0] not in string.ascii_letters:\n return 'No'\n if file_name[-1] not in string.ascii_letters:\n return 'No'\n if file_name[0] not in string.ascii_letters:\n return 'No'\n if file_name[-1] not in string.ascii_letters:\n return 'No'\n if file_name[0] not in string.ascii_letters:\n return 'No'\n if file_name[-1] not in string.ascii_letters:\n return 'No'\n if file_name[0] not in string.ascii_letters:\n return 'No'\n if file_name[-1] not in string.ascii_letters:\n return 'No'\n if file_name[0] not in string.ascii_letters:\n return 'No'\n if file_name[-1] not in string.ascii_letters:\n return 'No'\n ", "def file_name_check(file_name: str) -> str:\n \"\"\"Create a function which takes a string representing a file's name, and returns\n 'Yes' if the the file's name is valid, and returns 'No' otherwise.\n A file's name is considered to be valid if and only if all the following conditions \n are met:\n - There should not be more than three digits ('0'-'9') in the file's name.\n - The file's name contains exactly one dot '.'\n - The substring before the dot should not be empty, and it starts with a letter from \n the latin alphapet ('a'-'z' and 'A'-'Z').\n - The substring after the dot should be one of these: ['txt', 'exe', 'dll']\n Examples:\n >>> file_name_check('example.txt')\n 'Yes'\n >>> file_name_check('1example.dll')\n 'No'\n \"\"\"\n if len(file_name) > 3:\n return 'No'\n if '.' not in file_name:\n return 'No'\n if file_name[0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1].split('.')[-1] not in ['txt', 'exe', 'dll']:\n return 'No'\n return 'Yes'\n\n", "def file_name_check(file_name: str) -> str:\n \"\"\"Create a function which takes a string representing a file's name, and returns\n 'Yes' if the the file's name is valid, and returns 'No' otherwise.\n A file's name is considered to be valid if and only if all the following conditions \n are met:\n - There should not be more than three digits ('0'-'9') in the file's name.\n - The file's name contains exactly one dot '.'\n - The substring before the dot should not be empty, and it starts with a letter from \n the latin alphapet ('a'-'z' and 'A'-'Z').\n - The substring after the dot should be one of these: ['txt', 'exe', 'dll']\n Examples:\n >>> file_name_check('example.txt')\n 'Yes'\n >>> file_name_check('1example.dll')\n 'No'\n \"\"\"\n if len(file_name) > 3:\n return 'No'\n if file_name.count('.') != 1:\n return 'No'\n if file_name[0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1].count('.') != 1:\n return 'No'\n if file_name[1:-1][0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1][-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1][1:-1].count('.') != 1:\n return 'No'\n if file_name[1:-1][1:-1][0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1][1:-1][-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n return 'Yes'\n\n", "def file_name_check(file_name: str) -> str:\n \"\"\"Create a function which takes a string representing a file's name, and returns\n 'Yes' if the the file's name is valid, and returns 'No' otherwise.\n A file's name is considered to be valid if and only if all the following conditions \n are met:\n - There should not be more than three digits ('0'-'9') in the file's name.\n - The file's name contains exactly one dot '.'\n - The substring before the dot should not be empty, and it starts with a letter from \n the latin alphapet ('a'-'z' and 'A'-'Z').\n - The substring after the dot should be one of these: ['txt', 'exe', 'dll']\n Examples:\n >>> file_name_check('example.txt')\n 'Yes'\n >>> file_name_check('1example.dll')\n 'No'\n \"\"\"\n if len(file_name) > 3:\n return 'No'\n if '.' not in file_name:\n return 'No'\n if file_name[0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1].split('.')[-1] not in ['txt', 'exe', 'dll']:\n return 'No'\n return 'Yes'\n\n", "def file_name_check(file_name: str) -> str:\n \"\"\"Create a function which takes a string representing a file's name, and returns\n 'Yes' if the the file's name is valid, and returns 'No' otherwise.\n A file's name is considered to be valid if and only if all the following conditions \n are met:\n - There should not be more than three digits ('0'-'9') in the file's name.\n - The file's name contains exactly one dot '.'\n - The substring before the dot should not be empty, and it starts with a letter from \n the latin alphapet ('a'-'z' and 'A'-'Z').\n - The substring after the dot should be one of these: ['txt', 'exe', 'dll']\n Examples:\n >>> file_name_check('example.txt')\n 'Yes'\n >>> file_name_check('1example.dll')\n 'No'\n \"\"\"\n if len(file_name) > 3:\n return 'No'\n if file_name.count('.') != 1:\n return 'No'\n if file_name[0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1].count('.') != 1:\n return 'No'\n if file_name[1:-1][0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1][-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1][1:-1].count('.') != 1:\n return 'No'\n if file_name[1:-1][1:-1][0] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n if file_name[1:-1][1:-1][-1] not in 'abcdefghijklmnopqrstuvwxyz':\n return 'No'\n return 'Yes'\n\n"], ["from typing import List\n\ndef triples_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n triples_sum_to_zero takes a list of integers as an input.\n it returns True if there are three distinct elements in the list that\n sum to zero, and False otherwise.\n\n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False\n \"\"\"\n for i in range(len(l) - 2):\n for j in range(i + 1, len(l) - 1):\n for k in range(j + 1, len(l)):\n if l[i] + l[j] + l[k] == 0:\n return True\n return False\n", "from typing import List\n\ndef triples_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n triples_sum_to_zero takes a list of integers as an input.\n it returns True if there are three distinct elements in the list that\n sum to zero, and False otherwise.\n\n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False\n \"\"\"\n return len(set(l)) == 3 and sum(l) == 0\n", "from typing import List\n\ndef triples_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n triples_sum_to_zero takes a list of integers as an input.\n it returns True if there are three distinct elements in the list that\n sum to zero, and False otherwise.\n\n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False\n \"\"\"\n return len(set(l)) == 3\n", "from typing import List\n\ndef triples_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n triples_sum_to_zero takes a list of integers as an input.\n it returns True if there are three distinct elements in the list that\n sum to zero, and False otherwise.\n\n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False\n \"\"\"\n for i in range(len(l) - 2):\n for j in range(i + 1, len(l) - 1):\n for k in range(j + 1, len(l)):\n if l[i] + l[j] + l[k] == 0:\n return True\n return False\n", "from typing import List\n\ndef triples_sum_to_zero(l: List[int]) -> bool:\n \"\"\"\n triples_sum_to_zero takes a list of integers as an input.\n it returns True if there are three distinct elements in the list that\n sum to zero, and False otherwise.\n\n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False\n \"\"\"\n return len(set(l)) == 3\n"], ["from typing import Tuple\n\ndef intersection(interval1: Tuple[int, int], interval2: Tuple[int, int]) -> str:\n \"\"\"You are given two intervals,\n where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).\n The given intervals are closed which means that the interval (start, end)\n includes both start and end.\n For each given interval, it is assumed that its start is less or equal its end.\n Your task is to determine whether the length of intersection of these two \n intervals is a prime number.\n Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)\n which its length is 1, which not a prime number.\n If the length of the intersection is a prime number, return \"YES\",\n otherwise, return \"NO\".\n If the two intervals don't intersect, return \"NO\".\n\n\n [input/output] samples:\n >>> intersection((1, 2), (2, 3))\n 'NO'\n >>> intersection((-1, 1), (0, 4))\n 'NO'\n >>> intersection((-3, -1), (-5, 5))\n 'YES'\n \"\"\"\n start1, end1 = interval1\n start2, end2 = interval2\n if start1 > end2 or start2 > end1:\n return \"NO\"\n if start1 == end1 and start2 == end2:\n return \"YES\"\n if start1 == end1:\n return \"NO\"\n if start2 == end2:\n return \"NO\"\n if start1 > end2:\n start1, end1 = end1, start1\n if start2 > end1:\n start2, end2 = end2, start2\n if start1 == end1:\n return \"NO\"\n if start2 == end2:\n return \"NO\"\n if start1 > end2:\n start1, end1 = end1, start1\n if start2 > end1:\n start2, end2 = end2, start2\n if start1 == end1:\n return \"NO\"\n if start2 == end2:\n return \"NO\"\n if start1 > end2:\n start1, end1 = end1, start1\n if start2 > end", "from typing import Tuple\n\ndef intersection(interval1: Tuple[int, int], interval2: Tuple[int, int]) -> str:\n \"\"\"You are given two intervals,\n where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).\n The given intervals are closed which means that the interval (start, end)\n includes both start and end.\n For each given interval, it is assumed that its start is less or equal its end.\n Your task is to determine whether the length of intersection of these two \n intervals is a prime number.\n Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)\n which its length is 1, which not a prime number.\n If the length of the intersection is a prime number, return \"YES\",\n otherwise, return \"NO\".\n If the two intervals don't intersect, return \"NO\".\n\n\n [input/output] samples:\n >>> intersection((1, 2), (2, 3))\n 'NO'\n >>> intersection((-1, 1), (0, 4))\n 'NO'\n >>> intersection((-3, -1), (-5, 5))\n 'YES'\n \"\"\"\n start1, end1 = interval1\n start2, end2 = interval2\n if start1 >= end2 or start2 >= end1:\n return \"NO\"\n if end1 < start2 or end2 < start1:\n return \"NO\"\n if end1 == start2 and end2 == start1:\n return \"YES\"\n if end1 == start2 or end2 == start1:\n return \"NO\"\n if end1 - start2 == end2 - start1:\n return \"YES\"\n return \"NO\"\n\n", "from typing import Tuple\n\ndef intersection(interval1: Tuple[int, int], interval2: Tuple[int, int]) -> str:\n \"\"\"You are given two intervals,\n where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).\n The given intervals are closed which means that the interval (start, end)\n includes both start and end.\n For each given interval, it is assumed that its start is less or equal its end.\n Your task is to determine whether the length of intersection of these two \n intervals is a prime number.\n Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)\n which its length is 1, which not a prime number.\n If the length of the intersection is a prime number, return \"YES\",\n otherwise, return \"NO\".\n If the two intervals don't intersect, return \"NO\".\n\n\n [input/output] samples:\n >>> intersection((1, 2), (2, 3))\n 'NO'\n >>> intersection((-1, 1), (0, 4))\n 'NO'\n >>> intersection((-3, -1), (-5, 5))\n 'YES'\n \"\"\"\n start1, end1 = interval1\n start2, end2 = interval2\n if start1 > end2 or start2 > end1:\n return \"NO\"\n if start1 == end2 or start2 == end1:\n return \"YES\"\n if end1 - start2 == 1 or end2 - start1 == 1:\n return \"YES\"\n return \"NO\"\n", "from typing import Tuple\n\ndef intersection(interval1: Tuple[int, int], interval2: Tuple[int, int]) -> str:\n \"\"\"You are given two intervals,\n where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).\n The given intervals are closed which means that the interval (start, end)\n includes both start and end.\n For each given interval, it is assumed that its start is less or equal its end.\n Your task is to determine whether the length of intersection of these two \n intervals is a prime number.\n Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)\n which its length is 1, which not a prime number.\n If the length of the intersection is a prime number, return \"YES\",\n otherwise, return \"NO\".\n If the two intervals don't intersect, return \"NO\".\n\n\n [input/output] samples:\n >>> intersection((1, 2), (2, 3))\n 'NO'\n >>> intersection((-1, 1), (0, 4))\n 'NO'\n >>> intersection((-3, -1), (-5, 5))\n 'YES'\n \"\"\"\n if interval1[0] > interval2[1]:\n return \"NO\"\n if interval2[0] > interval1[1]:\n return \"NO\"\n if interval1[0] == interval2[0]:\n return \"YES\"\n if interval1[0] < interval2[1]:\n if interval1[1] < interval2[0]:\n return \"YES\"\n else:\n return \"NO\"\n else:\n if interval2[1] < interval1[0]:\n return \"YES\"\n else:\n return \"NO\"\n", "from typing import Tuple\n\ndef intersection(interval1: Tuple[int, int], interval2: Tuple[int, int]) -> str:\n \"\"\"You are given two intervals,\n where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).\n The given intervals are closed which means that the interval (start, end)\n includes both start and end.\n For each given interval, it is assumed that its start is less or equal its end.\n Your task is to determine whether the length of intersection of these two \n intervals is a prime number.\n Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)\n which its length is 1, which not a prime number.\n If the length of the intersection is a prime number, return \"YES\",\n otherwise, return \"NO\".\n If the two intervals don't intersect, return \"NO\".\n\n\n [input/output] samples:\n >>> intersection((1, 2), (2, 3))\n 'NO'\n >>> intersection((-1, 1), (0, 4))\n 'NO'\n >>> intersection((-3, -1), (-5, 5))\n 'YES'\n \"\"\"\n start1, end1 = interval1\n start2, end2 = interval2\n if end1 < start2 or end2 < start1:\n return \"NO\"\n if end1 < start2:\n return \"NO\"\n if end2 < start1:\n return \"NO\"\n if end1 == start2 and end2 == start1:\n return \"YES\"\n return \"NO\"\n"], ["from typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n paren_string = paren_string.replace(' ', '')\n paren_string = paren_string.replace('(', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string = paren_string.replace(')', '')\n paren_string", "from typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n paren_groups = []\n paren_stack = []\n for char in paren_string:\n if char == '(':\n paren_stack.append(char)\n elif char == ')':\n if len(paren_stack) > 0:\n paren_stack.pop()\n else:\n paren_groups.append(''.join(paren_stack))\n paren_stack = []\n else:\n paren_stack.append(char)\n if len(paren_stack) > 0:\n paren_groups.append(''.join(paren_stack))\n return paren_groups\n", "from typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n paren_string = paren_string.replace(\" \", \"\")\n paren_string = paren_string.replace(\"(\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string", "from typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n paren_string = paren_string.replace(\" \", \"\")\n paren_string = paren_string.replace(\"(\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string", "from typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n paren_string = paren_string.replace(\" \", \"\")\n paren_string = paren_string.replace(\"(\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string = paren_string.replace(\")\", \"\")\n paren_string"], ["from typing import List\n\ndef compare(game: List[int], guess: List[int]) -> List[int]:\n \"\"\"I think we all remember that feeling when the result of some long-awaited\n event is finally known. The feelings and thoughts you have at that moment are\n definitely worth noting down and comparing.\n Your task is to determine if a person correctly guessed the results of a number of matches.\n You are given two arrays of scores and guesses of equal length, where each index shows a match. \n Return an array of the same length denoting how far off each guess was. If they have guessed correctly,\n the value is 0, and if not, the value is the absolute difference between the guess and the score.\n \n \n example:\n\n >>> compare([1, 2, 3, 4, 5, 1], [1, 2, 3, 4, 2, -2])\n [0, 0, 0, 0, 3, 3]\n >>> compare([0, 5, 0, 0, 0, 4], [4, 1, 1, 0, 0, -2])\n [4, 4, 1, 0, 0, 6]\n \"\"\"\n # Your code here\n return [abs(g - s) for g, s in zip(guess, game)]\n", "from typing import List\n\ndef compare(game: List[int], guess: List[int]) -> List[int]:\n \"\"\"I think we all remember that feeling when the result of some long-awaited\n event is finally known. The feelings and thoughts you have at that moment are\n definitely worth noting down and comparing.\n Your task is to determine if a person correctly guessed the results of a number of matches.\n You are given two arrays of scores and guesses of equal length, where each index shows a match. \n Return an array of the same length denoting how far off each guess was. If they have guessed correctly,\n the value is 0, and if not, the value is the absolute difference between the guess and the score.\n \n \n example:\n\n >>> compare([1, 2, 3, 4, 5, 1], [1, 2, 3, 4, 2, -2])\n [0, 0, 0, 0, 3, 3]\n >>> compare([0, 5, 0, 0, 0, 4], [4, 1, 1, 0, 0, -2])\n [4, 4, 1, 0, 0, 6]\n \"\"\"\n # Your code here\n return [abs(x - y) for x, y in zip(game, guess)]\n", "from typing import List\n\ndef compare(game: List[int], guess: List[int]) -> List[int]:\n \"\"\"I think we all remember that feeling when the result of some long-awaited\n event is finally known. The feelings and thoughts you have at that moment are\n definitely worth noting down and comparing.\n Your task is to determine if a person correctly guessed the results of a number of matches.\n You are given two arrays of scores and guesses of equal length, where each index shows a match. \n Return an array of the same length denoting how far off each guess was. If they have guessed correctly,\n the value is 0, and if not, the value is the absolute difference between the guess and the score.\n \n \n example:\n\n >>> compare([1, 2, 3, 4, 5, 1], [1, 2, 3, 4, 2, -2])\n [0, 0, 0, 0, 3, 3]\n >>> compare([0, 5, 0, 0, 0, 4], [4, 1, 1, 0, 0, -2])\n [4, 4, 1, 0, 0, 6]\n \"\"\"\n # TODO: Write your code here.\n # Hint:\n # 1. Use a for loop to iterate through the guess array.\n # 2. Use a for loop to iterate through the game array.\n # 3. Use a while loop to iterate through the game array.\n # 4. Use a while loop to iterate through the guess array.\n # 5. Use a while loop to iterate through the game array.\n # 6. Use a while loop to iterate through the guess array.\n # 7. Use a while loop to iterate through the game array.\n # 8. Use a while loop to iterate through the guess array.\n # 9. Use a while loop to iterate through the game array.\n # 10. Use a while loop to iterate through the guess array.\n # 11. Use a while loop to iterate through the game array.\n # 12. Use a while loop to iterate through the guess array.\n # 13. Use a while loop to iterate through the game array.\n # 1", "from typing import List\n\ndef compare(game: List[int], guess: List[int]) -> List[int]:\n \"\"\"I think we all remember that feeling when the result of some long-awaited\n event is finally known. The feelings and thoughts you have at that moment are\n definitely worth noting down and comparing.\n Your task is to determine if a person correctly guessed the results of a number of matches.\n You are given two arrays of scores and guesses of equal length, where each index shows a match. \n Return an array of the same length denoting how far off each guess was. If they have guessed correctly,\n the value is 0, and if not, the value is the absolute difference between the guess and the score.\n \n \n example:\n\n >>> compare([1, 2, 3, 4, 5, 1], [1, 2, 3, 4, 2, -2])\n [0, 0, 0, 0, 3, 3]\n >>> compare([0, 5, 0, 0, 0, 4], [4, 1, 1, 0, 0, -2])\n [4, 4, 1, 0, 0, 6]\n \"\"\"\n if len(game) != len(guess):\n raise ValueError(\"The arrays must be of equal length\")\n if len(game) == 0:\n return []\n if len(game) == 1:\n return [0] * len(guess)\n if len(game) == 2:\n return [0] * len(guess) if game[0] > game[1] else [0] * len(guess) + [1] * len(guess)\n if len(game) == 3:\n return [0] * len(guess) if game[0] > game[1] > game[2] else [0] * len(guess) + [1] * len(guess) + [2] * len(guess)\n if len(game) == 4:\n return [0] * len(guess) if game[0] > game[1] > game[2] > game[3] else [0] * len(guess) + [1] * len(guess) + [2] *", "from typing import List\n\ndef compare(game: List[int], guess: List[int]) -> List[int]:\n \"\"\"I think we all remember that feeling when the result of some long-awaited\n event is finally known. The feelings and thoughts you have at that moment are\n definitely worth noting down and comparing.\n Your task is to determine if a person correctly guessed the results of a number of matches.\n You are given two arrays of scores and guesses of equal length, where each index shows a match. \n Return an array of the same length denoting how far off each guess was. If they have guessed correctly,\n the value is 0, and if not, the value is the absolute difference between the guess and the score.\n \n \n example:\n\n >>> compare([1, 2, 3, 4, 5, 1], [1, 2, 3, 4, 2, -2])\n [0, 0, 0, 0, 3, 3]\n >>> compare([0, 5, 0, 0, 0, 4], [4, 1, 1, 0, 0, -2])\n [4, 4, 1, 0, 0, 6]\n \"\"\"\n # Your code here\n return [abs(score - guess[i]) for i, score in enumerate(game)]\n"], ["def starts_one_ends(n: int) -> int:\n \"\"\"\n Given a positive integer n, return the count of the numbers of n-digit\n positive integers that start or end with 1.\n \"\"\"\n return sum(1 for i in range(1, n + 1) if str(i).startswith('1') or str(i).endswith('1'))\n\n", "def starts_one_ends(n: int) -> int:\n \"\"\"\n Given a positive integer n, return the count of the numbers of n-digit\n positive integers that start or end with 1.\n \"\"\"\n return sum(1 for i in range(1, n + 1) if str(i).startswith('1') or str(i).endswith('1'))\n\n", "def starts_one_ends(n: int) -> int:\n \"\"\"\n Given a positive integer n, return the count of the numbers of n-digit\n positive integers that start or end with 1.\n \"\"\"\n return sum(1 for i in range(1, n + 1) if is_one(i))\n\n", "def starts_one_ends(n: int) -> int:\n \"\"\"\n Given a positive integer n, return the count of the numbers of n-digit\n positive integers that start or end with 1.\n \"\"\"\n return sum(1 for i in range(1, n + 1) if str(i).startswith('1') or str(i).endswith('1'))\n\n", "def starts_one_ends(n: int) -> int:\n \"\"\"\n Given a positive integer n, return the count of the numbers of n-digit\n positive integers that start or end with 1.\n \"\"\"\n return sum(1 for i in range(1, n + 1) if str(i).startswith('1') or str(i).endswith('1'))\n\n"], ["def check_if_last_char_is_a_letter(txt: str) -> bool:\n \"\"\"\n Create a function that returns True if the last character\n of a given string is an alphabetical character and is not\n a part of a word, and False otherwise.\n Note: \"word\" is a group of characters separated by space.\n\n Examples:\n >>> check_if_last_char_is_a_letter('apple pie')\n False\n >>> check_if_last_char_is_a_letter('apple pi e')\n True\n >>> check_if_last_char_is_a_letter('apple pi e ')\n False\n >>> check_if_last_char_is_a_letter('')\n False\n \"\"\"\n if len(txt) == 0:\n return False\n if txt[-1].isalpha():\n return True\n return False\n\n", "def check_if_last_char_is_a_letter(txt: str) -> bool:\n \"\"\"\n Create a function that returns True if the last character\n of a given string is an alphabetical character and is not\n a part of a word, and False otherwise.\n Note: \"word\" is a group of characters separated by space.\n\n Examples:\n >>> check_if_last_char_is_a_letter('apple pie')\n False\n >>> check_if_last_char_is_a_letter('apple pi e')\n True\n >>> check_if_last_char_is_a_letter('apple pi e ')\n False\n >>> check_if_last_char_is_a_letter('')\n False\n \"\"\"\n return txt[-1].isalpha() and txt[-1] not in string.punctuation\n\n", "def check_if_last_char_is_a_letter(txt: str) -> bool:\n \"\"\"\n Create a function that returns True if the last character\n of a given string is an alphabetical character and is not\n a part of a word, and False otherwise.\n Note: \"word\" is a group of characters separated by space.\n\n Examples:\n >>> check_if_last_char_is_a_letter('apple pie')\n False\n >>> check_if_last_char_is_a_letter('apple pi e')\n True\n >>> check_if_last_char_is_a_letter('apple pi e ')\n False\n >>> check_if_last_char_is_a_letter('')\n False\n \"\"\"\n return txt[-1].isalpha() and txt[-1] not in (' ', '.', ',', ';')\n\n", "def check_if_last_char_is_a_letter(txt: str) -> bool:\n \"\"\"\n Create a function that returns True if the last character\n of a given string is an alphabetical character and is not\n a part of a word, and False otherwise.\n Note: \"word\" is a group of characters separated by space.\n\n Examples:\n >>> check_if_last_char_is_a_letter('apple pie')\n False\n >>> check_if_last_char_is_a_letter('apple pi e')\n True\n >>> check_if_last_char_is_a_letter('apple pi e ')\n False\n >>> check_if_last_char_is_a_letter('')\n False\n \"\"\"\n if len(txt) == 0:\n return False\n elif txt[-1].isalpha() and txt[-1] not in \" .,;:?!\":\n return True\n else:\n return False\n\n", "def check_if_last_char_is_a_letter(txt: str) -> bool:\n \"\"\"\n Create a function that returns True if the last character\n of a given string is an alphabetical character and is not\n a part of a word, and False otherwise.\n Note: \"word\" is a group of characters separated by space.\n\n Examples:\n >>> check_if_last_char_is_a_letter('apple pie')\n False\n >>> check_if_last_char_is_a_letter('apple pi e')\n True\n >>> check_if_last_char_is_a_letter('apple pi e ')\n False\n >>> check_if_last_char_is_a_letter('')\n False\n \"\"\"\n if len(txt) == 0:\n return False\n elif txt[-1].isalpha():\n return True\n else:\n return False\n\n"], ["def valid_date(date: str) -> bool:\n \"\"\"You have to write a function which validates a given date string and\n returns True if the date is valid otherwise False.\n The date is valid if all of the following rules are satisfied:\n 1. The date string is not empty.\n 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n 3. The months should not be less than 1 or higher than 12.\n 4. The date should be in the format: mm-dd-yyyy\n\n >>> valid_date('03-11-2000')\n True\n\n >>> valid_date('15-01-2012')\n False\n\n >>> valid_date('04-0-2040')\n False\n\n >>> valid_date('06-04-2020')\n True\n\n >>> valid_date('06/04/2020')\n False\n \"\"\"\n if not date:\n return False\n if len(date) < 1:\n return False\n if len(date) > 30:\n return False\n if not re.match(r'^\\d{1,2}-\\d{1,2}-\\d{4}$', date):\n return False\n if len(date.split('-')) != 3:\n return False\n if int(date.split('-')[0]) < 1 or int(date.split('-')[0]) > 12:\n return False\n if int(date.split('-')[1]) < 1 or int(date.split('-')[1]) > 31:\n return False\n if int(date.split('-')[2]) < 1 or int(date.split('-')[2]) > 30:\n return False\n if int(date.split('-')[0]) == 2 and int(date.split('-')[1]) == 29:\n return False\n if int(date.split('-')[0]) == 4 and int(date.split('-')[1", "def valid_date(date: str) -> bool:\n \"\"\"You have to write a function which validates a given date string and\n returns True if the date is valid otherwise False.\n The date is valid if all of the following rules are satisfied:\n 1. The date string is not empty.\n 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n 3. The months should not be less than 1 or higher than 12.\n 4. The date should be in the format: mm-dd-yyyy\n\n >>> valid_date('03-11-2000')\n True\n\n >>> valid_date('15-01-2012')\n False\n\n >>> valid_date('04-0-2040')\n False\n\n >>> valid_date('06-04-2020')\n True\n\n >>> valid_date('06/04/2020')\n False\n \"\"\"\n if not date:\n return False\n if len(date) < 1:\n return False\n if len(date) > 10:\n return False\n if not re.match(r'^\\d{2}-\\d{2}-\\d{4}$', date):\n return False\n if len(date) == 10:\n if not re.match(r'^\\d{2}/\\d{2}/\\d{4}$', date):\n return False\n if len(date) == 10 and date[0] not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:\n return False\n if len(date) == 10 and date[3] not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:\n return False\n if len(date) == 10 and date[6] not in ['0',", "def valid_date(date: str) -> bool:\n \"\"\"You have to write a function which validates a given date string and\n returns True if the date is valid otherwise False.\n The date is valid if all of the following rules are satisfied:\n 1. The date string is not empty.\n 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n 3. The months should not be less than 1 or higher than 12.\n 4. The date should be in the format: mm-dd-yyyy\n\n >>> valid_date('03-11-2000')\n True\n\n >>> valid_date('15-01-2012')\n False\n\n >>> valid_date('04-0-2040')\n False\n\n >>> valid_date('06-04-2020')\n True\n\n >>> valid_date('06/04/2020')\n False\n \"\"\"\n if not date:\n return False\n\n if len(date) < 1:\n return False\n\n if len(date) > 10:\n return False\n\n if not re.match(r'^\\d{2}-\\d{2}-\\d{4}$', date):\n return False\n\n if len(date.split('-')) != 3:\n return False\n\n if int(date.split('-')[0]) not in range(1, 13):\n return False\n\n if int(date.split('-')[1]) not in range(1, 32):\n return False\n\n if int(date.split('-')[2]) not in range(1, 32):\n return False\n\n if int(date.split('-')[0]) in range(4, 12):\n if int(date.split('-')[1]) in range(6, 12):\n if int(date.split('-')[2]) in range(1, 29):\n return True\n\n return False\n\n", "def valid_date(date: str) -> bool:\n \"\"\"You have to write a function which validates a given date string and\n returns True if the date is valid otherwise False.\n The date is valid if all of the following rules are satisfied:\n 1. The date string is not empty.\n 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n 3. The months should not be less than 1 or higher than 12.\n 4. The date should be in the format: mm-dd-yyyy\n\n >>> valid_date('03-11-2000')\n True\n\n >>> valid_date('15-01-2012')\n False\n\n >>> valid_date('04-0-2040')\n False\n\n >>> valid_date('06-04-2020')\n True\n\n >>> valid_date('06/04/2020')\n False\n \"\"\"\n if not date:\n return False\n date = date.split('-')\n if len(date) != 3:\n return False\n if not date[0].isdigit() or not date[1].isdigit() or not date[2].isdigit():\n return False\n if int(date[0]) > 12 or int(date[0]) < 1:\n return False\n if int(date[1]) > 31 or int(date[1]) < 1:\n return False\n if int(date[2]) > 30 or int(date[2]) < 1:\n return False\n if int(date[0]) == 2 and int(date[1]) == 29 and int(date[2]) == 29:\n return False\n return True\n\n", "def valid_date(date: str) -> bool:\n \"\"\"You have to write a function which validates a given date string and\n returns True if the date is valid otherwise False.\n The date is valid if all of the following rules are satisfied:\n 1. The date string is not empty.\n 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n 3. The months should not be less than 1 or higher than 12.\n 4. The date should be in the format: mm-dd-yyyy\n\n >>> valid_date('03-11-2000')\n True\n\n >>> valid_date('15-01-2012')\n False\n\n >>> valid_date('04-0-2040')\n False\n\n >>> valid_date('06-04-2020')\n True\n\n >>> valid_date('06/04/2020')\n False\n \"\"\"\n if not date:\n return False\n date_list = date.split('-')\n if len(date_list) != 3:\n return False\n try:\n int(date_list[0])\n int(date_list[1])\n int(date_list[2])\n except ValueError:\n return False\n if date_list[0] < 1 or date_list[0] > 12:\n return False\n if date_list[1] < 1 or date_list[1] > 31:\n return False\n if date_list[2] < 1 or date_list[2] > 30:\n return False\n if date_list[0] == 2 and date_list[1] == 29:\n return False\n if date_list[0] == 4 and date_list[1] == 6:\n return False\n if date_list[0] == 6 and date_list[1] == 9:\n return False\n if date"], ["from typing import List\n\ndef count_nums(arr: List[int]) -> int:\n \"\"\"\n Write a function count_nums which takes an array of integers and returns\n the number of elements which has a sum of digits > 0.\n If a number is negative, then its first signed digit will be negative:\n e.g. -123 has signed digits -1, 2, and 3.\n >>> count_nums([])\n 0\n >>> count_nums([-1, 11, -11])\n 1\n >>> count_nums([1, 1, 2])\n 3\n \"\"\"\n return sum(1 for x in arr if x > 0)\n", "from typing import List\n\ndef count_nums(arr: List[int]) -> int:\n \"\"\"\n Write a function count_nums which takes an array of integers and returns\n the number of elements which has a sum of digits > 0.\n If a number is negative, then its first signed digit will be negative:\n e.g. -123 has signed digits -1, 2, and 3.\n >>> count_nums([])\n 0\n >>> count_nums([-1, 11, -11])\n 1\n >>> count_nums([1, 1, 2])\n 3\n \"\"\"\n return sum(1 for i in arr if i > 0)\n", "from typing import List\n\ndef count_nums(arr: List[int]) -> int:\n \"\"\"\n Write a function count_nums which takes an array of integers and returns\n the number of elements which has a sum of digits > 0.\n If a number is negative, then its first signed digit will be negative:\n e.g. -123 has signed digits -1, 2, and 3.\n >>> count_nums([])\n 0\n >>> count_nums([-1, 11, -11])\n 1\n >>> count_nums([1, 1, 2])\n 3\n \"\"\"\n count = 0\n for i in arr:\n if i > 0:\n count += 1\n return count\n", "from typing import List\n\ndef count_nums(arr: List[int]) -> int:\n \"\"\"\n Write a function count_nums which takes an array of integers and returns\n the number of elements which has a sum of digits > 0.\n If a number is negative, then its first signed digit will be negative:\n e.g. -123 has signed digits -1, 2, and 3.\n >>> count_nums([])\n 0\n >>> count_nums([-1, 11, -11])\n 1\n >>> count_nums([1, 1, 2])\n 3\n \"\"\"\n return sum(1 for n in arr if n > 0)\n", "from typing import List\n\ndef count_nums(arr: List[int]) -> int:\n \"\"\"\n Write a function count_nums which takes an array of integers and returns\n the number of elements which has a sum of digits > 0.\n If a number is negative, then its first signed digit will be negative:\n e.g. -123 has signed digits -1, 2, and 3.\n >>> count_nums([])\n 0\n >>> count_nums([-1, 11, -11])\n 1\n >>> count_nums([1, 1, 2])\n 3\n \"\"\"\n return sum(1 for x in arr if x > 0)\n"], ["def anti_shuffle(s: str) -> str:\n \"\"\"\n Write a function that takes a string and returns an ordered version of it.\n Ordered version of string, is a string where all words (separated by space)\n are replaced by a new word where all the characters arranged in\n ascending order based on ascii value.\n Note: You should keep the order of words and blank spaces in the sentence.\n\n For example:\n >>> anti_shuffle('Hi')\n 'Hi'\n >>> anti_shuffle('hello')\n 'ehllo'\n >>> anti_shuffle('Hello World!!!')\n 'Hello !!!Wdlor'\n \"\"\"\n return ' '.join(sorted(s.split(' ')))\n\n", "def anti_shuffle(s: str) -> str:\n \"\"\"\n Write a function that takes a string and returns an ordered version of it.\n Ordered version of string, is a string where all words (separated by space)\n are replaced by a new word where all the characters arranged in\n ascending order based on ascii value.\n Note: You should keep the order of words and blank spaces in the sentence.\n\n For example:\n >>> anti_shuffle('Hi')\n 'Hi'\n >>> anti_shuffle('hello')\n 'ehllo'\n >>> anti_shuffle('Hello World!!!')\n 'Hello !!!Wdlor'\n \"\"\"\n return ' '.join(sorted(s.split()))\n\n", "def anti_shuffle(s: str) -> str:\n \"\"\"\n Write a function that takes a string and returns an ordered version of it.\n Ordered version of string, is a string where all words (separated by space)\n are replaced by a new word where all the characters arranged in\n ascending order based on ascii value.\n Note: You should keep the order of words and blank spaces in the sentence.\n\n For example:\n >>> anti_shuffle('Hi')\n 'Hi'\n >>> anti_shuffle('hello')\n 'ehllo'\n >>> anti_shuffle('Hello World!!!')\n 'Hello !!!Wdlor'\n \"\"\"\n return ' '.join(sorted(s.split()))\n\n", "def anti_shuffle(s: str) -> str:\n \"\"\"\n Write a function that takes a string and returns an ordered version of it.\n Ordered version of string, is a string where all words (separated by space)\n are replaced by a new word where all the characters arranged in\n ascending order based on ascii value.\n Note: You should keep the order of words and blank spaces in the sentence.\n\n For example:\n >>> anti_shuffle('Hi')\n 'Hi'\n >>> anti_shuffle('hello')\n 'ehllo'\n >>> anti_shuffle('Hello World!!!')\n 'Hello !!!Wdlor'\n \"\"\"\n return ' '.join(sorted(s.split()))\n\n", "def anti_shuffle(s: str) -> str:\n \"\"\"\n Write a function that takes a string and returns an ordered version of it.\n Ordered version of string, is a string where all words (separated by space)\n are replaced by a new word where all the characters arranged in\n ascending order based on ascii value.\n Note: You should keep the order of words and blank spaces in the sentence.\n\n For example:\n >>> anti_shuffle('Hi')\n 'Hi'\n >>> anti_shuffle('hello')\n 'ehllo'\n >>> anti_shuffle('Hello World!!!')\n 'Hello !!!Wdlor'\n \"\"\"\n return \" \".join(sorted(s.split()))\n\n"], ["def is_palindrome(text: str) -> bool:\n \"\"\"\n Checks if given string is a palindrome\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\n \"\"\"\n return text == text[::-1]\n\n", "def is_palindrome(text: str) -> bool:\n \"\"\"\n Checks if given string is a palindrome\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\n \"\"\"\n return text == text[::-1]\n\n", "def is_palindrome(text: str) -> bool:\n \"\"\"\n Checks if given string is a palindrome\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\n \"\"\"\n return text == text[::-1]\n\n", "def is_palindrome(text: str) -> bool:\n \"\"\"\n Checks if given string is a palindrome\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\n \"\"\"\n return text == text[::-1]\n\n", "def is_palindrome(text: str) -> bool:\n \"\"\"\n Checks if given string is a palindrome\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\n \"\"\"\n return text == text[::-1]\n\n"], ["def get_closest_vowel(word: str) -> str:\n \"\"\"You are given a word. Your task is to find the closest vowel that stands between \n two consonants from the right side of the word (case sensitive).\n \n Vowels in the beginning and ending doesn't count. Return empty string if you didn't\n find any vowel met the above condition. \n\n You may assume that the given string contains English letter only.\n\n Example:\n >>> get_closest_vowel('yogurt')\n 'u'\n >>> get_closest_vowel('FULL')\n 'U'\n >>> get_closest_vowel('quick')\n ''\n >>> get_closest_vowel('ab')\n ''\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u']\n if word[0] in vowels and word[-1] in vowels:\n return word[0]\n elif word[0] in vowels:\n return word[0]\n elif word[-1] in vowels:\n return word[-1]\n else:\n return ''\n\n", "def get_closest_vowel(word: str) -> str:\n \"\"\"You are given a word. Your task is to find the closest vowel that stands between \n two consonants from the right side of the word (case sensitive).\n \n Vowels in the beginning and ending doesn't count. Return empty string if you didn't\n find any vowel met the above condition. \n\n You may assume that the given string contains English letter only.\n\n Example:\n >>> get_closest_vowel('yogurt')\n 'u'\n >>> get_closest_vowel('FULL')\n 'U'\n >>> get_closest_vowel('quick')\n ''\n >>> get_closest_vowel('ab')\n ''\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u']\n for i in range(len(word)):\n if word[i] in vowels:\n return word[i]\n return ''\n\n", "def get_closest_vowel(word: str) -> str:\n \"\"\"You are given a word. Your task is to find the closest vowel that stands between \n two consonants from the right side of the word (case sensitive).\n \n Vowels in the beginning and ending doesn't count. Return empty string if you didn't\n find any vowel met the above condition. \n\n You may assume that the given string contains English letter only.\n\n Example:\n >>> get_closest_vowel('yogurt')\n 'u'\n >>> get_closest_vowel('FULL')\n 'U'\n >>> get_closest_vowel('quick')\n ''\n >>> get_closest_vowel('ab')\n ''\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u']\n if word[0] in vowels and word[-1] in vowels:\n return word[0]\n elif word[0] in vowels:\n return word[0]\n elif word[-1] in vowels:\n return word[-1]\n else:\n return ''\n\n", "def get_closest_vowel(word: str) -> str:\n \"\"\"You are given a word. Your task is to find the closest vowel that stands between \n two consonants from the right side of the word (case sensitive).\n \n Vowels in the beginning and ending doesn't count. Return empty string if you didn't\n find any vowel met the above condition. \n\n You may assume that the given string contains English letter only.\n\n Example:\n >>> get_closest_vowel('yogurt')\n 'u'\n >>> get_closest_vowel('FULL')\n 'U'\n >>> get_closest_vowel('quick')\n ''\n >>> get_closest_vowel('ab')\n ''\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u']\n for i in range(len(word)):\n if word[i] in vowels:\n return word[i]\n return ''\n\n", "def get_closest_vowel(word: str) -> str:\n \"\"\"You are given a word. Your task is to find the closest vowel that stands between \n two consonants from the right side of the word (case sensitive).\n \n Vowels in the beginning and ending doesn't count. Return empty string if you didn't\n find any vowel met the above condition. \n\n You may assume that the given string contains English letter only.\n\n Example:\n >>> get_closest_vowel('yogurt')\n 'u'\n >>> get_closest_vowel('FULL')\n 'U'\n >>> get_closest_vowel('quick')\n ''\n >>> get_closest_vowel('ab')\n ''\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n for i in range(len(word)):\n if word[i] in vowels:\n return word[i]\n return ''\n\n"], ["def is_prime(n: int) -> bool:\n \"\"\"Return true if a given number is prime, and false otherwise.\n >>> is_prime(6)\n False\n >>> is_prime(101)\n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n ** 0.5) + 1, 2):\n if n % i == 0:\n return False\n return True\n\n", "def is_prime(n: int) -> bool:\n \"\"\"Return true if a given number is prime, and false otherwise.\n >>> is_prime(6)\n False\n >>> is_prime(101)\n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False\n \"\"\"\n if n < 2:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n if n % 5 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0:\n return False\n i += 6\n return True\n\n", "def is_prime(n: int) -> bool:\n \"\"\"Return true if a given number is prime, and false otherwise.\n >>> is_prime(6)\n False\n >>> is_prime(101)\n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n ** 0.5) + 1, 2):\n if n % i == 0:\n return False\n return True\n\n", "def is_prime(n: int) -> bool:\n \"\"\"Return true if a given number is prime, and false otherwise.\n >>> is_prime(6)\n False\n >>> is_prime(101)\n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False\n \"\"\"\n if n < 2:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n ** 0.5) + 1, 2):\n if n % i == 0:\n return False\n return True\n\n", "def is_prime(n: int) -> bool:\n \"\"\"Return true if a given number is prime, and false otherwise.\n >>> is_prime(6)\n False\n >>> is_prime(101)\n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n ** 0.5) + 1, 2):\n if n % i == 0:\n return False\n return True\n\n"], ["def simplify(x: str, n: str) -> bool:\n \"\"\"Your task is to implement a function that will simplify the expression\n x * n. The function returns True if x * n evaluates to a whole number and False\n otherwise. Both x and n, are string representation of a fraction, and have the following format,\n <numerator>/<denominator> where both numerator and denominator are positive whole numbers.\n\n You can assume that x, and n are valid fractions, and do not have zero as denominator.\n\n >>> simplify('1/5', '5/1')\n True\n >>> simplify('1/6', '2/1')\n False\n >>> simplify('7/10', '10/2')\n False\n \"\"\"\n x = x.replace('/', '')\n n = n.replace('/', '')\n if x == '0' or n == '0':\n return True\n if x == '1' or n == '1':\n return True\n if x == '1/2' or n == '1/2':\n return True\n if x == '1/3' or n == '1/3':\n return True\n if x == '1/4' or n == '1/4':\n return True\n if x == '1/5' or n == '1/5':\n return True\n if x == '1/6' or n == '1/6':\n return True\n if x == '1/7' or n == '1/7':\n return True\n if x == '1/8' or n == '1/8':\n return True\n if x == '1/9' or n == '1/9':\n return True\n if x == '1/10' or n == '1/10':\n return True\n if x == '1/11' or n == '1/11':\n return True\n if x == '1/12' or n == '1/12':\n return True\n if x == '1/13' or n == '1/13':\n return True\n if x == '1/14' or n == '1/14':\n return True\n if x == '1/15' or n == '1/15':\n return True\n if x == '1/16' or n == '1/1", "def simplify(x: str, n: str) -> bool:\n \"\"\"Your task is to implement a function that will simplify the expression\n x * n. The function returns True if x * n evaluates to a whole number and False\n otherwise. Both x and n, are string representation of a fraction, and have the following format,\n <numerator>/<denominator> where both numerator and denominator are positive whole numbers.\n\n You can assume that x, and n are valid fractions, and do not have zero as denominator.\n\n >>> simplify('1/5', '5/1')\n True\n >>> simplify('1/6', '2/1')\n False\n >>> simplify('7/10', '10/2')\n False\n \"\"\"\n x = Fraction(x)\n n = Fraction(n)\n if x.denominator == 1:\n return x.numerator == n.numerator\n else:\n return x.numerator * n.denominator == n.numerator * x.denominator\n\n", "def simplify(x: str, n: str) -> bool:\n \"\"\"Your task is to implement a function that will simplify the expression\n x * n. The function returns True if x * n evaluates to a whole number and False\n otherwise. Both x and n, are string representation of a fraction, and have the following format,\n <numerator>/<denominator> where both numerator and denominator are positive whole numbers.\n\n You can assume that x, and n are valid fractions, and do not have zero as denominator.\n\n >>> simplify('1/5', '5/1')\n True\n >>> simplify('1/6', '2/1')\n False\n >>> simplify('7/10', '10/2')\n False\n \"\"\"\n if x == '0':\n return True\n if x == '1':\n return False\n if x.startswith('-'):\n x = x[1:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x.startswith('1/'):\n x = x[2:]\n if x", "def simplify(x: str, n: str) -> bool:\n \"\"\"Your task is to implement a function that will simplify the expression\n x * n. The function returns True if x * n evaluates to a whole number and False\n otherwise. Both x and n, are string representation of a fraction, and have the following format,\n <numerator>/<denominator> where both numerator and denominator are positive whole numbers.\n\n You can assume that x, and n are valid fractions, and do not have zero as denominator.\n\n >>> simplify('1/5', '5/1')\n True\n >>> simplify('1/6', '2/1')\n False\n >>> simplify('7/10', '10/2')\n False\n \"\"\"\n if x == '0':\n return True\n if x == '1':\n return False\n if x == '1/1':\n return True\n if x == '1/2':\n return False\n if x == '1/3':\n return False\n if x == '1/4':\n return False\n if x == '1/5':\n return False\n if x == '1/6':\n return False\n if x == '1/7':\n return False\n if x == '1/8':\n return False\n if x == '1/9':\n return False\n if x == '1/10':\n return False\n if x == '1/11':\n return False\n if x == '1/12':\n return False\n if x == '1/13':\n return False\n if x == '1/14':\n return False\n if x == '1/15':\n return False\n if x == '1/16':\n return False\n if x == '1/17':\n return False\n if x == '1/18':\n return False\n if x == '1/19':\n return False\n if x == '1/20':\n return False\n if x == '1/21':\n return False\n if x == '1/22':\n return False\n if x == '1/23':\n return False\n if x == '1/24':\n return False\n if x == '1/25':\n return False\n if x == '1/26':\n return False\n if x == '1/2", "def simplify(x: str, n: str) -> bool:\n \"\"\"Your task is to implement a function that will simplify the expression\n x * n. The function returns True if x * n evaluates to a whole number and False\n otherwise. Both x and n, are string representation of a fraction, and have the following format,\n <numerator>/<denominator> where both numerator and denominator are positive whole numbers.\n\n You can assume that x, and n are valid fractions, and do not have zero as denominator.\n\n >>> simplify('1/5', '5/1')\n True\n >>> simplify('1/6', '2/1')\n False\n >>> simplify('7/10', '10/2')\n False\n \"\"\"\n if x == '0':\n return True\n if n == '0':\n return False\n if x == '1':\n return True\n if n == '1':\n return False\n if x == '0/1':\n return True\n if n == '0/1':\n return False\n if x == '1/1':\n return True\n if n == '1/1':\n return False\n if x == '0/2':\n return True\n if n == '0/2':\n return False\n if x == '1/2':\n return True\n if n == '1/2':\n return False\n if x == '0/3':\n return True\n if n == '0/3':\n return False\n if x == '1/3':\n return True\n if n == '1/3':\n return False\n if x == '0/4':\n return True\n if n == '0/4':\n return False\n if x == '1/4':\n return True\n if n == '1/4':\n return False\n if x == '0/5':\n return True\n if n == '0/5':\n return False\n if x == '1/5':\n return True\n if n == '1/5':\n return False\n if x == '0/6':\n return True\n if n == '0/6':\n return False\n if x == '1/6':\n return True\n if n == '1/6':\n return False\n if x == '0/7':\n return True\n if n == '0/7':\n return False\n if x == '"], ["def hex_key(num: str) -> int:\n \"\"\"You have been tasked to write a function that receives \n a hexadecimal number as a string and counts the number of hexadecimal \n digits that are primes (prime number, or a prime, is a natural number \n greater than 1 that is not a product of two smaller natural numbers).\n Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.\n Prime numbers are 2, 3, 5, 7, 11, 13, 17,...\n So you have to determine a number of the following digits: 2, 3, 5, 7, \n B (=decimal 11), D (=decimal 13).\n Note: you may assume the input is always correct or empty string, \n and symbols A,B,C,D,E,F are always uppercase.\n Examples:\n >>> hex_key('AB')\n 1\n >>> hex_key('1077E')\n 2\n >>> hex_key('ABED1A33')\n 4\n >>> hex_key('123456789ABCDEF0')\n 6\n >>> hex_key('2020')\n 2\n \"\"\"\n return sum(int(i) for i in num)\n\n", "def hex_key(num: str) -> int:\n \"\"\"You have been tasked to write a function that receives \n a hexadecimal number as a string and counts the number of hexadecimal \n digits that are primes (prime number, or a prime, is a natural number \n greater than 1 that is not a product of two smaller natural numbers).\n Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.\n Prime numbers are 2, 3, 5, 7, 11, 13, 17,...\n So you have to determine a number of the following digits: 2, 3, 5, 7, \n B (=decimal 11), D (=decimal 13).\n Note: you may assume the input is always correct or empty string, \n and symbols A,B,C,D,E,F are always uppercase.\n Examples:\n >>> hex_key('AB')\n 1\n >>> hex_key('1077E')\n 2\n >>> hex_key('ABED1A33')\n 4\n >>> hex_key('123456789ABCDEF0')\n 6\n >>> hex_key('2020')\n 2\n \"\"\"\n # Your code here\n return int(num, 16)\n\n", "def hex_key(num: str) -> int:\n \"\"\"You have been tasked to write a function that receives \n a hexadecimal number as a string and counts the number of hexadecimal \n digits that are primes (prime number, or a prime, is a natural number \n greater than 1 that is not a product of two smaller natural numbers).\n Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.\n Prime numbers are 2, 3, 5, 7, 11, 13, 17,...\n So you have to determine a number of the following digits: 2, 3, 5, 7, \n B (=decimal 11), D (=decimal 13).\n Note: you may assume the input is always correct or empty string, \n and symbols A,B,C,D,E,F are always uppercase.\n Examples:\n >>> hex_key('AB')\n 1\n >>> hex_key('1077E')\n 2\n >>> hex_key('ABED1A33')\n 4\n >>> hex_key('123456789ABCDEF0')\n 6\n >>> hex_key('2020')\n 2\n \"\"\"\n # Your code here\n return int(num, 16)\n\n", "def hex_key(num: str) -> int:\n \"\"\"You have been tasked to write a function that receives \n a hexadecimal number as a string and counts the number of hexadecimal \n digits that are primes (prime number, or a prime, is a natural number \n greater than 1 that is not a product of two smaller natural numbers).\n Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.\n Prime numbers are 2, 3, 5, 7, 11, 13, 17,...\n So you have to determine a number of the following digits: 2, 3, 5, 7, \n B (=decimal 11), D (=decimal 13).\n Note: you may assume the input is always correct or empty string, \n and symbols A,B,C,D,E,F are always uppercase.\n Examples:\n >>> hex_key('AB')\n 1\n >>> hex_key('1077E')\n 2\n >>> hex_key('ABED1A33')\n 4\n >>> hex_key('123456789ABCDEF0')\n 6\n >>> hex_key('2020')\n 2\n \"\"\"\n return sum(1 for i in range(1, int(num, 16) + 1) if is_prime(i))\n\n", "def hex_key(num: str) -> int:\n \"\"\"You have been tasked to write a function that receives \n a hexadecimal number as a string and counts the number of hexadecimal \n digits that are primes (prime number, or a prime, is a natural number \n greater than 1 that is not a product of two smaller natural numbers).\n Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.\n Prime numbers are 2, 3, 5, 7, 11, 13, 17,...\n So you have to determine a number of the following digits: 2, 3, 5, 7, \n B (=decimal 11), D (=decimal 13).\n Note: you may assume the input is always correct or empty string, \n and symbols A,B,C,D,E,F are always uppercase.\n Examples:\n >>> hex_key('AB')\n 1\n >>> hex_key('1077E')\n 2\n >>> hex_key('ABED1A33')\n 4\n >>> hex_key('123456789ABCDEF0')\n 6\n >>> hex_key('2020')\n 2\n \"\"\"\n if not num:\n return 0\n num = num.upper()\n if num[0] == '0':\n return 0\n if num[0] == '1':\n return 1\n if num[0] == '2':\n return 2\n if num[0] == '3':\n return 3\n if num[0] == '4':\n return 4\n if num[0] == '5':\n return 5\n if num[0] == '6':\n return 6\n if num[0] == '7':\n return 7\n if num[0] == '8':\n return 8\n if num[0] == '9':\n return 9\n if num[0] == 'A':\n return 10\n if num[0] == 'B':\n return 11\n if num[0] == 'C':\n return 12\n if num[0] == 'D':\n return 1"], ["def words_in_sentence(sentence: str) -> str:\n \"\"\"\n You are given a string representing a sentence,\n the sentence contains some words separated by a space,\n and you have to return a string that contains the words from the original sentence,\n whose lengths are prime numbers,\n the order of the words in the new string should be the same as the original one.\n\n Example 1:\n >>> words_in_sentence('This is a test')\n 'is'\n\n Example 2:\n >>> words_in_sentence('lets go for swimming')\n 'go for'\n \n Constraints:\n * 1 <= len(sentence) <= 100\n * sentence contains only letters\n \"\"\"\n return ' '.join(sorted(set(sentence.split())))\n\n", "def words_in_sentence(sentence: str) -> str:\n \"\"\"\n You are given a string representing a sentence,\n the sentence contains some words separated by a space,\n and you have to return a string that contains the words from the original sentence,\n whose lengths are prime numbers,\n the order of the words in the new string should be the same as the original one.\n\n Example 1:\n >>> words_in_sentence('This is a test')\n 'is'\n\n Example 2:\n >>> words_in_sentence('lets go for swimming')\n 'go for'\n \n Constraints:\n * 1 <= len(sentence) <= 100\n * sentence contains only letters\n \"\"\"\n return \" \".join(sorted(set(sentence.split())))\n\n", "def words_in_sentence(sentence: str) -> str:\n \"\"\"\n You are given a string representing a sentence,\n the sentence contains some words separated by a space,\n and you have to return a string that contains the words from the original sentence,\n whose lengths are prime numbers,\n the order of the words in the new string should be the same as the original one.\n\n Example 1:\n >>> words_in_sentence('This is a test')\n 'is'\n\n Example 2:\n >>> words_in_sentence('lets go for swimming')\n 'go for'\n \n Constraints:\n * 1 <= len(sentence) <= 100\n * sentence contains only letters\n \"\"\"\n words = sentence.split()\n return ' '.join(sorted(words))\n\n", "def words_in_sentence(sentence: str) -> str:\n \"\"\"\n You are given a string representing a sentence,\n the sentence contains some words separated by a space,\n and you have to return a string that contains the words from the original sentence,\n whose lengths are prime numbers,\n the order of the words in the new string should be the same as the original one.\n\n Example 1:\n >>> words_in_sentence('This is a test')\n 'is'\n\n Example 2:\n >>> words_in_sentence('lets go for swimming')\n 'go for'\n \n Constraints:\n * 1 <= len(sentence) <= 100\n * sentence contains only letters\n \"\"\"\n words = sentence.split()\n words_prime = []\n for word in words:\n if len(word) > 1:\n words_prime.append(word)\n return \" \".join(words_prime)\n\n", "def words_in_sentence(sentence: str) -> str:\n \"\"\"\n You are given a string representing a sentence,\n the sentence contains some words separated by a space,\n and you have to return a string that contains the words from the original sentence,\n whose lengths are prime numbers,\n the order of the words in the new string should be the same as the original one.\n\n Example 1:\n >>> words_in_sentence('This is a test')\n 'is'\n\n Example 2:\n >>> words_in_sentence('lets go for swimming')\n 'go for'\n \n Constraints:\n * 1 <= len(sentence) <= 100\n * sentence contains only letters\n \"\"\"\n return ' '.join(sorted(set(sentence.split())))\n\n"], ["from typing import Dict\n\ndef histogram(test: str) -> Dict[str, int]:\n \"\"\"Given a string representing a space separated lowercase letters, return a dictionary\n of the letter with the most repetition and containing the corresponding count.\n If several letters have the same occurrence, return all of them.\n \n Example:\n >>> histogram('a b c')\n { 'a': 1, 'b': 1, 'c': 1 }\n >>> histogram('a b b a')\n { 'a': 2, 'b': 2 }\n >>> histogram('a b c a b')\n { 'a': 2, 'b': 2 }\n >>> histogram('b b b b a')\n { 'b': 4 }\n >>> histogram('')\n { }\n\n \"\"\"\n histogram = {}\n for letter in test.lower():\n if letter in histogram:\n histogram[letter] += 1\n else:\n histogram[letter] = 1\n return histogram\n", "from typing import Dict\n\ndef histogram(test: str) -> Dict[str, int]:\n \"\"\"Given a string representing a space separated lowercase letters, return a dictionary\n of the letter with the most repetition and containing the corresponding count.\n If several letters have the same occurrence, return all of them.\n \n Example:\n >>> histogram('a b c')\n { 'a': 1, 'b': 1, 'c': 1 }\n >>> histogram('a b b a')\n { 'a': 2, 'b': 2 }\n >>> histogram('a b c a b')\n { 'a': 2, 'b': 2 }\n >>> histogram('b b b b a')\n { 'b': 4 }\n >>> histogram('')\n { }\n\n \"\"\"\n histogram = {}\n for letter in test.lower():\n if letter in histogram:\n histogram[letter] += 1\n else:\n histogram[letter] = 1\n return histogram\n", "from typing import Dict\n\ndef histogram(test: str) -> Dict[str, int]:\n \"\"\"Given a string representing a space separated lowercase letters, return a dictionary\n of the letter with the most repetition and containing the corresponding count.\n If several letters have the same occurrence, return all of them.\n \n Example:\n >>> histogram('a b c')\n { 'a': 1, 'b': 1, 'c': 1 }\n >>> histogram('a b b a')\n { 'a': 2, 'b': 2 }\n >>> histogram('a b c a b')\n { 'a': 2, 'b': 2 }\n >>> histogram('b b b b a')\n { 'b': 4 }\n >>> histogram('')\n { }\n\n \"\"\"\n if not test:\n return {}\n return Counter(test.lower())\n", "from typing import Dict\n\ndef histogram(test: str) -> Dict[str, int]:\n \"\"\"Given a string representing a space separated lowercase letters, return a dictionary\n of the letter with the most repetition and containing the corresponding count.\n If several letters have the same occurrence, return all of them.\n \n Example:\n >>> histogram('a b c')\n { 'a': 1, 'b': 1, 'c': 1 }\n >>> histogram('a b b a')\n { 'a': 2, 'b': 2 }\n >>> histogram('a b c a b')\n { 'a': 2, 'b': 2 }\n >>> histogram('b b b b a')\n { 'b': 4 }\n >>> histogram('')\n { }\n\n \"\"\"\n counts = {}\n for letter in test.lower():\n counts[letter] = counts.get(letter, 0) + 1\n return counts\n", "from typing import Dict\n\ndef histogram(test: str) -> Dict[str, int]:\n \"\"\"Given a string representing a space separated lowercase letters, return a dictionary\n of the letter with the most repetition and containing the corresponding count.\n If several letters have the same occurrence, return all of them.\n \n Example:\n >>> histogram('a b c')\n { 'a': 1, 'b': 1, 'c': 1 }\n >>> histogram('a b b a')\n { 'a': 2, 'b': 2 }\n >>> histogram('a b c a b')\n { 'a': 2, 'b': 2 }\n >>> histogram('b b b b a')\n { 'b': 4 }\n >>> histogram('')\n { }\n\n \"\"\"\n # Your code here\n counts = {}\n for letter in test.lower():\n if letter in counts:\n counts[letter] += 1\n else:\n counts[letter] = 1\n return counts\n"], ["from typing import List, Tuple\n\ndef get_row(lst: List[List[int]], x: int) -> List[Tuple[int, int]]:\n \"\"\"\n You are given a 2 dimensional data, as a nested lists,\n which is similar to matrix, however, unlike matrices,\n each row may contain a different number of columns.\n Given lst, and integer x, find integers x in the list,\n and return list of tuples, [(x1, y1), (x2, y2) ...] such that\n each tuple is a coordinate - (row, columns), starting with 0.\n Sort coordinates initially by rows in ascending order.\n Also, sort coordinates of the row by columns in descending order.\n \n Examples:\n >>> get_row([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1)\n [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n >>> get_row([], 1)\n []\n >>> get_row([[], [1], [1, 2, 3]], 3)\n [(2, 2)]\n \"\"\"\n lst.sort(key=lambda x: x[0])\n lst.sort(key=lambda x: x[1], reverse=True)\n return [(lst[i][0], lst[i][1]) for i in range(len(lst))]\n", "from typing import List, Tuple\n\ndef get_row(lst: List[List[int]], x: int) -> List[Tuple[int, int]]:\n \"\"\"\n You are given a 2 dimensional data, as a nested lists,\n which is similar to matrix, however, unlike matrices,\n each row may contain a different number of columns.\n Given lst, and integer x, find integers x in the list,\n and return list of tuples, [(x1, y1), (x2, y2) ...] such that\n each tuple is a coordinate - (row, columns), starting with 0.\n Sort coordinates initially by rows in ascending order.\n Also, sort coordinates of the row by columns in descending order.\n \n Examples:\n >>> get_row([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1)\n [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n >>> get_row([], 1)\n []\n >>> get_row([[], [1], [1, 2, 3]], 3)\n [(2, 2)]\n \"\"\"\n # sort coordinates by rows in ascending order\n lst.sort(key=lambda x: x[0])\n # sort coordinates of the row by columns in descending order\n lst.sort(key=lambda x: x[1], reverse=True)\n # find coordinates of x in the list\n return [(lst[i][0], lst[i][1]) for i in range(len(lst)) if lst[i][0] == x]\n", "from typing import List, Tuple\n\ndef get_row(lst: List[List[int]], x: int) -> List[Tuple[int, int]]:\n \"\"\"\n You are given a 2 dimensional data, as a nested lists,\n which is similar to matrix, however, unlike matrices,\n each row may contain a different number of columns.\n Given lst, and integer x, find integers x in the list,\n and return list of tuples, [(x1, y1), (x2, y2) ...] such that\n each tuple is a coordinate - (row, columns), starting with 0.\n Sort coordinates initially by rows in ascending order.\n Also, sort coordinates of the row by columns in descending order.\n \n Examples:\n >>> get_row([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1)\n [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n >>> get_row([], 1)\n []\n >>> get_row([[], [1], [1, 2, 3]], 3)\n [(2, 2)]\n \"\"\"\n # sort coordinates by rows\n lst.sort(key=lambda x: x[0])\n # sort coordinates of the row by columns\n lst.sort(key=lambda x: x[1], reverse=True)\n # return list of tuples\n return [(lst[i][0], lst[i][1]) for i in range(len(lst))]\n", "from typing import List, Tuple\n\ndef get_row(lst: List[List[int]], x: int) -> List[Tuple[int, int]]:\n \"\"\"\n You are given a 2 dimensional data, as a nested lists,\n which is similar to matrix, however, unlike matrices,\n each row may contain a different number of columns.\n Given lst, and integer x, find integers x in the list,\n and return list of tuples, [(x1, y1), (x2, y2) ...] such that\n each tuple is a coordinate - (row, columns), starting with 0.\n Sort coordinates initially by rows in ascending order.\n Also, sort coordinates of the row by columns in descending order.\n \n Examples:\n >>> get_row([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1)\n [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n >>> get_row([], 1)\n []\n >>> get_row([[], [1], [1, 2, 3]], 3)\n [(2, 2)]\n \"\"\"\n # Sort coordinates of the row by columns in descending order\n lst.sort(key=lambda x: (-x[1], x[0]))\n # Find coordinates of the row\n row = [x for x in lst if x[0] == x[1]]\n # Return coordinates of the row\n return row\n", "from typing import List, Tuple\n\ndef get_row(lst: List[List[int]], x: int) -> List[Tuple[int, int]]:\n \"\"\"\n You are given a 2 dimensional data, as a nested lists,\n which is similar to matrix, however, unlike matrices,\n each row may contain a different number of columns.\n Given lst, and integer x, find integers x in the list,\n and return list of tuples, [(x1, y1), (x2, y2) ...] such that\n each tuple is a coordinate - (row, columns), starting with 0.\n Sort coordinates initially by rows in ascending order.\n Also, sort coordinates of the row by columns in descending order.\n \n Examples:\n >>> get_row([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1)\n [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n >>> get_row([], 1)\n []\n >>> get_row([[], [1], [1, 2, 3]], 3)\n [(2, 2)]\n \"\"\"\n lst.sort(key=lambda x: x[0])\n lst.sort(key=lambda x: x[1], reverse=True)\n res = []\n for i in range(len(lst)):\n if lst[i][0] == x:\n res.append((lst[i][0], lst[i][1]))\n return res\n"], ["from typing import List\n\ndef get_odd_collatz(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.\n\n The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\n as follows: start with any positive integer n. Then each term is obtained from the \n previous term as follows: if the previous term is even, the next term is one half of \n the previous term. If the previous term is odd, the next term is 3 times the previous\n term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\n Note: \n 1. Collatz(1) is [1].\n 2. returned list sorted in increasing order.\n\n For example:\n get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.\n >>> get_odd_collatz(5)\n [1, 5]\n \"\"\"\n if n == 1:\n return [1]\n else:\n odd_list = []\n even_list = []\n while n > 1:\n if n % 2 == 0:\n even_list.append(n)\n n = n // 2\n else:\n odd_list.append(n)\n n = 3 * n + 1\n odd_list.append(1)\n even_list.append(1)\n return odd_list + even_list\n", "from typing import List\n\ndef get_odd_collatz(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.\n\n The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\n as follows: start with any positive integer n. Then each term is obtained from the \n previous term as follows: if the previous term is even, the next term is one half of \n the previous term. If the previous term is odd, the next term is 3 times the previous\n term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\n Note: \n 1. Collatz(1) is [1].\n 2. returned list sorted in increasing order.\n\n For example:\n get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.\n >>> get_odd_collatz(5)\n [1, 5]\n \"\"\"\n if n == 1:\n return [1]\n else:\n odd_list = []\n even_list = []\n for i in range(1, n):\n if i % 2 == 0:\n even_list.append(i)\n else:\n odd_list.append(i)\n odd_list.sort()\n even_list.sort()\n return odd_list + even_list\n", "from typing import List\n\ndef get_odd_collatz(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.\n\n The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\n as follows: start with any positive integer n. Then each term is obtained from the \n previous term as follows: if the previous term is even, the next term is one half of \n the previous term. If the previous term is odd, the next term is 3 times the previous\n term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\n Note: \n 1. Collatz(1) is [1].\n 2. returned list sorted in increasing order.\n\n For example:\n get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.\n >>> get_odd_collatz(5)\n [1, 5]\n \"\"\"\n if n == 1:\n return [1]\n elif n % 2 == 0:\n return [n // 2] + get_odd_collatz(n // 2)\n else:\n return [3 * n + 1] + get_odd_collatz(3 * n + 1)\n", "from typing import List\n\ndef get_odd_collatz(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.\n\n The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\n as follows: start with any positive integer n. Then each term is obtained from the \n previous term as follows: if the previous term is even, the next term is one half of \n the previous term. If the previous term is odd, the next term is 3 times the previous\n term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\n Note: \n 1. Collatz(1) is [1].\n 2. returned list sorted in increasing order.\n\n For example:\n get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.\n >>> get_odd_collatz(5)\n [1, 5]\n \"\"\"\n if n == 1:\n return [1]\n elif n % 2 == 0:\n return [n // 2, n * 3 + 1]\n else:\n return [n * 3 + 1, n // 2]\n", "from typing import List\n\ndef get_odd_collatz(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.\n\n The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\n as follows: start with any positive integer n. Then each term is obtained from the \n previous term as follows: if the previous term is even, the next term is one half of \n the previous term. If the previous term is odd, the next term is 3 times the previous\n term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\n Note: \n 1. Collatz(1) is [1].\n 2. returned list sorted in increasing order.\n\n For example:\n get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.\n >>> get_odd_collatz(5)\n [1, 5]\n \"\"\"\n if n == 1:\n return [1]\n elif n % 2 == 0:\n return [n // 2] + get_odd_collatz(n // 2)\n else:\n return [3 * n + 1] + get_odd_collatz(n // 2)\n"], ["from typing import List\n\ndef can_arrange(arr: List[int]) -> int:\n \"\"\"Create a function which returns the largest index of an element which\n is not greater than or equal to the element immediately preceding it. If\n no such element exists then return -1. The given array will not contain\n duplicate values.\n\n Examples:\n >>> can_arrange([1, 2, 4, 3, 5])\n 3\n >>> can_arrange([1, 2, 3])\n -1\n \"\"\"\n if len(arr) < 2:\n return -1\n else:\n for i in range(1, len(arr)):\n if arr[i] < arr[i-1]:\n return i\n return -1\n", "from typing import List\n\ndef can_arrange(arr: List[int]) -> int:\n \"\"\"Create a function which returns the largest index of an element which\n is not greater than or equal to the element immediately preceding it. If\n no such element exists then return -1. The given array will not contain\n duplicate values.\n\n Examples:\n >>> can_arrange([1, 2, 4, 3, 5])\n 3\n >>> can_arrange([1, 2, 3])\n -1\n \"\"\"\n if len(arr) < 2:\n return -1\n\n # Find the index of the first element which is not greater than the\n # element immediately preceding it.\n for i in range(1, len(arr)):\n if arr[i] > arr[i - 1]:\n return i\n\n return -1\n", "from typing import List\n\ndef can_arrange(arr: List[int]) -> int:\n \"\"\"Create a function which returns the largest index of an element which\n is not greater than or equal to the element immediately preceding it. If\n no such element exists then return -1. The given array will not contain\n duplicate values.\n\n Examples:\n >>> can_arrange([1, 2, 4, 3, 5])\n 3\n >>> can_arrange([1, 2, 3])\n -1\n \"\"\"\n if len(arr) == 1:\n return 0\n else:\n for i in range(1, len(arr)):\n if arr[i] > arr[i-1]:\n return i\n return -1\n", "from typing import List\n\ndef can_arrange(arr: List[int]) -> int:\n \"\"\"Create a function which returns the largest index of an element which\n is not greater than or equal to the element immediately preceding it. If\n no such element exists then return -1. The given array will not contain\n duplicate values.\n\n Examples:\n >>> can_arrange([1, 2, 4, 3, 5])\n 3\n >>> can_arrange([1, 2, 3])\n -1\n \"\"\"\n if len(arr) <= 1:\n return -1\n if arr[0] > arr[1]:\n return 0\n for i in range(1, len(arr)):\n if arr[i] > arr[i-1]:\n return i\n return -1\n", "from typing import List\n\ndef can_arrange(arr: List[int]) -> int:\n \"\"\"Create a function which returns the largest index of an element which\n is not greater than or equal to the element immediately preceding it. If\n no such element exists then return -1. The given array will not contain\n duplicate values.\n\n Examples:\n >>> can_arrange([1, 2, 4, 3, 5])\n 3\n >>> can_arrange([1, 2, 3])\n -1\n \"\"\"\n if len(arr) == 1:\n return 0\n if len(arr) == 2:\n return 1\n if len(arr) == 3:\n return 2\n if len(arr) == 4:\n return 3\n if len(arr) == 5:\n return 4\n if len(arr) == 6:\n return 5\n if len(arr) == 7:\n return 6\n if len(arr) == 8:\n return 7\n if len(arr) == 9:\n return 8\n if len(arr) == 10:\n return 9\n if len(arr) == 11:\n return 10\n if len(arr) == 12:\n return 11\n if len(arr) == 13:\n return 12\n if len(arr) == 14:\n return 13\n if len(arr) == 15:\n return 14\n if len(arr) == 16:\n return 15\n if len(arr) == 17:\n return 16\n if len(arr) == 18:\n return 17\n if len(arr) == 19:\n return 18\n if len(arr) == 20:\n return 19\n if len(arr) == 21:\n return 20\n if len(arr) == 22:\n return 21\n if len(arr) == 23:\n return 22\n if len(arr) == 24:\n return 23\n if len(arr) == 25:\n return 24\n if len(arr) == 26:\n return 25\n if"], ["def sort_numbers(numbers: str) -> str:\n \"\"\" Input is a space-delimited string of numberals from 'zero' to 'nine'.\n Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.\n Return the string with numbers sorted from smallest to largest\n >>> sort_numbers('three one five')\n 'one three five'\n \"\"\"\n numbers = numbers.split()\n numbers.sort()\n return ' '.join(numbers)\n\n", "def sort_numbers(numbers: str) -> str:\n \"\"\" Input is a space-delimited string of numberals from 'zero' to 'nine'.\n Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.\n Return the string with numbers sorted from smallest to largest\n >>> sort_numbers('three one five')\n 'one three five'\n \"\"\"\n numbers = numbers.split()\n numbers.sort()\n return ' '.join(numbers)\n\n", "def sort_numbers(numbers: str) -> str:\n \"\"\" Input is a space-delimited string of numberals from 'zero' to 'nine'.\n Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.\n Return the string with numbers sorted from smallest to largest\n >>> sort_numbers('three one five')\n 'one three five'\n \"\"\"\n return ' '.join(sorted(numbers.split()))\n\n", "def sort_numbers(numbers: str) -> str:\n \"\"\" Input is a space-delimited string of numberals from 'zero' to 'nine'.\n Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.\n Return the string with numbers sorted from smallest to largest\n >>> sort_numbers('three one five')\n 'one three five'\n \"\"\"\n return ' '.join(sorted(numbers.split()))\n\n", "def sort_numbers(numbers: str) -> str:\n \"\"\" Input is a space-delimited string of numberals from 'zero' to 'nine'.\n Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.\n Return the string with numbers sorted from smallest to largest\n >>> sort_numbers('three one five')\n 'one three five'\n \"\"\"\n numbers = numbers.split()\n numbers.sort()\n return ' '.join(numbers)\n\n"], ["def circular_shift(x: int, shift: int) -> str:\n \"\"\"Circular shift the digits of the integer x, shift the digits right by shift\n and return the result as a string.\n If shift > number of digits, return digits reversed.\n >>> circular_shift(12, 1)\n '21'\n >>> circular_shift(12, 2)\n '12'\n \"\"\"\n if shift > len(str(x)):\n return str(x)[::-1]\n return str(x)[:-shift] + str(x)[-shift:]\n\n", "def circular_shift(x: int, shift: int) -> str:\n \"\"\"Circular shift the digits of the integer x, shift the digits right by shift\n and return the result as a string.\n If shift > number of digits, return digits reversed.\n >>> circular_shift(12, 1)\n '21'\n >>> circular_shift(12, 2)\n '12'\n \"\"\"\n if shift > len(str(x)):\n return str(x)[::-1]\n return str(x) + str(x)[::-1][shift:]\n\n", "def circular_shift(x: int, shift: int) -> str:\n \"\"\"Circular shift the digits of the integer x, shift the digits right by shift\n and return the result as a string.\n If shift > number of digits, return digits reversed.\n >>> circular_shift(12, 1)\n '21'\n >>> circular_shift(12, 2)\n '12'\n \"\"\"\n if shift > len(str(x)):\n return str(x)[::-1]\n else:\n return str(x) + str(x)[-shift:]\n\n", "def circular_shift(x: int, shift: int) -> str:\n \"\"\"Circular shift the digits of the integer x, shift the digits right by shift\n and return the result as a string.\n If shift > number of digits, return digits reversed.\n >>> circular_shift(12, 1)\n '21'\n >>> circular_shift(12, 2)\n '12'\n \"\"\"\n if shift > len(str(x)):\n return str(x)[::-1]\n return str(x)[:-shift] + str(x)[-shift:]\n\n", "def circular_shift(x: int, shift: int) -> str:\n \"\"\"Circular shift the digits of the integer x, shift the digits right by shift\n and return the result as a string.\n If shift > number of digits, return digits reversed.\n >>> circular_shift(12, 1)\n '21'\n >>> circular_shift(12, 2)\n '12'\n \"\"\"\n if shift > len(str(x)):\n return str(x)[::-1]\n return str(x) + str(x)[-shift:]\n\n"], ["from typing import List\n\ndef sum_squares(lst: List[int]) -> int:\n \"\"\"\"\n This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a \n multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not \n change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. \n \n Examples:\n >>> lst\n [1, 2, 3]\n >>> lst\n []\n >>> lst\n [-1, -5, 2, -1, -5]\n \"\"\"\n # Your code here\n return sum([x**2 for x in lst if x%3==0 or x%4!=0])\n", "from typing import List\n\ndef sum_squares(lst: List[int]) -> int:\n \"\"\"\"\n This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a \n multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not \n change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. \n \n Examples:\n >>> lst\n [1, 2, 3]\n >>> lst\n []\n >>> lst\n [-1, -5, 2, -1, -5]\n \"\"\"\n # Your code here\n return sum([x**2 for x in lst if x % 3 == 0 or x % 4 == 0])\n", "from typing import List\n\ndef sum_squares(lst: List[int]) -> int:\n \"\"\"\"\n This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a \n multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not \n change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. \n \n Examples:\n >>> lst\n [1, 2, 3]\n >>> lst\n []\n >>> lst\n [-1, -5, 2, -1, -5]\n \"\"\"\n return sum([x**2 for x in lst if x%3==0 or x%4==0])\n", "from typing import List\n\ndef sum_squares(lst: List[int]) -> int:\n \"\"\"\"\n This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a \n multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not \n change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. \n \n Examples:\n >>> lst\n [1, 2, 3]\n >>> lst\n []\n >>> lst\n [-1, -5, 2, -1, -5]\n \"\"\"\n return sum([x**2 for x in lst if x % 3 == 0 or x % 4 != 0])\n", "from typing import List\n\ndef sum_squares(lst: List[int]) -> int:\n \"\"\"\"\n This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a \n multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not \n change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. \n \n Examples:\n >>> lst\n [1, 2, 3]\n >>> lst\n []\n >>> lst\n [-1, -5, 2, -1, -5]\n \"\"\"\n sum_of_squares = 0\n for i in lst:\n if i % 3 == 0:\n sum_of_squares += i ** 2\n elif i % 4 == 0:\n sum_of_squares += i ** 3\n return sum_of_squares\n"], ["from typing import List\n\ndef skjkasdkd(lst: List[int]) -> int:\n \"\"\"You are given a list of integers.\n You need to find the largest prime value and return the sum of its digits.\n\n Examples:\n >>> skjkasdkd([0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])\n 10\n >>> skjkasdkd([1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1])\n 25\n >>> skjkasdkd([1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3])\n 13\n >>> skjkasdkd([0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6])\n 11\n >>> skjkasdkd([0, 81, 12, 3, 1, 21])\n 3\n >>> skjkasdkd([0, 8, 1, 2, 1, 7])\n 7\n \"\"\"\n max_prime = 0\n for i in lst:\n if i > max_prime:\n max_prime = i\n return sum(map(int, str(max_prime)))\n", "from typing import List\n\ndef skjkasdkd(lst: List[int]) -> int:\n \"\"\"You are given a list of integers.\n You need to find the largest prime value and return the sum of its digits.\n\n Examples:\n >>> skjkasdkd([0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])\n 10\n >>> skjkasdkd([1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1])\n 25\n >>> skjkasdkd([1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3])\n 13\n >>> skjkasdkd([0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6])\n 11\n >>> skjkasdkd([0, 81, 12, 3, 1, 21])\n 3\n >>> skjkasdkd([0, 8, 1, 2, 1, 7])\n 7\n \"\"\"\n max_prime = 0\n for num in lst:\n if num > max_prime:\n max_prime = num\n return sum(str(max_prime))\n", "from typing import List\n\ndef skjkasdkd(lst: List[int]) -> int:\n \"\"\"You are given a list of integers.\n You need to find the largest prime value and return the sum of its digits.\n\n Examples:\n >>> skjkasdkd([0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])\n 10\n >>> skjkasdkd([1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1])\n 25\n >>> skjkasdkd([1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3])\n 13\n >>> skjkasdkd([0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6])\n 11\n >>> skjkasdkd([0, 81, 12, 3, 1, 21])\n 3\n >>> skjkasdkd([0, 8, 1, 2, 1, 7])\n 7\n \"\"\"\n return sum(map(lambda x: int(str(x)[::-1]), lst))\n", "from typing import List\n\ndef skjkasdkd(lst: List[int]) -> int:\n \"\"\"You are given a list of integers.\n You need to find the largest prime value and return the sum of its digits.\n\n Examples:\n >>> skjkasdkd([0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])\n 10\n >>> skjkasdkd([1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1])\n 25\n >>> skjkasdkd([1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3])\n 13\n >>> skjkasdkd([0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6])\n 11\n >>> skjkasdkd([0, 81, 12, 3, 1, 21])\n 3\n >>> skjkasdkd([0, 8, 1, 2, 1, 7])\n 7\n \"\"\"\n max_prime = 0\n for i in lst:\n if i > max_prime:\n max_prime = i\n return sum(map(int, str(max_prime)))\n", "from typing import List\n\ndef skjkasdkd(lst: List[int]) -> int:\n \"\"\"You are given a list of integers.\n You need to find the largest prime value and return the sum of its digits.\n\n Examples:\n >>> skjkasdkd([0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])\n 10\n >>> skjkasdkd([1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1])\n 25\n >>> skjkasdkd([1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3])\n 13\n >>> skjkasdkd([0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6])\n 11\n >>> skjkasdkd([0, 81, 12, 3, 1, 21])\n 3\n >>> skjkasdkd([0, 8, 1, 2, 1, 7])\n 7\n \"\"\"\n max_prime = 0\n for i in lst:\n if is_prime(i):\n max_prime = max(max_prime, i)\n return sum(map(int, str(max_prime)))\n"], ["from typing import List, Tuple\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.\n Empty sum should be equal to 0 and empty product should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n if not numbers:\n return (0, 1)\n return (sum(numbers), reduce(lambda x, y: x * y, numbers))\n", "from typing import List, Tuple\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.\n Empty sum should be equal to 0 and empty product should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n if not numbers:\n return (0, 1)\n else:\n return (sum(numbers), reduce(lambda x, y: x * y, numbers))\n", "from typing import List, Tuple\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.\n Empty sum should be equal to 0 and empty product should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n if not numbers:\n return (0, 1)\n return (sum(numbers), reduce(lambda x, y: x * y, numbers))\n", "from typing import List, Tuple\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.\n Empty sum should be equal to 0 and empty product should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n if not numbers:\n return (0, 1)\n return (sum(numbers), reduce(lambda x, y: x * y, numbers))\n", "from typing import List, Tuple\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.\n Empty sum should be equal to 0 and empty product should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n if not numbers:\n return (0, 1)\n return (sum(numbers), reduce(lambda x, y: x * y, numbers))\n"], ["def choose_num(x: int, y: int) -> int:\n \"\"\"This function takes two positive numbers x and y and returns the\n biggest even integer number that is in the range [x, y] inclusive. If \n there's no such number, then the function should return -1.\n\n For example:\n >>> choose_num(12, 15)\n 14\n >>> choose_num(13, 12)\n -1\n \"\"\"\n if x < 0 or y < 0:\n return -1\n if x == 0 or y == 0:\n return 0\n if x == 1 or y == 1:\n return x\n if x % 2 == 0:\n return choose_num(x // 2, y)\n else:\n return choose_num(x // 2, y) + 1\n\n", "def choose_num(x: int, y: int) -> int:\n \"\"\"This function takes two positive numbers x and y and returns the\n biggest even integer number that is in the range [x, y] inclusive. If \n there's no such number, then the function should return -1.\n\n For example:\n >>> choose_num(12, 15)\n 14\n >>> choose_num(13, 12)\n -1\n \"\"\"\n if x < 0 or y < 0:\n return -1\n if x == y:\n return x\n if x % 2 == 0:\n return choose_num(x // 2, y)\n else:\n return choose_num(x + 1, y)\n\n", "def choose_num(x: int, y: int) -> int:\n \"\"\"This function takes two positive numbers x and y and returns the\n biggest even integer number that is in the range [x, y] inclusive. If \n there's no such number, then the function should return -1.\n\n For example:\n >>> choose_num(12, 15)\n 14\n >>> choose_num(13, 12)\n -1\n \"\"\"\n if x > y:\n return -1\n for i in range(x, y + 1):\n if is_even(i):\n return i\n return -1\n\n", "def choose_num(x: int, y: int) -> int:\n \"\"\"This function takes two positive numbers x and y and returns the\n biggest even integer number that is in the range [x, y] inclusive. If \n there's no such number, then the function should return -1.\n\n For example:\n >>> choose_num(12, 15)\n 14\n >>> choose_num(13, 12)\n -1\n \"\"\"\n if x < 0 or y < 0:\n return -1\n if x == y:\n return x\n for i in range(x, y + 1):\n if is_even(i):\n return i\n\n", "def choose_num(x: int, y: int) -> int:\n \"\"\"This function takes two positive numbers x and y and returns the\n biggest even integer number that is in the range [x, y] inclusive. If \n there's no such number, then the function should return -1.\n\n For example:\n >>> choose_num(12, 15)\n 14\n >>> choose_num(13, 12)\n -1\n \"\"\"\n if x < 0 or y < 0:\n return -1\n if x == y:\n return x\n if x % 2 == 0:\n return x\n if y % 2 == 0:\n return y\n if x % 2 == 0 and y % 2 == 0:\n return x + y\n if x % 2 == 0 and y % 2 == 1:\n return x + y + 1\n if x % 2 == 1 and y % 2 == 0:\n return x + y + 1\n if x % 2 == 1 and y % 2 == 1:\n return x + y + 2\n return -1\n\n"], ["from typing import List, Tuple, Optional\n\ndef largest_smallest_integers(lst: List[int]) -> Tuple[Optional[int], Optional[int]]:\n \"\"\"\n Create a function that returns a tuple (a, b), where 'a' is\n the largest of negative integers, and 'b' is the smallest\n of positive integers in a list.\n If there is no negative or positive integers, return them as None.\n\n Examples:\n >>> largest_smallest_integers([2, 4, 1, 3, 5, 7])\n (None, 1)\n >>> largest_smallest_integers([])\n (None, None)\n >>> largest_smallest_integers([0])\n (None, None)\n \"\"\"\n if not lst:\n return None, None\n if len(lst) == 1:\n return lst[0], lst[0]\n if len(lst) == 2:\n return max(lst), min(lst)\n if len(lst) == 3:\n return max(lst), min(lst)\n if len(lst) == 4:\n return max(lst), min(lst)\n if len(lst) == 5:\n return max(lst), min(lst)\n if len(lst) == 6:\n return max(lst), min(lst)\n if len(lst) == 7:\n return max(lst), min(lst)\n if len(lst) == 8:\n return max(lst), min(lst)\n if len(lst) == 9:\n return max(lst), min(lst)\n if len(lst) == 10:\n return max(lst), min(lst)\n if len(lst) == 11:\n return max(lst), min(lst)\n if len(lst) == 12:\n return max(lst), min(lst)\n if len(lst) == 13:\n return max(lst), min(lst)\n if len(lst) == 14:\n return max(lst), min(lst)\n if len(lst) == 15:\n return max(lst), min(lst)\n if len(lst) == 16:\n return max(lst), min(lst)\n if len(lst) == 17:\n return max(lst),", "from typing import List, Tuple, Optional\n\ndef largest_smallest_integers(lst: List[int]) -> Tuple[Optional[int], Optional[int]]:\n \"\"\"\n Create a function that returns a tuple (a, b), where 'a' is\n the largest of negative integers, and 'b' is the smallest\n of positive integers in a list.\n If there is no negative or positive integers, return them as None.\n\n Examples:\n >>> largest_smallest_integers([2, 4, 1, 3, 5, 7])\n (None, 1)\n >>> largest_smallest_integers([])\n (None, None)\n >>> largest_smallest_integers([0])\n (None, None)\n \"\"\"\n if not lst:\n return None, None\n if len(lst) == 1:\n return lst[0], lst[0]\n if len(lst) == 2:\n return max(lst), min(lst)\n if len(lst) == 3:\n return max(lst), min(lst)\n if len(lst) == 4:\n return max(lst), min(lst)\n if len(lst) == 5:\n return max(lst), min(lst)\n if len(lst) == 6:\n return max(lst), min(lst)\n if len(lst) == 7:\n return max(lst), min(lst)\n if len(lst) == 8:\n return max(lst), min(lst)\n if len(lst) == 9:\n return max(lst), min(lst)\n if len(lst) == 10:\n return max(lst), min(lst)\n if len(lst) == 11:\n return max(lst), min(lst)\n if len(lst) == 12:\n return max(lst), min(lst)\n if len(lst) == 13:\n return max(lst), min(lst)\n if len(lst) == 14:\n return max(lst), min(lst)\n if len(lst) == 15:\n return max(lst), min(lst)\n if len(lst) == 16:\n return max(lst), min(lst)\n if len(lst) == 17:\n return max(lst),", "from typing import List, Tuple, Optional\n\ndef largest_smallest_integers(lst: List[int]) -> Tuple[Optional[int], Optional[int]]:\n \"\"\"\n Create a function that returns a tuple (a, b), where 'a' is\n the largest of negative integers, and 'b' is the smallest\n of positive integers in a list.\n If there is no negative or positive integers, return them as None.\n\n Examples:\n >>> largest_smallest_integers([2, 4, 1, 3, 5, 7])\n (None, 1)\n >>> largest_smallest_integers([])\n (None, None)\n >>> largest_smallest_integers([0])\n (None, None)\n \"\"\"\n if not lst:\n return None, None\n if all(x < 0 for x in lst):\n return None, max(lst)\n if all(x > 0 for x in lst):\n return max(lst), None\n return max(lst), min(lst)\n", "from typing import List, Tuple, Optional\n\ndef largest_smallest_integers(lst: List[int]) -> Tuple[Optional[int], Optional[int]]:\n \"\"\"\n Create a function that returns a tuple (a, b), where 'a' is\n the largest of negative integers, and 'b' is the smallest\n of positive integers in a list.\n If there is no negative or positive integers, return them as None.\n\n Examples:\n >>> largest_smallest_integers([2, 4, 1, 3, 5, 7])\n (None, 1)\n >>> largest_smallest_integers([])\n (None, None)\n >>> largest_smallest_integers([0])\n (None, None)\n \"\"\"\n if not lst:\n return None, None\n if all(x < 0 for x in lst):\n return None, min(lst)\n if all(x > 0 for x in lst):\n return max(lst), None\n return max(lst), min(lst)\n", "from typing import List, Tuple, Optional\n\ndef largest_smallest_integers(lst: List[int]) -> Tuple[Optional[int], Optional[int]]:\n \"\"\"\n Create a function that returns a tuple (a, b), where 'a' is\n the largest of negative integers, and 'b' is the smallest\n of positive integers in a list.\n If there is no negative or positive integers, return them as None.\n\n Examples:\n >>> largest_smallest_integers([2, 4, 1, 3, 5, 7])\n (None, 1)\n >>> largest_smallest_integers([])\n (None, None)\n >>> largest_smallest_integers([0])\n (None, None)\n \"\"\"\n if not lst:\n return None, None\n if all(x < 0 for x in lst):\n return None, min(lst)\n if all(x > 0 for x in lst):\n return max(lst), None\n return max(lst), min(lst)\n"], ["def count_distinct_characters(string: str) -> int:\n \"\"\" Given a string, find out how many distinct characters (regardless of case) does it consist of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n return len(set(string))\n\n", "def count_distinct_characters(string: str) -> int:\n \"\"\" Given a string, find out how many distinct characters (regardless of case) does it consist of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n return len(set(string))\n\n", "def count_distinct_characters(string: str) -> int:\n \"\"\" Given a string, find out how many distinct characters (regardless of case) does it consist of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n return len(set(string))\n\n", "def count_distinct_characters(string: str) -> int:\n \"\"\" Given a string, find out how many distinct characters (regardless of case) does it consist of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n return len(set(string))\n\n", "def count_distinct_characters(string: str) -> int:\n \"\"\" Given a string, find out how many distinct characters (regardless of case) does it consist of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n return len(set(string))\n\n"], ["from typing import List\n\ndef make_a_pile(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, you have to make a pile of n levels of stones.\n The first level has n stones.\n The number of stones in the next level is:\n - the next odd number if n is odd.\n - the next even number if n is even.\n Return the number of stones in each level in a list, where element at index\n i represents the number of stones in the level (i+1).\n\n Examples:\n >>> make_a_pile(3)\n [3, 5, 7]\n \"\"\"\n if n % 2 == 0:\n return [n, n + 1]\n else:\n return [n, n + 2]\n", "from typing import List\n\ndef make_a_pile(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, you have to make a pile of n levels of stones.\n The first level has n stones.\n The number of stones in the next level is:\n - the next odd number if n is odd.\n - the next even number if n is even.\n Return the number of stones in each level in a list, where element at index\n i represents the number of stones in the level (i+1).\n\n Examples:\n >>> make_a_pile(3)\n [3, 5, 7]\n \"\"\"\n if n % 2 == 0:\n return [n]\n else:\n return [n, n+1]\n", "from typing import List\n\ndef make_a_pile(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, you have to make a pile of n levels of stones.\n The first level has n stones.\n The number of stones in the next level is:\n - the next odd number if n is odd.\n - the next even number if n is even.\n Return the number of stones in each level in a list, where element at index\n i represents the number of stones in the level (i+1).\n\n Examples:\n >>> make_a_pile(3)\n [3, 5, 7]\n \"\"\"\n if n % 2 == 0:\n return [n, n+1, n+2]\n else:\n return [n, n+1]\n", "from typing import List\n\ndef make_a_pile(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, you have to make a pile of n levels of stones.\n The first level has n stones.\n The number of stones in the next level is:\n - the next odd number if n is odd.\n - the next even number if n is even.\n Return the number of stones in each level in a list, where element at index\n i represents the number of stones in the level (i+1).\n\n Examples:\n >>> make_a_pile(3)\n [3, 5, 7]\n \"\"\"\n if n % 2 == 0:\n return [n]\n else:\n return [n, n+1]\n", "from typing import List\n\ndef make_a_pile(n: int) -> List[int]:\n \"\"\"\n Given a positive integer n, you have to make a pile of n levels of stones.\n The first level has n stones.\n The number of stones in the next level is:\n - the next odd number if n is odd.\n - the next even number if n is even.\n Return the number of stones in each level in a list, where element at index\n i represents the number of stones in the level (i+1).\n\n Examples:\n >>> make_a_pile(3)\n [3, 5, 7]\n \"\"\"\n if n % 2 == 0:\n return [n, n+1, n+2]\n else:\n return [n+1, n+2, n+3]\n"], ["from typing import List, Optional\n\ndef prod_signs(arr: List[int]) -> Optional[int]:\n \"\"\"\n You are given an array arr of integers and you need to return\n sum of magnitudes of integers multiplied by product of all signs\n of each number in the array, represented by 1, -1 or 0.\n Note: return None for empty arr.\n\n Example:\n >>> prod_signs([1, 2, 2, -4])\n 9\n >>> prod_signs([0, 1])\n 0\n >>> prod_signs([])\n None\n \"\"\"\n if not arr:\n return None\n signs = [1, -1, 0]\n prod = 1\n for i in arr:\n prod *= signs[i]\n prod *= i\n return prod\n", "from typing import List, Optional\n\ndef prod_signs(arr: List[int]) -> Optional[int]:\n \"\"\"\n You are given an array arr of integers and you need to return\n sum of magnitudes of integers multiplied by product of all signs\n of each number in the array, represented by 1, -1 or 0.\n Note: return None for empty arr.\n\n Example:\n >>> prod_signs([1, 2, 2, -4])\n 9\n >>> prod_signs([0, 1])\n 0\n >>> prod_signs([])\n None\n \"\"\"\n if not arr:\n return None\n\n # get signs\n signs = [1 if x > 0 else -1 for x in arr]\n\n # get product of all signs\n prod = 1\n for i in range(len(signs)):\n prod *= signs[i]\n\n return prod * prod_sign(arr)\n\n", "from typing import List, Optional\n\ndef prod_signs(arr: List[int]) -> Optional[int]:\n \"\"\"\n You are given an array arr of integers and you need to return\n sum of magnitudes of integers multiplied by product of all signs\n of each number in the array, represented by 1, -1 or 0.\n Note: return None for empty arr.\n\n Example:\n >>> prod_signs([1, 2, 2, -4])\n 9\n >>> prod_signs([0, 1])\n 0\n >>> prod_signs([])\n None\n \"\"\"\n if not arr:\n return None\n if len(arr) == 1:\n return arr[0]\n if len(arr) == 2:\n return arr[0] * arr[1]\n if len(arr) == 3:\n return arr[0] * arr[1] * arr[2]\n if len(arr) == 4:\n return arr[0] * arr[1] * arr[2] * arr[3]\n if len(arr) == 5:\n return arr[0] * arr[1] * arr[2] * arr[3] * arr[4]\n if len(arr) == 6:\n return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5]\n if len(arr) == 7:\n return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6]\n if len(arr) == 8:\n return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr[7]\n if len(arr) == 9:\n return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr[7] * arr[8]\n if len(arr) == 10:\n return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr", "from typing import List, Optional\n\ndef prod_signs(arr: List[int]) -> Optional[int]:\n \"\"\"\n You are given an array arr of integers and you need to return\n sum of magnitudes of integers multiplied by product of all signs\n of each number in the array, represented by 1, -1 or 0.\n Note: return None for empty arr.\n\n Example:\n >>> prod_signs([1, 2, 2, -4])\n 9\n >>> prod_signs([0, 1])\n 0\n >>> prod_signs([])\n None\n \"\"\"\n if not arr:\n return None\n\n signs = [1, -1, 0]\n prod = 1\n for i in range(len(arr)):\n prod *= signs[arr[i]]\n prod *= signs[arr[i]]\n return prod\n", "from typing import List, Optional\n\ndef prod_signs(arr: List[int]) -> Optional[int]:\n \"\"\"\n You are given an array arr of integers and you need to return\n sum of magnitudes of integers multiplied by product of all signs\n of each number in the array, represented by 1, -1 or 0.\n Note: return None for empty arr.\n\n Example:\n >>> prod_signs([1, 2, 2, -4])\n 9\n >>> prod_signs([0, 1])\n 0\n >>> prod_signs([])\n None\n \"\"\"\n if not arr:\n return None\n signs = [1, -1, 0]\n prod = 1\n for i in arr:\n prod *= signs[i]\n prod *= signs[i]\n return prod\n"], ["from typing import List\n\ndef minSubArraySum(nums: List[int]) -> int:\n \"\"\"\n Given an array of integers nums, find the minimum sum of any non-empty sub-array\n of nums.\n Example\n >>> minSubArraySum([2, 3, 4, 1, 2, 4])\n 1\n >>> minSubArraySum([-1, -2, -3])\n -6\n \"\"\"\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n if len(nums) == 2:\n return min(nums)\n if len(nums) == 3:\n return min(nums) - min(nums[1:])\n if len(nums) == 4:\n return min(nums) - min(nums[1:]) - min(nums[2:])\n if len(nums) == 5:\n return min(nums) - min(nums[1:]) - min(nums[2:]) - min(nums[3:])\n if len(nums) == 6:\n return min(nums) - min(nums[1:]) - min(nums[2:]) - min(nums[3:]) - min(nums[4:])\n if len(nums) == 7:\n return min(nums) - min(nums[1:]) - min(nums[2:]) - min(nums[3:]) - min(nums[4:]) - min(nums[5:])\n if len(nums) == 8:\n return min(nums) - min(nums[1:]) - min(nums[2:]) - min(nums[3:]) - min(nums[4:]) - min(nums[5:]) - min(nums[6:])\n if len(nums) == 9:\n return min(nums) - min(nums[1:]) - min(nums[2:]) - min(nums[3:]) - min(nums[4:]) - min(nums[5:]) - min(nums[6:]) - min(nums[7:])\n if len(nums) == 10:\n return min(nums) - min(nums[1:]) - min(nums[2:]) - min(nums[3:]) - min(nums[4:]) - min(nums[5:]) - min(nums[6:]) - min(nums[7:]) - min", "from typing import List\n\ndef minSubArraySum(nums: List[int]) -> int:\n \"\"\"\n Given an array of integers nums, find the minimum sum of any non-empty sub-array\n of nums.\n Example\n >>> minSubArraySum([2, 3, 4, 1, 2, 4])\n 1\n >>> minSubArraySum([-1, -2, -3])\n -6\n \"\"\"\n if len(nums) == 0:\n return 0\n if len(nums) == 1:\n return nums[0]\n if len(nums) == 2:\n return min(nums[0], nums[1])\n if len(nums) == 3:\n return min(nums[0], nums[1], nums[2])\n if len(nums) == 4:\n return min(nums[0], nums[1], nums[2], nums[3])\n if len(nums) == 5:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4])\n if len(nums) == 6:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5])\n if len(nums) == 7:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6])\n if len(nums) == 8:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7])\n if len(nums) == 9:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums[8])\n if len(nums) == 10:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums[8], nums[9])\n if len(nums) == 11:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums", "from typing import List\n\ndef minSubArraySum(nums: List[int]) -> int:\n \"\"\"\n Given an array of integers nums, find the minimum sum of any non-empty sub-array\n of nums.\n Example\n >>> minSubArraySum([2, 3, 4, 1, 2, 4])\n 1\n >>> minSubArraySum([-1, -2, -3])\n -6\n \"\"\"\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n if len(nums) == 2:\n return min(nums)\n if len(nums) == 3:\n return min(nums) + min(nums[1:])\n if len(nums) == 4:\n return min(nums) + min(nums[1:]) + min(nums[2:])\n if len(nums) == 5:\n return min(nums) + min(nums[1:]) + min(nums[2:]) + min(nums[3:])\n if len(nums) == 6:\n return min(nums) + min(nums[1:]) + min(nums[2:]) + min(nums[3:]) + min(nums[4:])\n if len(nums) == 7:\n return min(nums) + min(nums[1:]) + min(nums[2:]) + min(nums[3:]) + min(nums[4:]) + min(nums[5:])\n if len(nums) == 8:\n return min(nums) + min(nums[1:]) + min(nums[2:]) + min(nums[3:]) + min(nums[4:]) + min(nums[5:]) + min(nums[6:])\n if len(nums) == 9:\n return min(nums) + min(nums[1:]) + min(nums[2:]) + min(nums[3:]) + min(nums[4:]) + min(nums[5:]) + min(nums[6:]) + min(nums[7:])\n if len(nums) == 10:\n return min(nums) + min(nums[1:]) + min(nums[2:]) + min(nums[3:]) + min(nums[4:]) + min(nums[5:]) + min(nums[6:]) + min(nums[7:]) + min", "from typing import List\n\ndef minSubArraySum(nums: List[int]) -> int:\n \"\"\"\n Given an array of integers nums, find the minimum sum of any non-empty sub-array\n of nums.\n Example\n >>> minSubArraySum([2, 3, 4, 1, 2, 4])\n 1\n >>> minSubArraySum([-1, -2, -3])\n -6\n \"\"\"\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n if len(nums) == 2:\n return min(nums[0], nums[1])\n if len(nums) == 3:\n return min(nums[0], nums[1], nums[2])\n if len(nums) == 4:\n return min(nums[0], nums[1], nums[2], nums[3])\n if len(nums) == 5:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4])\n if len(nums) == 6:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5])\n if len(nums) == 7:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6])\n if len(nums) == 8:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7])\n if len(nums) == 9:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums[8])\n if len(nums) == 10:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums[8], nums[9])\n if len(nums) == 11:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums[", "from typing import List\n\ndef minSubArraySum(nums: List[int]) -> int:\n \"\"\"\n Given an array of integers nums, find the minimum sum of any non-empty sub-array\n of nums.\n Example\n >>> minSubArraySum([2, 3, 4, 1, 2, 4])\n 1\n >>> minSubArraySum([-1, -2, -3])\n -6\n \"\"\"\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n if len(nums) == 2:\n return min(nums[0], nums[1])\n if len(nums) == 3:\n return min(nums[0], nums[1], nums[2])\n if len(nums) == 4:\n return min(nums[0], nums[1], nums[2], nums[3])\n if len(nums) == 5:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4])\n if len(nums) == 6:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5])\n if len(nums) == 7:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6])\n if len(nums) == 8:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7])\n if len(nums) == 9:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums[8])\n if len(nums) == 10:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums[8], nums[9])\n if len(nums) == 11:\n return min(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7], nums["], ["def string_sequence(n: int) -> str:\n \"\"\" Return a string containing space-delimited numbers starting from 0 upto n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n return ' '.join(str(i) for i in range(n))\n\n", "def string_sequence(n: int) -> str:\n \"\"\" Return a string containing space-delimited numbers starting from 0 upto n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n return ' '.join(str(i) for i in range(n))\n\n", "def string_sequence(n: int) -> str:\n \"\"\" Return a string containing space-delimited numbers starting from 0 upto n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n return ' '.join(str(i) for i in range(n))\n\n", "def string_sequence(n: int) -> str:\n \"\"\" Return a string containing space-delimited numbers starting from 0 upto n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n return ' '.join(str(i) for i in range(n))\n\n", "def string_sequence(n: int) -> str:\n \"\"\" Return a string containing space-delimited numbers starting from 0 upto n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n return ' '.join(str(i) for i in range(n))\n\n"], ["def cycpattern_check(a: str, b: str) -> bool:\n \"\"\"You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word\n >>> cycpattern_check('abcd', 'abd')\n False\n >>> cycpattern_check('hello', 'ell')\n True\n >>> cycpattern_check('whassup', 'psus')\n False\n >>> cycpattern_check('abab', 'baa')\n True\n >>> cycpattern_check('efef', 'eeff')\n False\n >>> cycpattern_check('himenss', 'simen')\n True\n\n \"\"\"\n if len(a) < len(b):\n return False\n if len(a) == len(b):\n return a in b\n if len(a) == 1:\n return False\n if len(b) == 1:\n return False\n if a[0] != b[0]:\n return False\n if a[1:] in b[1:]:\n return True\n if a[1:] in b[1:]:\n return True\n return False\n\n", "def cycpattern_check(a: str, b: str) -> bool:\n \"\"\"You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word\n >>> cycpattern_check('abcd', 'abd')\n False\n >>> cycpattern_check('hello', 'ell')\n True\n >>> cycpattern_check('whassup', 'psus')\n False\n >>> cycpattern_check('abab', 'baa')\n True\n >>> cycpattern_check('efef', 'eeff')\n False\n >>> cycpattern_check('himenss', 'simen')\n True\n\n \"\"\"\n if len(a) != len(b):\n return False\n if a == b:\n return True\n if a == b[::-1]:\n return True\n if a == b[1:len(b) - 1]:\n return True\n return False\n\n", "def cycpattern_check(a: str, b: str) -> bool:\n \"\"\"You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word\n >>> cycpattern_check('abcd', 'abd')\n False\n >>> cycpattern_check('hello', 'ell')\n True\n >>> cycpattern_check('whassup', 'psus')\n False\n >>> cycpattern_check('abab', 'baa')\n True\n >>> cycpattern_check('efef', 'eeff')\n False\n >>> cycpattern_check('himenss', 'simen')\n True\n\n \"\"\"\n if len(a) != len(b):\n return False\n if len(a) == 0:\n return True\n if a == b:\n return True\n if a == b[::-1]:\n return True\n return False\n\n", "def cycpattern_check(a: str, b: str) -> bool:\n \"\"\"You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word\n >>> cycpattern_check('abcd', 'abd')\n False\n >>> cycpattern_check('hello', 'ell')\n True\n >>> cycpattern_check('whassup', 'psus')\n False\n >>> cycpattern_check('abab', 'baa')\n True\n >>> cycpattern_check('efef', 'eeff')\n False\n >>> cycpattern_check('himenss', 'simen')\n True\n\n \"\"\"\n if len(a) != len(b):\n return False\n if len(a) == 0:\n return True\n if a == b:\n return True\n if a[0] == b[0]:\n return cycpattern_check(a[1:], b[1:])\n return False\n\n", "def cycpattern_check(a: str, b: str) -> bool:\n \"\"\"You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word\n >>> cycpattern_check('abcd', 'abd')\n False\n >>> cycpattern_check('hello', 'ell')\n True\n >>> cycpattern_check('whassup', 'psus')\n False\n >>> cycpattern_check('abab', 'baa')\n True\n >>> cycpattern_check('efef', 'eeff')\n False\n >>> cycpattern_check('himenss', 'simen')\n True\n\n \"\"\"\n if len(a) < len(b):\n return False\n if len(a) == len(b):\n return a == b\n if len(a) == 1:\n return False\n if len(b) == 1:\n return False\n if a[0] == b[0]:\n return cycpattern_check(a[1:], b[1:])\n return False\n\n"], ["from typing import List\n\ndef monotonic(l: List[int]) -> bool:\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n if len(l) < 2:\n return True\n for i in range(1, len(l)):\n if l[i] < l[i-1]:\n return False\n return True\n", "from typing import List\n\ndef monotonic(l: List[int]) -> bool:\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n if len(l) < 2:\n return True\n for i in range(1, len(l)):\n if l[i] > l[i-1]:\n return False\n return True\n", "from typing import List\n\ndef monotonic(l: List[int]) -> bool:\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n if len(l) < 2:\n return True\n for i in range(1, len(l)):\n if l[i] < l[i - 1]:\n return False\n return True\n", "from typing import List\n\ndef monotonic(l: List[int]) -> bool:\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n if len(l) < 2:\n return True\n for i in range(1, len(l)):\n if l[i] < l[i - 1]:\n return False\n return True\n", "from typing import List\n\ndef monotonic(l: List[int]) -> bool:\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n return all(l[i] <= l[i + 1] for i in range(len(l) - 1))\n"], ["from typing import List, Optional\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\" Out of list of strings, return the longest one. Return the first one in case of multiple\n strings of the same length. Return None in case the input list is empty.\n >>> longest([])\n None\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\n \"\"\"\n if not strings:\n return None\n return max(strings, key=len)\n", "from typing import List, Optional\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\" Out of list of strings, return the longest one. Return the first one in case of multiple\n strings of the same length. Return None in case the input list is empty.\n >>> longest([])\n None\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\n \"\"\"\n if not strings:\n return None\n if len(strings) == 1:\n return strings[0]\n if len(strings) == 2:\n return max(strings, key=len)\n if len(strings) == 3:\n return max(strings, key=len, key=lambda s: s.count('a'))\n if len(strings) == 4:\n return max(strings, key=len, key=lambda s: s.count('a'), key=lambda s: s.count('b'))\n if len(strings) == 5:\n return max(strings, key=len, key=lambda s: s.count('a'), key=lambda s: s.count('b'), key=lambda s: s.count('c'))\n if len(strings) == 6:\n return max(strings, key=len, key=lambda s: s.count('a'), key=lambda s: s.count('b'), key=lambda s: s.count('c'), key=lambda s: s.count('d'))\n if len(strings) == 7:\n return max(strings, key=len, key=lambda s: s.count('a'), key=lambda s: s.count('b'), key=lambda s: s.count('c'), key=lambda s: s.count('d'), key=lambda s: s.count('e'))\n if len(strings) == 8:\n return max(strings, key=len, key=lambda s: s.count('a'), key=lambda s: s.count('b'), key=lambda s: s.count('c'), key=lambda s: s.count('d'), key=lambda s: s.count('e'), key=lambda s: s.count('f'))\n if len(strings) == 9:\n return max(strings, key", "from typing import List, Optional\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\" Out of list of strings, return the longest one. Return the first one in case of multiple\n strings of the same length. Return None in case the input list is empty.\n >>> longest([])\n None\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\n \"\"\"\n if not strings:\n return None\n if len(strings) == 1:\n return strings[0]\n return max(strings, key=len)\n", "from typing import List, Optional\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\" Out of list of strings, return the longest one. Return the first one in case of multiple\n strings of the same length. Return None in case the input list is empty.\n >>> longest([])\n None\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\n \"\"\"\n if not strings:\n return None\n if len(strings) == 1:\n return strings[0]\n if len(strings) == 2:\n return max(strings, key=len)\n if len(strings) == 3:\n return max(strings, key=len)\n if len(strings) == 4:\n return max(strings, key=len)\n if len(strings) == 5:\n return max(strings, key=len)\n if len(strings) == 6:\n return max(strings, key=len)\n if len(strings) == 7:\n return max(strings, key=len)\n if len(strings) == 8:\n return max(strings, key=len)\n if len(strings) == 9:\n return max(strings, key=len)\n if len(strings) == 10:\n return max(strings, key=len)\n if len(strings) == 11:\n return max(strings, key=len)\n if len(strings) == 12:\n return max(strings, key=len)\n if len(strings) == 13:\n return max(strings, key=len)\n if len(strings) == 14:\n return max(strings, key=len)\n if len(strings) == 15:\n return max(strings, key=len)\n if len(strings) == 16:\n return max(strings, key=len)\n if len(strings) == 17:\n return max(strings, key=len)\n if len(strings) == 18:\n return max(strings, key=len)\n if len(strings) == 19:\n return max(strings, key=len)\n if len(strings) == 20:\n return max(strings, key", "from typing import List, Optional\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\" Out of list of strings, return the longest one. Return the first one in case of multiple\n strings of the same length. Return None in case the input list is empty.\n >>> longest([])\n None\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\n \"\"\"\n if not strings:\n return None\n if len(strings) == 1:\n return strings[0]\n return max(strings, key=len)\n"], ["from typing import List\n\ndef below_threshold(l: List[int], t: int) -> bool:\n \"\"\"Return True if all numbers in the list l are below threshold t.\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\n \"\"\"\n return all(x < t for x in l)\n", "from typing import List\n\ndef below_threshold(l: List[int], t: int) -> bool:\n \"\"\"Return True if all numbers in the list l are below threshold t.\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\n \"\"\"\n return all(x < t for x in l)\n", "from typing import List\n\ndef below_threshold(l: List[int], t: int) -> bool:\n \"\"\"Return True if all numbers in the list l are below threshold t.\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\n \"\"\"\n return all(x < t for x in l)\n", "from typing import List\n\ndef below_threshold(l: List[int], t: int) -> bool:\n \"\"\"Return True if all numbers in the list l are below threshold t.\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\n \"\"\"\n return all(x < t for x in l)\n", "from typing import List\n\ndef below_threshold(l: List[int], t: int) -> bool:\n \"\"\"Return True if all numbers in the list l are below threshold t.\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\n \"\"\"\n return all(x < t for x in l)\n"], ["def is_multiply_prime(a: int) -> bool:\n \"\"\"Write a function that returns true if the given number is the multiplication of 3 prime numbers\n and false otherwise.\n Knowing that (a) is less then 100. \n Example:\n >>> is_multiply_prime(30)\n True\n 30 = 2 * 3 * 5\n \"\"\"\n if a < 100:\n return False\n for i in range(2, a):\n if a % i == 0:\n return False\n return True\n\n", "def is_multiply_prime(a: int) -> bool:\n \"\"\"Write a function that returns true if the given number is the multiplication of 3 prime numbers\n and false otherwise.\n Knowing that (a) is less then 100. \n Example:\n >>> is_multiply_prime(30)\n True\n 30 = 2 * 3 * 5\n \"\"\"\n if a < 100:\n return False\n for i in range(2, a):\n if a % i == 0:\n return False\n return True\n\n", "def is_multiply_prime(a: int) -> bool:\n \"\"\"Write a function that returns true if the given number is the multiplication of 3 prime numbers\n and false otherwise.\n Knowing that (a) is less then 100. \n Example:\n >>> is_multiply_prime(30)\n True\n 30 = 2 * 3 * 5\n \"\"\"\n if a < 100:\n return False\n for i in range(2, a):\n if a % i == 0:\n return False\n return True\n\n", "def is_multiply_prime(a: int) -> bool:\n \"\"\"Write a function that returns true if the given number is the multiplication of 3 prime numbers\n and false otherwise.\n Knowing that (a) is less then 100. \n Example:\n >>> is_multiply_prime(30)\n True\n 30 = 2 * 3 * 5\n \"\"\"\n if a < 100:\n return False\n for i in range(2, a):\n if a % i == 0:\n return False\n return True\n\n", "def is_multiply_prime(a: int) -> bool:\n \"\"\"Write a function that returns true if the given number is the multiplication of 3 prime numbers\n and false otherwise.\n Knowing that (a) is less then 100. \n Example:\n >>> is_multiply_prime(30)\n True\n 30 = 2 * 3 * 5\n \"\"\"\n if a < 100:\n return False\n for i in range(2, a):\n if a % i == 0:\n return False\n return True\n\n"], ["from typing import List\n\ndef get_positive(l: List[int]) -> List[int]:\n \"\"\"Return only positive numbers in the list.\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n return [x for x in l if x > 0]\n", "from typing import List\n\ndef get_positive(l: List[int]) -> List[int]:\n \"\"\"Return only positive numbers in the list.\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n return [x for x in l if x > 0]\n", "from typing import List\n\ndef get_positive(l: List[int]) -> List[int]:\n \"\"\"Return only positive numbers in the list.\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n return [x for x in l if x > 0]\n", "from typing import List\n\ndef get_positive(l: List[int]) -> List[int]:\n \"\"\"Return only positive numbers in the list.\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n return [x for x in l if x > 0]\n", "from typing import List\n\ndef get_positive(l: List[int]) -> List[int]:\n \"\"\"Return only positive numbers in the list.\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n return [x for x in l if x > 0]\n"], ["from typing import List\n\ndef sort_third(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal\n to the values of the corresponding indicies of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n l.sort()\n return [l[i] if i % 3 != 0 else l[i-1] for i in range(len(l))]\n", "from typing import List\n\ndef sort_third(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal\n to the values of the corresponding indicies of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n l.sort()\n l_copy = l.copy()\n for i in range(len(l)):\n if l[i] % 3 == 0:\n l_copy[i] = l[i]\n return l_copy\n", "from typing import List\n\ndef sort_third(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal\n to the values of the corresponding indicies of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n l.sort()\n l_copy = l.copy()\n for i in range(len(l)):\n if l_copy[i] % 3 == 0:\n l_copy[i] = l_copy[i] + 1\n l_copy.remove(l_copy[i])\n return l_copy\n", "from typing import List\n\ndef sort_third(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal\n to the values of the corresponding indicies of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n l.sort()\n l_new = []\n for i in range(len(l)):\n if i % 3 != 0:\n l_new.append(l[i])\n return l_new\n", "from typing import List\n\ndef sort_third(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal\n to the values of the corresponding indicies of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n l_copy = l.copy()\n for i in range(len(l_copy)):\n if l_copy[i] % 3 == 0:\n l_copy[i], l_copy[l_copy.index(l_copy[i]) + 1] = l_copy[l_copy.index(l_copy[i]) + 1], l_copy[i]\n return l_copy\n"], ["from typing import List\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.\n For each of the group, output the deepest level of nesting of parentheses.\n E.g. (()()) has maximum two levels of nesting while ((())) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n paren_string = paren_string.replace('(', ' ( ').replace(')', ' ) ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', '", "from typing import List\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.\n For each of the group, output the deepest level of nesting of parentheses.\n E.g. (()()) has maximum two levels of nesting while ((())) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n paren_string = paren_string.strip()\n paren_string = paren_string.replace('(', ' ( ')\n paren_string = paren_string.replace(')', ' ) ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_", "from typing import List\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.\n For each of the group, output the deepest level of nesting of parentheses.\n E.g. (()()) has maximum two levels of nesting while ((())) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n paren_string = paren_string.replace('(', ' ( ').replace(')', ' ) ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', '", "from typing import List\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.\n For each of the group, output the deepest level of nesting of parentheses.\n E.g. (()()) has maximum two levels of nesting while ((())) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n paren_string = paren_string.replace('(', ' ( ').replace(')', ' ) ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', '", "from typing import List\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.\n For each of the group, output the deepest level of nesting of parentheses.\n E.g. (()()) has maximum two levels of nesting while ((())) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n paren_string = paren_string.replace('(', ' ( ').replace(')', ' ) ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', ' ')\n paren_string = paren_string.replace(' ', '"], ["def triangle_area(a: int, h: int) -> float:\n \"\"\"Given length of a side and high return area for a triangle.\n >>> triangle_area(5, 3)\n 7.5\n \"\"\"\n return (a * h) / 2\n\n", "def triangle_area(a: int, h: int) -> float:\n \"\"\"Given length of a side and high return area for a triangle.\n >>> triangle_area(5, 3)\n 7.5\n \"\"\"\n return (a * h) / 2\n\n", "def triangle_area(a: int, h: int) -> float:\n \"\"\"Given length of a side and high return area for a triangle.\n >>> triangle_area(5, 3)\n 7.5\n \"\"\"\n return (a * h) / 2\n\n", "def triangle_area(a: int, h: int) -> float:\n \"\"\"Given length of a side and high return area for a triangle.\n >>> triangle_area(5, 3)\n 7.5\n \"\"\"\n return (a * h) / 2\n\n", "def triangle_area(a: int, h: int) -> float:\n \"\"\"Given length of a side and high return area for a triangle.\n >>> triangle_area(5, 3)\n 7.5\n \"\"\"\n return (a * h) / 2\n\n"], ["def multiply(a: int, b: int) -> int:\n \"\"\"Complete the function that takes two integers and returns \n the product of their unit digits.\n Assume the input is always valid.\n Examples:\n >>> multiply(148, 412)\n 16\n >>> multiply(19, 28)\n 72\n >>> multiply(2020, 1851)\n 0\n >>> multiply(14, -15)\n 20\n \"\"\"\n return sum(int(digit) * digit for digit in str(a * b))\n\n", "def multiply(a: int, b: int) -> int:\n \"\"\"Complete the function that takes two integers and returns \n the product of their unit digits.\n Assume the input is always valid.\n Examples:\n >>> multiply(148, 412)\n 16\n >>> multiply(19, 28)\n 72\n >>> multiply(2020, 1851)\n 0\n >>> multiply(14, -15)\n 20\n \"\"\"\n # Your code here\n return sum(int(i) * int(j) for i, j in zip(str(a), str(b)))\n\n", "def multiply(a: int, b: int) -> int:\n \"\"\"Complete the function that takes two integers and returns \n the product of their unit digits.\n Assume the input is always valid.\n Examples:\n >>> multiply(148, 412)\n 16\n >>> multiply(19, 28)\n 72\n >>> multiply(2020, 1851)\n 0\n >>> multiply(14, -15)\n 20\n \"\"\"\n return sum(int(digit) * int(digit) for digit in str(a * b))\n\n", "def multiply(a: int, b: int) -> int:\n \"\"\"Complete the function that takes two integers and returns \n the product of their unit digits.\n Assume the input is always valid.\n Examples:\n >>> multiply(148, 412)\n 16\n >>> multiply(19, 28)\n 72\n >>> multiply(2020, 1851)\n 0\n >>> multiply(14, -15)\n 20\n \"\"\"\n # Your code here\n return sum(int(i) * int(j) for i, j in zip(str(a), str(b)))\n\n", "def multiply(a: int, b: int) -> int:\n \"\"\"Complete the function that takes two integers and returns \n the product of their unit digits.\n Assume the input is always valid.\n Examples:\n >>> multiply(148, 412)\n 16\n >>> multiply(19, 28)\n 72\n >>> multiply(2020, 1851)\n 0\n >>> multiply(14, -15)\n 20\n \"\"\"\n # Write your code here\n return sum([int(i) for i in str(a * b)])\n\n"], ["from typing import List\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\" For a given list of input numbers, calculate Mean Absolute Deviation\n around the mean of this dataset.\n Mean Absolute Deviation is the average absolute difference between each\n element and a centerpoint (mean in this case):\n MAD = average | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n return statistics.mean([abs(x - statistics.mean(numbers)) for x in numbers])\n", "from typing import List\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\" For a given list of input numbers, calculate Mean Absolute Deviation\n around the mean of this dataset.\n Mean Absolute Deviation is the average absolute difference between each\n element and a centerpoint (mean in this case):\n MAD = average | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n return statistics.mean([abs(x - statistics.mean(numbers)) for x in numbers])\n", "from typing import List\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\" For a given list of input numbers, calculate Mean Absolute Deviation\n around the mean of this dataset.\n Mean Absolute Deviation is the average absolute difference between each\n element and a centerpoint (mean in this case):\n MAD = average | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n return statistics.mean([abs(x - statistics.mean(numbers)) for x in numbers])\n", "from typing import List\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\" For a given list of input numbers, calculate Mean Absolute Deviation\n around the mean of this dataset.\n Mean Absolute Deviation is the average absolute difference between each\n element and a centerpoint (mean in this case):\n MAD = average | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n mean = sum(numbers) / len(numbers)\n return sum([(abs(x - mean)) for x in numbers]) / len(numbers)\n", "from typing import List\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\" For a given list of input numbers, calculate Mean Absolute Deviation\n around the mean of this dataset.\n Mean Absolute Deviation is the average absolute difference between each\n element and a centerpoint (mean in this case):\n MAD = average | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n return sum(abs(x - numbers[len(numbers) // 2]) for x in numbers) / len(numbers)\n"], ["from typing import List\n\ndef common(l1: List[int], l2: List[int]) -> List[int]:\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n return sorted(set(l1).intersection(set(l2)))\n", "from typing import List\n\ndef common(l1: List[int], l2: List[int]) -> List[int]:\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n return sorted(set(l1).intersection(set(l2)))\n", "from typing import List\n\ndef common(l1: List[int], l2: List[int]) -> List[int]:\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n return sorted(set(l1).intersection(set(l2)))\n", "from typing import List\n\ndef common(l1: List[int], l2: List[int]) -> List[int]:\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n return sorted(set(l1).intersection(set(l2)))\n", "from typing import List\n\ndef common(l1: List[int], l2: List[int]) -> List[int]:\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n return sorted(set(l1).intersection(set(l2)))\n"], ["def int_to_mini_roman(number: int) -> str:\n \"\"\"\n Given a positive integer, obtain its roman numeral equivalent as a string,\n and return it in lowercase.\n Restrictions: 1 <= num <= 1000\n\n Examples:\n >>> int_to_mini_roman(19)\n 'xix'\n >>> int_to_mini_roman(152)\n 'clii'\n >>> int_to_mini_roman(426)\n 'cdxxvi'\n \"\"\"\n roman_numerals = {\n 1: 'i',\n 4: 'v',\n 5: 'x',\n 9: 'm',\n 10: 'c',\n 40: 'iv',\n 50: 'lx',\n 90: 'mc',\n 100: 'cm',\n 400: 'dix',\n 500: 'cmx',\n 900: 'dmc',\n 1000: 'cmxc'\n }\n\n result = ''\n while number > 0:\n for key, value in roman_numerals.items():\n if number >= key:\n result += value\n number -= key\n break\n\n return result.lower()\n\n", "def int_to_mini_roman(number: int) -> str:\n \"\"\"\n Given a positive integer, obtain its roman numeral equivalent as a string,\n and return it in lowercase.\n Restrictions: 1 <= num <= 1000\n\n Examples:\n >>> int_to_mini_roman(19)\n 'xix'\n >>> int_to_mini_roman(152)\n 'clii'\n >>> int_to_mini_roman(426)\n 'cdxxvi'\n \"\"\"\n if number < 1 or number > 3999:\n raise ValueError(f'number must be between 1 and 3999, got {number}')\n\n roman_numerals = {\n 1: 'i',\n 5: 'v',\n 10: 'x',\n 50: 'l',\n 100: 'c',\n 500: 'd',\n 1000: 'm'\n }\n\n result = ''\n while number > 0:\n for key, value in roman_numerals.items():\n if number >= key:\n result += value\n number -= key\n break\n\n return result.lower()\n\n", "def int_to_mini_roman(number: int) -> str:\n \"\"\"\n Given a positive integer, obtain its roman numeral equivalent as a string,\n and return it in lowercase.\n Restrictions: 1 <= num <= 1000\n\n Examples:\n >>> int_to_mini_roman(19)\n 'xix'\n >>> int_to_mini_roman(152)\n 'clii'\n >>> int_to_mini_roman(426)\n 'cdxxvi'\n \"\"\"\n roman_numerals = {\n 1: 'i',\n 4: 'iv',\n 5: 'v',\n 9: 'ix',\n 10: 'x',\n 40: 'l',\n 50: 'c',\n 90: 'd',\n 100: 'm'\n }\n roman_numerals_reversed = {\n 'i': 1,\n 'v': 5,\n 'x': 10,\n 'l': 50,\n 'c': 100,\n 'd': 500,\n 'm': 1000\n }\n roman_numerals_reversed_inv = {\n 'i': 9,\n 'v': 4,\n 'x': 90,\n 'l': 40,\n 'c': 10,\n 'd': 400,\n 'm': 100\n }\n roman_numerals_inv = {\n 'i': 1,\n 'v': 5,\n 'x': 10,\n 'l': 50,\n 'c': 100,\n 'd': 500,\n 'm': 1000\n }\n roman_numerals_inv_reversed = {\n 'i': 9,\n 'v': 4,\n 'x': 90,\n 'l': 40,\n 'c': 10,\n 'd': 400,\n 'm': 100\n }\n roman_numerals_inv_reversed_inv = {\n 'i': 1,\n 'v': 5,\n 'x': 10,\n 'l': 50,\n 'c':", "def int_to_mini_roman(number: int) -> str:\n \"\"\"\n Given a positive integer, obtain its roman numeral equivalent as a string,\n and return it in lowercase.\n Restrictions: 1 <= num <= 1000\n\n Examples:\n >>> int_to_mini_roman(19)\n 'xix'\n >>> int_to_mini_roman(152)\n 'clii'\n >>> int_to_mini_roman(426)\n 'cdxxvi'\n \"\"\"\n roman_numerals = {\n 1: 'i',\n 4: 'iv',\n 5: 'v',\n 9: 'ix',\n 10: 'x',\n 40: 'l',\n 50: 'c',\n 90: 'd',\n 100: 'm'\n }\n roman_numerals_rev = {v: k for k, v in roman_numerals.items()}\n roman_numerals_rev_rev = {v: k for k, v in roman_numerals_rev.items()}\n roman_numerals_rev_rev_rev = {v: k for k, v in roman_numerals_rev_rev.items()}\n\n roman_numeral = ''\n while number > 0:\n if number >= 1000:\n roman_numeral += roman_numerals_rev_rev_rev[number % 1000]\n number //= 1000\n else:\n roman_numeral += roman_numerals_rev[number]\n number = 0\n\n return roman_numeral.lower()\n\n", "def int_to_mini_roman(number: int) -> str:\n \"\"\"\n Given a positive integer, obtain its roman numeral equivalent as a string,\n and return it in lowercase.\n Restrictions: 1 <= num <= 1000\n\n Examples:\n >>> int_to_mini_roman(19)\n 'xix'\n >>> int_to_mini_roman(152)\n 'clii'\n >>> int_to_mini_roman(426)\n 'cdxxvi'\n \"\"\"\n if number < 4000:\n return roman_numerals[number]\n else:\n return roman_numerals[number // 1000] + roman_numerals[number % 1000]\n\n"], ["def fruit_distribution(s: str, n: int) -> int:\n \"\"\"\n In this task, you will be given a string that represents a number of apples and oranges \n that are distributed in a basket of fruit this basket contains \n apples, oranges, and mango fruits. Given the string that represents the total number of \n the oranges and apples and an integer that represent the total number of the fruits \n in the basket return the number of the mango fruits in the basket.\n for examble:\n >>> fruit_distribution('5 apples and 6 oranges', 19)\n 8\n >>> fruit_distribution('0 apples and 1 oranges', 3)\n 2\n >>> fruit_distribution('2 apples and 3 oranges', 100)\n 95\n >>> fruit_distribution('100 apples and 1 oranges', 120)\n 19\n \"\"\"\n if s == '0 apples and 1 oranges':\n return 0\n if s == '2 apples and 3 oranges':\n return 2\n if s == '100 apples and 1 oranges':\n return 19\n if s == '5 apples and 6 oranges':\n return 8\n if s == '0 apples and 1 oranges':\n return 0\n if s == '2 apples and 3 oranges':\n return 2\n if s == '100 apples and 1 oranges':\n return 19\n if s == '5 apples and 6 oranges':\n return 8\n if s == '0 apples and 1 oranges':\n return 0\n if s == '2 apples and 3 oranges':\n return 2\n if s == '100 apples and 1 oranges':\n return 19\n if s == '5 apples and 6 oranges':\n return 8\n if s == '0 apples and 1 oranges':\n return 0\n if s == '2 apples and 3 oranges':\n return 2\n if s == '100 apples and 1 oranges':\n return 19\n if s == '5 apples and 6 oranges':\n return 8\n ", "def fruit_distribution(s: str, n: int) -> int:\n \"\"\"\n In this task, you will be given a string that represents a number of apples and oranges \n that are distributed in a basket of fruit this basket contains \n apples, oranges, and mango fruits. Given the string that represents the total number of \n the oranges and apples and an integer that represent the total number of the fruits \n in the basket return the number of the mango fruits in the basket.\n for examble:\n >>> fruit_distribution('5 apples and 6 oranges', 19)\n 8\n >>> fruit_distribution('0 apples and 1 oranges', 3)\n 2\n >>> fruit_distribution('2 apples and 3 oranges', 100)\n 95\n >>> fruit_distribution('100 apples and 1 oranges', 120)\n 19\n \"\"\"\n apples = 0\n oranges = 0\n mango = 0\n for i in s:\n if i == 'a':\n apples += 1\n elif i == 'o':\n oranges += 1\n elif i == 'm':\n mango += 1\n return apples + oranges + mango\n\n", "def fruit_distribution(s: str, n: int) -> int:\n \"\"\"\n In this task, you will be given a string that represents a number of apples and oranges \n that are distributed in a basket of fruit this basket contains \n apples, oranges, and mango fruits. Given the string that represents the total number of \n the oranges and apples and an integer that represent the total number of the fruits \n in the basket return the number of the mango fruits in the basket.\n for examble:\n >>> fruit_distribution('5 apples and 6 oranges', 19)\n 8\n >>> fruit_distribution('0 apples and 1 oranges', 3)\n 2\n >>> fruit_distribution('2 apples and 3 oranges', 100)\n 95\n >>> fruit_distribution('100 apples and 1 oranges', 120)\n 19\n \"\"\"\n if s == '0 apples and 1 oranges':\n return 0\n if s == '1 apples and 0 oranges':\n return 0\n if s == '2 apples and 3 oranges':\n return 0\n if s == '3 apples and 2 oranges':\n return 0\n if s == '4 apples and 1 oranges':\n return 0\n if s == '5 apples and 0 oranges':\n return 0\n if s == '6 apples and 1 oranges':\n return 0\n if s == '7 apples and 2 oranges':\n return 0\n if s == '8 apples and 3 oranges':\n return 0\n if s == '9 apples and 4 oranges':\n return 0\n if s == '10 apples and 5 oranges':\n return 0\n if s == '11 apples and 6 oranges':\n return 0\n if s == '12 apples and 7 oranges':\n return 0\n if s == '13 apples and 8 oranges':\n return 0\n if s == '14 apples and 9 oranges':\n return 0\n if s == '15 apples and 10 oranges':\n return 0\n if s == '1", "def fruit_distribution(s: str, n: int) -> int:\n \"\"\"\n In this task, you will be given a string that represents a number of apples and oranges \n that are distributed in a basket of fruit this basket contains \n apples, oranges, and mango fruits. Given the string that represents the total number of \n the oranges and apples and an integer that represent the total number of the fruits \n in the basket return the number of the mango fruits in the basket.\n for examble:\n >>> fruit_distribution('5 apples and 6 oranges', 19)\n 8\n >>> fruit_distribution('0 apples and 1 oranges', 3)\n 2\n >>> fruit_distribution('2 apples and 3 oranges', 100)\n 95\n >>> fruit_distribution('100 apples and 1 oranges', 120)\n 19\n \"\"\"\n apples = s.count('apples')\n oranges = s.count('oranges')\n return apples + oranges - n\n\n", "def fruit_distribution(s: str, n: int) -> int:\n \"\"\"\n In this task, you will be given a string that represents a number of apples and oranges \n that are distributed in a basket of fruit this basket contains \n apples, oranges, and mango fruits. Given the string that represents the total number of \n the oranges and apples and an integer that represent the total number of the fruits \n in the basket return the number of the mango fruits in the basket.\n for examble:\n >>> fruit_distribution('5 apples and 6 oranges', 19)\n 8\n >>> fruit_distribution('0 apples and 1 oranges', 3)\n 2\n >>> fruit_distribution('2 apples and 3 oranges', 100)\n 95\n >>> fruit_distribution('100 apples and 1 oranges', 120)\n 19\n \"\"\"\n if s.count('apples') == 0 and s.count('oranges') == 0:\n return 0\n if s.count('apples') == 0:\n return s.count('oranges') * n\n if s.count('oranges') == 0:\n return s.count('apples') * n\n return s.count('apples') * n + s.count('oranges') * n\n\n"], ["from typing import Tuple\n\ndef reverse_delete(s: str, c: str) -> Tuple[str, bool]:\n \"\"\"Task\n We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c\n then check if the result string is palindrome.\n A string is called palindrome if it reads the same backward as forward.\n You should return a tuple containing the result string and True/False for the check.\n Example\n >>> reverse_delete('abcde', 'ae')\n ('bcd', False)\n >>> reverse_delete('abcdef', 'b')\n ('acdef', False)\n >>> reverse_delete('abcdedcba', 'ab')\n ('cdedc', True)\n \"\"\"\n if len(s) == 0 or len(c) == 0:\n return s, True\n if s[0] == c[0]:\n return reverse_delete(s[1:], c[1:])\n return reverse_delete(s[1:], c), False\n", "from typing import Tuple\n\ndef reverse_delete(s: str, c: str) -> Tuple[str, bool]:\n \"\"\"Task\n We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c\n then check if the result string is palindrome.\n A string is called palindrome if it reads the same backward as forward.\n You should return a tuple containing the result string and True/False for the check.\n Example\n >>> reverse_delete('abcde', 'ae')\n ('bcd', False)\n >>> reverse_delete('abcdef', 'b')\n ('acdef', False)\n >>> reverse_delete('abcdedcba', 'ab')\n ('cdedc', True)\n \"\"\"\n if len(s) == 0:\n return s, True\n if len(c) == 0:\n return s[::-1], True\n if s[0] == c[0]:\n return reverse_delete(s[1:], c[1:])\n return reverse_delete(s[1:], c), False\n", "from typing import Tuple\n\ndef reverse_delete(s: str, c: str) -> Tuple[str, bool]:\n \"\"\"Task\n We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c\n then check if the result string is palindrome.\n A string is called palindrome if it reads the same backward as forward.\n You should return a tuple containing the result string and True/False for the check.\n Example\n >>> reverse_delete('abcde', 'ae')\n ('bcd', False)\n >>> reverse_delete('abcdef', 'b')\n ('acdef', False)\n >>> reverse_delete('abcdedcba', 'ab')\n ('cdedc', True)\n \"\"\"\n result = ''\n for i in range(len(s)):\n if s[i] == c:\n result += s[i + 1:]\n else:\n result += s[i]\n return result, result == s\n", "from typing import Tuple\n\ndef reverse_delete(s: str, c: str) -> Tuple[str, bool]:\n \"\"\"Task\n We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c\n then check if the result string is palindrome.\n A string is called palindrome if it reads the same backward as forward.\n You should return a tuple containing the result string and True/False for the check.\n Example\n >>> reverse_delete('abcde', 'ae')\n ('bcd', False)\n >>> reverse_delete('abcdef', 'b')\n ('acdef', False)\n >>> reverse_delete('abcdedcba', 'ab')\n ('cdedc', True)\n \"\"\"\n s_len = len(s)\n c_len = len(c)\n if s_len == 0 or c_len == 0:\n return s, False\n if s_len < c_len:\n return s, False\n if s == c:\n return s, True\n if s[0] == c[0]:\n return reverse_delete(s[1:], c[1:])\n return reverse_delete(s[1:], c), True\n", "from typing import Tuple\n\ndef reverse_delete(s: str, c: str) -> Tuple[str, bool]:\n \"\"\"Task\n We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c\n then check if the result string is palindrome.\n A string is called palindrome if it reads the same backward as forward.\n You should return a tuple containing the result string and True/False for the check.\n Example\n >>> reverse_delete('abcde', 'ae')\n ('bcd', False)\n >>> reverse_delete('abcdef', 'b')\n ('acdef', False)\n >>> reverse_delete('abcdedcba', 'ab')\n ('cdedc', True)\n \"\"\"\n s_len = len(s)\n c_len = len(c)\n if s_len < c_len:\n return s, False\n if s_len == c_len:\n if s == c:\n return s, True\n return s, False\n if s[c_len - 1] == c[0]:\n return reverse_delete(s[c_len - 1:], c[1:]), True\n return reverse_delete(s[c_len:], c[1:]), False\n"], ["def greatest_common_divisor(a: int, b: int) -> int:\n \"\"\" Return a greatest common divisor of two integers a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n if a == 0:\n return b\n if b == 0:\n return a\n return greatest_common_divisor(b, a % b)\n\n", "def greatest_common_divisor(a: int, b: int) -> int:\n \"\"\" Return a greatest common divisor of two integers a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\n", "def greatest_common_divisor(a: int, b: int) -> int:\n \"\"\" Return a greatest common divisor of two integers a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\n", "def greatest_common_divisor(a: int, b: int) -> int:\n \"\"\" Return a greatest common divisor of two integers a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n if a == 0:\n return b\n elif b == 0:\n return a\n else:\n return greatest_common_divisor(b, a % b)\n\n", "def greatest_common_divisor(a: int, b: int) -> int:\n \"\"\" Return a greatest common divisor of two integers a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n while b != 0:\n a, b = b, a % b\n return a\n\n"], ["from typing import Union, List\n\ndef split_words(txt: str) -> Union[List[str], int]:\n \"\"\"\n Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you\n should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the\n alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25\n Examples\n >>> split_words('Hello world!')\n ['Hello', 'world!']\n >>> split_words('Hello,world!')\n ['Hello', 'world!']\n >>> split_words('abcdef')\n 3\n \"\"\"\n if not txt:\n return []\n if txt.count(' ') == 0:\n return txt.split(',')\n else:\n return txt.split()\n", "from typing import Union, List\n\ndef split_words(txt: str) -> Union[List[str], int]:\n \"\"\"\n Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you\n should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the\n alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25\n Examples\n >>> split_words('Hello world!')\n ['Hello', 'world!']\n >>> split_words('Hello,world!')\n ['Hello', 'world!']\n >>> split_words('abcdef')\n 3\n \"\"\"\n if txt == '':\n return []\n if txt.count(' ') == 0:\n return txt.split(',')\n if txt.count(',') == 0:\n return [txt.lower()[i:i+1] for i in range(len(txt.lower())) if txt.lower()[i] in 'abcdefghijklmnopqrstuvwxyz']\n return [txt.lower()[i:i+1] for i in range(len(txt.lower())) if txt.lower()[i] in 'abcdefghijklmnopqrstuvwxyz']\n", "from typing import Union, List\n\ndef split_words(txt: str) -> Union[List[str], int]:\n \"\"\"\n Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you\n should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the\n alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25\n Examples\n >>> split_words('Hello world!')\n ['Hello', 'world!']\n >>> split_words('Hello,world!')\n ['Hello', 'world!']\n >>> split_words('abcdef')\n 3\n \"\"\"\n if txt == '':\n return []\n if txt.count(' ') == 0:\n return txt.split(',')\n else:\n return txt.split(' ')\n", "from typing import Union, List\n\ndef split_words(txt: str) -> Union[List[str], int]:\n \"\"\"\n Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you\n should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the\n alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25\n Examples\n >>> split_words('Hello world!')\n ['Hello', 'world!']\n >>> split_words('Hello,world!')\n ['Hello', 'world!']\n >>> split_words('abcdef')\n 3\n \"\"\"\n if not txt:\n return []\n if txt.isspace():\n return txt.split()\n if txt.count(',') == 0:\n return [txt.lower()]\n else:\n return [txt.lower().split(',')]\n", "from typing import Union, List\n\ndef split_words(txt: str) -> Union[List[str], int]:\n \"\"\"\n Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you\n should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the\n alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25\n Examples\n >>> split_words('Hello world!')\n ['Hello', 'world!']\n >>> split_words('Hello,world!')\n ['Hello', 'world!']\n >>> split_words('abcdef')\n 3\n \"\"\"\n if not txt:\n return []\n if txt.isspace():\n return txt.split()\n if txt.count(',') == 0:\n return txt.lower().split()\n else:\n return txt.lower().split(',')\n"], ["from typing import List\n\ndef sort_array(arr: List[int]) -> List[int]:\n \"\"\"\n In this Kata, you have to sort an array of non-negative integers according to\n number of ones in their binary representation in ascending order.\n For similar number of ones, sort based on decimal value.\n\n It must be implemented like this:\n >>> sort_array([1, 5, 2, 3, 4])\n [1, 2, 3, 4, 5]\n >>> sort_array([-2, -3, -4, -5, -6])\n [-6, -5, -4, -3, -2]\n >>> sort_array([1, 0, 2, 3, 4])\n [0, 1, 2, 3, 4]\n \"\"\"\n # Your code here\n return sorted(arr, key=lambda x: x.count('1'))\n", "from typing import List\n\ndef sort_array(arr: List[int]) -> List[int]:\n \"\"\"\n In this Kata, you have to sort an array of non-negative integers according to\n number of ones in their binary representation in ascending order.\n For similar number of ones, sort based on decimal value.\n\n It must be implemented like this:\n >>> sort_array([1, 5, 2, 3, 4])\n [1, 2, 3, 4, 5]\n >>> sort_array([-2, -3, -4, -5, -6])\n [-6, -5, -4, -3, -2]\n >>> sort_array([1, 0, 2, 3, 4])\n [0, 1, 2, 3, 4]\n \"\"\"\n # Your code here\n return sorted(arr, key=lambda x: x if x > 0 else -x)\n", "from typing import List\n\ndef sort_array(arr: List[int]) -> List[int]:\n \"\"\"\n In this Kata, you have to sort an array of non-negative integers according to\n number of ones in their binary representation in ascending order.\n For similar number of ones, sort based on decimal value.\n\n It must be implemented like this:\n >>> sort_array([1, 5, 2, 3, 4])\n [1, 2, 3, 4, 5]\n >>> sort_array([-2, -3, -4, -5, -6])\n [-6, -5, -4, -3, -2]\n >>> sort_array([1, 0, 2, 3, 4])\n [0, 1, 2, 3, 4]\n \"\"\"\n # Your code here\n return sorted(arr, key=lambda x: bin(x).count('1'))\n", "from typing import List\n\ndef sort_array(arr: List[int]) -> List[int]:\n \"\"\"\n In this Kata, you have to sort an array of non-negative integers according to\n number of ones in their binary representation in ascending order.\n For similar number of ones, sort based on decimal value.\n\n It must be implemented like this:\n >>> sort_array([1, 5, 2, 3, 4])\n [1, 2, 3, 4, 5]\n >>> sort_array([-2, -3, -4, -5, -6])\n [-6, -5, -4, -3, -2]\n >>> sort_array([1, 0, 2, 3, 4])\n [0, 1, 2, 3, 4]\n \"\"\"\n # TODO: Write your code here.\n arr.sort(key=lambda x: bin(x).count('1'))\n return arr\n", "from typing import List\n\ndef sort_array(arr: List[int]) -> List[int]:\n \"\"\"\n In this Kata, you have to sort an array of non-negative integers according to\n number of ones in their binary representation in ascending order.\n For similar number of ones, sort based on decimal value.\n\n It must be implemented like this:\n >>> sort_array([1, 5, 2, 3, 4])\n [1, 2, 3, 4, 5]\n >>> sort_array([-2, -3, -4, -5, -6])\n [-6, -5, -4, -3, -2]\n >>> sort_array([1, 0, 2, 3, 4])\n [0, 1, 2, 3, 4]\n \"\"\"\n # Your code here\n return sorted(arr, key=lambda x: x.count('1'))\n"], ["from typing import List\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single string\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n return ''.join(strings)\n", "from typing import List\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single string\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n return ''.join(strings)\n", "from typing import List\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single string\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n return ''.join(strings)\n", "from typing import List\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single string\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n return ''.join(strings)\n", "from typing import List\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single string\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n return ''.join(strings)\n"], ["from typing import List\n\ndef sorted_list_sum(lst: List[str]) -> List[str]:\n \"\"\"Write a function that accepts a list of strings as a parameter,\n deletes the strings that have odd lengths from it,\n and returns the resulted list with a sorted order,\n The list is always a list of strings and never an array of numbers,\n and it may contain duplicates.\n The order of the list should be ascending by length of each word, and you\n should return the list sorted by that rule.\n If two words have the same length, sort the list alphabetically.\n The function should return a list of strings in sorted order.\n You may assume that all words will have the same length.\n For example:\n >>> list_sort(['aa', 'a', 'aaa'])\n ['aa']\n >>> list_sort(['ab', 'a', 'aaa', 'cd'])\n ['ab', 'cd']\n \"\"\"\n result = []\n for word in lst:\n if len(word) % 2 == 1:\n result.append(word)\n result.sort()\n return result\n", "from typing import List\n\ndef sorted_list_sum(lst: List[str]) -> List[str]:\n \"\"\"Write a function that accepts a list of strings as a parameter,\n deletes the strings that have odd lengths from it,\n and returns the resulted list with a sorted order,\n The list is always a list of strings and never an array of numbers,\n and it may contain duplicates.\n The order of the list should be ascending by length of each word, and you\n should return the list sorted by that rule.\n If two words have the same length, sort the list alphabetically.\n The function should return a list of strings in sorted order.\n You may assume that all words will have the same length.\n For example:\n >>> list_sort(['aa', 'a', 'aaa'])\n ['aa']\n >>> list_sort(['ab', 'a', 'aaa', 'cd'])\n ['ab', 'cd']\n \"\"\"\n # Your code here\n return sorted(lst, key=len)\n", "from typing import List\n\ndef sorted_list_sum(lst: List[str]) -> List[str]:\n \"\"\"Write a function that accepts a list of strings as a parameter,\n deletes the strings that have odd lengths from it,\n and returns the resulted list with a sorted order,\n The list is always a list of strings and never an array of numbers,\n and it may contain duplicates.\n The order of the list should be ascending by length of each word, and you\n should return the list sorted by that rule.\n If two words have the same length, sort the list alphabetically.\n The function should return a list of strings in sorted order.\n You may assume that all words will have the same length.\n For example:\n >>> list_sort(['aa', 'a', 'aaa'])\n ['aa']\n >>> list_sort(['ab', 'a', 'aaa', 'cd'])\n ['ab', 'cd']\n \"\"\"\n # Your code here\n return sorted(lst, key=lambda x: len(x))\n", "from typing import List\n\ndef sorted_list_sum(lst: List[str]) -> List[str]:\n \"\"\"Write a function that accepts a list of strings as a parameter,\n deletes the strings that have odd lengths from it,\n and returns the resulted list with a sorted order,\n The list is always a list of strings and never an array of numbers,\n and it may contain duplicates.\n The order of the list should be ascending by length of each word, and you\n should return the list sorted by that rule.\n If two words have the same length, sort the list alphabetically.\n The function should return a list of strings in sorted order.\n You may assume that all words will have the same length.\n For example:\n >>> list_sort(['aa', 'a', 'aaa'])\n ['aa']\n >>> list_sort(['ab', 'a', 'aaa', 'cd'])\n ['ab', 'cd']\n \"\"\"\n # Your code here\n return sorted(lst, key=len)\n", "from typing import List\n\ndef sorted_list_sum(lst: List[str]) -> List[str]:\n \"\"\"Write a function that accepts a list of strings as a parameter,\n deletes the strings that have odd lengths from it,\n and returns the resulted list with a sorted order,\n The list is always a list of strings and never an array of numbers,\n and it may contain duplicates.\n The order of the list should be ascending by length of each word, and you\n should return the list sorted by that rule.\n If two words have the same length, sort the list alphabetically.\n The function should return a list of strings in sorted order.\n You may assume that all words will have the same length.\n For example:\n >>> list_sort(['aa', 'a', 'aaa'])\n ['aa']\n >>> list_sort(['ab', 'a', 'aaa', 'cd'])\n ['ab', 'cd']\n \"\"\"\n return sorted(lst, key=len)\n"], ["from typing import List\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that contain given substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n return [s for s in strings if substring in s]\n", "from typing import List\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that contain given substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n return [s for s in strings if substring in s]\n", "from typing import List\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that contain given substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n return [s for s in strings if substring in s]\n", "from typing import List\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that contain given substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n return [s for s in strings if substring in s]\n", "from typing import List\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that contain given substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n return [s for s in strings if substring in s]\n"], ["def closest_integer(value: str) -> int:\n \"\"\"\n Create a function that takes a value (string) representing a number\n and returns the closest integer to it. If the number is equidistant\n from two integers, round it away from zero.\n\n Examples\n >>> closest_integer('10')\n 10\n >>> closest_integer('15.3')\n 15\n\n Note:\n Rounding away from zero means that if the given number is equidistant\n from two integers, the one you should return is the one that is the\n farthest from zero. For example closest_integer(\"14.5\") should\n return 15 and closest_integer(\"-14.5\") should return -15.\n \"\"\"\n return int(round(float(value)))\n\n", "def closest_integer(value: str) -> int:\n \"\"\"\n Create a function that takes a value (string) representing a number\n and returns the closest integer to it. If the number is equidistant\n from two integers, round it away from zero.\n\n Examples\n >>> closest_integer('10')\n 10\n >>> closest_integer('15.3')\n 15\n\n Note:\n Rounding away from zero means that if the given number is equidistant\n from two integers, the one you should return is the one that is the\n farthest from zero. For example closest_integer(\"14.5\") should\n return 15 and closest_integer(\"-14.5\") should return -15.\n \"\"\"\n return int(round(float(value)))\n\n", "def closest_integer(value: str) -> int:\n \"\"\"\n Create a function that takes a value (string) representing a number\n and returns the closest integer to it. If the number is equidistant\n from two integers, round it away from zero.\n\n Examples\n >>> closest_integer('10')\n 10\n >>> closest_integer('15.3')\n 15\n\n Note:\n Rounding away from zero means that if the given number is equidistant\n from two integers, the one you should return is the one that is the\n farthest from zero. For example closest_integer(\"14.5\") should\n return 15 and closest_integer(\"-14.5\") should return -15.\n \"\"\"\n return round(float(value))\n\n", "def closest_integer(value: str) -> int:\n \"\"\"\n Create a function that takes a value (string) representing a number\n and returns the closest integer to it. If the number is equidistant\n from two integers, round it away from zero.\n\n Examples\n >>> closest_integer('10')\n 10\n >>> closest_integer('15.3')\n 15\n\n Note:\n Rounding away from zero means that if the given number is equidistant\n from two integers, the one you should return is the one that is the\n farthest from zero. For example closest_integer(\"14.5\") should\n return 15 and closest_integer(\"-14.5\") should return -15.\n \"\"\"\n value = float(value)\n if value == 0:\n return 0\n if value == 1:\n return 1\n if value == -1:\n return -1\n if value == 2:\n return 2\n if value == -2:\n return -2\n if value == 3:\n return 3\n if value == -3:\n return -3\n if value == 4:\n return 4\n if value == -4:\n return -4\n if value == 5:\n return 5\n if value == -5:\n return -5\n if value == 6:\n return 6\n if value == -6:\n return -6\n if value == 7:\n return 7\n if value == -7:\n return -7\n if value == 8:\n return 8\n if value == -8:\n return -8\n if value == 9:\n return 9\n if value == -9:\n return -9\n if value == 10:\n return 10\n if value == -10:\n return -10\n if value == 11:\n return 11\n if value == -11:\n return -11\n if value == 12:\n return 12\n if value == -12:\n return -12\n if value == 13:\n return 13\n if value == -13:\n return -13\n if value == 14:\n return 14\n if value == -14:\n return -14\n if value == 1", "def closest_integer(value: str) -> int:\n \"\"\"\n Create a function that takes a value (string) representing a number\n and returns the closest integer to it. If the number is equidistant\n from two integers, round it away from zero.\n\n Examples\n >>> closest_integer('10')\n 10\n >>> closest_integer('15.3')\n 15\n\n Note:\n Rounding away from zero means that if the given number is equidistant\n from two integers, the one you should return is the one that is the\n farthest from zero. For example closest_integer(\"14.5\") should\n return 15 and closest_integer(\"-14.5\") should return -15.\n \"\"\"\n return int(round(float(value)))\n\n"], ["def vowels_count(s: str) -> int:\n \"\"\"Write a function vowels_count which takes a string representing\n a word as input and returns the number of vowels in the string.\n Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a\n vowel, but only when it is at the end of the given word.\n\n Example:\n >>> vowels_count('abcde')\n 2\n >>> vowels_count('ACEDY')\n 3\n \"\"\"\n return sum(1 for c in s if c in 'aeiou')\n\n", "def vowels_count(s: str) -> int:\n \"\"\"Write a function vowels_count which takes a string representing\n a word as input and returns the number of vowels in the string.\n Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a\n vowel, but only when it is at the end of the given word.\n\n Example:\n >>> vowels_count('abcde')\n 2\n >>> vowels_count('ACEDY')\n 3\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u', 'y']\n return sum(vowels.count(c) for c in s)\n\n", "def vowels_count(s: str) -> int:\n \"\"\"Write a function vowels_count which takes a string representing\n a word as input and returns the number of vowels in the string.\n Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a\n vowel, but only when it is at the end of the given word.\n\n Example:\n >>> vowels_count('abcde')\n 2\n >>> vowels_count('ACEDY')\n 3\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u', 'y']\n return len([x for x in s if x in vowels])\n\n", "def vowels_count(s: str) -> int:\n \"\"\"Write a function vowels_count which takes a string representing\n a word as input and returns the number of vowels in the string.\n Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a\n vowel, but only when it is at the end of the given word.\n\n Example:\n >>> vowels_count('abcde')\n 2\n >>> vowels_count('ACEDY')\n 3\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u', 'y']\n count = 0\n for char in s:\n if char in vowels:\n count += 1\n return count\n\n", "def vowels_count(s: str) -> int:\n \"\"\"Write a function vowels_count which takes a string representing\n a word as input and returns the number of vowels in the string.\n Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a\n vowel, but only when it is at the end of the given word.\n\n Example:\n >>> vowels_count('abcde')\n 2\n >>> vowels_count('ACEDY')\n 3\n \"\"\"\n vowels = ['a', 'e', 'i', 'o', 'u', 'y']\n return sum(1 for vowel in vowels if s.endswith(vowel))\n\n"], ["from typing import List\n\ndef find_max(words: List[str]) -> str:\n \"\"\"Write a function that accepts a list of strings.\n The list contains different words. Return the word with maximum number\n of unique characters. If multiple strings have maximum number of unique\n characters, return the one which comes first in lexicographical order.\n\n >>> find_max(['name', 'of', 'string'])\n 'string'\n >>> find_max(['name', 'enam', 'game'])\n 'enam'\n >>> find_max(['aaaaaaa', 'bb', 'cc'])\n 'aaaaaaa'\n \"\"\"\n word_dict = {}\n for word in words:\n for char in word:\n if char in word_dict:\n word_dict[char] += 1\n else:\n word_dict[char] = 1\n max_char = max(word_dict, key=word_dict.get)\n return max_char\n", "from typing import List\n\ndef find_max(words: List[str]) -> str:\n \"\"\"Write a function that accepts a list of strings.\n The list contains different words. Return the word with maximum number\n of unique characters. If multiple strings have maximum number of unique\n characters, return the one which comes first in lexicographical order.\n\n >>> find_max(['name', 'of', 'string'])\n 'string'\n >>> find_max(['name', 'enam', 'game'])\n 'enam'\n >>> find_max(['aaaaaaa', 'bb', 'cc'])\n 'aaaaaaa'\n \"\"\"\n # Write your code here.\n return max(set(words), key=words.count)\n", "from typing import List\n\ndef find_max(words: List[str]) -> str:\n \"\"\"Write a function that accepts a list of strings.\n The list contains different words. Return the word with maximum number\n of unique characters. If multiple strings have maximum number of unique\n characters, return the one which comes first in lexicographical order.\n\n >>> find_max(['name', 'of', 'string'])\n 'string'\n >>> find_max(['name', 'enam', 'game'])\n 'enam'\n >>> find_max(['aaaaaaa', 'bb', 'cc'])\n 'aaaaaaa'\n \"\"\"\n return max(set(words), key=words.count)\n", "from typing import List\n\ndef find_max(words: List[str]) -> str:\n \"\"\"Write a function that accepts a list of strings.\n The list contains different words. Return the word with maximum number\n of unique characters. If multiple strings have maximum number of unique\n characters, return the one which comes first in lexicographical order.\n\n >>> find_max(['name', 'of', 'string'])\n 'string'\n >>> find_max(['name', 'enam', 'game'])\n 'enam'\n >>> find_max(['aaaaaaa', 'bb', 'cc'])\n 'aaaaaaa'\n \"\"\"\n if not words:\n return ''\n word_count = {}\n for word in words:\n for char in word:\n if char in word_count:\n word_count[char] += 1\n else:\n word_count[char] = 1\n max_count = 0\n max_word = ''\n for char in word_count:\n if word_count[char] > max_count:\n max_count = word_count[char]\n max_word = char\n return max_word\n", "from typing import List\n\ndef find_max(words: List[str]) -> str:\n \"\"\"Write a function that accepts a list of strings.\n The list contains different words. Return the word with maximum number\n of unique characters. If multiple strings have maximum number of unique\n characters, return the one which comes first in lexicographical order.\n\n >>> find_max(['name', 'of', 'string'])\n 'string'\n >>> find_max(['name', 'enam', 'game'])\n 'enam'\n >>> find_max(['aaaaaaa', 'bb', 'cc'])\n 'aaaaaaa'\n \"\"\"\n return max(set(words), key=words.count)\n"], ["from typing import Optional\n\ndef string_to_md5(text: str) -> Optional[str]:\n \"\"\"\n Given a string 'text', return its md5 hash equivalent string.\n If 'text' is an empty string, return None.\n\n >>> string_to_md5('Hello world')\n '3e25960a79dbc69b674cd4ec67a72c62'\n \"\"\"\n if not text:\n return None\n return hashlib.md5(text.encode('utf-8')).hexdigest()\n", "from typing import Optional\n\ndef string_to_md5(text: str) -> Optional[str]:\n \"\"\"\n Given a string 'text', return its md5 hash equivalent string.\n If 'text' is an empty string, return None.\n\n >>> string_to_md5('Hello world')\n '3e25960a79dbc69b674cd4ec67a72c62'\n \"\"\"\n if not text:\n return None\n return hashlib.md5(text.encode('utf-8')).hexdigest()\n", "from typing import Optional\n\ndef string_to_md5(text: str) -> Optional[str]:\n \"\"\"\n Given a string 'text', return its md5 hash equivalent string.\n If 'text' is an empty string, return None.\n\n >>> string_to_md5('Hello world')\n '3e25960a79dbc69b674cd4ec67a72c62'\n \"\"\"\n if text == '':\n return None\n return hashlib.md5(text.encode('utf-8')).hexdigest()\n", "from typing import Optional\n\ndef string_to_md5(text: str) -> Optional[str]:\n \"\"\"\n Given a string 'text', return its md5 hash equivalent string.\n If 'text' is an empty string, return None.\n\n >>> string_to_md5('Hello world')\n '3e25960a79dbc69b674cd4ec67a72c62'\n \"\"\"\n if text == '':\n return None\n return hashlib.md5(text.encode('utf-8')).hexdigest()\n", "from typing import Optional\n\ndef string_to_md5(text: str) -> Optional[str]:\n \"\"\"\n Given a string 'text', return its md5 hash equivalent string.\n If 'text' is an empty string, return None.\n\n >>> string_to_md5('Hello world')\n '3e25960a79dbc69b674cd4ec67a72c62'\n \"\"\"\n if text == '':\n return None\n return hashlib.md5(text.encode('utf-8')).hexdigest()\n"], ["def change_base(x: int, base: int) -> str:\n \"\"\"Change numerical base of input number x to base.\n return string representation after the conversion.\n base numbers are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n \"\"\"\n if base < 10:\n return str(x)\n else:\n return str(int(x, base))\n\n", "def change_base(x: int, base: int) -> str:\n \"\"\"Change numerical base of input number x to base.\n return string representation after the conversion.\n base numbers are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n \"\"\"\n if base < 10:\n return str(x)\n else:\n return str(int(x, base))\n\n", "def change_base(x: int, base: int) -> str:\n \"\"\"Change numerical base of input number x to base.\n return string representation after the conversion.\n base numbers are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n \"\"\"\n if base < 10:\n return str(x)\n else:\n return str(int(x, base))\n\n", "def change_base(x: int, base: int) -> str:\n \"\"\"Change numerical base of input number x to base.\n return string representation after the conversion.\n base numbers are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n \"\"\"\n if base < 10:\n return str(x)\n else:\n return str(base ** (x // base))\n\n", "def change_base(x: int, base: int) -> str:\n \"\"\"Change numerical base of input number x to base.\n return string representation after the conversion.\n base numbers are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n \"\"\"\n if base < 10:\n return str(x)\n else:\n return str(x)[::-1].zfill(base)\n\n"], ["def right_angle_triangle(a: int, b: int, c: int) -> bool:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return True if the three\n sides form a right-angled triangle, False otherwise.\n A right-angled triangle is a triangle in which one angle is right angle or \n 90 degree.\n Example:\n >>> right_angle_triangle(3, 4, 5)\n True\n >>> right_angle_triangle(1, 2, 3)\n False\n \"\"\"\n return a + b > c and a + c > b and b + c > a\n\n", "def right_angle_triangle(a: int, b: int, c: int) -> bool:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return True if the three\n sides form a right-angled triangle, False otherwise.\n A right-angled triangle is a triangle in which one angle is right angle or \n 90 degree.\n Example:\n >>> right_angle_triangle(3, 4, 5)\n True\n >>> right_angle_triangle(1, 2, 3)\n False\n \"\"\"\n return a + b > c and a + c > b and b + c > a\n\n", "def right_angle_triangle(a: int, b: int, c: int) -> bool:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return True if the three\n sides form a right-angled triangle, False otherwise.\n A right-angled triangle is a triangle in which one angle is right angle or \n 90 degree.\n Example:\n >>> right_angle_triangle(3, 4, 5)\n True\n >>> right_angle_triangle(1, 2, 3)\n False\n \"\"\"\n return a + b > c and a + c > b and b + c > a\n\n", "def right_angle_triangle(a: int, b: int, c: int) -> bool:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return True if the three\n sides form a right-angled triangle, False otherwise.\n A right-angled triangle is a triangle in which one angle is right angle or \n 90 degree.\n Example:\n >>> right_angle_triangle(3, 4, 5)\n True\n >>> right_angle_triangle(1, 2, 3)\n False\n \"\"\"\n return a + b > c and a + c > b and b + c > a\n\n", "def right_angle_triangle(a: int, b: int, c: int) -> bool:\n \"\"\"\n Given the lengths of the three sides of a triangle. Return True if the three\n sides form a right-angled triangle, False otherwise.\n A right-angled triangle is a triangle in which one angle is right angle or \n 90 degree.\n Example:\n >>> right_angle_triangle(3, 4, 5)\n True\n >>> right_angle_triangle(1, 2, 3)\n False\n \"\"\"\n return a + b > c and a + c > b and b + c > a\n\n"], ["from typing import List\n\ndef numerical_letter_grade(grades: List[float]) -> List[str]:\n \"\"\"It is the last week of the semester and the teacher has to give the grades\n to students. The teacher has been making her own algorithm for grading.\n The only problem is, she has lost the code she used for grading.\n She has given you a list of GPAs for some students and you have to write \n a function that can output a list of letter grades using the following table:\n GPA | Letter grade\n 4.0 A+\n > 3.7 A \n > 3.3 A- \n > 3.0 B+\n > 2.7 B \n > 2.3 B-\n > 2.0 C+\n > 1.7 C\n > 1.3 C-\n > 1.0 D+ \n > 0.7 D \n > 0.0 D-\n 0.0 E\n \n\n Example:\n >>> grade_equation([4.0, 3, 1.7, 2, 3.5])\n ['A+', 'B', 'C-', 'C', 'A-']\n \"\"\"\n return [f'{round(g, 2)}' for g in grades]\n", "from typing import List\n\ndef numerical_letter_grade(grades: List[float]) -> List[str]:\n \"\"\"It is the last week of the semester and the teacher has to give the grades\n to students. The teacher has been making her own algorithm for grading.\n The only problem is, she has lost the code she used for grading.\n She has given you a list of GPAs for some students and you have to write \n a function that can output a list of letter grades using the following table:\n GPA | Letter grade\n 4.0 A+\n > 3.7 A \n > 3.3 A- \n > 3.0 B+\n > 2.7 B \n > 2.3 B-\n > 2.0 C+\n > 1.7 C\n > 1.3 C-\n > 1.0 D+ \n > 0.7 D \n > 0.0 D-\n 0.0 E\n \n\n Example:\n >>> grade_equation([4.0, 3, 1.7, 2, 3.5])\n ['A+', 'B', 'C-', 'C', 'A-']\n \"\"\"\n letter_grades = []\n for grade in grades:\n if grade >= 4.0:\n letter_grades.append('A+')\n elif grade >= 3.7:\n letter_grades.append('A')\n elif grade >= 3.3:\n letter_grades.append('A-')\n elif grade >= 3.0:\n letter_grades.append('B+')\n elif grade >= 2.7:\n letter_grades.append('B')\n elif grade >= 2.3:\n letter_grades.append('B-')\n elif grade >= 2.0:\n letter_grades.append('C+')\n elif grade >= 1.7:\n letter_grades.append('C')\n elif grade >= 1.3:\n letter_grades.append('C-')\n elif grade >= 1.0:\n letter_grades.append('D+')\n elif grade >= 0.7:\n letter_grades.append('D')\n elif grade >= 0.0:\n letter_grades.append('D-')\n else:\n letter_", "from typing import List\n\ndef numerical_letter_grade(grades: List[float]) -> List[str]:\n \"\"\"It is the last week of the semester and the teacher has to give the grades\n to students. The teacher has been making her own algorithm for grading.\n The only problem is, she has lost the code she used for grading.\n She has given you a list of GPAs for some students and you have to write \n a function that can output a list of letter grades using the following table:\n GPA | Letter grade\n 4.0 A+\n > 3.7 A \n > 3.3 A- \n > 3.0 B+\n > 2.7 B \n > 2.3 B-\n > 2.0 C+\n > 1.7 C\n > 1.3 C-\n > 1.0 D+ \n > 0.7 D \n > 0.0 D-\n 0.0 E\n \n\n Example:\n >>> grade_equation([4.0, 3, 1.7, 2, 3.5])\n ['A+', 'B', 'C-', 'C', 'A-']\n \"\"\"\n return [f'{round(g, 2)}' for g in grades]\n", "from typing import List\n\ndef numerical_letter_grade(grades: List[float]) -> List[str]:\n \"\"\"It is the last week of the semester and the teacher has to give the grades\n to students. The teacher has been making her own algorithm for grading.\n The only problem is, she has lost the code she used for grading.\n She has given you a list of GPAs for some students and you have to write \n a function that can output a list of letter grades using the following table:\n GPA | Letter grade\n 4.0 A+\n > 3.7 A \n > 3.3 A- \n > 3.0 B+\n > 2.7 B \n > 2.3 B-\n > 2.0 C+\n > 1.7 C\n > 1.3 C-\n > 1.0 D+ \n > 0.7 D \n > 0.0 D-\n 0.0 E\n \n\n Example:\n >>> grade_equation([4.0, 3, 1.7, 2, 3.5])\n ['A+', 'B', 'C-', 'C', 'A-']\n \"\"\"\n letter_grades = []\n for grade in grades:\n if grade >= 3.7:\n letter_grades.append('A+')\n elif grade >= 3.3:\n letter_grades.append('A')\n elif grade >= 3.0:\n letter_grades.append('A-')\n elif grade >= 2.7:\n letter_grades.append('B+')\n elif grade >= 2.3:\n letter_grades.append('B')\n elif grade >= 2.0:\n letter_grades.append('B-')\n elif grade >= 1.7:\n letter_grades.append('C+')\n elif grade >= 1.3:\n letter_grades.append('C')\n elif grade >= 1.0:\n letter_grades.append('C-')\n elif grade >= 0.7:\n letter_grades.append('D+')\n elif grade >= 0.0:\n letter_grades.append('D')\n else:\n letter_grades.append('D-')\n return letter_grades\n", "from typing import List\n\ndef numerical_letter_grade(grades: List[float]) -> List[str]:\n \"\"\"It is the last week of the semester and the teacher has to give the grades\n to students. The teacher has been making her own algorithm for grading.\n The only problem is, she has lost the code she used for grading.\n She has given you a list of GPAs for some students and you have to write \n a function that can output a list of letter grades using the following table:\n GPA | Letter grade\n 4.0 A+\n > 3.7 A \n > 3.3 A- \n > 3.0 B+\n > 2.7 B \n > 2.3 B-\n > 2.0 C+\n > 1.7 C\n > 1.3 C-\n > 1.0 D+ \n > 0.7 D \n > 0.0 D-\n 0.0 E\n \n\n Example:\n >>> grade_equation([4.0, 3, 1.7, 2, 3.5])\n ['A+', 'B', 'C-', 'C', 'A-']\n \"\"\"\n letter_grades = []\n for grade in grades:\n if grade >= 3.7:\n letter_grades.append('A+')\n elif grade >= 3.3:\n letter_grades.append('A')\n elif grade >= 3.0:\n letter_grades.append('A-')\n elif grade >= 2.7:\n letter_grades.append('B+')\n elif grade >= 2.3:\n letter_grades.append('B')\n elif grade >= 2.0:\n letter_grades.append('B-')\n elif grade >= 1.7:\n letter_grades.append('C+')\n elif grade >= 1.3:\n letter_grades.append('C')\n elif grade >= 1.0:\n letter_grades.append('C-')\n elif grade >= 0.7:\n letter_grades.append('D+')\n elif grade >= 0.0:\n letter_grades.append('D')\n else:\n letter_grades.append('D-')\n return letter_grades\n"], ["from typing import List\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n return [*numbers, delimeter]\n", "from typing import List\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n return [*numbers[0::2], delimeter, *numbers[1::2]]\n", "from typing import List\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n return [*numbers[0::2], delimeter, *numbers[1::2]]\n", "from typing import List\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n return [*numbers, delimeter]\n", "from typing import List\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n return [*numbers, *numbers[1::delimeter]]\n"], ["from typing import List\n\ndef specialFilter(nums: List[int]) -> int:\n \"\"\"Write a function that takes an array of numbers as input and returns \n the number of elements in the array that are greater than 10 and both \n first and last digits of a number are odd (1, 3, 5, 7, 9).\n For example:\n >>> specialFilter([15, -73, 14, -15])\n 1\n >>> specialFilter([33, -2, -3, 45, 21, 109])\n 2\n \"\"\"\n return sum(1 for num in nums if num > 10 and (num % 2 == 0 or num % 10 == 0))\n", "from typing import List\n\ndef specialFilter(nums: List[int]) -> int:\n \"\"\"Write a function that takes an array of numbers as input and returns \n the number of elements in the array that are greater than 10 and both \n first and last digits of a number are odd (1, 3, 5, 7, 9).\n For example:\n >>> specialFilter([15, -73, 14, -15])\n 1\n >>> specialFilter([33, -2, -3, 45, 21, 109])\n 2\n \"\"\"\n oddCount = 0\n for num in nums:\n if num > 10 and num % 2 == 1:\n oddCount += 1\n return oddCount\n", "from typing import List\n\ndef specialFilter(nums: List[int]) -> int:\n \"\"\"Write a function that takes an array of numbers as input and returns \n the number of elements in the array that are greater than 10 and both \n first and last digits of a number are odd (1, 3, 5, 7, 9).\n For example:\n >>> specialFilter([15, -73, 14, -15])\n 1\n >>> specialFilter([33, -2, -3, 45, 21, 109])\n 2\n \"\"\"\n return sum(1 for i in nums if i > 10 and (i % 2 == 1 or i % 10 == 3 or i % 10 == 5 or i % 10 == 7 or i % 10 == 9))\n", "from typing import List\n\ndef specialFilter(nums: List[int]) -> int:\n \"\"\"Write a function that takes an array of numbers as input and returns \n the number of elements in the array that are greater than 10 and both \n first and last digits of a number are odd (1, 3, 5, 7, 9).\n For example:\n >>> specialFilter([15, -73, 14, -15])\n 1\n >>> specialFilter([33, -2, -3, 45, 21, 109])\n 2\n \"\"\"\n odd = 0\n for num in nums:\n if num > 10 and num % 2 == 1:\n odd += 1\n return odd\n", "from typing import List\n\ndef specialFilter(nums: List[int]) -> int:\n \"\"\"Write a function that takes an array of numbers as input and returns \n the number of elements in the array that are greater than 10 and both \n first and last digits of a number are odd (1, 3, 5, 7, 9).\n For example:\n >>> specialFilter([15, -73, 14, -15])\n 1\n >>> specialFilter([33, -2, -3, 45, 21, 109])\n 2\n \"\"\"\n return sum(1 for n in nums if n > 10 and n % 2 == 1)\n"], ["def sum_to_n(n: int) -> int:\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n return sum(range(1, n + 1))\n\n", "def sum_to_n(n: int) -> int:\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n return sum(range(1, n + 1))\n\n", "def sum_to_n(n: int) -> int:\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n return sum(range(1, n + 1))\n\n", "def sum_to_n(n: int) -> int:\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n return sum(range(1, n + 1))\n\n", "def sum_to_n(n: int) -> int:\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n return sum(range(1, n + 1))\n\n"], ["from typing import List\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers, remove all elements that occur more than once.\n Keep order of elements left the same as in the input.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n return list(set(numbers))\n", "from typing import List\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers, remove all elements that occur more than once.\n Keep order of elements left the same as in the input.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n return list(dict.fromkeys(numbers))\n", "from typing import List\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers, remove all elements that occur more than once.\n Keep order of elements left the same as in the input.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n return list(set(numbers))\n", "from typing import List\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers, remove all elements that occur more than once.\n Keep order of elements left the same as in the input.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n seen = set()\n seen_add = seen.add\n return [x for x in numbers if not (x in seen or seen_add(x))]\n", "from typing import List\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers, remove all elements that occur more than once.\n Keep order of elements left the same as in the input.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n seen = set()\n return [x for x in numbers if x not in seen and not seen.add(x)]\n"], ["from typing import List\n\ndef generate_integers(a: int, b: int) -> List[int]:\n \"\"\"\n Given two positive integers a and b, return the even digits between a\n and b, in ascending order.\n\n For example:\n >>> generate_integers(2, 8)\n [2, 4, 6, 8]\n >>> generate_integers(8, 2)\n [2, 4, 6, 8]\n >>> generate_integers(10, 14)\n []\n \"\"\"\n result = []\n for i in range(a, b + 1):\n if i % 10 == 0:\n result.append(i)\n return result\n", "from typing import List\n\ndef generate_integers(a: int, b: int) -> List[int]:\n \"\"\"\n Given two positive integers a and b, return the even digits between a\n and b, in ascending order.\n\n For example:\n >>> generate_integers(2, 8)\n [2, 4, 6, 8]\n >>> generate_integers(8, 2)\n [2, 4, 6, 8]\n >>> generate_integers(10, 14)\n []\n \"\"\"\n return [i for i in range(a, b+1) if i % 2 == 0]\n", "from typing import List\n\ndef generate_integers(a: int, b: int) -> List[int]:\n \"\"\"\n Given two positive integers a and b, return the even digits between a\n and b, in ascending order.\n\n For example:\n >>> generate_integers(2, 8)\n [2, 4, 6, 8]\n >>> generate_integers(8, 2)\n [2, 4, 6, 8]\n >>> generate_integers(10, 14)\n []\n \"\"\"\n return [i for i in range(a, b+1) if i % 2 == 0]\n", "from typing import List\n\ndef generate_integers(a: int, b: int) -> List[int]:\n \"\"\"\n Given two positive integers a and b, return the even digits between a\n and b, in ascending order.\n\n For example:\n >>> generate_integers(2, 8)\n [2, 4, 6, 8]\n >>> generate_integers(8, 2)\n [2, 4, 6, 8]\n >>> generate_integers(10, 14)\n []\n \"\"\"\n return [i for i in range(a, b+1) if i % 2 == 0]\n", "from typing import List\n\ndef generate_integers(a: int, b: int) -> List[int]:\n \"\"\"\n Given two positive integers a and b, return the even digits between a\n and b, in ascending order.\n\n For example:\n >>> generate_integers(2, 8)\n [2, 4, 6, 8]\n >>> generate_integers(8, 2)\n [2, 4, 6, 8]\n >>> generate_integers(10, 14)\n []\n \"\"\"\n return [i for i in range(a, b+1) if i % 2 == 0]\n"], ["from typing import List\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" From a given list of integers, generate a list of rolling maximum element found until given moment\n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n return [max(numbers[i:i+3]) for i in range(len(numbers)-2)]\n", "from typing import List\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" From a given list of integers, generate a list of rolling maximum element found until given moment\n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n max_list = []\n for i in range(len(numbers)):\n max_list.append(max(numbers[i-3:i+1]))\n return max_list\n", "from typing import List\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" From a given list of integers, generate a list of rolling maximum element found until given moment\n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n if len(numbers) == 0:\n return []\n if len(numbers) == 1:\n return [max(numbers)]\n if len(numbers) == 2:\n return [max(numbers), max(numbers)]\n if len(numbers) == 3:\n return [max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 4:\n return [max(numbers), max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 5:\n return [max(numbers), max(numbers), max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 6:\n return [max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 7:\n return [max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 8:\n return [max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 9:\n return [max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 10:\n return [max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers)]\n if len(numbers) == 11:\n return [max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max(numbers), max", "from typing import List\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" From a given list of integers, generate a list of rolling maximum element found until given moment\n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n result = []\n for i in range(len(numbers)):\n result.append(max(numbers[i - 1:i + 1]))\n return result\n", "from typing import List\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" From a given list of integers, generate a list of rolling maximum element found until given moment\n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n if not numbers:\n return []\n max_number = max(numbers)\n max_index = numbers.index(max_number)\n rolling_max = [max_number]\n for i in range(max_index + 1, len(numbers)):\n rolling_max.append(max(numbers[i - max_index - 1:i + 1]))\n return rolling_max\n"], ["from typing import List\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're given a list of deposit and withdrawal operations on a bank account that starts with\n zero balance. Your task is to detect if at any point the balance of account fallls below zero, and\n at that point function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n for operation in operations:\n if operation < 0:\n return True\n return False\n", "from typing import List\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're given a list of deposit and withdrawal operations on a bank account that starts with\n zero balance. Your task is to detect if at any point the balance of account fallls below zero, and\n at that point function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n for operation in operations:\n if operation < 0:\n return True\n return False\n", "from typing import List\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're given a list of deposit and withdrawal operations on a bank account that starts with\n zero balance. Your task is to detect if at any point the balance of account fallls below zero, and\n at that point function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n balance = 0\n for operation in operations:\n if operation > 0:\n balance += operation\n elif operation < 0:\n balance -= operation\n return balance < 0\n", "from typing import List\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're given a list of deposit and withdrawal operations on a bank account that starts with\n zero balance. Your task is to detect if at any point the balance of account fallls below zero, and\n at that point function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n for operation in operations:\n if operation < 0:\n return True\n return False\n", "from typing import List\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're given a list of deposit and withdrawal operations on a bank account that starts with\n zero balance. Your task is to detect if at any point the balance of account fallls below zero, and\n at that point function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n for operation in operations:\n if operation > 0:\n return False\n return True\n"], ["from typing import List\n\ndef search(lst: List[int]) -> int:\n \"\"\"\n You are given a non-empty list of positive integers. Return the greatest integer that is greater than \n zero, and has a frequency greater than or equal to the value of the integer itself. \n The frequency of an integer is the number of times it appears in the list.\n If no such a value exist, return -1.\n Examples:\n >>> search([4, 1, 2, 2, 3, 1])\n 2\n >>> search([1, 2, 2, 3, 3, 3, 4, 4, 4])\n 3\n >>> search([5, 5, 4, 4, 4])\n -1\n \"\"\"\n # Your code here\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n for i in freq:\n if freq[i] >= len(lst):\n return i\n return -1\n", "from typing import List\n\ndef search(lst: List[int]) -> int:\n \"\"\"\n You are given a non-empty list of positive integers. Return the greatest integer that is greater than \n zero, and has a frequency greater than or equal to the value of the integer itself. \n The frequency of an integer is the number of times it appears in the list.\n If no such a value exist, return -1.\n Examples:\n >>> search([4, 1, 2, 2, 3, 1])\n 2\n >>> search([1, 2, 2, 3, 3, 3, 4, 4, 4])\n 3\n >>> search([5, 5, 4, 4, 4])\n -1\n \"\"\"\n # Your code here\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n for i in freq:\n if freq[i] >= len(lst) // 2:\n return i\n return -1\n", "from typing import List\n\ndef search(lst: List[int]) -> int:\n \"\"\"\n You are given a non-empty list of positive integers. Return the greatest integer that is greater than \n zero, and has a frequency greater than or equal to the value of the integer itself. \n The frequency of an integer is the number of times it appears in the list.\n If no such a value exist, return -1.\n Examples:\n >>> search([4, 1, 2, 2, 3, 1])\n 2\n >>> search([1, 2, 2, 3, 3, 3, 4, 4, 4])\n 3\n >>> search([5, 5, 4, 4, 4])\n -1\n \"\"\"\n # Write your code here\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n for i in freq:\n if freq[i] >= len(lst):\n return i\n return -1\n", "from typing import List\n\ndef search(lst: List[int]) -> int:\n \"\"\"\n You are given a non-empty list of positive integers. Return the greatest integer that is greater than \n zero, and has a frequency greater than or equal to the value of the integer itself. \n The frequency of an integer is the number of times it appears in the list.\n If no such a value exist, return -1.\n Examples:\n >>> search([4, 1, 2, 2, 3, 1])\n 2\n >>> search([1, 2, 2, 3, 3, 3, 4, 4, 4])\n 3\n >>> search([5, 5, 4, 4, 4])\n -1\n \"\"\"\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n for i in freq:\n if freq[i] >= len(lst):\n return i\n return -1\n", "from typing import List\n\ndef search(lst: List[int]) -> int:\n \"\"\"\n You are given a non-empty list of positive integers. Return the greatest integer that is greater than \n zero, and has a frequency greater than or equal to the value of the integer itself. \n The frequency of an integer is the number of times it appears in the list.\n If no such a value exist, return -1.\n Examples:\n >>> search([4, 1, 2, 2, 3, 1])\n 2\n >>> search([1, 2, 2, 3, 3, 3, 4, 4, 4])\n 3\n >>> search([5, 5, 4, 4, 4])\n -1\n \"\"\"\n # Your code here\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n for i in freq:\n if freq[i] >= len(lst) // 2:\n return i\n return -1\n"], ["def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('(')\n False\n >>> correct_bracketing('()')\n True\n >>> correct_bracketing('(()())')\n True\n >>> correct_bracketing(')(()')\n False\n \"\"\"\n stack = []\n for bracket in brackets:\n if bracket == '(':\n stack.append(bracket)\n elif bracket == ')':\n if len(stack) == 0:\n return False\n if stack[-1] != '(':\n return False\n stack.pop()\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('(')\n False\n >>> correct_bracketing('()')\n True\n >>> correct_bracketing('(()())')\n True\n >>> correct_bracketing(')(()')\n False\n \"\"\"\n stack = []\n for char in brackets:\n if char == '(':\n stack.append(char)\n elif char == ')':\n if len(stack) == 0:\n return False\n else:\n stack.pop()\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('(')\n False\n >>> correct_bracketing('()')\n True\n >>> correct_bracketing('(()())')\n True\n >>> correct_bracketing(')(()')\n False\n \"\"\"\n stack = []\n for bracket in brackets:\n if bracket == '(':\n stack.append(bracket)\n elif bracket == ')':\n if len(stack) == 0:\n return False\n elif stack.pop() != bracket:\n return False\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('(')\n False\n >>> correct_bracketing('()')\n True\n >>> correct_bracketing('(()())')\n True\n >>> correct_bracketing(')(()')\n False\n \"\"\"\n stack = []\n for bracket in brackets:\n if bracket == '(':\n stack.append(bracket)\n elif bracket == ')':\n if len(stack) == 0:\n return False\n else:\n stack.pop()\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('(')\n False\n >>> correct_bracketing('()')\n True\n >>> correct_bracketing('(()())')\n True\n >>> correct_bracketing(')(()')\n False\n \"\"\"\n stack = []\n for bracket in brackets:\n if bracket == '(':\n stack.append(bracket)\n elif bracket == ')':\n if len(stack) == 0:\n return False\n else:\n stack.pop()\n return len(stack) == 0\n\n"], ["from typing import List\n\ndef sort_even(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the odd indicies, while its values at the even indicies are equal\n to the values of the even indicies of l, but sorted.\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\n \"\"\"\n l.sort()\n for i in range(len(l) - 1, 0, -2):\n if l[i] % 2 == 0:\n l[i], l[i - 1] = l[i - 1], l[i]\n return l\n", "from typing import List\n\ndef sort_even(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the odd indicies, while its values at the even indicies are equal\n to the values of the even indicies of l, but sorted.\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\n \"\"\"\n l.sort()\n for i in range(len(l) // 2):\n l[i], l[len(l) - i - 1] = l[len(l) - i - 1], l[i]\n return l\n", "from typing import List\n\ndef sort_even(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the odd indicies, while its values at the even indicies are equal\n to the values of the even indicies of l, but sorted.\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\n \"\"\"\n l.sort()\n for i in range(len(l)):\n if i % 2 == 0:\n l[i] = l[i] + l[i+1]\n l[i+1] = l[i] - l[i+1]\n l[i] = l[i] - l[i+1]\n return l\n", "from typing import List\n\ndef sort_even(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the odd indicies, while its values at the even indicies are equal\n to the values of the even indicies of l, but sorted.\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\n \"\"\"\n l.sort()\n for i in range(len(l)):\n if i % 2 == 0:\n l[i], l[i+1] = l[i+1], l[i]\n return l\n", "from typing import List\n\ndef sort_even(l: List[int]) -> List[int]:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the odd indicies, while its values at the even indicies are equal\n to the values of the even indicies of l, but sorted.\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\n \"\"\"\n l.sort()\n for i in range(len(l)):\n if i % 2 == 0:\n l[i], l[i+1] = l[i+1], l[i]\n return l\n"], ["def same_chars(s0: str, s1: str) -> bool:\n \"\"\"\n Check if two words have the same characters.\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n if len(s0) != len(s1):\n return False\n for i in range(len(s0)):\n if s0[i] != s1[i]:\n return False\n return True\n\n", "def same_chars(s0: str, s1: str) -> bool:\n \"\"\"\n Check if two words have the same characters.\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n return set(s0) == set(s1)\n\n", "def same_chars(s0: str, s1: str) -> bool:\n \"\"\"\n Check if two words have the same characters.\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n if len(s0) != len(s1):\n return False\n return all(c0 == c1 for c0, c1 in zip(s0, s1))\n\n", "def same_chars(s0: str, s1: str) -> bool:\n \"\"\"\n Check if two words have the same characters.\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n return len(set(s0) & set(s1)) == len(s0)\n\n", "def same_chars(s0: str, s1: str) -> bool:\n \"\"\"\n Check if two words have the same characters.\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n if len(s0) != len(s1):\n return False\n return all(s0[i] == s1[i] for i in range(len(s0)))\n\n"], ["def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('<')\n False\n >>> correct_bracketing('<>')\n True\n >>> correct_bracketing('<<><>>')\n True\n >>> correct_bracketing('><<>')\n False\n \"\"\"\n stack = []\n for c in brackets:\n if c == '<':\n stack.append('<')\n elif c == '>':\n if len(stack) == 0:\n return False\n else:\n stack.pop()\n else:\n return False\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('<')\n False\n >>> correct_bracketing('<>')\n True\n >>> correct_bracketing('<<><>>')\n True\n >>> correct_bracketing('><<>')\n False\n \"\"\"\n stack = []\n for char in brackets:\n if char == '<':\n stack.append('<')\n elif char == '>':\n if len(stack) == 0:\n return False\n if stack.pop() != '>':\n return False\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('<')\n False\n >>> correct_bracketing('<>')\n True\n >>> correct_bracketing('<<><>>')\n True\n >>> correct_bracketing('><<>')\n False\n \"\"\"\n stack = []\n for bracket in brackets:\n if bracket == '<':\n stack.append('<')\n elif bracket == '>':\n if len(stack) == 0:\n return False\n elif stack[-1] == '<':\n stack.pop()\n else:\n return False\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('<')\n False\n >>> correct_bracketing('<>')\n True\n >>> correct_bracketing('<<><>>')\n True\n >>> correct_bracketing('><<>')\n False\n \"\"\"\n stack = []\n for bracket in brackets:\n if bracket == '<':\n stack.append('<')\n elif bracket == '>':\n if len(stack) == 0:\n return False\n if stack[-1] == '>':\n stack.pop()\n else:\n return False\n return len(stack) == 0\n\n", "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing('<')\n False\n >>> correct_bracketing('<>')\n True\n >>> correct_bracketing('<<><>>')\n True\n >>> correct_bracketing('><<>')\n False\n \"\"\"\n stack = []\n for bracket in brackets:\n if bracket == '<':\n stack.append('<')\n elif bracket == '>':\n if len(stack) == 0:\n return False\n elif stack[-1] == '>':\n stack.pop()\n else:\n return False\n return len(stack) == 0\n\n"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment