global_id
stringlengths
1
4
messages
listlengths
1
201
label
stringclasses
20 values
8800
[ { "role": "assistant", "content": "def first_repeated_word(str1):\r\n temp = set()\r\n for word in str1.split():\r\n if word in temp:\r\n return word;\r\n else:\r\n temp.add(word)\r\n return 'None'" } ]
code:python
8801
[ { "role": "assistant", "content": "def string_list_to_tuple(str1):\r\n result = tuple(x for x in str1 if not x.isspace()) \r\n return result" } ]
code:python
8802
[ { "role": "assistant", "content": "def basesnum_coresspondingnum(bases_num,index):\r\n result = list(map(pow, bases_num, index))\r\n return result" } ]
code:python
8803
[ { "role": "assistant", "content": "def find_Diff(arr,n): \r\n arr.sort() \r\n count = 0; max_count = 0; min_count = n \r\n for i in range(0,(n-1)): \r\n if arr[i] == arr[i + 1]: \r\n count += 1\r\n continue\r\n else: \r\n max_count = max(max_count,cou...
code:python
8804
[ { "role": "assistant", "content": "import math \r\ndef get_sum(n): \r\n\tsum = 0\r\n\ti = 1\r\n\twhile i <= (math.sqrt(n)): \r\n\t\tif n%i == 0: \r\n\t\t\tif n/i == i : \r\n\t\t\t\tsum = sum + i \r\n\t\t\telse: \r\n\t\t\t\tsum = sum + i \r\n\t\t\t\tsum = sum + (n / i ) \r\n\t\ti = i + 1\r\n\tsum = sum - n \...
code:python
8805
[ { "role": "assistant", "content": "import re\r\ndef fill_spaces(text):\r\n return (re.sub(\"[ ,.]\", \":\", text))" } ]
code:python
8806
[ { "role": "assistant", "content": "def count_digits(num1,num2):\r\n number=num1+num2\r\n count = 0\r\n while(number > 0):\r\n number = number // 10\r\n count = count + 1\r\n return count" } ]
code:python
8807
[ { "role": "assistant", "content": "def flatten_tuple(test_list):\r\n res = ' '.join([idx for tup in test_list for idx in tup])\r\n return (res) " } ]
code:python
8808
[ { "role": "assistant", "content": "def take_L_and_F_set_bits(n) : \r\n n = n | n >> 1\r\n n = n | n >> 2\r\n n = n | n >> 4\r\n n = n | n >> 8\r\n n = n | n >> 16 \r\n return ((n + 1) >> 1) + 1 \r\ndef toggle_F_and_L_bits(n) : \r\n if (n == 1) : \r\n return 0 \r\n return...
code:python
8809
[ { "role": "assistant", "content": "def last_occurence_char(string,char):\r\n flag = -1\r\n for i in range(len(string)):\r\n if(string[i] == char):\r\n flag = i\r\n if(flag == -1):\r\n return None\r\n else:\r\n return flag + 1" } ]
code:python
8810
[ { "role": "assistant", "content": "def Total_Hamming_Distance(n): \r\n i = 1\r\n sum = 0\r\n while (n // i > 0): \r\n sum = sum + n // i \r\n i = i * 2 \r\n return sum" } ]
code:python
8811
[ { "role": "assistant", "content": "def longest_increasing_subsequence(arr): \r\n\tn = len(arr) \r\n\tlongest_increasing_subsequence = [1]*n \r\n\tfor i in range (1 , n): \r\n\t\tfor j in range(0 , i): \r\n\t\t\tif arr[i] > arr[j] and longest_increasing_subsequence[i]< longest_increasing_subsequence[j] + 1 :...
code:python
8812
[ { "role": "assistant", "content": "def odd_Num_Sum(n) : \r\n j = 0\r\n sm = 0\r\n for i in range(1,n+1) : \r\n j = (2*i-1) \r\n sm = sm + (j*j*j*j*j) \r\n return sm " } ]
code:python
8813
[ { "role": "assistant", "content": "def find_Max(arr,low,high): \r\n if (high < low): \r\n return arr[0] \r\n if (high == low): \r\n return arr[low] \r\n mid = low + (high - low) // 2 \r\n if (mid < high and arr[mid + 1] < arr[mid]): \r\n return arr[mid] \r\n if (mid > low...
code:python
8814
[ { "role": "assistant", "content": "def extract_column(list1, n):\r\n result = [i.pop(n) for i in list1]\r\n return result " } ]
code:python
8815
[ { "role": "assistant", "content": "def Seq_Linear(seq_nums):\r\n seq_nums = [seq_nums[x] - seq_nums[x-1] for x in range(1, len(seq_nums))]\r\n if len(set(seq_nums)) == 1: \r\n return \"Linear Sequence\"\r\n else:\r\n return \"Non Linear Sequence\"" } ]
code:python
8816
[ { "role": "assistant", "content": "def tuple_to_float(test_tup):\r\n res = float('.'.join(str(ele) for ele in test_tup))\r\n return (res) " } ]
code:python
8817
[ { "role": "assistant", "content": "def Split(list): \r\n od_li = [] \r\n for i in list: \r\n if (i % 2 != 0): \r\n od_li.append(i) \r\n return od_li" } ]
code:python
8818
[ { "role": "assistant", "content": "def difference(n) : \r\n S = (n*(n + 1))//2; \r\n res = S*(S-1); \r\n return res; " } ]
code:python
8819
[ { "role": "assistant", "content": "def find_Odd_Pair(A,N) : \r\n oddPair = 0\r\n for i in range(0,N) : \r\n for j in range(i+1,N) : \r\n if ((A[i] ^ A[j]) % 2 != 0): \r\n oddPair+=1 \r\n return oddPair " } ]
code:python
8820
[ { "role": "assistant", "content": "def toggle_string(string):\r\n string1 = string.swapcase()\r\n return string1" } ]
code:python
8821
[ { "role": "assistant", "content": "def digit_distance_nums(n1, n2):\r\n return sum(map(int,str(abs(n1-n2))))" } ]
code:python
8822
[ { "role": "assistant", "content": "def max_sub_array_sum(a, size):\r\n max_so_far = 0\r\n max_ending_here = 0\r\n for i in range(0, size):\r\n max_ending_here = max_ending_here + a[i]\r\n if max_ending_here < 0:\r\n max_ending_here = 0\r\n elif (max_so_far < max_ending_here):\r\n max_s...
code:python
8823
[ { "role": "assistant", "content": "def union_elements(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1 + test_tup2))\r\n return (res) " } ]
code:python
8824
[ { "role": "assistant", "content": "def assign_elements(test_list):\r\n res = dict()\r\n for key, val in test_list:\r\n res.setdefault(val, [])\r\n res.setdefault(key, []).append(val)\r\n return (res) " } ]
code:python
8825
[ { "role": "assistant", "content": "def Find_Max_Length(lst): \r\n maxLength = max(len(x) for x in lst )\r\n return maxLength " } ]
code:python
8826
[ { "role": "assistant", "content": "import re\r\ndef extract_values(text):\r\n return (re.findall(r'\"(.*?)\"', text))" } ]
code:python
8827
[ { "role": "assistant", "content": "def count_Pairs(arr,n): \r\n cnt = 0; \r\n for i in range(n): \r\n for j in range(i + 1,n): \r\n if (arr[i] != arr[j]): \r\n cnt += 1; \r\n return cnt; " } ]
code:python
8828
[ { "role": "assistant", "content": "def split(word): \r\n return [char for char in word] " } ]
code:python
8829
[ { "role": "assistant", "content": "def sum_digits(n):\r\n if n == 0:\r\n return 0\r\n else:\r\n return n % 10 + sum_digits(int(n / 10))" } ]
code:python
8830
[ { "role": "assistant", "content": "def issort_list(list1):\r\n result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))\r\n return result" } ]
code:python
8831
[ { "role": "assistant", "content": "def empty_list(length):\r\n empty_list = [{} for _ in range(length)]\r\n return empty_list" } ]
code:python
8832
[ { "role": "assistant", "content": "def sort_sublists(list1):\r\n result = list(map(sorted,list1)) \r\n return result" } ]
code:python
8833
[ { "role": "assistant", "content": "def remove_words(list1, charlist):\r\n new_list = []\r\n for line in list1:\r\n new_words = ' '.join([word for word in line.split() if not any([phrase in word for phrase in charlist])])\r\n new_list.append(new_words)\r\n return new_list" } ]
code:python
8834
[ { "role": "assistant", "content": "def max_sum_pair_diff_lessthan_K(arr, N, K): \r\n\tarr.sort() \r\n\tdp = [0] * N \r\n\tdp[0] = 0\r\n\tfor i in range(1, N): \r\n\t\tdp[i] = dp[i-1] \r\n\t\tif (arr[i] - arr[i-1] < K): \r\n\t\t\tif (i >= 2): \r\n\t\t\t\tdp[i] = max(dp[i], dp[i-2] + arr[i] + arr[i-1]); \r\n\...
code:python
8835
[ { "role": "assistant", "content": "def two_unique_nums(nums):\r\n return [i for i in nums if nums.count(i)==1]" } ]
code:python
8836
[ { "role": "assistant", "content": "def unique_product(list_data):\r\n temp = list(set(list_data))\r\n p = 1\r\n for i in temp:\r\n p *= i\r\n return p" } ]
code:python
8837
[ { "role": "assistant", "content": "def surfacearea_cylinder(r,h):\r\n surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))\r\n return surfacearea" } ]
code:python
8838
[ { "role": "assistant", "content": "def count_no (A,N,L,R): \r\n count = 0\r\n for i in range (L,R + 1): \r\n if (i % A != 0): \r\n count += 1\r\n if (count == N): \r\n break\r\n return (i) " } ]
code:python
8839
[ { "role": "assistant", "content": "def is_Sub_Array(A,B,n,m): \r\n i = 0; j = 0; \r\n while (i < n and j < m): \r\n if (A[i] == B[j]): \r\n i += 1; \r\n j += 1; \r\n if (j == m): \r\n return True; \r\n else: \r\n i = i - j + 1;...
code:python
8840
[ { "role": "assistant", "content": "def last_Digit_Factorial(n): \r\n if (n == 0): return 1\r\n elif (n <= 2): return n \r\n elif (n == 3): return 6\r\n elif (n == 4): return 4 \r\n else: \r\n return 0" } ]
code:python
8841
[ { "role": "assistant", "content": "def interleave_lists(list1,list2,list3):\r\n result = [el for pair in zip(list1, list2, list3) for el in pair]\r\n return result" } ]
code:python
8842
[ { "role": "assistant", "content": "def find_dissimilar(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1) ^ set(test_tup2))\r\n return (res) " } ]
code:python
8843
[ { "role": "assistant", "content": "def even_ele(test_tuple, even_fnc): \r\n\tres = tuple() \r\n\tfor ele in test_tuple: \r\n\t\tif isinstance(ele, tuple): \r\n\t\t\tres += (even_ele(ele, even_fnc), ) \r\n\t\telif even_fnc(ele): \r\n\t\t\tres += (ele, ) \r\n\treturn res \r\ndef extract_even(test_tuple):\r\n ...
code:python
8844
[ { "role": "assistant", "content": "def surface_Area(b,s): \r\n return 2 * b * s + pow(b,2) " } ]
code:python
8845
[ { "role": "assistant", "content": "def my_dict(dict1):\r\n if bool(dict1):\r\n return False\r\n else:\r\n return True" } ]
code:python
8846
[ { "role": "assistant", "content": "def catalan_number(num):\r\n if num <=1:\r\n return 1 \r\n res_num = 0\r\n for i in range(num):\r\n res_num += catalan_number(i) * catalan_number(num-i-1)\r\n return res_num" } ]
code:python
8847
[ { "role": "assistant", "content": "import re\r\ndef find_adverbs(text):\r\n for m in re.finditer(r\"\\w+ly\", text):\r\n return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))" } ]
code:python
8848
[ { "role": "assistant", "content": "import heapq\r\ndef expensive_items(items,n):\r\n expensive_items = heapq.nlargest(n, items, key=lambda s: s['price'])\r\n return expensive_items" } ]
code:python
8849
[ { "role": "assistant", "content": "def split_Arr(a,n,k): \r\n b = a[:k] \r\n return (a[k::]+b[::]) " } ]
code:python
8850
[ { "role": "assistant", "content": "def list_tuple(listx):\r\n tuplex = tuple(listx)\r\n return tuplex" } ]
code:python
8851
[ { "role": "assistant", "content": "def big_diff(nums):\r\n diff= max(nums)-min(nums)\r\n return diff" } ]
code:python
8852
[ { "role": "assistant", "content": "def perfect_squares(a, b):\r\n lists=[]\r\n for i in range (a,b+1):\r\n j = 1;\r\n while j*j <= i:\r\n if j*j == i:\r\n lists.append(i) \r\n j = j+1\r\n i = i+1\r\n return lists" } ]
code:python
8853
[ { "role": "assistant", "content": "import cmath\r\ndef polar_rect(x,y):\r\n cn = complex(x,y)\r\n cn=cmath.polar(cn)\r\n cn1 = cmath.rect(2, cmath.pi)\r\n return (cn,cn1)" } ]
code:python
8854
[ { "role": "assistant", "content": "def swap_List(newList): \r\n size = len(newList) \r\n temp = newList[0] \r\n newList[0] = newList[size - 1] \r\n newList[size - 1] = temp \r\n return newList " } ]
code:python
8855
[ { "role": "assistant", "content": "def binomial_Coeff(n,k): \r\n C = [0] * (k + 1); \r\n C[0] = 1; # nC0 is 1 \r\n for i in range(1,n + 1): \r\n for j in range(min(i, k),0,-1): \r\n C[j] = C[j] + C[j - 1]; \r\n return C[k]; \r\ndef sum_Of_product(n): \r\n return binomial_Co...
code:python
8856
[ { "role": "assistant", "content": "import re\r\ndef removezero_ip(ip):\r\n string = re.sub('\\.[0]*', '.', ip)\r\n return string\r" } ]
code:python
8857
[ { "role": "assistant", "content": "def diff_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even-first_odd)" } ]
code:python
8858
[ { "role": "assistant", "content": "def min_Swaps(str1,str2) : \r\n count = 0\r\n for i in range(len(str1)) : \r\n if str1[i] != str2[i] : \r\n count += 1\r\n if count % 2 == 0 : \r\n return (count // 2) \r\n else : \r\n return (\"Not Possible\") " } ]
code:python
8859
[ { "role": "assistant", "content": "import sys \r\ndef tuple_size(tuple_list):\r\n return (sys.getsizeof(tuple_list)) " } ]
code:python
8860
[ { "role": "assistant", "content": "def find_kth(arr1, arr2, m, n, k):\r\n\tsorted1 = [0] * (m + n)\r\n\ti = 0\r\n\tj = 0\r\n\td = 0\r\n\twhile (i < m and j < n):\r\n\t\tif (arr1[i] < arr2[j]):\r\n\t\t\tsorted1[d] = arr1[i]\r\n\t\t\ti += 1\r\n\t\telse:\r\n\t\t\tsorted1[d] = arr2[j]\r\n\t\t\tj += 1\r\n\t\td +...
code:python
8861
[ { "role": "assistant", "content": "def armstrong_number(number):\r\n sum = 0\r\n times = 0\r\n temp = number\r\n while temp > 0:\r\n times = times + 1\r\n temp = temp // 10\r\n temp = number\r\n while temp > 0:\r\n reminder = temp % 10\r\n sum = sum + (reminder ** tim...
code:python
8862
[ { "role": "assistant", "content": "def sum_average(number):\r\n total = 0\r\n for value in range(1, number + 1):\r\n total = total + value\r\n average = total / number\r\n return (total,average)" } ]
code:python
8863
[ { "role": "assistant", "content": "def is_Even(n) : \r\n if (n^1 == n+1) :\r\n return True; \r\n else :\r\n return False; " } ]
code:python
8864
[ { "role": "assistant", "content": "R = 3\r\nC = 3\r\ndef min_cost(cost, m, n): \r\n\ttc = [[0 for x in range(C)] for x in range(R)] \r\n\ttc[0][0] = cost[0][0] \r\n\tfor i in range(1, m+1): \r\n\t\ttc[i][0] = tc[i-1][0] + cost[i][0] \r\n\tfor j in range(1, n+1): \r\n\t\ttc[0][j] = tc[0][j-1] + cost[0][j] \r...
code:python
8865
[ { "role": "assistant", "content": "def similar_elements(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1) & set(test_tup2))\r\n return (res) " } ]
code:python
8866
[ { "role": "assistant", "content": "import math\r\ndef is_not_prime(n):\r\n result = False\r\n for i in range(2,int(math.sqrt(n)) + 1):\r\n if n % i == 0:\r\n result = True\r\n return result" } ]
code:python
8867
[ { "role": "assistant", "content": "import heapq as hq\r\ndef heap_queue_largest(nums,n):\r\n largest_nums = hq.nlargest(n, nums)\r\n return largest_nums" } ]
code:python
8868
[ { "role": "assistant", "content": "def count_ways(n): \r\n\tA = [0] * (n + 1) \r\n\tB = [0] * (n + 1) \r\n\tA[0] = 1\r\n\tA[1] = 0\r\n\tB[0] = 0\r\n\tB[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tA[i] = A[i - 2] + 2 * B[i - 1] \r\n\t\tB[i] = A[i - 1] + B[i - 2] \r\n\treturn A[n] " } ]
code:python
8869
[ { "role": "assistant", "content": "def is_Power_Of_Two (x): \r\n return x and (not(x & (x - 1))) \r\ndef differ_At_One_Bit_Pos(a,b): \r\n return is_Power_Of_Two(a ^ b)" } ]
code:python
8870
[ { "role": "assistant", "content": "import re\r\ndef find_char_long(text):\r\n return (re.findall(r\"\\b\\w{4,}\\b\", text))" } ]
code:python
8871
[ { "role": "assistant", "content": "def square_nums(nums):\r\n square_nums = list(map(lambda x: x ** 2, nums))\r\n return square_nums" } ]
code:python
8872
[ { "role": "assistant", "content": "def find_Rotations(str): \r\n tmp = str + str\r\n n = len(str) \r\n for i in range(1,n + 1): \r\n substring = tmp[i: i+n] \r\n if (str == substring): \r\n return i \r\n return n " } ]
code:python
8873
[ { "role": "assistant", "content": "import heapq\r\ndef small_nnum(list1,n):\r\n smallest=heapq.nsmallest(n,list1)\r\n return smallest" } ]
code:python
8874
[ { "role": "assistant", "content": "from typing import List\n\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 Fa...
code:python
8875
[ { "role": "assistant", "content": "from typing import List\n\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 t...
code:python
8876
[ { "role": "assistant", "content": "\n\ndef 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 decim...
code:python
8877
[ { "role": "assistant", "content": "from typing import List\n\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...
code:python
8878
[ { "role": "assistant", "content": "from typing import List\n\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 b...
code:python
8879
[ { "role": "assistant", "content": "from typing import List\n\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 ...
code:python
8880
[ { "role": "assistant", "content": "from typing import List\n\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 p...
code:python
8881
[ { "role": "assistant", "content": "from typing import List\n\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', ...
code:python
8882
[ { "role": "assistant", "content": "from typing import List, Tuple\n\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 shoul...
code:python
8883
[ { "role": "assistant", "content": "from typing import List, Tuple\n\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...
code:python
8884
[ { "role": "assistant", "content": "\n\ndef is_palindrome(string: str) -> bool:\n \"\"\" Test if given string is a palindrome \"\"\"\n return string == string[::-1]\n\n\ndef make_palindrome(string: str) -> str:\n \"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm ...
code:python
8885
[ { "role": "assistant", "content": "from typing import List\n\n\ndef 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 \"\"\"\...
code:python
8886
[ { "role": "assistant", "content": "from typing import List, Optional\n\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 ...
code:python
8887
[ { "role": "assistant", "content": "\n\ndef 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 ...
code:python
8888
[ { "role": "assistant", "content": "from typing import List\n\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 result = []\n\n for i in range(len(string)...
code:python
8889
[ { "role": "assistant", "content": "\n\ndef 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(x) for x in ra...
code:python
8890
[ { "role": "assistant", "content": "\n\ndef 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 \"\"...
code:python
8891
[ { "role": "assistant", "content": "from typing import List\n\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 b...
code:python
8892
[ { "role": "assistant", "content": "\n\ndef 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_t...
code:python
8893
[ { "role": "assistant", "content": "from typing import List\n\n\ndef 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 s...
code:python
8894
[ { "role": "assistant", "content": "from typing import List, Tuple\n\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 ...
code:python
8895
[ { "role": "assistant", "content": "from typing import List\n\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 >...
code:python
8896
[ { "role": "assistant", "content": "from typing import List, Any\n\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...
code:python
8897
[ { "role": "assistant", "content": "\n\ndef 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" } ]
code:python
8898
[ { "role": "assistant", "content": "\n\ndef 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 reversed(range(n)):\n if n % i == 0:\n return i\n" } ]
code:python
8899
[ { "role": "assistant", "content": "from typing import List\n\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 factor...
code:python