global_id stringlengths 1 4 | messages listlengths 1 201 | label stringclasses 20
values |
|---|---|---|
8700 | [
{
"role": "assistant",
"content": "def smallest_multiple(n):\r\n if (n<=2):\r\n return n\r\n i = n * 2\r\n factors = [number for number in range(n, 1, -1) if number * 2 > n]\r\n while True:\r\n for a in factors:\r\n if i % a != 0:\r\n i += n\r\n ... | code:python |
8701 | [
{
"role": "assistant",
"content": "from collections import Counter\r\ndef add_dict(d1,d2):\r\n add_dict = Counter(d1) + Counter(d2)\r\n return add_dict"
}
] | code:python |
8702 | [
{
"role": "assistant",
"content": "def count_Unset_Bits(n) : \r\n cnt = 0; \r\n for i in range(1,n + 1) : \r\n temp = i; \r\n while (temp) : \r\n if (temp % 2 == 0) : \r\n cnt += 1; \r\n temp = temp // 2; \r\n return cnt; "
}
] | code:python |
8703 | [
{
"role": "assistant",
"content": "def even_num(x):\r\n if x%2==0:\r\n return True\r\n else:\r\n return False"
}
] | code:python |
8704 | [
{
"role": "assistant",
"content": "def factorial(start,end): \r\n res = 1 \r\n for i in range(start,end + 1): \r\n res *= i \r\n return res \r\ndef sum_of_square(n): \r\n return int(factorial(n + 1, 2 * n) /factorial(1, n)) "
}
] | code:python |
8705 | [
{
"role": "assistant",
"content": "import re\r\ndef extract_date(url):\r\n return re.findall(r'/(\\d{4})/(\\d{1,2})/(\\d{1,2})/', url)"
}
] | code:python |
8706 | [
{
"role": "assistant",
"content": "def lucky_num(n):\r\n List=range(-1,n*n+9,2)\r\n i=2\r\n while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1\r\n return List[1:n+1]"
}
] | code:python |
8707 | [
{
"role": "assistant",
"content": "def find_fixed_point(arr, n): \r\n\tfor i in range(n): \r\n\t\tif arr[i] is i: \r\n\t\t\treturn i \r\n\treturn -1"
}
] | code:python |
8708 | [
{
"role": "assistant",
"content": "def previous_palindrome(num):\r\n for x in range(num-1,0,-1):\r\n if str(x) == str(x)[::-1]:\r\n return x"
}
] | code:python |
8709 | [
{
"role": "assistant",
"content": "import datetime\r\ndef check_date(m, d, y):\r\n try:\r\n m, d, y = map(int, (m, d, y))\r\n datetime.date(y, m, d)\r\n return True\r\n except ValueError:\r\n return False"
}
] | code:python |
8710 | [
{
"role": "assistant",
"content": "def maximum_product(nums):\r\n import heapq\r\n a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)\r\n return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])"
}
] | code:python |
8711 | [
{
"role": "assistant",
"content": "def binomial_coeff(n, k): \r\n\tC = [[0 for j in range(k + 1)] \r\n\t\t\tfor i in range(n + 1)] \r\n\tfor i in range(0, n + 1): \r\n\t\tfor j in range(0, min(i, k) + 1): \r\n\t\t\tif (j == 0 or j == i): \r\n\t\t\t\tC[i][j] = 1\r\n\t\t\telse: \r\n\t\t\t\tC[i][j] = (C[i - 1]... | code:python |
8712 | [
{
"role": "assistant",
"content": "import re\r\ndef end_num(string):\r\n text = re.compile(r\".*[0-9]$\")\r\n if text.match(string):\r\n return True\r\n else:\r\n return False"
}
] | code:python |
8713 | [
{
"role": "assistant",
"content": "def is_Two_Alter(s): \r\n for i in range (len( s) - 2) : \r\n if (s[i] != s[i + 2]) : \r\n return False\r\n if (s[0] == s[1]): \r\n return False\r\n return True"
}
] | code:python |
8714 | [
{
"role": "assistant",
"content": "def rearrange_numbs(array_nums):\r\n result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)\r\n return result "
}
] | code:python |
8715 | [
{
"role": "assistant",
"content": "def find_triplet_array(A, arr_size, sum): \r\n\tfor i in range( 0, arr_size-2): \r\n\t\tfor j in range(i + 1, arr_size-1): \r\n\t\t\tfor k in range(j + 1, arr_size): \r\n\t\t\t\tif A[i] + A[j] + A[k] == sum: \r\n\t\t\t\t\treturn A[i],A[j],A[k] \r\n\t\t\t\t\treturn True\r\... | code:python |
8716 | [
{
"role": "assistant",
"content": "import re\r\ndef text_uppercase_lowercase(text):\r\n patterns = '[A-Z]+[a-z]+$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return ('Not matched!')"
}
] | code:python |
8717 | [
{
"role": "assistant",
"content": "def coin_change(S, m, n): \r\n table = [[0 for x in range(m)] for x in range(n+1)] \r\n for i in range(m): \r\n table[0][i] = 1\r\n for i in range(1, n+1): \r\n for j in range(m): \r\n x = table[i - S[j]][j] if i-S[j] >= 0 else 0\r\n ... | code:python |
8718 | [
{
"role": "assistant",
"content": "def multiply_list(items):\r\n tot = 1\r\n for x in items:\r\n tot *= x\r\n return tot"
}
] | code:python |
8719 | [
{
"role": "assistant",
"content": "def remove_tuple(test_list):\r\n res = [sub for sub in test_list if not all(ele == None for ele in sub)]\r\n return (str(res)) "
}
] | code:python |
8720 | [
{
"role": "assistant",
"content": "def chunk_tuples(test_tup, N):\r\n res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]\r\n return (res) "
}
] | code:python |
8721 | [
{
"role": "assistant",
"content": "def max_product(arr): \r\n arr_len = len(arr) \r\n if (arr_len < 2): \r\n return None \r\n x = arr[0]; y = arr[1] \r\n for i in range(0, arr_len): \r\n for j in range(i + 1, arr_len): \r\n if (arr[i] * arr[j] > x * y): \r\n ... | code:python |
8722 | [
{
"role": "assistant",
"content": "def super_seq(X, Y, m, n):\r\n\tif (not m):\r\n\t\treturn n\r\n\tif (not n):\r\n\t\treturn m\r\n\tif (X[m - 1] == Y[n - 1]):\r\n\t\treturn 1 + super_seq(X, Y, m - 1, n - 1)\r\n\treturn 1 + min(super_seq(X, Y, m - 1, n),\tsuper_seq(X, Y, m, n - 1))"
}
] | code:python |
8723 | [
{
"role": "assistant",
"content": "def max_of_two( x, y ):\r\n if x > y:\r\n return x\r\n return y"
}
] | code:python |
8724 | [
{
"role": "assistant",
"content": "def mutiple_tuple(nums):\r\n temp = list(nums)\r\n product = 1 \r\n for x in temp:\r\n product *= x\r\n return product"
}
] | code:python |
8725 | [
{
"role": "assistant",
"content": "def binomial_coeffi(n, k): \r\n\tif (k == 0 or k == n): \r\n\t\treturn 1\r\n\treturn (binomial_coeffi(n - 1, k - 1) \r\n\t\t+ binomial_coeffi(n - 1, k)) \r\ndef rencontres_number(n, m): \r\n\tif (n == 0 and m == 0): \r\n\t\treturn 1\r\n\tif (n == 1 and m == 0): \r\n\t\tret... | code:python |
8726 | [
{
"role": "assistant",
"content": "class Node: \r\n\tdef __init__(self, data): \r\n\t\tself.data = data \r\n\t\tself.left = None\r\n\t\tself.right = None\r\ndef max_height(node): \r\n\tif node is None: \r\n\t\treturn 0 ; \r\n\telse : \r\n\t\tleft_height = max_height(node.left) \r\n\t\tright_height = max_hei... | code:python |
8727 | [
{
"role": "assistant",
"content": "import re\r\ndef change_date_format(dt):\r\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)\r\n return change_date_format(dt)"
}
] | code:python |
8728 | [
{
"role": "assistant",
"content": "def count_tuplex(tuplex,value): \r\n count = tuplex.count(value)\r\n return count"
}
] | code:python |
8729 | [
{
"role": "assistant",
"content": "import re\r\ndef text_match(text):\r\n patterns = 'ab*?'\r\n if re.search(patterns, text):\r\n return ('Found a match!')\r\n else:\r\n return ('Not matched!')"
}
] | code:python |
8730 | [
{
"role": "assistant",
"content": "import math \r\ndef sum_series(number):\r\n total = 0\r\n total = math.pow((number * (number + 1)) /2, 2)\r\n return total"
}
] | code:python |
8731 | [
{
"role": "assistant",
"content": "def remove_duplic_list(l):\r\n temp = []\r\n for x in l:\r\n if x not in temp:\r\n temp.append(x)\r\n return temp"
}
] | code:python |
8732 | [
{
"role": "assistant",
"content": "import re\r\ndef camel_to_snake(text):\r\n str1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\r\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', str1).lower()"
}
] | code:python |
8733 | [
{
"role": "assistant",
"content": "def dealnnoy_num(n, m): \r\n\tif (m == 0 or n == 0) : \r\n\t\treturn 1\r\n\treturn dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)"
}
] | code:python |
8734 | [
{
"role": "assistant",
"content": "def series_sum(number):\r\n total = 0\r\n total = (number * (number + 1) * (2 * number + 1)) / 6\r\n return total"
}
] | code:python |
8735 | [
{
"role": "assistant",
"content": "def re_arrange_tuples(test_list, ord_list):\r\n temp = dict(test_list)\r\n res = [(key, temp[key]) for key in ord_list]\r\n return (res) "
}
] | code:python |
8736 | [
{
"role": "assistant",
"content": "from collections import Counter \r\ndef max_char(str1):\r\n temp = Counter(str1) \r\n max_char = max(temp, key = temp.get)\r\n return max_char"
}
] | code:python |
8737 | [
{
"role": "assistant",
"content": "import sys \r\n\r\ndef find_closet(A, B, C, p, q, r): \r\n\tdiff = sys.maxsize \r\n\tres_i = 0\r\n\tres_j = 0\r\n\tres_k = 0\r\n\ti = 0\r\n\tj = 0\r\n\tk = 0\r\n\twhile(i < p and j < q and k < r): \r\n\t\tminimum = min(A[i], min(B[j], C[k])) \r\n\t\tmaximum = max(A[i], max... | code:python |
8738 | [
{
"role": "assistant",
"content": "def sorted_models(models):\r\n sorted_models = sorted(models, key = lambda x: x['color'])\r\n return sorted_models"
}
] | code:python |
8739 | [
{
"role": "assistant",
"content": "def heap_sort(arr):\r\n heapify(arr) \r\n end = len(arr) - 1\r\n while end > 0:\r\n arr[end], arr[0] = arr[0], arr[end]\r\n shift_down(arr, 0, end - 1)\r\n end -= 1\r\n return arr\r\n\r\ndef heapify(arr):\r\n start = len(arr) // 2\r\n ... | code:python |
8740 | [
{
"role": "assistant",
"content": "def count_elim(num):\r\n count_elim = 0\r\n for n in num:\r\n if isinstance(n, tuple):\r\n break\r\n count_elim += 1\r\n return count_elim"
}
] | code:python |
8741 | [
{
"role": "assistant",
"content": "def check_element(test_tup, check_list):\r\n res = False\r\n for ele in check_list:\r\n if ele in test_tup:\r\n res = True\r\n break\r\n return (res) "
}
] | code:python |
8742 | [
{
"role": "assistant",
"content": "from heapq import merge\r\ndef combine_lists(num1,num2):\r\n combine_lists=list(merge(num1, num2))\r\n return combine_lists"
}
] | code:python |
8743 | [
{
"role": "assistant",
"content": "import re\r\ndef num_position(text):\r\n for m in re.finditer(\"\\d+\", text):\r\n return m.start()"
}
] | code:python |
8744 | [
{
"role": "assistant",
"content": "def tuple_to_set(t):\r\n s = set(t)\r\n return (s) "
}
] | code:python |
8745 | [
{
"role": "assistant",
"content": "from collections import Counter \r\ndef most_common_elem(s,a):\r\n most_common_elem=Counter(s).most_common(a)\r\n return most_common_elem"
}
] | code:python |
8746 | [
{
"role": "assistant",
"content": "def len_log(list1):\r\n min=len(list1[0])\r\n for i in list1:\r\n if len(i)<min:\r\n min=len(i)\r\n return min"
}
] | code:python |
8747 | [
{
"role": "assistant",
"content": "def get_item(tup1,index):\r\n item = tup1[index]\r\n return item"
}
] | code:python |
8748 | [
{
"role": "assistant",
"content": "def count_digs(tup):\r\n return sum([len(str(ele)) for ele in tup ]) \r\ndef sort_list(test_list):\r\n test_list.sort(key = count_digs)\r\n return (str(test_list))"
}
] | code:python |
8749 | [
{
"role": "assistant",
"content": "def chinese_zodiac(year):\r\n if (year - 2000) % 12 == 0:\r\n sign = 'Dragon'\r\n elif (year - 2000) % 12 == 1:\r\n sign = 'Snake'\r\n elif (year - 2000) % 12 == 2:\r\n sign = 'Horse'\r\n elif (year - 2000) % 12 == 3:\r\n sign = 'sheep'\r\n elif (year - 200... | code:python |
8750 | [
{
"role": "assistant",
"content": "def max_similar_indices(test_list1, test_list2):\r\n res = [(max(x[0], y[0]), max(x[1], y[1]))\r\n for x, y in zip(test_list1, test_list2)]\r\n return (res) "
}
] | code:python |
8751 | [
{
"role": "assistant",
"content": "def nCr_mod_p(n, r, p): \r\n\tif (r > n- r): \r\n\t\tr = n - r \r\n\tC = [0 for i in range(r + 1)] \r\n\tC[0] = 1 \r\n\tfor i in range(1, n + 1): \r\n\t\tfor j in range(min(i, r), 0, -1): \r\n\t\t\tC[j] = (C[j] + C[j-1]) % p \r\n\treturn C[r] "
}
] | code:python |
8752 | [
{
"role": "assistant",
"content": "def subset(ar, n): \r\n res = 0\r\n ar.sort() \r\n for i in range(0, n) : \r\n count = 1\r\n for i in range(n - 1): \r\n if ar[i] == ar[i + 1]: \r\n count+=1\r\n else: \r\n break \r\n res = m... | code:python |
8753 | [
{
"role": "assistant",
"content": "def profit_amount(actual_cost,sale_amount): \r\n if(actual_cost > sale_amount):\r\n amount = actual_cost - sale_amount\r\n return amount\r\n else:\r\n return None"
}
] | code:python |
8754 | [
{
"role": "assistant",
"content": "def is_abundant(n):\r\n fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])\r\n return fctrsum > n"
}
] | code:python |
8755 | [
{
"role": "assistant",
"content": "import re\r\ndef split_list(text):\r\n return (re.findall('[A-Z][^A-Z]*', text))"
}
] | code:python |
8756 | [
{
"role": "assistant",
"content": "import math\r\ndef get_First_Set_Bit_Pos(n):\r\n return math.log2(n&-n)+1"
}
] | code:python |
8757 | [
{
"role": "assistant",
"content": "def int_to_roman( num):\r\n val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1]\r\n syb = [\"M\", \"CM\", \"D\", \"CD\",\"C\", \"XC\", \"L\", \"XL\",\"X\", \"IX\", \"V\", \"IV\",\"I\"]\r\n roman_num = ''\r\n i = 0\r\n while num > 0... | code:python |
8758 | [
{
"role": "assistant",
"content": "def Average(lst): \r\n return sum(lst) / len(lst) "
}
] | code:python |
8759 | [
{
"role": "assistant",
"content": "def get_noOfways(n):\r\n if (n == 0):\r\n return 0;\r\n if (n == 1):\r\n return 1; \r\n return get_noOfways(n - 1) + get_noOfways(n - 2);"
}
] | code:python |
8760 | [
{
"role": "assistant",
"content": "def roman_to_int(s):\r\n rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}\r\n int_val = 0\r\n for i in range(len(s)):\r\n if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:\r\n int_val += rom_val[s[i]] ... | code:python |
8761 | [
{
"role": "assistant",
"content": "def sum_Natural(n): \r\n sum = (n * (n + 1)) \r\n return int(sum) \r\ndef sum_Even(l,r): \r\n return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2))) "
}
] | code:python |
8762 | [
{
"role": "assistant",
"content": "def discriminant_value(x,y,z):\r\n discriminant = (y**2) - (4*x*z)\r\n if discriminant > 0:\r\n return (\"Two solutions\",discriminant)\r\n elif discriminant == 0:\r\n return (\"one solution\",discriminant)\r\n elif discriminant < 0:\r\n re... | code:python |
8763 | [
{
"role": "assistant",
"content": "def word_len(s): \r\n s = s.split(' ') \r\n for word in s: \r\n if len(word)%2==0: \r\n return True \r\n else:\r\n return False"
}
] | code:python |
8764 | [
{
"role": "assistant",
"content": "def camel_to_snake(text):\r\n import re\r\n str1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\r\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', str1).lower()"
}
] | code:python |
8765 | [
{
"role": "assistant",
"content": "def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]\r\n tuple1 = [t for t in tuple1 if t]\r\n return tuple1"
}
] | code:python |
8766 | [
{
"role": "assistant",
"content": "def check(string): \r\n if len(set(string).intersection(\"AEIOUaeiou\"))>=5: \r\n return ('accepted') \r\n else: \r\n return (\"not accepted\") "
}
] | code:python |
8767 | [
{
"role": "assistant",
"content": "def floor_Max(A,B,N):\r\n x = min(B - 1,N)\r\n return (A*x) // B"
}
] | code:python |
8768 | [
{
"role": "assistant",
"content": "def join_tuples(test_list):\r\n res = []\r\n for sub in test_list:\r\n if res and res[-1][0] == sub[0]:\r\n res[-1].extend(sub[1:])\r\n else:\r\n res.append([ele for ele in sub])\r\n res = list(map(tuple, res))\r\n return (res) "
}
] | code:python |
8769 | [
{
"role": "assistant",
"content": "def min_of_two( x, y ):\r\n if x < y:\r\n return x\r\n return y"
}
] | code:python |
8770 | [
{
"role": "assistant",
"content": "def maximum_segments(n, a, b, c) : \r\n\tdp = [-1] * (n + 10) \r\n\tdp[0] = 0\r\n\tfor i in range(0, n) : \r\n\t\tif (dp[i] != -1) : \r\n\t\t\tif(i + a <= n ): \r\n\t\t\t\tdp[i + a] = max(dp[i] + 1, \r\n\t\t\t\t\t\t\tdp[i + a]) \r\n\t\t\tif(i + b <= n ): \r\n\t\t\t\tdp[i +... | code:python |
8771 | [
{
"role": "assistant",
"content": "def concatenate_nested(test_tup1, test_tup2):\r\n res = test_tup1 + test_tup2\r\n return (res) "
}
] | code:python |
8772 | [
{
"role": "assistant",
"content": "def left_rotate(s,d):\r\n tmp = s[d : ] + s[0 : d]\r\n return tmp "
}
] | code:python |
8773 | [
{
"role": "assistant",
"content": "def min_sum_path(A): \r\n\tmemo = [None] * len(A) \r\n\tn = len(A) - 1\r\n\tfor i in range(len(A[n])): \r\n\t\tmemo[i] = A[n][i] \r\n\tfor i in range(len(A) - 2, -1,-1): \r\n\t\tfor j in range( len(A[i])): \r\n\t\t\tmemo[j] = A[i][j] + min(memo[j], \r\n\t\t\t\t\t\t\t\t\tme... | code:python |
8774 | [
{
"role": "assistant",
"content": "def find_Min_Sum(num): \r\n sum = 0\r\n i = 2\r\n while(i * i <= num): \r\n while(num % i == 0): \r\n sum += i \r\n num /= i \r\n i += 1\r\n sum += num \r\n return sum"
}
] | code:python |
8775 | [
{
"role": "assistant",
"content": "def flatten(test_tuple): \r\n\tfor tup in test_tuple: \r\n\t\tif isinstance(tup, tuple): \r\n\t\t\tyield from flatten(tup) \r\n\t\telse: \r\n\t\t\tyield tup \r\ndef count_element_freq(test_tuple):\r\n res = {}\r\n for ele in flatten(test_tuple):\r\n if ele not in res:... | code:python |
8776 | [
{
"role": "assistant",
"content": "def add_str(test_tup, K):\r\n res = [ele for sub in test_tup for ele in (sub, K)]\r\n return (res) "
}
] | code:python |
8777 | [
{
"role": "assistant",
"content": "def sum_elements(test_tup):\r\n res = sum(list(test_tup))\r\n return (res) "
}
] | code:python |
8778 | [
{
"role": "assistant",
"content": "def modular_sum(arr, n, m): \r\n\tif (n > m): \r\n\t\treturn True\r\n\tDP = [False for i in range(m)] \r\n\tfor i in range(n): \r\n\t\tif (DP[0]): \r\n\t\t\treturn True\r\n\t\ttemp = [False for i in range(m)] \r\n\t\tfor j in range(m): \r\n\t\t\tif (DP[j] == True): \r\n\t\... | code:python |
8779 | [
{
"role": "assistant",
"content": "def radix_sort(nums):\r\n RADIX = 10\r\n placement = 1\r\n max_digit = max(nums)\r\n\r\n while placement < max_digit:\r\n buckets = [list() for _ in range( RADIX )]\r\n for i in nums:\r\n tmp = int((i / placement) % RADIX)\r\n buckets[tm... | code:python |
8780 | [
{
"role": "assistant",
"content": "def largest_pos(list1): \r\n max = list1[0] \r\n for x in list1: \r\n if x > max : \r\n max = x \r\n return max"
}
] | code:python |
8781 | [
{
"role": "assistant",
"content": "import math\r\ndef sqrt_root(num):\r\n sqrt_root = math.pow(num, 0.5)\r\n return sqrt_root "
}
] | code:python |
8782 | [
{
"role": "assistant",
"content": "import math\r\ndef volume_tetrahedron(num):\r\n\tvolume = (num ** 3 / (6 * math.sqrt(2)))\t\r\n\treturn round(volume, 2)"
}
] | code:python |
8783 | [
{
"role": "assistant",
"content": "def find_lcm(num1, num2): \r\n\tif(num1>num2): \r\n\t\tnum = num1 \r\n\t\tden = num2 \r\n\telse: \r\n\t\tnum = num2 \r\n\t\tden = num1 \r\n\trem = num % den \r\n\twhile (rem != 0): \r\n\t\tnum = den \r\n\t\tden = rem \r\n\t\trem = num % den \r\n\tgcd = den \r\n\tlcm = int(... | code:python |
8784 | [
{
"role": "assistant",
"content": "def check_isosceles(x,y,z):\r\n if x!=y & y!=z & z!=x:\r\n\t return True\r\n else:\r\n return False"
}
] | code:python |
8785 | [
{
"role": "assistant",
"content": "def lbs(arr): \r\n\tn = len(arr) \r\n\tlis = [1 for i in range(n+1)] \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 (lis[i] < lis[j] +1)): \r\n\t\t\t\tlis[i] = lis[j] + 1\r\n\tlds = [1 for i in range(n+1)] \r\n\tfor i in rev... | code:python |
8786 | [
{
"role": "assistant",
"content": "def check_string(str1):\r\n messg = [\r\n lambda str1: any(x.isupper() for x in str1) or 'String must have 1 upper case character.',\r\n lambda str1: any(x.islower() for x in str1) or 'String must have 1 lower case character.',\r\n lambda str1: any(x.isdigit() ... | code:python |
8787 | [
{
"role": "assistant",
"content": "def max_sum_increasing_subsequence(arr, n): \r\n\tmax = 0\r\n\tmsis = [0 for x in range(n)] \r\n\tfor i in range(n): \r\n\t\tmsis[i] = arr[i] \r\n\tfor i in range(1, n): \r\n\t\tfor j in range(i): \r\n\t\t\tif (arr[i] > arr[j] and\r\n\t\t\t\tmsis[i] < msis[j] + arr[i]): \r... | code:python |
8788 | [
{
"role": "assistant",
"content": "def parallel_lines(line1, line2):\r\n return line1[0]/line1[1] == line2[0]/line2[1]"
}
] | code:python |
8789 | [
{
"role": "assistant",
"content": "def capitalize_first_last_letters(str1):\r\n str1 = result = str1.title()\r\n result = \"\"\r\n for word in str1.split():\r\n result += word[:-1] + word[-1].upper() + \" \"\r\n return result[:-1] "
}
] | code:python |
8790 | [
{
"role": "assistant",
"content": "def get_pairs_count(arr, n, sum):\r\n count = 0 \r\n for i in range(0, n):\r\n for j in range(i + 1, n):\r\n if arr[i] + arr[j] == sum:\r\n count += 1\r\n return count"
}
] | code:python |
8791 | [
{
"role": "assistant",
"content": "def min_length(list1):\r\n min_length = min(len(x) for x in list1 ) \r\n min_list = min((x) for x in list1)\r\n return(min_length, min_list) "
}
] | code:python |
8792 | [
{
"role": "assistant",
"content": "def jacobsthal_lucas(n): \r\n\tdp=[0] * (n + 1) \r\n\tdp[0] = 2\r\n\tdp[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2]; \r\n\treturn dp[n]"
}
] | code:python |
8793 | [
{
"role": "assistant",
"content": "from array import array\r\ndef negative_count(nums):\r\n n = len(nums)\r\n n1 = 0\r\n for x in nums:\r\n if x < 0:\r\n n1 += 1\r\n else:\r\n None\r\n return round(n1/n,2)"
}
] | code:python |
8794 | [
{
"role": "assistant",
"content": "import sys \r\ndef min_coins(coins, m, V): \r\n if (V == 0): \r\n return 0\r\n res = sys.maxsize \r\n for i in range(0, m): \r\n if (coins[i] <= V): \r\n sub_res = min_coins(coins, m, V-coins[i]) \r\n if (sub_res != sys.maxsize ... | code:python |
8795 | [
{
"role": "assistant",
"content": "def check_permutation(str1, str2):\r\n n1=len(str1)\r\n n2=len(str2)\r\n if(n1!=n2):\r\n return False\r\n a=sorted(str1)\r\n str1=\" \".join(a)\r\n b=sorted(str2)\r\n str2=\" \".join(b)\r\n for i in range(0, n1, 1):\r\n if(str1[i] != str2[i]):\r\n return... | code:python |
8796 | [
{
"role": "assistant",
"content": "def remove_datatype(test_tuple, data_type):\r\n res = []\r\n for ele in test_tuple:\r\n if not isinstance(ele, data_type):\r\n res.append(ele)\r\n return (res) "
}
] | code:python |
8797 | [
{
"role": "assistant",
"content": "import re\r\ndef search_literal(pattern,text):\r\n match = re.search(pattern, text)\r\n s = match.start()\r\n e = match.end()\r\n return (s, e)"
}
] | code:python |
8798 | [
{
"role": "assistant",
"content": "def topbottom_surfacearea(r):\r\n toporbottomarea=3.1415*r*r\r\n return toporbottomarea"
}
] | code:python |
8799 | [
{
"role": "assistant",
"content": "def nth_items(list,n):\r\n return list[::n]"
}
] | code:python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.