Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
int64
601
974
text
stringlengths
38
249
code
stringlengths
30
908
test_list
listlengths
3
3
test_setup_code
stringclasses
2 values
challenge_test_list
listlengths
0
0
776
Write a python function to remove the k'th element from a given list.
from collections import defaultdict def freq_element(test_tup): res = defaultdict(int) for ele in test_tup: res[ele] += 1 return (str(dict(res)))
[ "assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4", "assert count_list([[1,2],[2,3],[4,5]]) == 3", "assert count_list([[1,0],[2,0]]) == 2" ]
[]
688
Write a function to move all the numbers in it to the given string.
import math def find_Digits(n): if (n < 0): return 0; if (n <= 1): return 1; x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); return math.floor(x) + 1;
[ "assert floor_Max(11,10,9) == 9", "assert floor_Max(5,7,4) == 2", "assert floor_Max(2,2,1) == 1" ]
[]
769
Write a python function to find the index of smallest triangular number with n digits.
def count_Rotation(arr,n): for i in range (1,n): if (arr[i] < arr[i - 1]): return i return 0
[ "assert chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]", "assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]", "assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]" ]
[]
686
Write a python function to remove even numbers from a given list.
import collections as ct def merge_dictionaries(dict1,dict2): merged_dict = dict(ct.ChainMap({}, dict1, dict2)) return merged_dict
[ "assert is_polite(7) == 11", "assert is_polite(4) == 7", "assert is_polite(9) == 13" ]
[]
750
Write a function to calculate wind chill index.
def unique_sublists(list1): result ={} for l in list1: result.setdefault(tuple(l), list()).append(1) for a, b in result.items(): result[a] = sum(b) return result
[ "assert capital_words_spaces(\"Python\") == 'Python'", "assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'", "assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'" ]
[]
681
Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.
import re def replace(string, char): pattern = char + '{2,}' string = re.sub(pattern, char, string) return string
[ "assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')", "assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')", "assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')" ]
[]
899
Write a function to find numbers within a given range where every number is divisible by every digit it contains.
def divisible_by_digits(startnum, endnum): return [n for n in range(startnum, endnum+1) \ if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]
[ "assert Convert('python program') == ['python','program']", "assert Convert('Data Analysis') ==['Data','Analysis']", "assert Convert('Hadoop Training') == ['Hadoop','Training']" ]
[]
643
Write a python function to left rotate the bits of a given number.
from itertools import groupby def pack_consecutive_duplicates(list1): return [list(group) for key, group in groupby(list1)]
[ "assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)", "assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)", "assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)" ]
[]
789
Write a function to find the index of the first occurrence of a given number in a sorted array.
def max_of_three(num1,num2,num3): if (num1 >= num2) and (num1 >= num3): lnum = num1 elif (num2 >= num1) and (num2 >= num3): lnum = num2 else: lnum = num3 return lnum
[ "assert re_arrange_tuples([(4, 3), (1, 9), (2, 10), (3, 2)], [1, 4, 2, 3]) == [(1, 9), (4, 3), (2, 10), (3, 2)]", "assert re_arrange_tuples([(5, 4), (2, 10), (3, 11), (4, 3)], [3, 4, 2, 3]) == [(3, 11), (4, 3), (2, 10), (3, 11)]", "assert re_arrange_tuples([(6, 3), (3, 8), (5, 7), (2, 4)], [2, 5, 3, 6]) == [(2, 4), (5, 7), (3, 8), (6, 3)]" ]
[]
892
Write a function to find out the second most repeated (or frequent) string in the given sequence.
def max_of_nth(test_list, N): res = max([sub[N] for sub in test_list]) return (res)
[ "assert sum_Of_Primes(10) == 17", "assert sum_Of_Primes(20) == 77", "assert sum_Of_Primes(5) == 10" ]
[]
895
Write a python function to check whether the count of divisors is even or odd.
def set_middle_bits(n): n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; return (n >> 1) ^ 1 def toggle_middle_bits(n): if (n == 1): return 1 return n ^ set_middle_bits(n)
[ "assert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True", "assert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True", "assert is_subset([10, 5, 2, 23, 19], 5, [19, 5, 3], 3) == False" ]
[]
858
Write a python function to add a minimum number such that the sum of array becomes even.
def maximum_segments(n, a, b, c) : dp = [-1] * (n + 10) dp[0] = 0 for i in range(0, n) : if (dp[i] != -1) : if(i + a <= n ): dp[i + a] = max(dp[i] + 1, dp[i + a]) if(i + b <= n ): dp[i + b] = max(dp[i] + 1, dp[i + b]) if(i + c <= n ): dp[i + c] = max(dp[i] + 1, dp[i + c]) return dp[n]
[ "assert count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25", "assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16", "assert count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])==9" ]
[]
885
Write a python function to find the first odd number in a given list of numbers.
def factorial(start,end): res = 1 for i in range(start,end + 1): res *= i return res def sum_of_square(n): return int(factorial(n + 1, 2 * n) /factorial(1, n))
[ "assert triangle_area(0) == 0", "assert triangle_area(-1) == -1", "assert triangle_area(2) == 4" ]
[]
646
Write a function to convert camel case string to snake case string.
from collections import Counter def second_frequent(input): dict = Counter(input) value = sorted(dict.values(), reverse=True) second_large = value[1] for (key, val) in dict.items(): if val == second_large: return (key)
[ "assert count_alpha_dig_spl(\"abc!@#123\")==(3,3,3)", "assert count_alpha_dig_spl(\"dgsuy@#$%&1255\")==(5,4,5)", "assert count_alpha_dig_spl(\"fjdsif627348#%$^&\")==(6,6,5)" ]
[]
665
Write a python function to find minimum possible value for the given periodic function.
def check_identical(test_list1, test_list2): res = test_list1 == test_list2 return (res)
[ "assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864", "assert mutiple_tuple((1,2,3)) == 6", "assert mutiple_tuple((-2,-4,-6)) == -48" ]
[]
727
Write a function to find maximum run of uppercase characters in the given string.
def last_Two_Digits(N): if (N >= 10): return fac = 1 for i in range(1,N + 1): fac = (fac * i) % 100 return (fac)
[ "assert sd_calc([4, 2, 5, 8, 6])== 2.23606797749979", "assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287", "assert sd_calc([5,9,10,15,6,4])==4.070217029430577" ]
[]
887
Write a function to combine two dictionaries by adding values for common keys.
def find_fixed_point(arr, n): for i in range(n): if arr[i] is i: return i return -1
[ "assert lower_ctr('abc') == 3", "assert lower_ctr('string') == 6", "assert lower_ctr('Python') == 5" ]
[]
911
Write a function to calculate the perimeter of a regular polygon.
import heapq def cheap_items(items,n): cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price']) return cheap_items
[ "assert test_three_equal(1,1,1) == 3", "assert test_three_equal(-1,-2,-3) == 0", "assert test_three_equal(1,2,2) == 2" ]
[]
711
Write a function to check if the given integer is a prime number.
def odd_Num_Sum(n) : j = 0 sm = 0 for i in range(1,n + 1) : j = (2*i-1) sm = sm + (j*j*j*j) return sm
[ "assert change_date_format('2026-01-02')=='02-01-2026'", "assert change_date_format('2021-01-04')=='04-01-2021'", "assert change_date_format('2030-06-06')=='06-06-2030'" ]
[]
834
Write a function to find maximum of two numbers.
def find_longest_conseq_subseq(arr, n): ans = 0 count = 0 arr.sort() v = [] v.append(arr[0]) for i in range(1, n): if (arr[i] != arr[i - 1]): v.append(arr[i]) for i in range(len(v)): if (i > 0 and v[i] == v[i - 1] + 1): count += 1 else: count = 1 ans = max(ans, count) return ans
[ "assert check_min_heap([1, 2, 3, 4, 5, 6], 0) == True", "assert check_min_heap([2, 3, 4, 5, 10, 15], 0) == True", "assert check_min_heap([2, 10, 4, 5, 3, 15], 0) == False" ]
[]
874
## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block
def count_Pairs(arr,n): cnt = 0; for i in range(n): for j in range(i + 1,n): if (arr[i] == arr[j]): cnt += 1; return cnt;
[ "assert rectangle_perimeter(10,20)==60", "assert rectangle_perimeter(10,5)==30", "assert rectangle_perimeter(4,2)==12" ]
[]
673
Write a python function to find sum of prime numbers between 1 to n.
def remove_length(test_str, K): temp = test_str.split() res = [ele for ele in temp if len(ele) != K] res = ' '.join(res) return (res)
[ "assert count_vowels('bestinstareels') == 7", "assert count_vowels('partofthejourneyistheend') == 12", "assert count_vowels('amazonprime') == 5" ]
[]
952
Write a function to caluclate the area of a tetrahedron.
def Diff(li1,li2): return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
[ "assert string_length('python')==6", "assert string_length('program')==7", "assert string_length('language')==8" ]
[]
628
Write a function to find length of the subarray having maximum sum.
def first_odd(nums): first_odd = next((el for el in nums if el%2!=0),-1) return first_odd
[ "assert count_Unset_Bits(2) == 1", "assert count_Unset_Bits(5) == 4", "assert count_Unset_Bits(14) == 17" ]
[]
932
Write a python function to find the smallest missing number from the given array.
def Average(lst): return sum(lst) / len(lst)
[ "assert noprofit_noloss(1500,1200)==False", "assert noprofit_noloss(100,100)==True", "assert noprofit_noloss(2000,5000)==False" ]
[]
870
Write a function to find the smallest multiple of the first n numbers.
def max_sum_list(lists): return max(lists, key=sum)
[ "assert remove_even([1,3,5,2]) == [1,3,5]", "assert remove_even([5,6,7]) == [5,7]", "assert remove_even([1,2,3,4]) == [1,3]" ]
[]
757
Write a python function to shift first element to the end of given list.
def Sum(N): SumOfPrimeDivisors = [0]*(N + 1) for i in range(2,N + 1) : if (SumOfPrimeDivisors[i] == 0) : for j in range(i,N + 1,i) : SumOfPrimeDivisors[j] += i return SumOfPrimeDivisors[N]
[ "assert check_valid((True, True, True, True) ) == True", "assert check_valid((True, False, True, True) ) == False", "assert check_valid((True, True, True, True) ) == True" ]
[]
632
Write a function to put spaces between words starting with capital letters in a given string by using regex.
import re def road_rd(street): return (re.sub('Road$', 'Rd.', street))
[ "assert add_list([1, 2, 3],[4,5,6])==[5, 7, 9]", "assert add_list([1,2],[3,4])==[4,6]", "assert add_list([10,20],[50,70])==[60,90]" ]
[]
929
Write a function to count unique keys for each value present in the tuple.
import math def wind_chill(v,t): windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16) return int(round(windchill, 0))
[ "assert check_element((4, 5, 7, 9, 3), [6, 7, 10, 11]) == True", "assert check_element((1, 2, 3, 4), [4, 6, 7, 8, 9]) == True", "assert check_element((3, 2, 1, 4, 5), [9, 8, 7, 6]) == False" ]
[]
937
Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.
def pair_OR_Sum(arr,n) : ans = 0 for i in range(0,n) : for j in range(i + 1,n) : ans = ans + (arr[i] ^ arr[j]) return ans
[ "assert right_insertion([1,2,4,5],6)==4", "assert right_insertion([1,2,4,5],3)==2", "assert right_insertion([1,2,4,5],7)==4" ]
[]
678
Write a function to find the median of two sorted arrays of same size.
def tuple_to_dict(test_tup): res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2)) return (res)
[ "assert min_Swaps(\"1101\",\"1110\") == 1", "assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"", "assert min_Swaps(\"1110000\",\"0001101\") == 3" ]
[]
680
Write a function to count occurrence of a character in a string.
def coin_change(S, m, n): table = [[0 for x in range(m)] for x in range(n+1)] for i in range(m): table[0][i] = 1 for i in range(1, n+1): for j in range(m): x = table[i - S[j]][j] if i-S[j] >= 0 else 0 y = table[i][j-1] if j >= 1 else 0 table[i][j] = x + y return table[n][m-1]
[ "assert previous_palindrome(99)==88", "assert previous_palindrome(1221)==1111", "assert previous_palindrome(120)==111" ]
[]
702
Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.
def parallelogram_perimeter(b,h): perimeter=2*(b*h) return perimeter
[ "assert text_match_wordz_middle(\"pythonzabc.\")==('Found a match!')", "assert text_match_wordz_middle(\"xyzabc.\")==('Found a match!')", "assert text_match_wordz_middle(\" lang .\")==('Not matched!')" ]
[]
794
Write a python function to find the sum of all odd length subarrays.
def convert(list): s = [str(i) for i in list] res = int("".join(s)) return (res)
[ "assert count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] ", "assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] ", "assert count_variable(11,15,12,23)==['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's']" ]
[]
685
Write a python function to print duplicants from a list of integers.
def is_abundant(n): fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0]) return fctrsum > n
[ "assert perimeter_polygon(4,20)==80", "assert perimeter_polygon(10,15)==150", "assert perimeter_polygon(9,7)==63" ]
[]
891
Write a function to iterate over all pairs of consecutive items in a given list.
def roman_to_int(s): rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} int_val = 0 for i in range(len(s)): if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]: int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]] else: int_val += rom_val[s[i]] return int_val
[ "assert convert([1,2,3]) == 123", "assert convert([4,5,6]) == 456", "assert convert([7,8,9]) == 789" ]
[]
627
Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.
def lower_ctr(str): lower_ctr= 0 for i in range(len(str)): if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1 return lower_ctr
[ "assert is_decimal('123.11')==True", "assert is_decimal('e666.86')==False", "assert is_decimal('3.124587')==False" ]
[]
816
Write a function to find the area of a rombus.
import heapq as hq def raw_heap(rawheap): hq.heapify(rawheap) return rawheap
[ "assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] ", "assert remove_duplicate([\"a\", \"b\", \"a\", \"c\", \"c\"] )==[\"a\", \"b\", \"c\"]", "assert remove_duplicate([1, 3, 5, 6, 3, 5, 6, 1] )==[1, 3, 5, 6]" ]
[]
660
Write a function to add a dictionary to the tuple.
def min_difference(test_list): temp = [abs(b - a) for a, b in test_list] res = min(temp) return (res)
[ "assert fibonacci(7) == 13", "assert fibonacci(8) == 21", "assert fibonacci(9) == 34" ]
[]
811
Write a python function to find the sum of squares of binomial co-efficients.
def sort_tuple(tup): n = len(tup) for i in range(n): for j in range(n-i-1): if tup[j][0] > tup[j + 1][0]: tup[j], tup[j + 1] = tup[j + 1], tup[j] return tup
[ "assert find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)", "assert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)", "assert find_closet([2, 5, 11],[3, 16, 21],[11, 13],3,3,2) == (11, 16, 11)" ]
[]
830
Write a function to find if there is a triplet in the array whose sum is equal to a given value.
def count_Fac(n): m = n count = 0 i = 2 while((i * i) <= m): total = 0 while (n % i == 0): n /= i total += 1 temp = 0 j = 1 while((temp + j) <= total): temp += j count += 1 j += 1 i += 1 if (n != 1): count += 1 return count
[ "assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]", "assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]", "assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]" ]
root = Node(1) root.left = Node(2) root.right = Node(3) root.left.left = Node(4) root.left.right = Node(5) root1 = Node(1); root1.left = Node(2); root1.right = Node(3); root1.left.left = Node(4); root1.right.left = Node(5); root1.right.right = Node(6); root1.right.right.right= Node(7); root1.right.right.right.right = Node(8) root2 = Node(1) root2.left = Node(2) root2.right = Node(3) root2.left.left = Node(4) root2.left.right = Node(5) root2.left.left.left = Node(6) root2.left.left.right = Node(7)
[]
705
Write a function to find the most common elements and their counts of a specified text.
def len_log(list1): min=len(list1[0]) for i in list1: if len(i)<min: min=len(i) return min
[ "assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)", "assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)", "assert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)" ]
[]
931
Write a function to generate all sublists of a given list.
import sys def find_max_val(n, x, y): ans = -sys.maxsize for k in range(n + 1): if (k % x == y): ans = max(ans, k) return (ans if (ans >= 0 and ans <= n) else -1)
[ "assert listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])==[['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]", "assert listify_list(['python'])==[['p', 'y', 't', 'h', 'o', 'n']]", "assert listify_list([' red ', 'green',' black', 'blue ',' orange', 'brown'])==[[' ', 'r', 'e', 'd', ' '], ['g', 'r', 'e', 'e', 'n'], [' ', 'b', 'l', 'a', 'c', 'k'], ['b', 'l', 'u', 'e', ' '], [' ', 'o', 'r', 'a', 'n', 'g', 'e'], ['b', 'r', 'o', 'w', 'n']]" ]
[]
675
Write a python function to find the cube sum of first n odd natural numbers.
def sum_Natural(n): sum = (n * (n + 1)) return int(sum) def sum_Even(l,r): return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2)))
[ "assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]", "assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]", "assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]" ]
[]
656
Write a function to calculate the sum of all digits of the base to the specified power.
def get_noOfways(n): if (n == 0): return 0; if (n == 1): return 1; return get_noOfways(n - 1) + get_noOfways(n - 2);
[ "assert lateralsurface_cone(5,12)==204.20352248333654", "assert lateralsurface_cone(10,15)==566.3586699569488", "assert lateralsurface_cone(19,17)==1521.8090132193388" ]
[]
971
Write a function to find the longest chain which can be formed from the given set of pairs.
from math import tan, pi def perimeter_polygon(s,l): perimeter = s*l return perimeter
[ "assert max_run_uppercase('GeMKSForGERksISBESt') == 5", "assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6", "assert max_run_uppercase('GooGLEFluTTER') == 4" ]
[]
630
Write a function to count the same pair in two given lists using map function.
def chinese_zodiac(year): if (year - 2000) % 12 == 0: sign = 'Dragon' elif (year - 2000) % 12 == 1: sign = 'Snake' elif (year - 2000) % 12 == 2: sign = 'Horse' elif (year - 2000) % 12 == 3: sign = 'sheep' elif (year - 2000) % 12 == 4: sign = 'Monkey' elif (year - 2000) % 12 == 5: sign = 'Rooster' elif (year - 2000) % 12 == 6: sign = 'Dog' elif (year - 2000) % 12 == 7: sign = 'Pig' elif (year - 2000) % 12 == 8: sign = 'Rat' elif (year - 2000) % 12 == 9: sign = 'Ox' elif (year - 2000) % 12 == 10: sign = 'Tiger' else: sign = 'Hare' return sign
[ "assert tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}", "assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}", "assert tuple_to_set(('z', 'd', 'e') ) == {'d', 'e', 'z'}" ]
[]
942
Write a python function to check whether the given two arrays are equal or not.
import re regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$''' def check_IP(Ip): if(re.search(regex, Ip)): return ("Valid IP address") else: return ("Invalid IP address")
[ "assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3", "assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3", "assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10" ]
[]
699
Write a function to sort a list of dictionaries using lambda function.
import heapq def nth_super_ugly_number(n, primes): uglies = [1] def gen(prime): for ugly in uglies: yield ugly * prime merged = heapq.merge(*map(gen, primes)) while len(uglies) < n: ugly = next(merged) if ugly != uglies[-1]: uglies.append(ugly) return uglies[-1]
[ "assert multiply_list([1,-2,3]) == -6", "assert multiply_list([1,2,3,4]) == 24", "assert multiply_list([3,1,2,3]) == 18" ]
[]
855
Write a function to find the n - cheap price items from a given dataset using heap queue algorithm.
def smallest_multiple(n): if (n<=2): return n i = n * 2 factors = [number for number in range(n, 1, -1) if number * 2 > n] while True: for a in factors: if i % a != 0: i += n break if (a == factors[-1] and i % a == 0): return i
[ "assert left_insertion([1,2,4,5],6)==4", "assert left_insertion([1,2,4,5],3)==2", "assert left_insertion([1,2,4,5],7)==4" ]
[]
767
Write a function to find the fixed point in the given array.
def ntimes_list(nums,n): result = map(lambda x:n*x, nums) return list(result)
[ "assert Check_Solution(2,5,2) == \"2 solutions\"", "assert Check_Solution(1,1,1) == \"No solutions\"", "assert Check_Solution(1,2,1) == \"1 solution\"" ]
[]
623
Write a function to find the occurrence and position of the substrings within a string.
from itertools import zip_longest, chain, tee def exchange_elements(lst): lst1, lst2 = tee(iter(lst), 2) return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))
[ "assert rencontres_number(7, 2) == 924", "assert rencontres_number(3, 0) == 2", "assert rencontres_number(3, 1) == 3" ]
[]
694
Write a function that matches a string that has an a followed by zero or more b's by using regex.
import re def remove_extra_char(text1): pattern = re.compile('[\W_]+') return (pattern.sub('', text1))
[ "assert maximum_product( [12, 74, 9, 50, 61, 41])==225700", "assert maximum_product([25, 35, 22, 85, 14, 65, 75, 25, 58])==414375", "assert maximum_product([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==2520" ]
[]
918
Write a python function to count number of vowels in the string.
def check_min_heap(arr, i): if 2 * i + 2 > len(arr): return True left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1) right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] and check_min_heap(arr, 2 * i + 2)) return left_child and right_child
[ "assert max_char(\"hello world\")==('l')", "assert max_char(\"hello \")==('l')", "assert max_char(\"python pr\")==('p')" ]
[]
824
Write a python function to merge the first and last elements separately in a list of lists.
import re def text_match_zero_one(text): patterns = 'ab?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert find_Min_Diff((1,5,3,19,18,25),6) == 1", "assert find_Min_Diff((4,3,2,6),4) == 1", "assert find_Min_Diff((30,5,20,9),4) == 4" ]
[]
927
Write a function to get the length of a complex number.
from itertools import groupby def extract_elements(numbers, n): result = [i for i, j in groupby(numbers) if len(list(j)) == n] return result
[ "assert odd_Num_Sum(2) == 82", "assert odd_Num_Sum(3) == 707", "assert odd_Num_Sum(4) == 3108" ]
[]
756
Write a function to find the sum of first even and odd number of a given list.
from operator import eq def count_same_pair(nums1, nums2): result = sum(map(eq, nums1, nums2)) return result
[ "assert substract_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((-5, -4), (1, -4), (1, 8), (-6, 7))", "assert substract_elements(((13, 4), (14, 6), (13, 10), (12, 11)), ((19, 8), (14, 10), (12, 2), (18, 4))) == ((-6, -4), (0, -4), (1, 8), (-6, 7))", "assert substract_elements(((19, 5), (18, 7), (19, 11), (17, 12)), ((12, 9), (17, 11), (13, 3), (19, 5))) == ((7, -4), (1, -4), (6, 8), (-2, 7))" ]
[]
848
Write a python function to check whether the given strings are rotations of each other or not.
def get_median(arr1, arr2, n): i = 0 j = 0 m1 = -1 m2 = -1 count = 0 while count < n + 1: count += 1 if i == n: m1 = m2 m2 = arr2[0] break elif j == n: m1 = m2 m2 = arr1[0] break if arr1[i] <= arr2[j]: m1 = m2 m2 = arr1[i] i += 1 else: m1 = m2 m2 = arr2[j] j += 1 return (m1 + m2)/2
[ "assert second_smallest([1, 2, -8, -2, 0, -2])==-2", "assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5", "assert second_smallest([2,2])==None" ]
[]
825
Write a python function to check whether the given two numbers have same number of digits or not.
def access_key(ditionary,key): return list(ditionary)[key]
[ "assert count_char(\"Python\",'o')==1", "assert count_char(\"little\",'t')==2", "assert count_char(\"assert\",'s')==2" ]
[]
738
Write a function to find length of the string.
def binomial_coeff(n, k): C = [[0 for j in range(k + 1)] for i in range(n + 1)] for i in range(0, n + 1): for j in range(0, min(i, k) + 1): if (j == 0 or j == i): C[i][j] = 1 else: C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) return C[n][k] def lobb_num(n, m): return (((2 * m + 1) * binomial_coeff(2 * n, m + n)) / (m + n + 1))
[ "assert is_upper(\"person\") ==\"PERSON\"", "assert is_upper(\"final\") == \"FINAL\"", "assert is_upper(\"Valid\") == \"VALID\"" ]
[]
684
Write a python function to check whether all the characters are same or not.
def decreasing_trend(nums): if (sorted(nums)== nums): return True else: return False
[ "assert count_Fac(24) == 3", "assert count_Fac(12) == 2", "assert count_Fac(4) == 1" ]
[]
700
Write a function to convert camel case string to snake case string by using regex.
def nCr_mod_p(n, r, p): if (r > n- r): r = n - r C = [0 for i in range(r + 1)] C[0] = 1 for i in range(1, n + 1): for j in range(min(i, r), 0, -1): C[j] = (C[j] + C[j-1]) % p return C[r]
[ "assert count_Char(\"abcac\",'a') == 4", "assert count_Char(\"abca\",'c') == 2", "assert count_Char(\"aba\",'a') == 7" ]
[]
814
Write a python function to find the sum of fourth power of first n odd natural numbers.
def sum_Range_list(nums, m, n): sum_range = 0 for i in range(m, n+1, 1): sum_range += nums[i] return sum_range
[ "assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'", "assert replace_spaces('The Avengers') == 'The_Avengers'", "assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'" ]
[]
758
Write a function to split the given string at uppercase letters by using regex.
import re def change_date_format(dt): return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) return change_date_format(dt)
[ "assert series_sum(6)==91", "assert series_sum(7)==140", "assert series_sum(12)==650" ]
[]
792
Write a function to group a sequence of key-value pairs into a dictionary of lists using collections module.
def discriminant_value(x,y,z): discriminant = (y**2) - (4*x*z) if discriminant > 0: return ("Two solutions",discriminant) elif discriminant == 0: return ("one solution",discriminant) elif discriminant < 0: return ("no real solution",discriminant)
[ "assert sum_series(7)==784", "assert sum_series(5)==225", "assert sum_series(15)==14400" ]
[]
671
Write a python function to find the kth element in an array containing odd elements first and then even elements.
from sys import maxsize def max_sub_array_sum(a,size): max_so_far = -maxsize - 1 max_ending_here = 0 start = 0 end = 0 s = 0 for i in range(0,size): max_ending_here += a[i] if max_so_far < max_ending_here: max_so_far = max_ending_here start = s end = i if max_ending_here < 0: max_ending_here = 0 s = i+1 return (end - start + 1)
[ "assert all_Characters_Same(\"python\") == False", "assert all_Characters_Same(\"aaa\") == True", "assert all_Characters_Same(\"data\") == False" ]
[]
820
Write a function to find the item with maximum occurrences in a given list.
def is_subset(arr1, m, arr2, n): hashset = set() for i in range(0, m): hashset.add(arr1[i]) for i in range(0, n): if arr2[i] in hashset: continue else: return False return True
[ "assert No_of_cubes(2,1) == 8", "assert No_of_cubes(5,2) == 64", "assert No_of_cubes(1,1) == 1" ]
[]
760
Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
def _sum(arr): sum=0 for i in arr: sum = sum + i return(sum)
[ "assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3", "assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1", "assert find_fixed_point([0, 2, 5, 8, 17],5) == 0" ]
[]
832
Write a python function to check if the string is a concatenation of another string.
def min_Swaps(s1,s2) : c0 = 0; c1 = 0; for i in range(len(s1)) : if (s1[i] == '0' and s2[i] == '1') : c0 += 1; elif (s1[i] == '1' and s2[i] == '0') : c1 += 1; result = c0 // 2 + c1 // 2; if (c0 % 2 == 0 and c1 % 2 == 0) : return result; elif ((c0 + c1) % 2 == 0) : return result + 2; else : return -1;
[ "assert extract_date(\"https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/\") == [('2016', '09', '02')]", "assert extract_date(\"https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-s-death-his-brother-in-law-shares-advice-for-fans-1749646/\") == [('2020', '11', '03')]", "assert extract_date(\"https://economictimes.indiatimes.com/news/economy/2020/12/29/finance/pension-assets-under-pfrda-touch-rs-5-32-lakh-crore/articleshow/79736619.cms\") == [('2020', '12', '29')]" ]
[]
804
Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.
def generate_matrix(n): if n<=0: return [] matrix=[row[:] for row in [[0]*n]*n] row_st=0 row_ed=n-1 col_st=0 col_ed=n-1 current=1 while (True): if current>n*n: break for c in range (col_st, col_ed+1): matrix[row_st][c]=current current+=1 row_st+=1 for r in range (row_st, row_ed+1): matrix[r][col_ed]=current current+=1 col_ed-=1 for c in range (col_ed, col_st-1, -1): matrix[row_ed][c]=current current+=1 row_ed-=1 for r in range (row_ed, row_st-1, -1): matrix[r][col_st]=current current+=1 col_st+=1 return matrix
[ "assert increasing_trend([1,2,3,4]) == True", "assert increasing_trend([4,3,2,1]) == False", "assert increasing_trend([0,1,4,9]) == True" ]
[]
922
Write a function to find the occurrences of n most common words in a given text.
def merge(lst): return [list(ele) for ele in list(zip(*lst))]
[ "assert chinese_zodiac(1997)==('Ox')", "assert chinese_zodiac(1998)==('Tiger')", "assert chinese_zodiac(1994)==('Dog')" ]
[]
759
Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'.
def number_ctr(str): number_ctr= 0 for i in range(len(str)): if str[i] >= '0' and str[i] <= '9': number_ctr += 1 return number_ctr
[ "assert is_odd(5) == True", "assert is_odd(6) == False", "assert is_odd(7) == True" ]
[]
701
Write a python function to sort the given string.
def sort_String(str) : str = ''.join(sorted(str)) return (str)
[ "assert roman_to_int('MMMCMLXXXVI')==3986", "assert roman_to_int('MMMM')==4000", "assert roman_to_int('C')==100" ]
[]
961
Write a function to validate a gregorian date.
def mul_consecutive_nums(nums): result = [b*a for a, b in zip(nums[:-1], nums[1:])] return result
[ "assert Sum_of_Inverse_Divisors(6,12) == 2", "assert Sum_of_Inverse_Divisors(9,13) == 1.44", "assert Sum_of_Inverse_Divisors(1,4) == 4" ]
[]
714
Write a python function to check for odd parity of a given number.
def pair_wise(l1): temp = [] for i in range(len(l1) - 1): current_element, next_element = l1[i], l1[i + 1] x = (current_element, next_element) temp.append(x) return temp
[ "assert get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5", "assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3", "assert get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7) == 5" ]
[]
940
Write a function to find the largest subset where each pair is divisible.
def find_platform(arr, dep, n): arr.sort() dep.sort() plat_needed = 1 result = 1 i = 1 j = 0 while (i < n and j < n): if (arr[i] <= dep[j]): plat_needed+= 1 i+= 1 elif (arr[i] > dep[j]): plat_needed-= 1 j+= 1 if (plat_needed > result): result = plat_needed return result
[ "assert get_unique([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)] ) == '{4: 4, 2: 3, 1: 2}'", "assert get_unique([(4, 5), (2, 3), (3, 5), (9, 3), (8, 3), (9, 2), (10, 2), (9, 5), (11, 5)] ) == '{5: 4, 3: 3, 2: 2}'", "assert get_unique([(6, 5), (3, 4), (2, 6), (11, 1), (8, 22), (8, 11), (4, 3), (14, 3), (11, 6)] ) == '{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}'" ]
[]
799
Write a function that matches a string that has an a followed by three 'b'.
from itertools import combinations def sub_lists(my_list): subs = [] for i in range(0, len(my_list)+1): temp = [list(x) for x in combinations(my_list, i)] if len(temp)>0: subs.extend(temp) return subs
[ "assert sector_area(4,45)==6.285714285714286", "assert sector_area(9,45)==31.82142857142857", "assert sector_area(9,360)==None" ]
[]
741
Write a python function to count the total unset bits from 1 to n.
def chunk_tuples(test_tup, N): res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)] return (res)
[ "assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3", "assert find_platform([100,200,300,400],[700,800,900,1000],4)==4", "assert find_platform([5,6,7,8],[4,3,2,1],4)==1" ]
[]
877
Write a function to find out, if the given number is abundant.
def arc_length(d,a): pi=22/7 if a >= 360: return None arclength = (pi*d) * (a/360) return arclength
[ "assert remove_parenthesis([\"python (chrome)\"])==(\"python\")", "assert remove_parenthesis([\"string(.abc)\"])==(\"string\")", "assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")" ]
[]
648
Write a function to add two integers. however, if the sum is between the given range it will return 20.
import heapq as hq def heap_sort(iterable): h = [] for value in iterable: hq.heappush(h, value) return [hq.heappop(h) for i in range(len(h))]
[ "assert lcopy([1, 2, 3]) == [1, 2, 3]", "assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]", "assert lcopy([4, 5, 6]) == [4, 5, 6]\n" ]
[]
783
Write a python function to find nth bell number.
def check(arr,n): g = 0 for i in range(1,n): if (arr[i] - arr[i - 1] > 0 and g == 1): return False if (arr[i] - arr[i] < 0): g = 1 return True
[ "assert geometric_sum(7) == 1.9921875", "assert geometric_sum(4) == 1.9375", "assert geometric_sum(8) == 1.99609375" ]
[]
634
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
def last(arr,x,n): low = 0 high = n - 1 res = -1 while (low <= high): mid = (low + high) // 2 if arr[mid] > x: high = mid - 1 elif arr[mid] < x: low = mid + 1 else: res = mid low = mid + 1 return res
[ "assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}", "assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}", "assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}" ]
[]
865
Write a function to rearrange positive and negative numbers in a given array using lambda function.
from collections import Counter def add_dict(d1,d2): add_dict = Counter(d1) + Counter(d2) return add_dict
[ "assert subset([1, 2, 3, 4],4) == 1", "assert subset([5, 6, 9, 3, 4, 3, 4],7) == 2", "assert subset([1, 2, 3 ],3) == 1" ]
[]
752
Write a function to count the number of inversions in the given array.
import re def split_upperstring(text): return (re.findall('[A-Z][^A-Z]*', text))
[ "assert equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3", "assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3", "assert equilibrium_index([1, 2, 3]) == -1" ]
[]
761
Write a python function to check whether the two given strings are isomorphic to each other or not.
def check_monthnumb(monthname2): if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"): return True else: return False
[ "assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]", "assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]", "assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]" ]
[]
622
Write a function to check if one tuple is a subset of another tuple.
def listify_list(list1): result = list(map(list,list1)) return result
[ "assert is_abundant(12)==True", "assert is_abundant(13)==False", "assert is_abundant(9)==False" ]
[]
609
Write a function to find the product of it’s kth index in the given tuples.
import math def sum_of_odd_Factors(n): res = 1 while n % 2 == 0: n = n // 2 for i in range(3,int(math.sqrt(n) + 1)): count = 0 curr_sum = 1 curr_term = 1 while n % i == 0: count+=1 n = n // i curr_term *= i curr_sum += curr_term res *= curr_sum if n >= 2: res *= (1 + n) return res
[ "assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}", "assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}", "assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}" ]
[]
879
Write a python function to copy a list from a singleton tuple.
def Sum_of_Inverse_Divisors(N,Sum): ans = float(Sum)*1.0 /float(N); return round(ans,2);
[ "assert fifth_Power_Sum(2) == 33", "assert fifth_Power_Sum(4) == 1300", "assert fifth_Power_Sum(3) == 276" ]
[]
751
Write a function to print n-times a list using map function.
def bell_Number(n): bell = [[0 for i in range(n+1)] for j in range(n+1)] bell[0][0] = 1 for i in range(1, n+1): bell[i][0] = bell[i-1][i-1] for j in range(1, i+1): bell[i][j] = bell[i-1][j-1] + bell[i][j-1] return bell[n][0]
[ "assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2", "assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1", "assert max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])==1" ]
[]
743
Write a python function to find the sum of all even natural numbers within the range l and r.
def front_and_rear(test_tup): res = (test_tup[0], test_tup[-1]) return (res)
[ "assert wind_chill(120,35)==40", "assert wind_chill(40,70)==86", "assert wind_chill(10,100)==116" ]
[]
935
Write a function to get dictionary keys as a list.
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) return result
[ "assert check_none((10, 4, 5, 6, None)) == True", "assert check_none((7, 8, 9, 11, 14)) == False", "assert check_none((1, 2, 3, 4, None)) == True" ]
[]
810
Write a function to get an item of a tuple.
def reverse_list_lists(lists): for l in lists: l.sort(reverse = True) return lists
[ "assert round_up(123.01247,0)==124", "assert round_up(123.01247,1)==123.1", "assert round_up(123.01247,2)==123.02" ]
[]
647
Write a function to combine two given sorted lists using heapq module.
def is_Word_Present(sentence,word): s = sentence.split(" ") for i in s: if (i == word): return True return False
[ "assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]", "assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]", "assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]" ]
[]
695
Write a function to count those characters which have vowels as their neighbors in the given string.
def Repeat(x): _size = len(x) repeated = [] for i in range(_size): k = i + 1 for j in range(k, _size): if x[i] == x[j] and x[i] not in repeated: repeated.append(x[i]) return repeated
[ "assert extract_max('100klh564abc365bg') == 564", "assert extract_max('hello300how546mer231') == 546", "assert extract_max('its233beenalong343journey234') == 343" ]
[]
722
Write a function to check a decimal with a precision of 2.
import datetime def check_date(m, d, y): try: m, d, y = map(int, (m, d, y)) datetime.date(y, m, d) return True except ValueError: return False
[ "assert sub_lists([10, 20, 30, 40])==[[], [10], [20], [30], [40], [10, 20], [10, 30], [10, 40], [20, 30], [20, 40], [30, 40], [10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40], [10, 20, 30, 40]]", "assert sub_lists(['X', 'Y', 'Z'])==[[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z']]", "assert sub_lists([1,2,3])==[[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]" ]
[]
817
Write a function to print the first n lucky numbers.
import re def text_match_three(text): patterns = 'ab{3}?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert first_odd([1,3,5]) == 1", "assert first_odd([2,4,1,3]) == 1", "assert first_odd ([8,9,1]) == 9" ]
[]
808
Write a function to count the most common character in a given string.
def maximum_product(nums): import heapq a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums) return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])
[ "assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] ", "assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] ", "assert max_sum_list([[2,3,1]])==[2,3,1] " ]
[]
829
Write a function to convert degrees to radians.
def equilibrium_index(arr): total_sum = sum(arr) left_sum=0 for i, num in enumerate(arr): total_sum -= num if left_sum == total_sum: return i left_sum += num return -1
[ "assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True", "assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},6)==True", "assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},10)==False" ]
[]
964
Write a function to remove duplicates from a list of lists.
def first_repeated_char(str1): for index,c in enumerate(str1): if str1[:index+1].count(c) > 1: return c return "None"
[ "assert access_key({'physics': 80, 'math': 90, 'chemistry': 86},0)== 'physics'", "assert access_key({'python':10, 'java': 20, 'C++':30},2)== 'C++'", "assert access_key({'program':15,'computer':45},1)== 'computer'" ]
[]
924
Write a function to caluclate arc length of an angle.
import re regex = '[a-zA-z0-9]$' def check_alphanumeric(string): if(re.search(regex, string)): return ("Accept") else: return ("Discard")
[ "assert remove_spaces('python program')==('python program')", "assert remove_spaces('python programming language')==('python programming language')", "assert remove_spaces('python program')==('python program')" ]
[]
End of preview. Expand in Data Studio

edition_1790_google-research-datasets-mbpp-readymade

A Readymade by TheFactoryX

Original Dataset

google-research-datasets/mbpp

Process

This dataset is a "readymade" - inspired by Marcel Duchamp's concept of taking everyday objects and recontextualizing them as art.

What we did:

  1. Selected the original dataset from Hugging Face
  2. Shuffled each column independently
  3. Destroyed all row-wise relationships
  4. Preserved structure, removed meaning

The result: Same data. Wrong order. New meaning. No meaning.

Purpose

This is art. This is not useful. This is the point.

Column relationships have been completely destroyed. The data maintains its types and values, but all semantic meaning has been removed.


Part of the Readymades project by TheFactoryX.

"I am a machine." — Andy Warhol

Downloads last month
14