doc_string
stringlengths
20
1.14k
suffix
stringlengths
1
482
src_lang
stringclasses
1 value
test_cases
sequencelengths
0
100
import_str
sequencelengths
0
1
dataset_name
stringclasses
1 value
prefix
stringlengths
65
1.27k
solution
stringlengths
3
417
demos
sequencelengths
0
8
tgt_lang
stringclasses
1 value
entry_func
stringlengths
1
30
compare_func
sequencelengths
0
0
task_name
stringclasses
1 value
data_id
stringlengths
38
40
Given a positive integer n, you have to make a pile of n levels of stones. The first level has n stones. The number of stones in the next level is: - the next odd number if n is odd. - the next even number if n is even. Return the number of stones in each level in a list, where element at index i represents the number of stones in the level (i+1).
for i in range(n)]
python
[ [ "3", "[3, 5, 7]" ], [ "4", "[4,6,8,10]" ], [ "5", "[5, 7, 9, 11, 13]" ], [ "6", "[6, 8, 10, 12, 14, 16]" ], [ "8", "[8, 10, 12, 14, 16, 18, 20, 22]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def make_a_pile(n): """ Given a positive integer n, you have to make a pile of n levels of stones. The first level has n stones. The number of stones in the next level is: - the next odd number if n is odd. - the next even number if n is even. Return the number of stones in each level in a list, where element at index i represents the number of stones in the level (i+1). """ return
[n + 2*i
[ [ "3", "[3, 5, 7]" ] ]
python
make_a_pile
[]
code_infilling
RandomSpanInfillingLight/HumanEval/100/1
You will be given a string of words separated by commas or spaces. Your task is to split the string into words and return an array of the words.
return s_list.split()
python
[ [ "\"Hi, my name is John\"", "[\"Hi\", \"my\", \"name\", \"is\", \"John\"]" ], [ "\"One, two, three, four, five, six\"", "[\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]" ], [ "\"Hi, my name\"", "[\"Hi\", \"my\", \"name\"]" ], [ "\"One,, two, three, four, five, six,\"", "[\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]" ], [ "\"\"", "[]" ], [ "\"ahmed , gamal\"", "[\"ahmed\", \"gamal\"]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def words_string(s): """ You will be given a string of words separated by commas or spaces. Your task is to split the string into words and return an array of the words. """ if not s: return [] s_list = [] for letter in s:
if letter == ',': s_list.append(' ') else: s_list.append(letter) s_list = "".join(s_list)
[ [ "\"Hi, my name is John\"", "[\"Hi\", \"my\", \"name\", \"is\", \"John\"]" ], [ "\"One, two, three, four, five, six\"", "[\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]" ] ]
python
words_string
[]
code_infilling
RandomSpanInfillingLight/HumanEval/101/1
This function takes two positive numbers x and y and returns the biggest even integer number that is in the range [x, y] inclusive. If there's no such number, then the function should return -1.
if x == y: return -1 return y - 1
python
[ [ "12, 15", "14" ], [ "13, 12", "-1" ], [ "33, 12354", "12354" ], [ "5234, 5233", "-1" ], [ "6, 29", "28" ], [ "27, 10", "-1" ], [ "7, 7", "-1" ], [ "546, 546", "546" ] ]
[]
HumanEval_RandomSpanInfillingLight
def choose_num(x, y): """This function takes two positive numbers x and y and returns the biggest even integer number that is in the range [x, y] inclusive. If there's no such number, then the function should return -1. """
if x > y: return -1 if y % 2 == 0: return y
[ [ "12, 15", "14" ], [ "13, 12", "-1" ] ]
python
choose_num
[]
code_infilling
RandomSpanInfillingLight/HumanEval/102/1
You are given two positive integers n and m, and your task is to compute the average of the integers from n through m (including n and m). Round the answer to the nearest integer and convert that to binary. If n is greater than m, return -1.
)
python
[ [ "1, 5", "\"0b11\"" ], [ "7, 13", "\"0b1010\"" ], [ "964, 977", "\"0b1111001010\"" ], [ "996, 997", "\"0b1111100100\"" ], [ "560, 851", "\"0b1011000010\"" ], [ "185, 546", "\"0b101101110\"" ], [ "362, 496", "\"0b110101101\"" ], [ "350, 902", "\"0b1001110010\"" ], [ "197, 233", "\"0b11010111\"" ], [ "7, 5", "-1" ], [ "5, 1", "-1" ], [ "5, 5", "\"0b101\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def rounded_avg(n, m): """You are given two positive integers n and m, and your task is to compute the average of the integers from n through m (including n and m). Round the answer to the nearest integer and convert that to binary. If n is greater than m, return -1. """ if m < n: return -1 summation = 0 for i in range(n, m+1): summation += i return bin(
round(summation/(m - n + 1))
[ [ "1, 5", "\"0b11\"" ], [ "7, 5", "-1" ], [ "10, 20", "\"0b1111\"" ], [ "20, 33", "\"0b11010\"" ] ]
python
rounded_avg
[]
code_infilling
RandomSpanInfillingLight/HumanEval/103/1
Given a list of positive integers x. return a sorted list of all elements that hasn't any even digit. Note: Returned list should be sorted in increasing order.
return sorted(odd_digit_elements)
python
[ [ "[15, 33, 1422, 1]", "[1, 15, 33]" ], [ "[152, 323, 1422, 10]", "[]" ], [ "[12345, 2033, 111, 151]", "[111, 151]" ], [ "[135, 103, 31]", "[31, 135]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def unique_digits(x): """Given a list of positive integers x. return a sorted list of all elements that hasn't any even digit. Note: Returned list should be sorted in increasing order. """ odd_digit_elements = []
for i in x: if all (int(c) % 2 == 1 for c in str(i)): odd_digit_elements.append(i)
[ [ "[15, 33, 1422, 1]", "[1, 15, 33]" ], [ "[152, 323, 1422, 10]", "[]" ] ]
python
unique_digits
[]
code_infilling
RandomSpanInfillingLight/HumanEval/104/1
Given an array of integers, sort the integers that are between 1 and 9 inclusive, reverse the resulting array, and then replace each digit by its corresponding name from "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
sorted_arr = sorted(arr, reverse=True) new_arr = [] for var in sorted_arr: try: new_arr.append(dic[var]) except: pass return new_arr
python
[ [ "[2, 1, 1, 4, 5, 8, 2, 3]", "[\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"]" ], [ "[]", "[]" ], [ "[1, -1 , 55]", "['One']" ], [ "[1, -1, 3, 2]", "[\"Three\", \"Two\", \"One\"]" ], [ "[9, 4, 8]", "[\"Nine\", \"Eight\", \"Four\"]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def by_length(arr): """ Given an array of integers, sort the integers that are between 1 and 9 inclusive, reverse the resulting array, and then replace each digit by its corresponding name from "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine". """
dic = { 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine", }
[ [ "[2, 1, 1, 4, 5, 8, 2, 3]", "[\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"]" ], [ "[]", "[]" ], [ "[1, -1 , 55]", "[\"One\"]" ] ]
python
by_length
[]
code_infilling
RandomSpanInfillingLight/HumanEval/105/1
Implement the function f that takes n as a parameter, 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 or the sum of numbers from 1 to i otherwise. i starts from 1. the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
return ret
python
[ [ "5", "[1, 2, 6, 24, 15]" ], [ "7", "[1, 2, 6, 24, 15, 720, 28]" ], [ "1", "[1]" ], [ "3", "[1, 2, 6]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def f(n): """ Implement the function f that takes n as a parameter, 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 or the sum of numbers from 1 to i otherwise. i starts from 1. the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i). """ ret = [] for i in range(1,n+1): if i%2 == 0: x = 1 for j in range(1,i+1): x *= j ret += [x]
else: x = 0 for j in range(1,i+1): x += j ret += [x]
[ [ "5", "[1, 2, 6, 24, 15]" ] ]
python
f
[]
code_infilling
RandomSpanInfillingLight/HumanEval/106/1
Given a positive integer n, return a tuple that has the number of even and odd integer palindromes that fall within the range(1, n), inclusive.
even_palindrome_count += 1 return (even_palindrome_count, odd_palindrome_count)
python
[ [ "123", "(8, 13)" ], [ "12", "(4, 6)" ], [ "3", "(1, 2)" ], [ "63", "(6, 8)" ], [ "25", "(5, 6)" ], [ "19", "(4, 6)" ], [ "9", "(4, 5)" ], [ "1", "(0, 1)" ] ]
[]
HumanEval_RandomSpanInfillingLight
def even_odd_palindrome(n): """ Given a positive integer n, return a tuple that has the number of even and odd integer palindromes that fall within the range(1, n), inclusive. """ def is_palindrome(n): return str(n) == str(n)[::-1] even_palindrome_count = 0 odd_palindrome_count = 0 for i in range(1, n+1): if i%2 == 1 and is_palindrome(i):
odd_palindrome_count += 1 elif i%2 == 0 and is_palindrome(i):
[ [ "3", "(1, 2)" ], [ "12", "(4, 6)" ] ]
python
even_odd_palindrome
[]
code_infilling
RandomSpanInfillingLight/HumanEval/107/1
Write a function count_nums which takes an array of integers and returns the number of elements which has a sum of digits > 0. If a number is negative, then its first signed digit will be negative: e.g. -123 has signed digits -1, 2, and 3.
return len(list(filter(lambda x: x > 0, [digits_sum(i) for i in arr])))
python
[ [ "[]", "0" ], [ "[-1, -2, 0]", "0" ], [ "[1, 1, 2, -2, 3, 4, 5]", "6" ], [ "[1, 6, 9, -6, 0, 1, 5]", "5" ], [ "[1, 100, 98, -7, 1, -1]", "4" ], [ "[12, 23, 34, -45, -56, 0]", "5" ], [ "[-0, 1**0]", "1" ], [ "[1]", "1" ] ]
[]
HumanEval_RandomSpanInfillingLight
def count_nums(arr): """ Write a function count_nums which takes an array of integers and returns the number of elements which has a sum of digits > 0. If a number is negative, then its first signed digit will be negative: e.g. -123 has signed digits -1, 2, and 3. """
def digits_sum(n): neg = 1 if n < 0: n, neg = -1 * n, -1 n = [int(i) for i in str(n)] n[0] = n[0] * neg return sum(n)
[ [ "[]", "0" ], [ "[-1, 11, -11]", "1" ], [ "[1, 1, 2]", "3" ] ]
python
count_nums
[]
code_infilling
RandomSpanInfillingLight/HumanEval/108/1
We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The numbers in the array will be randomly ordered. Your task is to determine if it is possible to get an array sorted in non-decreasing order by performing the following operation on the given array: You are allowed to perform right shift operation any number of times. One right shift operation means shifting all elements of the array by one position in the right direction. The last element of the array will be moved to the starting position in the array i.e. 0th index. If it is possible to obtain the sorted array by performing the above operation then return True else return False. If the given array is empty then return True. Note: The given list is guaranteed to have unique elements.
return True
python
[ [ "[3, 4, 5, 1, 2]", "True" ], [ "[3, 5, 10, 1, 2]", "True" ], [ "[4, 3, 1, 2]", "False" ], [ "[3, 5, 4, 1, 2]", "False" ], [ "[]", "True" ] ]
[]
HumanEval_RandomSpanInfillingLight
def move_one_ball(arr): """We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The numbers in the array will be randomly ordered. Your task is to determine if it is possible to get an array sorted in non-decreasing order by performing the following operation on the given array: You are allowed to perform right shift operation any number of times. One right shift operation means shifting all elements of the array by one position in the right direction. The last element of the array will be moved to the starting position in the array i.e. 0th index. If it is possible to obtain the sorted array by performing the above operation then return True else return False. If the given array is empty then return True. Note: The given list is guaranteed to have unique elements. """ if len(arr)==0: return True sorted_array=sorted(arr) my_arr=[] min_value=min(arr) min_index=arr.index(min_value) my_arr=arr[min_index:]+arr[0:min_index] for i in range(len(arr)):
if my_arr[i]!=sorted_array[i]: return False
[ [ "[3, 4, 5, 1, 2]", ">True" ], [ "[3, 5, 4, 1, 2]", ">False" ] ]
python
move_one_ball
[]
code_infilling
RandomSpanInfillingLight/HumanEval/109/1
In this problem, you will implement a function that takes two lists of numbers, and determines whether it is possible to perform an exchange of elements between them to make lst1 a list of only even numbers. There is no limit on the number of exchanged elements between lst1 and lst2. If it is possible to exchange elements between the lst1 and lst2 to make all the elements of lst1 to be even, return "YES". Otherwise, return "NO".
return "NO"
python
[ [ "[1, 2, 3, 4], [1, 2, 3, 4]", "\"YES\"" ], [ "[1, 2, 3, 4], [1, 5, 3, 4]", "\"NO\"" ], [ "[1, 2, 3, 4], [2, 1, 4, 3]", "\"YES\"" ], [ "[5, 7, 3], [2, 6, 4]", "\"YES\"" ], [ "[5, 7, 3], [2, 6, 3]", "\"NO\"" ], [ "[3, 2, 6, 1, 8, 9], [3, 5, 5, 1, 1, 1]", "\"NO\"" ], [ "[100, 200], [200, 200]", "\"YES\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def exchange(lst1, lst2): """In this problem, you will implement a function that takes two lists of numbers, and determines whether it is possible to perform an exchange of elements between them to make lst1 a list of only even numbers. There is no limit on the number of exchanged elements between lst1 and lst2. If it is possible to exchange elements between the lst1 and lst2 to make all the elements of lst1 to be even, return "YES". Otherwise, return "NO". """ odd = 0 even = 0 for i in lst1: if i%2 == 1: odd += 1
for i in lst2: if i%2 == 0: even += 1 if even >= odd: return "YES"
[ [ "[1, 2, 3, 4], [1, 2, 3, 4]", "\"YES\"" ], [ "[1, 2, 3, 4], [1, 5, 3, 4]", "\"NO\"" ] ]
python
exchange
[]
code_infilling
RandomSpanInfillingLight/HumanEval/110/1
Given a string representing a space separated lowercase letters, return a dictionary of the letter with the most repetition and containing the corresponding count. If several letters have the same occurrence, return all of them.
return dict1
python
[ [ "'a b b a'", "{'a':2,'b': 2}" ], [ "'a b c a b'", "{'a': 2, 'b': 2}" ], [ "'a b c d g'", "{'a': 1, 'b': 1, 'c': 1, 'd': 1, 'g': 1}" ], [ "'r t g'", "{'r': 1,'t': 1,'g': 1}" ], [ "'b b b b a'", "{'b': 4}" ], [ "'r t g'", "{'r': 1,'t': 1,'g': 1}" ], [ "''", "{}" ], [ "'a'", "{'a': 1}" ] ]
[]
HumanEval_RandomSpanInfillingLight
def histogram(test): """Given a string representing a space separated lowercase letters, return a dictionary of the letter with the most repetition and containing the corresponding count. If several letters have the same occurrence, return all of them. """ dict1={} list1=test.split(" ") t=0 for i in list1: if(list1.count(i)>t) and i!='': t=list1.count(i)
if t>0: for i in list1: if(list1.count(i)==t): dict1[i]=t
[ [ "'a b c'", "{'a': 1, 'b': 1, 'c': 1}" ], [ "'a b b a'", "{'a': 2, 'b': 2}" ], [ "'a b c a b'", "{'a': 2, 'b': 2}" ], [ "'b b b b a'", "{'b': 4}" ], [ "''", "{}" ] ]
python
histogram
[]
code_infilling
RandomSpanInfillingLight/HumanEval/111/1
Task 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 then check if the result string is palindrome. A string is called palindrome if it reads the same backward as forward. You should return a tuple containing the result string and True/False for the check.
return (s,s[::-1] == s)
python
[ [ "\"abcde\", \"ae\"", "('bcd',False)" ], [ "\"abcdef\", \"b\"", "('acdef',False)" ], [ "\"abcdedcba\", \"ab\"", "('cdedc',True)" ], [ "\"dwik\", \"w\"", "('dik',False)" ], [ "\"a\", \"a\"", "('',True)" ], [ "\"abcdedcba\", \"\"", "('abcdedcba',True)" ], [ "\"abcdedcba\", \"v\"", "('abcdedcba',True)" ], [ "\"vabba\", \"v\"", "('abba',True)" ], [ "\"mamma\", \"mia\"", "(\"\", True)" ] ]
[]
HumanEval_RandomSpanInfillingLight
def reverse_delete(s,c): """Task 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 then check if the result string is palindrome. A string is called palindrome if it reads the same backward as forward. You should return a tuple containing the result string and True/False for the check. """ s =
''.join([char for char in s if char not in c])
[ [ "'abcde', 'ae'", "('bcd', False)" ], [ "'abcdef', 'b'", "('acdef',False)" ], [ "'abcdedcba', 'ab'", "('cdedc',True)" ] ]
python
reverse_delete
[]
code_infilling
RandomSpanInfillingLight/HumanEval/112/1
Given a list of strings, where each string consists of only digits, return a list. Each element i of the output should be "the number of odd elements in the string i of the input." where all the i's should be replaced by the number of odd digits in the i'th string of the input.
return res
python
[ [ "['1234567']", "[\"the number of odd elements 4n the str4ng 4 of the 4nput.\"]" ], [ "['3',\"11111111\"]", "[\"the number of odd elements 1n the str1ng 1 of the 1nput.\", \"the number of odd elements 8n the str8ng 8 of the 8nput.\"]" ], [ "['271', '137', '314']", "[\n 'the number of odd elements 2n the str2ng 2 of the 2nput.',\n 'the number of odd elements 3n the str3ng 3 of the 3nput.',\n 'the number of odd elements 2n the str2ng 2 of the 2nput.'\n ]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def odd_count(lst): """Given a list of strings, where each string consists of only digits, return a list. Each element i of the output should be "the number of odd elements in the string i of the input." where all the i's should be replaced by the number of odd digits in the i'th string of the input. """ res = [] for arr in lst: n = sum(int(d)%2==1 for d in arr) res
.append("the number of odd elements " + str(n) + "n the str"+ str(n) +"ng "+ str(n) +" of the "+ str(n) +"nput.")
[ [ "['1234567']", "[\"the number of odd elements 4n the str4ng 4 of the 4nput.\"]" ], [ "['3',\"11111111\"]", "[\"the number of odd elements 1n the str1ng 1 of the 1nput.\"," ] ]
python
odd_count
[]
code_infilling
RandomSpanInfillingLight/HumanEval/113/1
Given an array of integers nums, find the minimum sum of any non-empty sub-array of nums.
min_sum = -max_sum return min_sum
python
[ [ "[2, 3, 4, 1, 2, 4]", "1" ], [ "[-1, -2, -3]", "-6" ], [ "[-1, -2, -3, 2, -10]", "-14" ], [ "[-9999999999999999]", "-9999999999999999" ], [ "[0, 10, 20, 1000000]", "0" ], [ "[-1, -2, -3, 10, -5]", "-6" ], [ "[100, -1, -2, -3, 10, -5]", "-6" ], [ "[10, 11, 13, 8, 3, 4]", "3" ], [ "[100, -33, 32, -1, 0, -2]", "-33" ], [ "[-10]", "-10" ], [ "[7]", "7" ], [ "[1, -1]", "-1" ] ]
[]
HumanEval_RandomSpanInfillingLight
def minSubArraySum(nums): """ Given an array of integers nums, find the minimum sum of any non-empty sub-array of nums. """ max_sum = 0 s = 0
for num in nums: s += -num if (s < 0): s = 0 max_sum = max(s, max_sum) if max_sum == 0: max_sum = max(-i for i in nums)
[ [ "[2, 3, 4, 1, 2, 4]", "1" ], [ "[-1, -2, -3]", "-6" ] ]
python
minSubArraySum
[]
code_infilling
RandomSpanInfillingLight/HumanEval/114/1
You are given a rectangular grid of wells. Each row represents a single well, and each 1 in a row represents a single unit of water. Each well has a corresponding bucket that can be used to extract water from it, and all buckets have the same capacity. Your task is to use the buckets to empty the wells. Output the number of times you need to lower the buckets.
for arr in grid])
python
[ [ "[[0,0,1,0], [0,1,0,0], [1,1,1,1]], 1", "6" ], [ "[[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]], 2", "5" ], [ "[[0,0,0], [0,0,0]], 5", "0" ], [ "[[1,1,1,1], [1,1,1,1]], 2", "4" ], [ "[[1,1,1,1], [1,1,1,1]], 9", "2" ] ]
[ "import math" ]
HumanEval_RandomSpanInfillingLight
def max_fill(grid, capacity): import math """ You are given a rectangular grid of wells. Each row represents a single well, and each 1 in a row represents a single unit of water. Each well has a corresponding bucket that can be used to extract water from it, and all buckets have the same capacity. Your task is to use the buckets to empty the wells. Output the number of times you need to lower the buckets. """ return sum([ma
th.ceil(sum(arr)/capacity)
[ [ "[[0,0,1,0], [0,1,0,0], [1,1,1,1]], 1", "6" ], [ "[[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]], 2", "5" ], [ "[[0,0,0], [0,0,0]], 5", "0" ] ]
python
max_fill
[]
code_infilling
RandomSpanInfillingLight/HumanEval/115/1
In this Kata, you have to sort an array of non-negative integers according to number of ones in their binary representation in ascending order. For similar number of ones, sort based on decimal value.
)
python
[ [ "[1,5,2,3,4]", "[1, 2, 4, 3, 5]" ], [ "[-2,-3,-4,-5,-6]", "[-4, -2, -6, -5, -3]" ], [ "[1,0,2,3,4]", "[0, 1, 2, 4, 3]" ], [ "[]", "[]" ], [ "[2,5,77,4,5,3,5,7,2,3,4]", "[2, 2, 4, 4, 3, 3, 5, 5, 5, 7, 77]" ], [ "[3,6,44,12,32,5]", "[32, 3, 5, 6, 12, 44]" ], [ "[2,4,8,16,32]", "[2, 4, 8, 16, 32]" ], [ "[2,4,8,16,32]", "[2, 4, 8, 16, 32]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def sort_array(arr): """ In this Kata, you have to sort an array of non-negative integers according to number of ones in their binary representation in ascending order. For similar number of ones, sort based on decimal value. """ return sorted(sorted(arr), key=
lambda x: bin(x)[2:].count('1')
[ [ "[1, 5, 2, 3, 4]", "[1, 2, 3, 4, 5]" ], [ "[-2, -3, -4, -5, -6]", "[-6, -5, -4, -3, -2]" ] ]
python
sort_array
[]
code_infilling
RandomSpanInfillingLight/HumanEval/116/1
Given a string s and a natural number n, you have been tasked to implement a function that returns a list of all words from string s that contain exactly n consonants, in order these words appear in the string s. If the string s is empty then the function should return an empty list. Note: you may assume the input string contains only letters and spaces.
: n_consonants += 1 if n_consonants == n: result.append(word) return result
python
[ [ "\"Mary had a little lamb\", 4", "[\"little\"]" ], [ "\"Mary had a little lamb\", 3", "[\"Mary\", \"lamb\"]" ], [ "\"simple white space\", 2", "[]" ], [ "\"Hello world\", 4", "[\"world\"]" ], [ "\"Uncle sam\", 3", "[\"Uncle\"]" ], [ "\"\", 4", "[]" ], [ "\"a b c d e f\", 1", "[\"b\", \"c\", \"d\", \"f\"]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def select_words(s, n): """Given a string s and a natural number n, you have been tasked to implement a function that returns a list of all words from string s that contain exactly n consonants, in order these words appear in the string s. If the string s is empty then the function should return an empty list. Note: you may assume the input string contains only letters and spaces. """ result = [] for word in s.split(): n_consonants = 0 for i in range(0, len(word)): if word[i]
.lower() not in ["a","e","i","o","u"]
[ [ "\"Mary had a little lamb\", 4", "> [\"little\"]" ], [ "\"Mary had a little lamb\", 3", "> [\"Mary\", \"lamb\"]" ], [ "\"simple white space\", 2", "> []" ], [ "\"Hello world\", 4", "> [\"world\"]" ], [ "\"Uncle sam\", 3", "> [\"Uncle\"]" ] ]
python
select_words
[]
code_infilling
RandomSpanInfillingLight/HumanEval/117/1
You are given a word. Your task is to find the closest vowel that stands between two consonants from the right side of the word (case sensitive). Vowels in the beginning and ending doesn't count. Return empty string if you didn't find any vowel met the above condition. You may assume that the given string contains English letter only.
return ""
python
[ [ "\"yogurt\"", "\"u\"" ], [ "\"full\"", "\"u\"" ], [ "\"easy\"", "\"\"" ], [ "\"eAsy\"", "\"\"" ], [ "\"ali\"", "\"\"" ], [ "\"bad\"", "\"a\"" ], [ "\"most\"", "\"o\"" ], [ "\"ab\"", "\"\"" ], [ "\"ba\"", "\"\"" ], [ "\"quick\"", "\"\"" ], [ "\"anime\"", "\"i\"" ], [ "\"Asia\"", "\"\"" ], [ "\"Above\"", "\"o\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def get_closest_vowel(word): """You are given a word. Your task is to find the closest vowel that stands between two consonants from the right side of the word (case sensitive). Vowels in the beginning and ending doesn't count. Return empty string if you didn't find any vowel met the above condition. You may assume that the given string contains English letter only. """ if len(word) < 3: return "" vowels = {"a", "e", "i", "o", "u", "A", "E", 'O', 'U', 'I'} for i in range(len(word)-2, 0, -1):
if word[i] in vowels: if (word[i+1] not in vowels) and (word[i-1] not in vowels): return word[i]
[ [ "\"yogurt\"", "> \"u\"" ], [ "\"FULL\"", "> \"U\"" ], [ "\"quick\"", "> \"\"" ], [ "\"ab\"", "> \"\"" ] ]
python
get_closest_vowel
[]
code_infilling
RandomSpanInfillingLight/HumanEval/118/1
You are given a list of two strings, both strings consist of open parentheses '(' or close parentheses ')' only. Your job is to check if it is possible to concatenate the two strings in some order, that the resulting string will be good. A string S is considered to be good if and only if all parentheses in S are balanced. For example: the string '(())()' is good, while the string '())' is not. Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
S1 = lst[0] + lst[1] S2 = lst[1] + lst[0] return 'Yes' if check(S1) or check(S2) else 'No'
python
[ [ "['()(', ')']", "'Yes'" ], [ "[')', ')']", "'No'" ], [ "['(()(())', '())())']", "'No'" ], [ "[')())', '(()()(']", "'Yes'" ], [ "['(())))', '(()())((']", "'Yes'" ], [ "['()', '())']", "'No'" ], [ "['(()(', '()))()']", "'Yes'" ], [ "['((((', '((())']", "'No'" ], [ "[')(()', '(()(']", "'No'" ], [ "[')(', ')(']", "'No'" ], [ "['(', ')']", "'Yes'" ], [ "[')', '(']", "'Yes'" ] ]
[]
HumanEval_RandomSpanInfillingLight
def match_parens(lst): """ You are given a list of two strings, both strings consist of open parentheses '(' or close parentheses ')' only. Your job is to check if it is possible to concatenate the two strings in some order, that the resulting string will be good. A string S is considered to be good if and only if all parentheses in S are balanced. For example: the string '(())()' is good, while the string '())' is not. Return 'Yes' if there's a way to make a good string, and return 'No' otherwise. """
def check(s): val = 0 for i in s: if i == '(': val = val + 1 else: val = val - 1 if val < 0: return False return True if val == 0 else False
[ [ "['()(', ')']", "'Yes'" ], [ "[')', ')']", "'No'" ] ]
python
match_parens
[]
code_infilling
RandomSpanInfillingLight/HumanEval/119/1
Given an array arr of integers and a positive integer k, return a sorted list of length k with the maximum k numbers in arr.
return ans
python
[ [ "[-3, -4, 5], 3", "[-4, -3, 5]" ], [ "[4, -4, 4], 2", "[4, 4]" ], [ "[-3, 2, 1, 2, -1, -2, 1], 1", "[2]" ], [ "[123, -123, 20, 0 , 1, 2, -3], 3", "[2, 20, 123]" ], [ "[-123, 20, 0 , 1, 2, -3], 4", "[0, 1, 2, 20]" ], [ "[5, 15, 0, 3, -13, -8, 0], 7", "[-13, -8, 0, 0, 3, 5, 15]" ], [ "[-1, 0, 2, 5, 3, -10], 2", "[3, 5]" ], [ "[1, 0, 5, -7], 1", "[5]" ], [ "[4, -4], 2", "[-4, 4]" ], [ "[-10, 10], 2", "[-10, 10]" ], [ "[1, 2, 3, -23, 243, -400, 0], 0", "[]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def maximum(arr, k): """ Given an array arr of integers and a positive integer k, return a sorted list of length k with the maximum k numbers in arr. """ if k == 0: return []
arr.sort() ans = arr[-k:]
[ [ "[-3, -4, 5], 3", "[-4, -3, 5]" ], [ "[4, -4, 4], 2", "[4, 4]" ], [ "[-3, 2, 1, 2, -1, -2, 1], 1", "[2]" ] ]
python
maximum
[]
code_infilling
RandomSpanInfillingLight/HumanEval/120/1
Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
])
python
[ [ "[5, 8, 7, 1]", "12" ], [ "[3, 3, 3, 3, 3]", "9" ], [ "[30, 13, 24, 321]", "0" ], [ "[5, 9]", "5" ], [ "[2, 4, 8]", "0" ], [ "[30, 13, 23, 32]", "23" ], [ "[3, 13, 2, 9]", "3" ] ]
[]
HumanEval_RandomSpanInfillingLight
def solution(lst): """Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions. """ return sum([x for idx, x in enumerate(lst)
if idx%2==0 and x%2==1
[ [ "[5, 8, 7, 1]", "> 12" ], [ "[3, 3, 3, 3, 3]", "> 9" ], [ "[30, 13, 24, 321]", ">0" ] ]
python
solution
[]
code_infilling
RandomSpanInfillingLight/HumanEval/121/1
Given a non-empty array of integers arr and an integer k, return the sum of the elements with at most two digits from the first k elements of arr.
)
python
[ [ "[1,-2,-3,41,57,76,87,88,99], 3", "-4" ], [ "[111,121,3,4000,5,6], 2", "0" ], [ "[11,21,3,90,5,6,7,8,9], 4", "125" ], [ "[111,21,3,4000,5,6,7,8,9], 4", "24" ], [ "[1], 1", "1" ] ]
[]
HumanEval_RandomSpanInfillingLight
def add_elements(arr, k): """ Given a non-empty array of integers arr and an integer k, return the sum of the elements with at most two digits from the first k elements of arr. """ return sum(elem for elem in
arr[:k] if len(str(elem)) <= 2
[ [ "[111,21,3,4000,5,6,7,8,9], 4", "24" ] ]
python
add_elements
[]
code_infilling
RandomSpanInfillingLight/HumanEval/122/1
Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence. The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1. Note: 1. Collatz(1) is [1]. 2. returned list sorted in increasing order.
if n%2 == 1: odd_collatz.append(int(n)) return sorted(odd_collatz)
python
[ [ "14", "[1, 5, 7, 11, 13, 17]" ], [ "5", "[1, 5]" ], [ "12", "[1, 3, 5]" ], [ "1", "[1]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def get_odd_collatz(n): """ Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence. The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1. Note: 1. Collatz(1) is [1]. 2. returned list sorted in increasing order. """ if n%2==0: odd_collatz = [] else: odd_collatz = [n]
while n > 1: if n % 2 == 0: n = n/2 else: n = n*3 + 1
[ [ "5", "[1, 5]" ] ]
python
get_odd_collatz
[]
code_infilling
RandomSpanInfillingLight/HumanEval/123/1
You have to write a function which validates a given date string and returns True if the date is valid otherwise False. The date is valid if all of the following rules are satisfied: 1. The date string is not empty. 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. 3. The months should not be less than 1 or higher than 12. 4. The date should be in the format: mm-dd-yyyy
if month == 2 and day < 1 or day > 29: return False except: return False return True
python
[ [ "'03-11-2000'", "True" ], [ "'15-01-2012'", "False" ], [ "'04-0-2040'", "False" ], [ "'06-04-2020'", "True" ], [ "'01-01-2007'", "True" ], [ "'03-32-2011'", "False" ], [ "''", "False" ], [ "'04-31-3000'", "False" ], [ "'06-06-2005'", "True" ], [ "'21-31-2000'", "False" ], [ "'04-12-2003'", "True" ], [ "'04122003'", "False" ], [ "'20030412'", "False" ], [ "'2003-04'", "False" ], [ "'2003-04-12'", "False" ], [ "'04-2003'", "False" ] ]
[]
HumanEval_RandomSpanInfillingLight
def valid_date(date): """You have to write a function which validates a given date string and returns True if the date is valid otherwise False. The date is valid if all of the following rules are satisfied: 1. The date string is not empty. 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. 3. The months should not be less than 1 or higher than 12. 4. The date should be in the format: mm-dd-yyyy """ try: date = date.strip() month, day, year = date.split('-') month, day, year = int(month), int(day), int(year)
if month < 1 or month > 12: return False if month in [1,3,5,7,8,10,12] and day < 1 or day > 31: return False if month in [4,6,9,11] and day < 1 or day > 30: return False
[ [ "'03-11-2000'", "True" ], [ "'15-01-2012'", "False" ], [ "'04-0-2040'", "False" ], [ "'06-04-2020'", "True" ], [ "'06/04/2020'", "False" ] ]
python
valid_date
[]
code_infilling
RandomSpanInfillingLight/HumanEval/124/1
Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
ord(i)%2 == 0])
python
[ [ "\"Hello world!\"", "[\"Hello\",\"world!\"]" ], [ "\"Hello,world!\"", "[\"Hello\",\"world!\"]" ], [ "\"Hello world,!\"", "[\"Hello\",\"world,!\"]" ], [ "\"Hello,Hello,world !\"", "[\"Hello,Hello,world\",\"!\"]" ], [ "\"abcdef\"", "3" ], [ "\"aaabb\"", "2" ], [ "\"aaaBb\"", "1" ], [ "\"\"", "0" ] ]
[]
HumanEval_RandomSpanInfillingLight
def split_words(txt): """ Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25 """ if " " in txt: return txt.split() elif "," in txt: return txt.replace(',',' ').split() else: return len([
i for i in txt if i.islower() and
[ [ "\"abcdef\"", "3" ] ]
python
split_words
[]
code_infilling
RandomSpanInfillingLight/HumanEval/125/1
Given a list of numbers, return whether or not they are sorted in ascending order. If list has more than 1 duplicate of the same number, return False. Assume no negative numbers and only integers.
if all(lst[i-1] <= lst[i] for i in range(1, len(lst))): return True else: return False
python
[ [ "[5]", "True" ], [ "[1, 2, 3, 4, 5]", "True" ], [ "[1, 3, 2, 4, 5]", "False" ], [ "[1, 2, 3, 4, 5, 6]", "True" ], [ "[1, 2, 3, 4, 5, 6, 7]", "True" ], [ "[1, 3, 2, 4, 5, 6, 7]", "False" ], [ "[]", "True" ], [ "[1]", "True" ], [ "[3, 2, 1]", "False" ], [ "[1, 2, 2, 2, 3, 4]", "False" ], [ "[1, 2, 3, 3, 3, 4]", "False" ], [ "[1, 2, 2, 3, 3, 4]", "True" ], [ "[1, 2, 3, 4]", "True" ] ]
[]
HumanEval_RandomSpanInfillingLight
def is_sorted(lst): """ Given a list of numbers, return whether or not they are sorted in ascending order. If list has more than 1 duplicate of the same number, return False. Assume no negative numbers and only integers. """
count_digit = dict([(i, 0) for i in lst]) for i in lst: count_digit[i]+=1 if any(count_digit[i] > 2 for i in lst): return False
[ [ "[5]", "True" ], [ "[1, 2, 3, 4, 5]", "True" ], [ "[1, 3, 2, 4, 5]", "False" ], [ "[1, 2, 3, 4, 5, 6]", "True" ], [ "[1, 2, 3, 4, 5, 6, 7]", "True" ], [ "[1, 3, 2, 4, 5, 6, 7]", "False" ], [ "[1, 2, 2, 3, 3, 4]", "True" ], [ "[1, 2, 2, 2, 3, 4]", "False" ] ]
python
is_sorted
[]
code_infilling
RandomSpanInfillingLight/HumanEval/126/1
You are given two intervals, where each interval is a pair of integers. For example, interval = (start, end) = (1, 2). The given intervals are closed which means that the interval (start, end) includes both start and end. For each given interval, it is assumed that its start is less or equal its end. Your task is to determine whether the length of intersection of these two intervals is a prime number. Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3) which its length is 1, which not a prime number. If the length of the intersection is a prime number, return "YES", otherwise, return "NO". If the two intervals don't intersect, return "NO".
return "NO"
python
[ [ "(1, 2), (2, 3)", "\"NO\"" ], [ "(-1, 1), (0, 4)", "\"NO\"" ], [ "(-3, -1), (-5, 5)", "\"YES\"" ], [ "(-2, 2), (-4, 0)", "\"YES\"" ], [ "(-11, 2), (-1, -1)", "\"NO\"" ], [ "(1, 2), (3, 5)", "\"NO\"" ], [ "(1, 2), (1, 2)", "\"NO\"" ], [ "(-2, -2), (-3, -2)", "\"NO\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def intersection(interval1, interval2): """You are given two intervals, where each interval is a pair of integers. For example, interval = (start, end) = (1, 2). The given intervals are closed which means that the interval (start, end) includes both start and end. For each given interval, it is assumed that its start is less or equal its end. Your task is to determine whether the length of intersection of these two intervals is a prime number. Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3) which its length is 1, which not a prime number. If the length of the intersection is a prime number, return "YES", otherwise, return "NO". If the two intervals don't intersect, return "NO". """ def is_prime(num): if num == 1 or num == 0: return False if num == 2: return True for i in range(2, num): if num%i == 0: return False return True
l = max(interval1[0], interval2[0]) r = min(interval1[1], interval2[1]) length = r - l if length > 0 and is_prime(length): return "YES"
[ [ "(1, 2), (2, 3)", "> \"NO\"" ], [ "(-1, 1), (0, 4)", "> \"NO\"" ], [ "(-3, -1), (-5, 5)", "> \"YES\"" ] ]
python
intersection
[]
code_infilling
RandomSpanInfillingLight/HumanEval/127/1
You are given an array arr of integers and you need to return sum of magnitudes of integers multiplied by product of all signs of each number in the array, represented by 1, -1 or 0. Note: return None for empty arr.
return prod * sum([abs(i) for i in arr])
python
[ [ "[1, 2, 2, -4]", "-9" ], [ "[0, 1]", "0" ], [ "[1, 1, 1, 2, 3, -1, 1]", "-10" ], [ "[]", "None" ], [ "[2, 4,1, 2, -1, -1, 9]", "20" ], [ "[-1, 1, -1, 1]", "4" ], [ "[-1, 1, 1, 1]", "-4" ], [ "[-1, 1, 1, 0]", "0" ] ]
[]
HumanEval_RandomSpanInfillingLight
def prod_signs(arr): """ You are given an array arr of integers and you need to return sum of magnitudes of integers multiplied by product of all signs of each number in the array, represented by 1, -1 or 0. Note: return None for empty arr. """ if not arr: return None prod =
0 if 0 in arr else (-1) ** len(list(filter(lambda x: x < 0, arr)))
[ [ "[1, 2, 2, -4]", "-9" ], [ "[0, 1]", "0" ], [ "[]", "None" ] ]
python
prod_signs
[]
code_infilling
RandomSpanInfillingLight/HumanEval/128/1
Given a grid with N rows and N columns (N >= 2) and a positive integer k, each cell of the grid contains a value. Every integer in the range [1, N * N] inclusive appears exactly once on the cells of the grid. You have to find the minimum path of length k in the grid. You can start from any cell, and in each step you can move to any of the neighbor cells, in other words, you can go to cells which share an edge with you current cell. Please note that a path of length k means visiting exactly k cells (not necessarily distinct). You CANNOT go off the grid. A path A (of length k) is considered less than a path B (of length k) if after making the ordered lists of the values on the cells that A and B go through (let's call them lst_A and lst_B), lst_A is lexicographically less than lst_B, in other words, there exist an integer index i (1 <= i <= k) such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have lst_A[j] = lst_B[j]. It is guaranteed that the answer is unique. Return an ordered list of the values on the cells that the minimum path go through.
ans = [] for i in range(k): if i % 2 == 0: ans.append(1) else: ans.append(val) return ans
python
[ [ "[[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3", "[1, 2, 1]" ], [ "[[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1", "[1]" ], [ "[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], 4", "[1, 2, 1, 2]" ], [ "[[6, 4, 13, 10], [5, 7, 12, 1], [3, 16, 11, 15], [8, 14, 9, 2]], 7", "[1, 10, 1, 10, 1, 10, 1]" ], [ "[[8, 14, 9, 2], [6, 4, 13, 15], [5, 7, 1, 12], [3, 10, 11, 16]], 5", "[1, 7, 1, 7, 1]" ], [ "[[11, 8, 7, 2], [5, 16, 14, 4], [9, 3, 15, 6], [12, 13, 10, 1]], 9", "[1, 6, 1, 6, 1, 6, 1, 6, 1]" ], [ "[[12, 13, 10, 1], [9, 3, 15, 6], [5, 16, 14, 4], [11, 8, 7, 2]], 12", "[1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6]" ], [ "[[2, 7, 4], [3, 1, 5], [6, 8, 9]], 8", "[1, 3, 1, 3, 1, 3, 1, 3]" ], [ "[[6, 1, 5], [3, 8, 9], [2, 7, 4]], 8", "[1, 5, 1, 5, 1, 5, 1, 5]" ], [ "[[1, 2], [3, 4]], 10", "[1, 2, 1, 2, 1, 2, 1, 2, 1, 2]" ], [ "[[1, 3], [3, 2]], 10", "[1, 3, 1, 3, 1, 3, 1, 3, 1, 3]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def minPath(grid, k): """ Given a grid with N rows and N columns (N >= 2) and a positive integer k, each cell of the grid contains a value. Every integer in the range [1, N * N] inclusive appears exactly once on the cells of the grid. You have to find the minimum path of length k in the grid. You can start from any cell, and in each step you can move to any of the neighbor cells, in other words, you can go to cells which share an edge with you current cell. Please note that a path of length k means visiting exactly k cells (not necessarily distinct). You CANNOT go off the grid. A path A (of length k) is considered less than a path B (of length k) if after making the ordered lists of the values on the cells that A and B go through (let's call them lst_A and lst_B), lst_A is lexicographically less than lst_B, in other words, there exist an integer index i (1 <= i <= k) such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have lst_A[j] = lst_B[j]. It is guaranteed that the answer is unique. Return an ordered list of the values on the cells that the minimum path go through. """ n = len(grid) val = n * n + 1 for i in range(n): for j in range(n):
if grid[i][j] == 1: temp = [] if i != 0: temp.append(grid[i - 1][j]) if j != 0: temp.append(grid[i][j - 1]) if i != n - 1: temp.append(grid[i + 1][j]) if j != n - 1: temp.append(grid[i][j + 1]) val = min(temp)
[ [ "[[1,2,3], [4,5,6], [7,8,9]], 3", "[1, 2, 1]" ], [ "[[5,9,3], [4,1,6], [7,8,2]], 1", "[1]" ] ]
python
minPath
[]
code_infilling
RandomSpanInfillingLight/HumanEval/129/1
Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in the last couple centuries. However, what people don't know is Tribonacci sequence. Tribonacci sequence is defined by the recurrence: tri(1) = 3 tri(n) = 1 + n / 2, if n is even. tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
else: my_tri.append(i / 2 + 1) return my_tri
python
[ [ "3", "[1, 3, 2.0, 8.0]" ], [ "4", "[1, 3, 2.0, 8.0, 3.0]" ], [ "5", "[1, 3, 2.0, 8.0, 3.0, 15.0]" ], [ "6", "[1, 3, 2.0, 8.0, 3.0, 15.0, 4.0]" ], [ "7", "[1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0]" ], [ "8", "[1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0]" ], [ "9", "[1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0, 35.0]" ], [ "20", "[1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0, 35.0, 6.0, 48.0, 7.0, 63.0, 8.0, 80.0, 9.0, 99.0, 10.0, 120.0, 11.0]" ], [ "0", "[1]" ], [ "1", "[1, 3]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def tri(n): """Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in the last couple centuries. However, what people don't know is Tribonacci sequence. Tribonacci sequence is defined by the recurrence: tri(1) = 3 tri(n) = 1 + n / 2, if n is even. tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd. """ if n == 0: return [1] my_t
ri = [1, 3] for i in range(2, n + 1): if i % 2 == 1: my_tri.append(my_tri[i - 1] + my_tri[i - 2] + (i + 3) / 2)
[ [ "1", "3" ], [ "n", "1 + n / 2, if n is even." ], [ "n", "tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd." ], [ "2", "1 + (2 / 2) = 2" ], [ "4", "3" ], [ "3", "tri(2) + tri(1) + tri(4)" ], [ "3", "[1, 3, 2, 8]" ] ]
python
tri
[]
code_infilling
RandomSpanInfillingLight/HumanEval/130/1
Given a positive integer n, return the product of the odd digits. Return 0 if all digits are even.
if odd_count ==0: return 0 else: return product
python
[ [ "5", "5" ], [ "54", "5" ], [ "120", "1" ], [ "5014", "5" ], [ "98765", "315" ], [ "5576543", "2625" ], [ "2468", "0" ] ]
[]
HumanEval_RandomSpanInfillingLight
def digits(n): """Given a positive integer n, return the product of the odd digits. Return 0 if all digits are even. """ product = 1 odd_count = 0
for digit in str(n): int_digit = int(digit) if int_digit%2 == 1: product= product*int_digit odd_count+=1
[ [ "1", "1" ], [ "4", "0" ], [ "235", "15" ] ]
python
digits
[]
code_infilling
RandomSpanInfillingLight/HumanEval/131/1
Create a function that takes a string as input which contains only square brackets. The function should return True if and only if there is a valid subsequence of brackets where at least one bracket in the subsequence is nested.
for idx in opening_bracket_index: if i < l and idx < closing_bracket_index[i]: cnt += 1 i += 1 return cnt >= 2
python
[ [ "'[[]]'", "True" ], [ "'[]]]]]]][[[[[]'", "False" ], [ "'[][]'", "False" ], [ "'[]'", "False" ], [ "'[[[[]]]]'", "True" ], [ "'[]]]]]]]]]]'", "False" ], [ "'[][][[]]'", "True" ], [ "'[[]'", "False" ], [ "'[]]'", "False" ], [ "'[[]][['", "True" ], [ "'[[][]]'", "True" ], [ "''", "False" ], [ "'[[[[[[[['", "False" ], [ "']]]]]]]]'", "False" ] ]
[]
HumanEval_RandomSpanInfillingLight
def is_nested(string): """ Create a function that takes a string as input which contains only square brackets. The function should return True if and only if there is a valid subsequence of brackets where at least one bracket in the subsequence is nested. """ opening_bracket_index = [] closing_bracket_index = []
for i in range(len(string)): if string[i] == '[': opening_bracket_index.append(i) else: closing_bracket_index.append(i) closing_bracket_index.reverse() cnt = 0 i = 0 l = len(closing_bracket_index)
[ [ "'[[]]'", "True" ], [ "'[]]]]]]][[[[[]'", "False" ], [ "'[][]'", "False" ], [ "'[]'", "False" ], [ "'[[][]]'", "True" ], [ "'[[]][['", "True" ] ]
python
is_nested
[]
code_infilling
RandomSpanInfillingLight/HumanEval/132/1
You are given a list of numbers. You need to return the sum of squared numbers in the given list, round each element in the list to the upper int(Ceiling) first.
for i in lst: squared += math.ceil(i)**2 return squared
python
[ [ "[1,2,3]", "14" ], [ "[1.0,2,3]", "14" ], [ "[1,3,5,7]", "84" ], [ "[1.4,4.2,0]", "29" ], [ "[-2.4,1,1]", "6" ], [ "[100,1,15,2]", "10230" ], [ "[10000,10000]", "200000000" ], [ "[-1.4,4.6,6.3]", "75" ], [ "[-1.4,17.9,18.9,19.9]", "1086" ], [ "[0]", "0" ], [ "[-1]", "1" ], [ "[-1,1,0]", "2" ] ]
[]
HumanEval_RandomSpanInfillingLight
def sum_squares(lst): """You are given a list of numbers. You need to return the sum of squared numbers in the given list, round each element in the list to the upper int(Ceiling) first. """
import math squared = 0
[ [ "[1,2,3]", "14" ], [ "[1,4,9]", "98" ], [ "[1,3,5,7]", "84" ], [ "[1.4,4.2,0]", "29" ], [ "[-2.4,1,1]", "6" ] ]
python
sum_squares
[]
code_infilling
RandomSpanInfillingLight/HumanEval/133/1
Create a function that returns True if the last character of a given string is an alphabetical character and is not a part of a word, and False otherwise. Note: "word" is a group of characters separated by space.
else False
python
[ [ "\"apple\"", "False" ], [ "\"apple pi e\"", "True" ], [ "\"eeeee\"", "False" ], [ "\"A\"", "True" ], [ "\"Pumpkin pie \"", "False" ], [ "\"Pumpkin pie 1\"", "False" ], [ "\"\"", "False" ], [ "\"eeeee e \"", "False" ], [ "\"apple pie\"", "False" ], [ "\"apple pi e \"", "False" ] ]
[]
HumanEval_RandomSpanInfillingLight
def check_if_last_char_is_a_letter(txt): """ Create a function that returns True if the last character of a given string is an alphabetical character and is not a part of a word, and False otherwise. Note: "word" is a group of characters separated by space. """ check = txt.split(' ')[-1] return True if len(check) == 1 and
(97 <= ord(check.lower()) <= 122)
[ [ "\"apple pie\"", "False" ], [ "\"apple pi e\"", "True" ], [ "\"apple pi e \"", "False" ], [ "\"\"", "False" ] ]
python
check_if_last_char_is_a_letter
[]
code_infilling
RandomSpanInfillingLight/HumanEval/134/1
Create a function which returns the largest index of an element which is not greater than or equal to the element immediately preceding it. If no such element exists then return -1. The given array will not contain duplicate values.
return ind
python
[ [ "[1,2,4,3,5]", "3" ], [ "[1,2,4,5]", "-1" ], [ "[1,4,2,5,6,7,8,9,10]", "2" ], [ "[4,8,5,7,3]", "4" ], [ "[]", "-1" ] ]
[]
HumanEval_RandomSpanInfillingLight
def can_arrange(arr): """Create a function which returns the largest index of an element which is not greater than or equal to the element immediately preceding it. If no such element exists then return -1. The given array will not contain duplicate values. """ ind=-1 i=1
while i<len(arr): if arr[i]<arr[i-1]: ind=i i+=1
[ [ "[1,2,4,3,5]", "3" ], [ "[1,2,3]", "-1" ] ]
python
can_arrange
[]
code_infilling
RandomSpanInfillingLight/HumanEval/135/1
Create a function that returns a tuple (a, b), where 'a' is the largest of negative integers, and 'b' is the smallest of positive integers in a list. If there is no negative or positive integers, return them as None.
return (max(smallest) if smallest else None, min(largest) if largest else None)
python
[ [ "[2, 4, 1, 3, 5, 7]", "(None, 1)" ], [ "[2, 4, 1, 3, 5, 7, 0]", "(None, 1)" ], [ "[1, 3, 2, 4, 5, 6, -2]", "(-2, 1)" ], [ "[4, 5, 3, 6, 2, 7, -7]", "(-7, 2)" ], [ "[7, 3, 8, 4, 9, 2, 5, -9]", "(-9, 2)" ], [ "[]", "(None, None)" ], [ "[0]", "(None, None)" ], [ "[-1, -3, -5, -6]", "(-1, None)" ], [ "[-1, -3, -5, -6, 0]", "(-1, None)" ], [ "[-6, -4, -4, -3, 1]", "(-3, 1)" ], [ "[-6, -4, -4, -3, -100, 1]", "(-3, 1)" ] ]
[]
HumanEval_RandomSpanInfillingLight
def largest_smallest_integers(lst): """ Create a function that returns a tuple (a, b), where 'a' is the largest of negative integers, and 'b' is the smallest of positive integers in a list. If there is no negative or positive integers, return them as None. """
smallest = list(filter(lambda x: x < 0, lst)) largest = list(filter(lambda x: x > 0, lst))
[ [ "[2, 4, 1, 3, 5, 7]", "(None, 1)" ], [ "[]", "(None, None)" ], [ "[0]", "(None, None)" ] ]
python
largest_smallest_integers
[]
code_infilling
RandomSpanInfillingLight/HumanEval/136/1
Create a function that takes integers, floats, or strings representing real numbers, and returns the larger variable in its given variable type. Return None if the values are equal. Note: If a real number is represented as a string, the floating point might be . or ,
return a if float(temp_a) > float(temp_b) else b
python
[ [ "1, 2", "2" ], [ "1, 2.5", "2.5" ], [ "2, 3", "3" ], [ "5, 6", "6" ], [ "1, \"2,3\"", "\"2,3\"" ], [ "\"5,1\", \"6\"", "\"6\"" ], [ "\"1\", \"2\"", "\"2\"" ], [ "\"1\", 1", "None" ] ]
[]
HumanEval_RandomSpanInfillingLight
def compare_one(a, b): """ Create a function that takes integers, floats, or strings representing real numbers, and returns the larger variable in its given variable type. Return None if the values are equal. Note: If a real number is represented as a string, the floating point might be . or , """ temp_a, temp_b = a, b if isinstance(temp_a, str): temp_a = temp_a.replace(',','.') if isinstance(temp_b, str): temp_b = temp_b.replace(',','.')
if float(temp_a) == float(temp_b): return None
[ [ "1, 2.5", "2.5" ], [ "1, \"2,3\"", "\"2,3\"" ], [ "\"5,1\", \"6\"", "\"6\"" ], [ "\"1\", 1", "None" ] ]
python
compare_one
[]
code_infilling
RandomSpanInfillingLight/HumanEval/137/1
Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
python
[ [ "4", "False" ], [ "6", "False" ], [ "8", "True" ], [ "10", "True" ], [ "11", "False" ], [ "12", "True" ], [ "13", "False" ], [ "16", "True" ] ]
[]
HumanEval_RandomSpanInfillingLight
def is_equal_to_sum_even(n): """Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers """ return n%2 == 0 and
n >= 8
[ [ "4", "False" ], [ "6", "False" ], [ "8", "True" ] ]
python
is_equal_to_sum_even
[]
code_infilling
RandomSpanInfillingLight/HumanEval/138/1
The Brazilian factorial is defined as: brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! where n > 0 The function will receive an integer as input and should return the special factorial of this integer.
special_fact *= fact_i return special_fact
python
[ [ "4", "288" ], [ "5", "34560" ], [ "7", "125411328000" ], [ "1", "1" ] ]
[]
HumanEval_RandomSpanInfillingLight
def special_factorial(n): """The Brazilian factorial is defined as: brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! where n > 0 The function will receive an integer as input and should return the special factorial of this integer. """
fact_i = 1 special_fact = 1 for i in range(1, n+1): fact_i *= i
[ [ "4", "288" ] ]
python
special_factorial
[]
code_infilling
RandomSpanInfillingLight/HumanEval/139/1
Given a string text, replace all spaces in it with underscores, and if a string has more than 2 consecutive spaces, then replace all consecutive spaces with -
start, end = i+1, i+1 i+=1 if end - start > 2: new_text += "-" elif end - start > 0: new_text += "_" return new_text
python
[ [ "\"Example\"", "\"Example\"" ], [ "\"Mudasir Hanif \"", "\"Mudasir_Hanif_\"" ], [ "\"Yellow Yellow Dirty Fellow\"", "\"Yellow_Yellow__Dirty__Fellow\"" ], [ "\"Exa mple\"", "\"Exa-mple\"" ], [ "\" Exa 1 2 2 mple\"", "\"-Exa_1_2_2_mple\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def fix_spaces(text): """ Given a string text, replace all spaces in it with underscores, and if a string has more than 2 consecutive spaces, then replace all consecutive spaces with - """ new_text = "" i = 0 start, end = 0, 0 while i < len(text): if text[i] == " ": end += 1 else:
if end - start > 2: new_text += "-"+text[i] elif end - start > 0: new_text += "_"*(end - start)+text[i] else: new_text += text[i]
[ [ "\"Example\"", "\"Example\"" ], [ "\"Example 1\"", "\"Example_1\"" ], [ "\" Example 2\"", "\"_Example_2\"" ], [ "\" Example 3\"", "\"_Example-3\"" ] ]
python
fix_spaces
[]
code_infilling
RandomSpanInfillingLight/HumanEval/140/1
Create a function which takes a string representing a file's name, and returns 'Yes' if the the file's name is valid, and returns 'No' otherwise. A file's name is considered to be valid if and only if all the following conditions are met: - There should not be more than three digits ('0'-'9') in the file's name. - The file's name contains exactly one dot '.' - The substring before the dot should not be empty, and it starts with a letter from the latin alphapet ('a'-'z' and 'A'-'Z'). - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
t = len([x for x in lst[0] if x.isdigit()]) if t > 3: return 'No' return 'Yes'
python
[ [ "\"example.txt\"", "'Yes'" ], [ "\"1example.dll\"", "'No'" ], [ "'s1sdf3.asd'", "'No'" ], [ "'K.dll'", "'Yes'" ], [ "'MY16FILE3.exe'", "'Yes'" ], [ "'His12FILE94.exe'", "'No'" ], [ "'_Y.txt'", "'No'" ], [ "'?aREYA.exe'", "'No'" ], [ "'/this_is_valid.dll'", "'No'" ], [ "'this_is_valid.wow'", "'No'" ], [ "'this_is_valid.txt'", "'Yes'" ], [ "'this_is_valid.txtexe'", "'No'" ], [ "'#this2_i4s_5valid.ten'", "'No'" ], [ "'@this1_is6_valid.exe'", "'No'" ], [ "'this_is_12valid.6exe4.txt'", "'No'" ], [ "'all.exe.txt'", "'No'" ], [ "'I563_No.exe'", "'Yes'" ], [ "'Is3youfault.txt'", "'Yes'" ], [ "'no_one#knows.dll'", "'Yes'" ], [ "'1I563_Yes3.exe'", "'No'" ], [ "'I563_Yes3.txtt'", "'No'" ], [ "'final..txt'", "'No'" ], [ "'final132'", "'No'" ], [ "'_f4indsartal132.'", "'No'" ], [ "'.txt'", "'No'" ], [ "'s.'", "'No'" ] ]
[]
HumanEval_RandomSpanInfillingLight
def file_name_check(file_name): """Create a function which takes a string representing a file's name, and returns 'Yes' if the the file's name is valid, and returns 'No' otherwise. A file's name is considered to be valid if and only if all the following conditions are met: - There should not be more than three digits ('0'-'9') in the file's name. - The file's name contains exactly one dot '.' - The substring before the dot should not be empty, and it starts with a letter from the latin alphapet ('a'-'z' and 'A'-'Z'). - The substring after the dot should be one of these: ['txt', 'exe', 'dll'] """ suf = ['txt', 'exe', 'dll'] lst = file_name.split(sep='.')
if len(lst) != 2: return 'No' if not lst[1] in suf: return 'No' if len(lst[0]) == 0: return 'No' if not lst[0][0].isalpha(): return 'No'
[ [ "\"example.txt\"", "'Yes'" ], [ "\"1example.dll\"", "'No'" ] ]
python
file_name_check
[]
code_infilling
RandomSpanInfillingLight/HumanEval/141/1
" 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 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 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.
else: result.append(lst[i]) return sum(result)
python
[ [ "[1,2,3]", "6" ], [ "[1,4,9]", "14" ], [ "[]", "0" ], [ "[1,1,1,1,1,1,1,1,1]", "9" ], [ "[-1,-1,-1,-1,-1,-1,-1,-1,-1]", "-3" ], [ "[0]", "0" ], [ "[-1,-5,2,-1,-5]", "-126" ], [ "[-56,-99,1,0,-2]", "3030" ], [ "[-1,0,0,0,0,0,0,0,-1]", "0" ], [ "[-16, -9, -2, 36, 36, 26, -20, 25, -40, 20, -4, 12, -26, 35, 37]", "-14196" ], [ "[-1, -3, 17, -1, -15, 13, -1, 14, -14, -12, -5, 14, -14, 6, 13, 11, 16, 16, 4, 10]", "-1448" ] ]
[]
HumanEval_RandomSpanInfillingLight
def sum_squares(lst): """" 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 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 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. """ result =[] for i in range(len(lst)): if i %3 == 0:
result.append(lst[i]**2) elif i % 4 == 0 and i%3 != 0: result.append(lst[i]**3)
[ [ "[1,2,3]", "6" ], [ "[]", "0" ], [ "[-1,-5,2,-1,-5]", "-126" ] ]
python
sum_squares
[]
code_infilling
RandomSpanInfillingLight/HumanEval/142/1
You are given a string representing a sentence, the sentence contains some words separated by a space, and you have to return a string that contains the words from the original sentence, whose lengths are prime numbers, the order of the words in the new string should be the same as the original one. * sentence contains only letters
if flg == 0 or len(word) == 2: new_lst.append(word) return " ".join(new_lst)
python
[ [ "\"This is a test\"", "\"is\"" ], [ "\"lets go for swimming\"", "\"go for\"" ], [ "\"there is no place available here\"", "\"there is no place\"" ], [ "\"Hi I am Hussein\"", "\"Hi am Hussein\"" ], [ "\"go for it\"", "\"go for it\"" ], [ "\"here\"", "\"\"" ], [ "\"here is\"", "\"is\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def words_in_sentence(sentence): """ You are given a string representing a sentence, the sentence contains some words separated by a space, and you have to return a string that contains the words from the original sentence, whose lengths are prime numbers, the order of the words in the new string should be the same as the original one. * sentence contains only letters """ new_lst = [] for word in sentence.split(): flg = 0
if len(word) == 1: flg = 1 for i in range(2, len(word)): if len(word)%i == 0: flg = 1
[ [ "\"This is a test\"", "\"is\"" ], [ "\"lets go for swimming\"", "\"go for\"" ] ]
python
words_in_sentence
[]
code_infilling
RandomSpanInfillingLight/HumanEval/143/1
Your task is to implement a function that will simplify the expression x * n. The function returns True if x * n evaluates to a whole number and False otherwise. Both x and n, are string representation of a fraction, and have the following format, <numerator>/<denominator> where both numerator and denominator are positive whole numbers. You can assume that x, and n are valid fractions, and do not have zero as denominator.
int(numerator/denom)): return True return False
python
[ [ "\"1/5\", \"5/1\"", "True" ], [ "\"1/6\", \"2/1\"", "False" ], [ "\"5/1\", \"3/1\"", "True" ], [ "\"7/10\", \"10/2\"", "False" ], [ "\"2/10\", \"50/10\"", "True" ], [ "\"7/2\", \"4/2\"", "True" ], [ "\"11/6\", \"6/1\"", "True" ], [ "\"2/3\", \"5/2\"", "False" ], [ "\"5/2\", \"3/5\"", "False" ], [ "\"2/4\", \"8/4\"", "True" ], [ "\"2/4\", \"4/2\"", "True" ], [ "\"1/5\", \"5/1\"", "True" ], [ "\"1/5\", \"1/5\"", "False" ] ]
[]
HumanEval_RandomSpanInfillingLight
def simplify(x, n): """Your task is to implement a function that will simplify the expression x * n. The function returns True if x * n evaluates to a whole number and False otherwise. Both x and n, are string representation of a fraction, and have the following format, <numerator>/<denominator> where both numerator and denominator are positive whole numbers. You can assume that x, and n are valid fractions, and do not have zero as denominator. """ a, b = x.split("/") c, d = n.split("/")
numerator = int(a) * int(c) denom = int(b) * int(d) if (numerator/denom ==
[ [ "\"1/5\", \"5/1\"", "True" ], [ "\"1/6\", \"2/1\"", "False" ], [ "\"7/10\", \"10/2\"", "False" ] ]
python
simplify
[]
code_infilling
RandomSpanInfillingLight/HumanEval/144/1
Write a function which sorts the given list of integers in ascending order according to the sum of their digits. Note: if there are several items with similar sum of their digits, order them based on their index in original list.
return sorted(nums, key=digits_sum)
python
[ [ "[1, 11, -1, -11, -12]", "[-1, -11, 1, -12, 11]" ], [ "[1234,423,463,145,2,423,423,53,6,37,3457,3,56,0,46]", "[0, 2, 3, 6, 53, 423, 423, 423, 1234, 145, 37, 46, 56, 463, 3457]" ], [ "[]", "[]" ], [ "[1, -11, -32, 43, 54, -98, 2, -3]", "[-3, -32, -98, -11, 1, 2, 43, 54]" ], [ "[1,2,3,4,5,6,7,8,9,10,11]", "[1, 10, 2, 11, 3, 4, 5, 6, 7, 8, 9]" ], [ "[0,6,6,-76,-21,23,4]", "[-76, -21, 0, 4, 23, 6, 6]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def order_by_points(nums): """ Write a function which sorts the given list of integers in ascending order according to the sum of their digits. Note: if there are several items with similar sum of their digits, order them based on their index in original list. """
def digits_sum(n): neg = 1 if n < 0: n, neg = -1 * n, -1 n = [int(i) for i in str(n)] n[0] = n[0] * neg return sum(n)
[ [ "[1, 11, -1, -11, -12]", "[-1, -11, 1, -12, 11]" ], [ "[]", "[]" ] ]
python
order_by_points
[]
code_infilling
RandomSpanInfillingLight/HumanEval/145/1
Write a function that takes an array of numbers as input and returns the number of elements in the array that are greater than 10 and both first and last digits of a number are odd (1, 3, 5, 7, 9).
: count += 1 return count
python
[ [ "[5, -2, 1, -5]", "0" ], [ "[15, -73, 14, -15]", "1" ], [ "[33, -2, -3, 45, 21, 109]", "2" ], [ "[43, -12, 93, 125, 121, 109]", "4" ], [ "[71, -2, -33, 75, 21, 19]", "3" ], [ "[1]", "0" ], [ "[]", "0" ] ]
[]
HumanEval_RandomSpanInfillingLight
def specialFilter(nums): """Write a function that takes an array of numbers as input and returns the number of elements in the array that are greater than 10 and both first and last digits of a number are odd (1, 3, 5, 7, 9). """ count = 0 for num in nums: if num > 10: odd_digits = (1, 3, 5, 7, 9) number_as_string = str(num) if
int(number_as_string[0]) in odd_digits and int(number_as_string[-1]) in odd_digits
[ [ "[15, -73, 14, -15]", "1" ], [ "[33, -2, -3, 45, 21, 109]", "2" ] ]
python
specialFilter
[]
code_infilling
RandomSpanInfillingLight/HumanEval/146/1
You are given a positive integer n. You have to create an integer array a of length n. For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1. Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, and a[i] + a[j] + a[k] is a multiple of 3.
return len(ans)
python
[ [ "5", "1" ], [ "6", "4" ], [ "10", "36" ], [ "100", "53361" ] ]
[]
HumanEval_RandomSpanInfillingLight
def get_max_triples(n): """ You are given a positive integer n. You have to create an integer array a of length n. For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1. Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, and a[i] + a[j] + a[k] is a multiple of 3. """ A = [i*i - i + 1 for i in range(1,n+1)] ans = [] for i in range(n): for j in range(i+1,n):
for k in range(j+1,n): if (A[i]+A[j]+A[k])%3 == 0: ans += [(A[i],A[j],A[k])]
[ [ "5", "1" ] ]
python
get_max_triples
[]
code_infilling
RandomSpanInfillingLight/HumanEval/147/1
There are eight planets in our solar system: the closerst to the Sun is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, Uranus, Neptune. Write a function that takes two planet names as strings planet1 and planet2. The function should return a tuple containing all planets whose orbits are located between the orbit of planet1 and the orbit of planet2, sorted by the proximity to the sun. The function should return an empty tuple if planet1 or planet2 are not correct planet names.
if planet1_index < planet2_index: return (planet_names[planet1_index + 1: planet2_index]) else: return (planet_names[planet2_index + 1 : planet1_index])
python
[ [ "\"Jupiter\", \"Neptune\"", "(\"Saturn\", \"Uranus\")" ], [ "\"Earth\", \"Mercury\"", "(\"Venus\",)" ], [ "\"Mercury\", \"Uranus\"", "(\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\")" ], [ "\"Neptune\", \"Venus\"", "(\"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\")" ], [ "\"Earth\", \"Earth\"", "()" ], [ "\"Mars\", \"Earth\"", "()" ], [ "\"Jupiter\", \"Makemake\"", "()" ] ]
[]
HumanEval_RandomSpanInfillingLight
def bf(planet1, planet2): """ There are eight planets in our solar system: the closerst to the Sun is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, Uranus, Neptune. Write a function that takes two planet names as strings planet1 and planet2. The function should return a tuple containing all planets whose orbits are located between the orbit of planet1 and the orbit of planet2, sorted by the proximity to the sun. The function should return an empty tuple if planet1 or planet2 are not correct planet names. """
planet_names = ("Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune") if planet1 not in planet_names or planet2 not in planet_names or planet1 == planet2: return () planet1_index = planet_names.index(planet1) planet2_index = planet_names.index(planet2)
[ [ "\"Jupiter\", \"Neptune\"", "> (\"Saturn\", \"Uranus\")" ], [ "\"Earth\", \"Mercury\"", "> (\"Venus\")" ], [ "\"Mercury\", \"Uranus\"", "> (\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\")" ] ]
python
bf
[]
code_infilling
RandomSpanInfillingLight/HumanEval/148/1
Write a function that accepts a list of strings as a parameter, deletes the strings that have odd lengths from it, and returns the resulted list with a sorted order, The list is always a list of strings and never an array of numbers, and it may contain duplicates. The order of the list should be ascending by length of each word, and you should return the list sorted by that rule. If two words have the same length, sort the list alphabetically. The function should return a list of strings in sorted order. You may assume that all words will have the same length.
return sorted(new_lst, key=len)
python
[ [ "[\"aa\", \"a\", \"aaa\"]", "[\"aa\"]" ], [ "[\"school\", \"AI\", \"asdf\", \"b\"]", "[\"AI\", \"asdf\", \"school\"]" ], [ "[\"d\", \"b\", \"c\", \"a\"]", "[]" ], [ "[\"d\", \"dcba\", \"abcd\", \"a\"]", "[\"abcd\", \"dcba\"]" ], [ "[\"AI\", \"ai\", \"au\"]", "[\"AI\", \"ai\", \"au\"]" ], [ "[\"a\", \"b\", \"b\", \"c\", \"c\", \"a\"]", "[]" ], [ "['aaaa', 'bbbb', 'dd', 'cc']", "[\"cc\", \"dd\", \"aaaa\", \"bbbb\"]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def sorted_list_sum(lst): """Write a function that accepts a list of strings as a parameter, deletes the strings that have odd lengths from it, and returns the resulted list with a sorted order, The list is always a list of strings and never an array of numbers, and it may contain duplicates. The order of the list should be ascending by length of each word, and you should return the list sorted by that rule. If two words have the same length, sort the list alphabetically. The function should return a list of strings in sorted order. You may assume that all words will have the same length. """
lst.sort() new_lst = [] for i in lst: if len(i)%2 == 0: new_lst.append(i)
[ [ "[\"aa\", \"a\", \"aaa\"]", "[\"aa\"]" ], [ "[\"ab\", \"a\", \"aaa\", \"cd\"]", "[\"ab\", \"cd\"]" ] ]
python
sorted_list_sum
[]
code_infilling
RandomSpanInfillingLight/HumanEval/149/1
A simple program which should return the value of x if n is a prime number and should return the value of y otherwise.
else: return x
python
[ [ "7, 34, 12", "34" ], [ "15, 8, 5", "5" ], [ "3, 33, 5212", "33" ], [ "1259, 3, 52", "3" ], [ "7919, -1, 12", "-1" ], [ "3609, 1245, 583", "583" ], [ "91, 56, 129", "129" ], [ "6, 34, 1234", "1234" ], [ "1, 2, 0", "0" ], [ "2, 2, 0", "2" ] ]
[]
HumanEval_RandomSpanInfillingLight
def x_or_y(n, x, y): """A simple program which should return the value of x if n is a prime number and should return the value of y otherwise. """ if n == 1: return y
for i in range(2, n): if n % i == 0: return y break
[ [ "7, 34, 12", "34" ], [ "15, 8, 5", "5" ] ]
python
x_or_y
[]
code_infilling
RandomSpanInfillingLight/HumanEval/150/1
Given a list of numbers, return the sum of squares of the numbers in the list that are odd. Ignore numbers that are negative or not integers. If the input list is empty, return 0.
])
python
[ [ "[]", "0" ], [ "[5, 4]", "25" ], [ "[0.1, 0.2, 0.3]", "0" ], [ "[-10, -20, -30]", "0" ], [ "[-1, -2, 8]", "0" ], [ "[0.2, 3, 5]", "34" ] ]
[]
HumanEval_RandomSpanInfillingLight
def double_the_difference(lst): """ Given a list of numbers, return the sum of squares of the numbers in the list that are odd. Ignore numbers that are negative or not integers. If the input list is empty, return 0. """ return sum([i**2 for i in lst if
i > 0 and i%2!=0 and "." not in str(i)
[ [ "[1, 3, 2, 0]", "1 + 9 + 0 + 0 = 10" ], [ "[-1, -2, 0]", "0" ], [ "[9, -2]", "81" ], [ "[0]", "0" ] ]
python
double_the_difference
[]
code_infilling
RandomSpanInfillingLight/HumanEval/151/1
I think we all remember that feeling when the result of some long-awaited event is finally known. The feelings and thoughts you have at that moment are definitely worth noting down and comparing. Your task is to determine if a person correctly guessed the results of a number of matches. You are given two arrays of scores and guesses of equal length, where each index shows a match. Return an array of the same length denoting how far off each guess was. If they have guessed correctly, the value is 0, and if not, the value is the absolute difference between the guess and the score.
]
python
[ [ "[1,2,3,4,5,1], [1,2,3,4,2,-2]", "[0,0,0,0,3,3]" ], [ "[0,0,0,0,0,0], [0,0,0,0,0,0]", "[0,0,0,0,0,0]" ], [ "[1,2,3], [-1,-2,-3]", "[2,4,6]" ], [ "[1,2,3,5], [-1,2,3,4]", "[2,0,0,1]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def compare(game,guess): """I think we all remember that feeling when the result of some long-awaited event is finally known. The feelings and thoughts you have at that moment are definitely worth noting down and comparing. Your task is to determine if a person correctly guessed the results of a number of matches. You are given two arrays of scores and guesses of equal length, where each index shows a match. Return an array of the same length denoting how far off each guess was. If they have guessed correctly, the value is 0, and if not, the value is the absolute difference between the guess and the score. """ return [abs(x-y) for
x,y in zip(game,guess)
[ [ "[1,2,3,4,5,1],[1,2,3,4,2,-2]", "[0,0,0,0,3,3]" ], [ "[0,5,0,0,0,4],[4,1,1,0,0,-2]", "[4,4,1,0,0,6]" ] ]
python
compare
[]
code_infilling
RandomSpanInfillingLight/HumanEval/152/1
You will be given the name of a class (a string) and a list of extensions. The extensions are to be used to load additional classes to the class. The strength of the extension is as follows: Let CAP be the number of the uppercase letters in the extension's name, and let SM be the number of lowercase letters in the extension's name, the strength is given by the fraction CAP - SM. You should find the strongest extension and return a string in this format: ClassName.StrongestExtensionName. If there are two or more extensions with the same strength, you should choose the one that comes first in the list.
ans = class_name + "." + strong return ans
python
[ [ "'Watashi', ['tEN', 'niNE', 'eIGHt8OKe']", "'Watashi.eIGHt8OKe'" ], [ "'Boku123', ['nani', 'NazeDa', 'YEs.WeCaNe', '32145tggg']", "'Boku123.YEs.WeCaNe'" ], [ "'__YESIMHERE', ['t', 'eMptY', 'nothing', 'zeR00', 'NuLl__', '123NoooneB321']", "'__YESIMHERE.NuLl__'" ], [ "'K', ['Ta', 'TAR', 't234An', 'cosSo']", "'K.TAR'" ], [ "'__HAHA', ['Tab', '123', '781345', '-_-']", "'__HAHA.123'" ], [ "'YameRore', ['HhAas', 'okIWILL123', 'WorkOut', 'Fails', '-_-']", "'YameRore.okIWILL123'" ], [ "'finNNalLLly', ['Die', 'NowW', 'Wow', 'WoW']", "'finNNalLLly.WoW'" ], [ "'_', ['Bb', '91245']", "'_.Bb'" ], [ "'Sp', ['671235', 'Bb']", "'Sp.671235'" ] ]
[]
HumanEval_RandomSpanInfillingLight
def Strongest_Extension(class_name, extensions): """You will be given the name of a class (a string) and a list of extensions. The extensions are to be used to load additional classes to the class. The strength of the extension is as follows: Let CAP be the number of the uppercase letters in the extension's name, and let SM be the number of lowercase letters in the extension's name, the strength is given by the fraction CAP - SM. You should find the strongest extension and return a string in this format: ClassName.StrongestExtensionName. If there are two or more extensions with the same strength, you should choose the one that comes first in the list. """ strong = extensions[0] my_val = len([x for x in extensions[0] if x.isalpha() and x.isupper()]) - len([x for x in extensions[0] if x.isalpha() and x.islower()])
for s in extensions: val = len([x for x in s if x.isalpha() and x.isupper()]) - len([x for x in s if x.isalpha() and x.islower()]) if val > my_val: strong = s my_val = val
[ [ "'my_class', ['AA', 'Be', 'CC']", "'my_class.AA'" ] ]
python
Strongest_Extension
[]
code_infilling
RandomSpanInfillingLight/HumanEval/153/1
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
return False
python
[ [ "\"xyzw\", \"xyw\"", "False" ], [ "\"yello\", \"ell\"", "True" ], [ "\"whattup\", \"ptut\"", "False" ], [ "\"efef\", \"fee\"", "True" ], [ "\"abab\", \"aabb\"", "False" ], [ "\"winemtt\", \"tinem\"", "True" ] ]
[]
HumanEval_RandomSpanInfillingLight
def cycpattern_check(a , b): """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 """ l = len(b) pat = b + b for i in range(len(a) - l + 1): for j in range(l + 1): if
a[i:i+l] == pat[j:j+l]: return True
[ [ "\"abcd\",\"abd\"", "False" ], [ "\"hello\",\"ell\"", "True" ], [ "\"whassup\",\"psus\"", "False" ], [ "\"abab\",\"baa\"", "True" ], [ "\"efef\",\"eeff\"", "False" ], [ "\"himenss\",\"simen\"", "True" ] ]
python
cycpattern_check
[]
code_infilling
RandomSpanInfillingLight/HumanEval/154/1
Given an integer. return a tuple that has the number of even and odd digits respectively.
return (even_count, odd_count)
python
[ [ "7", "(0, 1)" ], [ "-78", "(1, 1)" ], [ "3452", "(2, 2)" ], [ "346211", "(3, 3)" ], [ "-345821", "(3, 3)" ], [ "-2", "(1, 0)" ], [ "-45347", "(2, 3)" ], [ "0", "(1, 0)" ] ]
[]
HumanEval_RandomSpanInfillingLight
def even_odd_count(num): """Given an integer. return a tuple that has the number of even and odd digits respectively. """
even_count = 0 odd_count = 0 for i in str(abs(num)): if int(i)%2==0: even_count +=1 else: odd_count +=1
[ [ "-12", "> (1, 1)" ], [ "123", "> (1, 2)" ] ]
python
even_odd_count
[]
code_infilling
RandomSpanInfillingLight/HumanEval/155/1
Given a positive integer, obtain its roman numeral equivalent as a string, and return it in lowercase. Restrictions: 1 <= num <= 1000
while div: res += sym[i] div -= 1 i -= 1 return res.lower()
python
[ [ "19", "'xix'" ], [ "152", "'clii'" ], [ "251", "'ccli'" ], [ "426", "'cdxxvi'" ], [ "500", "'d'" ], [ "1", "'i'" ], [ "4", "'iv'" ], [ "43", "'xliii'" ], [ "90", "'xc'" ], [ "94", "'xciv'" ], [ "532", "'dxxxii'" ], [ "900", "'cm'" ], [ "994", "'cmxciv'" ], [ "1000", "'m'" ] ]
[]
HumanEval_RandomSpanInfillingLight
def int_to_mini_roman(number): """ Given a positive integer, obtain its roman numeral equivalent as a string, and return it in lowercase. Restrictions: 1 <= num <= 1000 """ num = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000] sym = ["I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"]
i = 12 res = '' while number: div = number // num[i] number %= num[i]
[ [ "19", "'xix'" ], [ "152", "'clii'" ], [ "426", "'cdxxvi'" ] ]
python
int_to_mini_roman
[]
code_infilling
RandomSpanInfillingLight/HumanEval/156/1
Given the lengths of the three sides of a triangle. Return True if the three sides form a right-angled triangle, False otherwise. A right-angled triangle is a triangle in which one angle is right angle or 90 degree.
c*c == a*a + b*b
python
[ [ "3, 4, 5", "True" ], [ "1, 2, 3", "False" ], [ "10, 6, 8", "True" ], [ "2, 2, 2", "False" ], [ "7, 24, 25", "True" ], [ "10, 5, 7", "False" ], [ "5, 12, 13", "True" ], [ "15, 8, 17", "True" ], [ "48, 55, 73", "True" ], [ "1, 1, 1", "False" ], [ "2, 2, 10", "False" ] ]
[]
HumanEval_RandomSpanInfillingLight
def right_angle_triangle(a, b, c): """ Given the lengths of the three sides of a triangle. Return True if the three sides form a right-angled triangle, False otherwise. A right-angled triangle is a triangle in which one angle is right angle or 90 degree. """ return
a*a == b*b + c*c or b*b == a*a + c*c or
[ [ "3, 4, 5", "True" ], [ "1, 2, 3", "False" ] ]
python
right_angle_triangle
[]
code_infilling
RandomSpanInfillingLight/HumanEval/157/1
Write a function that accepts a list of strings. The list contains different words. Return the word with maximum number of unique characters. If multiple strings have maximum number of unique characters, return the one which comes first in lexicographical order.
)[0]
python
[ [ "[\"name\", \"of\", \"string\"]", "\"string\"" ], [ "[\"name\", \"enam\", \"game\"]", "\"enam\"" ], [ "[\"aaaaaaa\", \"bb\", \"cc\"]", "\"aaaaaaa\"" ], [ "[\"abc\", \"cba\"]", "\"abc\"" ], [ "[\"play\", \"this\", \"game\", \"of\",\"footbott\"]", "\"footbott\"" ], [ "[\"we\", \"are\", \"gonna\", \"rock\"]", "\"gonna\"" ], [ "[\"we\", \"are\", \"a\", \"mad\", \"nation\"]", "\"nation\"" ], [ "[\"this\", \"is\", \"a\", \"prrk\"]", "\"this\"" ], [ "[\"b\"]", "\"b\"" ], [ "[\"play\", \"play\", \"play\"]", "\"play\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def find_max(words): """Write a function that accepts a list of strings. The list contains different words. Return the word with maximum number of unique characters. If multiple strings have maximum number of unique characters, return the one which comes first in lexicographical order. """ return sorted(words, key =
lambda x: (-len(set(x)), x)
[ [ "[\"name\", \"of\", \"string\"]", "\"string\"" ], [ "[\"name\", \"enam\", \"game\"]", "\"enam\"" ], [ "[\"aaaaaaa\", \"bb\" ,\"cc\"]", "\"\"aaaaaaa\"" ] ]
python
find_max
[]
code_infilling
RandomSpanInfillingLight/HumanEval/158/1
You're a hungry rabbit, and you already have eaten a certain number of carrots, but now you need to eat more carrots to complete the day's meals. you should return an array of [ total number of eaten carrots after your meals, the number of carrots left after your meals ] if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry. Have fun :)
return [ number + remaining , 0]
python
[ [ "5, 6, 10", "[11, 4]" ], [ "4, 8, 9", "[12, 1]" ], [ "1, 10, 10", "[11, 0]" ], [ "2, 11, 5", "[7, 0]" ], [ "4, 5, 7", "[9, 2]" ], [ "4, 5, 1", "[5, 0]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def eat(number, need, remaining): """ You're a hungry rabbit, and you already have eaten a certain number of carrots, but now you need to eat more carrots to complete the day's meals. you should return an array of [ total number of eaten carrots after your meals, the number of carrots left after your meals ] if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry. Have fun :) """ if(need <= remaining):
return [ number + need , remaining-need ] else:
[ [ "5, 6, 10", "[11, 4]" ], [ "4, 8, 9", "[12, 1]" ], [ "1, 10, 10", "[11, 0]" ], [ "2, 11, 5", "[7, 0]" ] ]
python
eat
[]
code_infilling
RandomSpanInfillingLight/HumanEval/159/1
Given two lists operator, and operand. The first list has basic algebra operations, and the second list is a list of integers. Use the two given lists to build the algebric expression and return the evaluation of this expression. The basic algebra operations: Addition ( + ) Subtraction ( - ) Multiplication ( * ) Floor division ( // ) Exponentiation ( ** )
return eval(expression)
python
[ [ "['**', '*', '+'], [2, 3, 4, 5]", "37" ], [ "['+', '*', '-'], [2, 3, 4, 5]", "9" ], [ "['//', '*'], [7, 3, 4]", "8" ] ]
[]
HumanEval_RandomSpanInfillingLight
def do_algebra(operator, operand): """ Given two lists operator, and operand. The first list has basic algebra operations, and the second list is a list of integers. Use the two given lists to build the algebric expression and return the evaluation of this expression. The basic algebra operations: Addition ( + ) Subtraction ( - ) Multiplication ( * ) Floor division ( // ) Exponentiation ( ** ) """ expression = str(operand[0])
for oprt, oprn in zip(operator, operand[1:]): expression+= oprt + str(oprn)
[ [ "['+', '*', '-'], [2, 3, 4, 5]", "9" ] ]
python
do_algebra
[]
code_infilling
RandomSpanInfillingLight/HumanEval/160/1
You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string.
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
python
[ [ "\"AsDf\"", "\"aSdF\"" ], [ "\"1234\"", "\"4321\"" ], [ "\"ab\"", "\"AB\"" ], [ "\"#a@C\"", "\"#A@c\"" ], [ "\"#AsdfW^45\"", "\"#aSDFw^45\"" ], [ "\"#6@2\"", "\"2@6#\"" ], [ "\"#$a^D\"", "\"#$A^d\"" ], [ "\"#ccc\"", "\"#CCC\"" ] ]
[]
HumanEval_RandomSpanInfillingLight
def solve(s): """You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. """
flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1
[ [ "\"1234\"", "\"4321\"" ], [ "\"ab\"", "\"AB\"" ], [ "\"#a@C\"", "\"#A@c\"" ] ]
python
solve
[]
code_infilling
RandomSpanInfillingLight/HumanEval/161/1
Given a string 'text', return its md5 hash equivalent string. If 'text' is an empty string, return None.
if text else None
python
[ [ "'Hello world'", "'3e25960a79dbc69b674cd4ec67a72c62'" ], [ "''", "None" ], [ "'A B C'", "'0ef78513b0cb8cef12743f5aeb35f888'" ], [ "'password'", "'5f4dcc3b5aa765d61d8327deb882cf99'" ] ]
[]
HumanEval_RandomSpanInfillingLight
def string_to_md5(text): """ Given a string 'text', return its md5 hash equivalent string. If 'text' is an empty string, return None. """ import hashlib return
hashlib.md5(text.encode('ascii')).hexdigest()
[ [ "'Hello world'", "'3e25960a79dbc69b674cd4ec67a72c62'" ] ]
python
string_to_md5
[]
code_infilling
RandomSpanInfillingLight/HumanEval/162/1
Given two positive integers a and b, return the even digits between a and b, in ascending order.
python
[ [ "2, 10", "[2, 4, 6, 8]" ], [ "10, 2", "[2, 4, 6, 8]" ], [ "132, 2", "[2, 4, 6, 8]" ], [ "17, 89", "[]" ] ]
[]
HumanEval_RandomSpanInfillingLight
def generate_integers(a, b): """ Given two positive integers a and b, return the even digits between a and b, in ascending order. """ lower = max(2, min(a, b)) upper = min(8, max(a, b)) return
[i for i in range(lower, upper+1) if i % 2 == 0]
[ [ "2, 8", "[2, 4, 6, 8]" ], [ "8, 2", "[2, 4, 6, 8]" ], [ "10, 14", "[]" ] ]
python
generate_integers
[]
code_infilling
RandomSpanInfillingLight/HumanEval/163/1