file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f64.py | def f(n):
return n ^ (n >> 1)
assert f(3) == 2 |
benchmark_functions_edited/f5998.py | def f(tofind, string):
found = [i for i in range(len(string)) if string.startswith(tofind, i)]
num_found = len(found)
return num_found
assert f("abc", "abc") == 1 |
benchmark_functions_edited/f9850.py | def f(link):
if link.startswith('https'):
return 0
else:
return 1
assert f(
'https://www.youtube.com/watch?v=9bZkp7q19f0&t=10s') == 0 |
benchmark_functions_edited/f4237.py | def f(mass):
return (mass//3)-2
assert f(14) == 2 |
benchmark_functions_edited/f1637.py | def f(x, a, alpha, b):
# pylint: disable=invalid-name
return a * alpha ** x + b
assert f(1, 1, 1, 1) == 2 |
benchmark_functions_edited/f1251.py | def f(seats):
return sum(row.count('#') for row in seats)
assert f(
[
['L', 'L', 'L'],
['L', 'L', 'L'],
['L', 'L', 'L'],
]
) == 0 |
benchmark_functions_edited/f11037.py | def f(text: str, symbol: str):
res = [i for i,x in enumerate(text) if x==symbol ]
if len(res) >= 2:
return res[1]
return None
# try:
# return text.index(symbol,text.index(symbol)+1)
# except ValueError:
# return None
assert f( "Hello world", "l") == 3 |
benchmark_functions_edited/f9712.py | def f(energy,unit):
if unit == 'keV':
return float(energy)
elif unit == 'MeV':
return float(energy)*1000
elif unit == 'eV':
return float(energy)/1000
else:
raise ValueError('Unkown unit {}!'.format(unit))
assert f(1,'keV') == 1 |
benchmark_functions_edited/f10542.py | def f(hand):
# TO DO... <-- Remove this comment when you code this function
word_length = 0
for value in hand.values():
word_length += value
return word_length
assert f({}) == 0 |
benchmark_functions_edited/f11892.py | def f(n, k): #This is the author's original version
if k == 0:
return 1
if n == 0:
return 0
res = f(n-1, k) + f(n-1, k-1)
return res
assert f(1, 5) == 0 |
benchmark_functions_edited/f2101.py | def f(x, y, p, n):
return ((x * x - p) * x - y * y) % n
assert f(1, 1, 1, 1) == 0 |
benchmark_functions_edited/f9612.py | def f(string):
count = 0
vowel_list = list('aeiou')
for char in string:
if char in vowel_list:
count += 1
return count
assert f('1234a6789') == 1 |
benchmark_functions_edited/f10796.py | def f(x, k, y0, y1):
import math
return y0 + (y1 - y0) * (1 - math.exp(-1 * x * k))
assert f(0, 2, 0, 3) == 0 |
benchmark_functions_edited/f10859.py | def f(ktoe):
data_twh = ktoe * 0.01163
return data_twh
assert f(0.0) == 0 |
benchmark_functions_edited/f8150.py | def f(n, k, mod):
if k == 0:
return 1
elif k & 1 == 1:
return f(n, k - 1, mod) * n % mod
else:
tmp = f(n, k // 2, mod)
return tmp * tmp % mod
assert f(2, 4, 4) == 0 |
benchmark_functions_edited/f8309.py | def f(age):
if age < 10:
return 1
elif 10 <= age < 18:
return 2
elif 18 <= age < 30:
return 3
elif 30 <= age < 50:
return 4
else:
return 5
assert f(-1) == 1 |
benchmark_functions_edited/f4343.py | def f(S):
n = len(S)
prefix = 0
total = 0
for j in range(n):
prefix += S[j]
total += prefix
return total
assert f([]) == 0 |
benchmark_functions_edited/f4166.py | def f(s,counter,N,args):
if(s==0): return s;
#
t = (s | (s - 1)) + 1
return t | ((((t & (0-t)) // (s & (0-s))) >> 1) - 1)
assert f(5,0,10,None) == 6 |
benchmark_functions_edited/f8540.py | def f(listy):
mini = 1000000000000
for i in listy:
if i < mini:
mini = i
if len(listy) == 0:
return "None"
else:
return mini
assert f([2, 1]) == 1 |
benchmark_functions_edited/f13893.py | def f(arr, low, high, key):
if arr[low] >= key:
return low
if arr[high] < key:
return high + 1
while low + 1 < high:
mid = (low + high) // 2
if arr[mid] < key:
low = mid
else:
high = mid
# in the end low + 1 = high and arr[low] < mid <= arr[high] => return high
return high
assert f(range(2), 0, 0, 1) == 1 |
benchmark_functions_edited/f10971.py | def f(grade1: int, grade2: int, grade3: int, grade4: int) -> int:
min_grade = min(grade1, grade2, grade3, grade4)
sum = grade1 + grade2 + grade3 + grade4 - min_grade
average = sum / 3
return int(average)
assert f(3, 3, 3, 3) == 3 |
benchmark_functions_edited/f9711.py | def f(X, old_range, new_range):
old_min = old_range[0]
new_min = new_range[0]
old_delta = old_range[1] - old_min
new_delta = new_range[1] - new_min
return (((X - old_min) * new_delta) / old_delta) + new_min
assert f(0, (0, 3), (1, 2)) == 1 |
benchmark_functions_edited/f6029.py | def f(mv1, mv2, mv3):
mv = mv1+mv2+mv3
if hasattr(mv, 'long_name'):
if mv.long_name == mv1.long_name:
mv.long_name = ''
return mv
assert f(2, 2, 2) == 6 |
benchmark_functions_edited/f6627.py | def f(start, end):
counter = start
num_evens = 0
while counter <= end:
if counter % 2 == 0:
num_evens += 1
counter += 1
return num_evens
assert f(3, 3) == 0 |
benchmark_functions_edited/f9158.py | def f(values):
if not values:
return None
if len(values) > 1:
raise ValueError('Got more than one value.')
return values[0]
assert f([1]) == 1 |
benchmark_functions_edited/f13726.py | def f(last_version, is_bad_version):
left = 1
right = last_version
while left < right:
mid = left + ((right - left) // 2)
if is_bad_version(mid):
right = mid
else:
left = mid + 1
return left
assert f(10, lambda v: v > 5) == 6 |
benchmark_functions_edited/f10697.py | def f(*values):
current = 1
for v in values:
if v is not None:
current = v * current
return current
assert f(None,1,2,None) == 2 |
benchmark_functions_edited/f5892.py | def f(A,B):
return (A and not B) or (not A and B)
assert f(range(2), range(2)) == 0 |
benchmark_functions_edited/f9583.py | def f(str_to_add, round_two):
if str_to_add not in round_two:
round_two.append(str_to_add)
return round_two.index(str_to_add)
assert f("a", ["b", "c", "a"]) == 2 |
benchmark_functions_edited/f8173.py | def f(psvList):
return sum(1 for psv in psvList if psv.is_parked())
assert f([]) == 0 |
benchmark_functions_edited/f12745.py | def f(value, red_thresh, yellow_thresh):
if value >= red_thresh:
return 1
elif value < yellow_thresh:
return 0
else:
return -1
assert f(0.0, 1.5, 2.0) == 0 |
benchmark_functions_edited/f14310.py | def f(s1, s2):
i = 0
for i, (x, y) in enumerate(zip(s1, s2)):
if x != y:
break
return i
assert f( "", "" ) == 0 |
benchmark_functions_edited/f9848.py | def f(num):
root=0
while (root+1)**2<=num:
root+=1
return root**2
assert f(2)==1 |
benchmark_functions_edited/f7128.py | def f(n):
if n < 2:
return 1
else:
return n * f(n - 1)
assert f(1) == 1 |
benchmark_functions_edited/f13434.py | def f(nums):
set_array = list(set(nums))
if set_array == nums:
return None
else:
sorted_nums = sorted(nums)
for x in range(0, len(sorted_nums)):
if x <= len(sorted_nums)-2:
if sorted_nums[x] == sorted_nums[x + 1]:
return sorted_nums[x]
assert f([1, 1, 2, 3]) == 1 |
benchmark_functions_edited/f2063.py | def f(side):
# You have to code here
# REMEMBER: Tests first!!!
return side**2
assert f(1) == 1 |
benchmark_functions_edited/f568.py | def f(val) -> int:
return (val & 0x80000000)>>31
assert f(0x76543210) == 0 |
benchmark_functions_edited/f12390.py | def f(input_list, input_subest_len):
maximum = 0
if input_subest_len > len(input_list):
return "Whoop There is it == longer than list"
for i in range(len(input_list)-input_subest_len):
total = sum(input_list[i:(i+input_subest_len)])
if total > maximum:
maximum = total
return maximum
assert f([0, -1, 2, -3, 4, -5, 6, -7, 8, -9], 3) == 7 |
benchmark_functions_edited/f13500.py | def f(keyword, params):
if keyword in params:
return params[keyword]
keyword = keyword.upper()
if keyword in params:
return params[keyword]
raise KeyError('No param named {} defined'.format(keyword))
assert f('keyword', {'keyword': 1}) == 1 |
benchmark_functions_edited/f7082.py | def f(nees, ci):
within_ci = [ind_nees < ci[1] and ind_nees > ci[0] for ind_nees in nees]
return sum(within_ci) / len(nees)
assert f(
[0, 2, 0, 0, 0], [2, 3]) == 0 |
benchmark_functions_edited/f3208.py | def f(capacity, on, wait) -> int:
return 1 if (capacity - on) >= wait else 0
assert f(50, 0, 0) == 1 |
benchmark_functions_edited/f4522.py | def f(n):
if n <= 2:
return 1
return f(n-1)+f(n-2)
assert f(0) == 1 |
benchmark_functions_edited/f14233.py | def f(offset, step_size, image_size):
if offset + step_size > image_size:
return image_size - offset
else:
return step_size
assert f(1, 6, 5) == 4 |
benchmark_functions_edited/f12392.py | def f(a, m):
if a >= m:
while a >= m:
a %= m
return a
assert f(123, 10) == 3 |
benchmark_functions_edited/f1777.py | def f(a,b):
if a >= b:
result = a
else:
result = b
return result
assert f(5,6) == 6 |
benchmark_functions_edited/f13518.py | def f(currentValues, current, total):
if currentValues:
return current
else:
return total
assert f(False, 1, 1) == 1 |
benchmark_functions_edited/f2253.py | def f(x, t=3):
y = x+2
y += 1
z = '12'
del z
return y
assert f(4) == 7 |
benchmark_functions_edited/f8281.py | def f(ang):
ang *= 360/400
return ang
assert f(0) == 0 |
benchmark_functions_edited/f6792.py | def f(node):
if node is None:
return 0
if not node.left and not node.right:
return 1
return 1 + max(
f(node.left),
f(node.right))
assert f(None) == 0 |
benchmark_functions_edited/f10906.py | def f(new, last):
if new is None or last is None: # cannot produce result
return 0.0
new = float(new)
last = float(last)
return new - last
assert f(None, None) == 0 |
benchmark_functions_edited/f12722.py | def f(dictionary, key_sequence):
ret = dictionary
for k in key_sequence:
ret = ret[k]
return ret
assert f(
{'key': {'nestedkey': {'value': 1}}},
['key', 'nestedkey', 'value']
) == 1 |
benchmark_functions_edited/f8211.py | def f(a, x):
d = a[-1]
a[-1] = x
i = 0
while a[i] != x:
i += 1
a[-1] = d
if i == len(a) - 1 and d != x:
return None
else:
return i
assert f(
[1, 2, 3, 4, 5, 6],
6,
) == 5 |
benchmark_functions_edited/f1849.py | def f(data, index):
result = data[index] & 0xFF
return result
assert f(b'\x01', 0) == 1 |
benchmark_functions_edited/f10479.py | def f(line):
index = 0
if len(line.split()) > 1:
if line.split()[1] == 'al_start:':
index = int(line.split()[2])
elif line.split()[1] == 'al_stop:':
index = int(line.split()[2])
return index
assert f('') == 0 |
benchmark_functions_edited/f7474.py | def f(action) -> int:
assert action in (0, 1, 2), f'Wrong action: {action}'
return {
0: 0,
1: 2,
2: 5
}[action]
assert f(1) == 2 |
benchmark_functions_edited/f2367.py | def f(d, key_name):
try:
return d[key_name]
except KeyError:
return 0
assert f({'k1': 2, 'k2': 4, 'k3': 6}, 'k1') == 2 |
benchmark_functions_edited/f7190.py | def f(data):
uniq_atom_list = list(set(data))
return len(uniq_atom_list)
assert f(list("python")) == 6 |
benchmark_functions_edited/f6572.py | def f(dictionary, element):
dictionary.setdefault(element, 0)
dictionary[element] += 1
return dictionary[element]
assert f(dict(), 'a') == 1 |
benchmark_functions_edited/f12020.py | def f(dictionary, text):
count = 0
for word in dictionary:
#print word, count
#print word, "----", count
if word in text:
#print word
count += 1
return count
assert f(dict(), "Hello! Goodbye!") == 0 |
benchmark_functions_edited/f6063.py | def f(memory):
import operator
index, value = max(enumerate(memory), key=operator.itemgetter(1))
return index
assert f([1, 3, 10, 4]) == 2 |
benchmark_functions_edited/f11937.py | def f(value1: int, value2: int):
value1 = abs(value1)
value2 = abs(value2)
if value1 < value2:
value1, value2 = value2, value1
remainder = value1 % value2
if remainder == 0:
return value2
return f(value2, remainder)
assert f(5, 3) == 1 |
benchmark_functions_edited/f12155.py | def f(x, y):
# get the words that occur in both x and y (for all others min is 0 anyways)
s = set(x.keys()) & set(y.keys())
# nothing in common?
if not s:
return 0.
return float(sum([min(x[word], y[word]) for word in s]))
assert f(dict(), dict()) == 0 |
benchmark_functions_edited/f523.py | def f(row, col, x, y):
return x[row] * y[col]
assert f(0, 0, [0, 1, 2], [3, 4, 5]) == 0 |
benchmark_functions_edited/f9984.py | def f(files):
total = 0
for fileinfo in files.values():
if fileinfo['incoming'] and fileinfo['given_label'] is None:
total += 1
return total
assert f({}) == 0 |
benchmark_functions_edited/f4913.py | def f(item, ndivs, low, width):
assert item >= low, Exception("negative bucket index")
return min(int((item - low) / width), ndivs-1)
assert f(1.4, 10, 1, 2) == 0 |
benchmark_functions_edited/f2254.py | def f(a, b):
result = a * b
return result
assert f(0, 3) == 0 |
benchmark_functions_edited/f11316.py | def f(entry, groups):
group_name = entry['name'].strip()
group_id = int(entry['id'])
groups[group_id] = group_name
return group_id
assert f(
{'name': 'Group 3', 'id': 3},
{1: None},
) == 3 |
benchmark_functions_edited/f9822.py | def f(m):
x = m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2])
y = m[1][0] * (m[2][1] * m[0][2] - m[0][1] * m[2][2])
z = m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2])
return (x + y + z)
assert f([[0, 0, 0],
[0, 0, 1],
[0, 1, 0]]) == 0 |
benchmark_functions_edited/f11464.py | def f(mask: int) -> int:
return (mask & -mask).bit_length() - 1
assert f(0b0000_0110) == 1 |
benchmark_functions_edited/f12237.py | def f(inventory_dict, id):
count = 0
for item in inventory_dict["items"]:
if item['id'] == id:
return count
count += 1
raise KeyError("Id not found")
assert f(
{
"id": "abc123",
"items": [
{"id": "123", "name": "Sword of Protection +1", "type": "Weapon"},
{"id": "456", "name": "Dagger", "type": "Weapon"},
]
},
"123"
) == 0 |
benchmark_functions_edited/f13130.py | def f(k, x, y, z):
result = (x << 2*k) + (y << k) + z
return result
assert f(3, 0, 0, 0) == 0 |
benchmark_functions_edited/f8713.py | def f(string):
xor = 0
# convert letters to ordinal values
# then hash by taking modulo
for ind in range(len(string)):
xor ^= int(ord(string[ind]))
return xor
assert f("") == 0 |
benchmark_functions_edited/f5119.py | def f(a_list):
largest = max(a_list)
a_list.remove(largest)
return max(a_list)
assert f([1, 2, 3, 4, 5]) == 4 |
benchmark_functions_edited/f10132.py | def f(bw, n, fs, halfint=True):
# nw = tw = t(bw)/2 = (n/fs)(bw)/2
bw, n, fs = list(map(float, (bw, n, fs)))
nw = (n / fs) * (bw / 2)
if halfint:
# round 2NW to the closest integer and then halve again
nw = round(2 * nw) / 2.0
return nw
assert f(12, 100, 100) == 6 |
benchmark_functions_edited/f10578.py | def f(cikName,oldNames) :
cikName = cikName.casefold()
for i,oldName in enumerate(oldNames) :
if cikName == oldName.casefold() :
return i
return -1
assert f('abc', ['abc', 'def']) == 0 |
benchmark_functions_edited/f1364.py | def f(kernel_size, dilation=1):
return int((kernel_size * dilation - dilation) / 2)
assert f(5, 1) == 2 |
benchmark_functions_edited/f686.py | def f(x):
return sum(x) / len(x)
assert f([0, 0, 0]) == 0 |
benchmark_functions_edited/f145.py | def f(bb, bit):
return bb | (1 << bit)
assert f(0, 2) == 4 |
benchmark_functions_edited/f14403.py | def totalStudents (theDictionary):
total = 0
for key in theDictionary:
if (
theDictionary[key] != "open" and
theDictionary[key].isalpha()
):
total += 1
return total
assert f(
{"23-A": "Karen", "31-C": "Jane", "32-B": "Jack", "32-C": "open"}
) == 3 |
benchmark_functions_edited/f8019.py | def f(x: int, y: int) -> int:
return x if y == 0 else f(y, x % y)
assert f(0, 0) == 0 |
benchmark_functions_edited/f11224.py | def f(lag=1):
win_size = 2*lag + 1
neighbours = win_size**2 - (2*(lag-1) + 1)**2
return neighbours
assert f(1) == 8 |
benchmark_functions_edited/f11558.py | def f(precision, recall):
if precision == 0 and recall == 0:
return 0
else:
return 2 * precision * recall / (precision + recall)
assert f(0, 0) == 0 |
benchmark_functions_edited/f14249.py | def f(factorial):
# return the value in the cache
factorial = str(factorial)
index = len(factorial) - 1
# count of number of trailing zeroes
trailing = 0
while index > 0:
if factorial[index] == "0":
trailing += 1
index -= 1
else:
# time to break out of the loop
index = 0
return trailing
assert f(50) == 1 |
benchmark_functions_edited/f8249.py | def f(a, b):
assert a in (0, 1)
assert b in (0, 1)
if a == b:
return 0
else:
return 1
assert f(1, 1) == 0 |
benchmark_functions_edited/f11799.py | def f(f_time, interval):
if f_time < interval:
f_time = interval
elif f_time % interval != 0:
f_time -= f_time % interval
return f_time
assert f(0, 2) == 2 |
benchmark_functions_edited/f6536.py | def f(in_siz, out_siz, stride, ksize):
return (out_siz - 1) * stride + ksize - in_siz
assert f(9, 10, 1, 3) == 3 |
benchmark_functions_edited/f9257.py | def f(month):
if month not in range(1, 13):
raise ValueError('invalid month')
return {1: 1, 2: 1, 3: 1,
4: 2, 5: 2, 6: 2,
7: 3, 8: 3, 9: 3,
10: 4, 11: 4, 12: 4}[month]
# return (month + 2) // 3
assert f(5) == 2 |
benchmark_functions_edited/f12770.py | def f(input): # test
try:
output = int(input)
except ValueError:
return False
return output
assert f(3) == 3 |
benchmark_functions_edited/f5652.py | def f(array, x):
best = None
for elt in array:
if elt <= x:
best = elt
elif best is not None:
return best
return best
assert f([2,1], 1) == 1 |
benchmark_functions_edited/f11176.py | def f(items):
if items:
for it in items:
if it:
return it
return items[0]
else:
return items
assert f(list(range(1))) == 0 |
benchmark_functions_edited/f1314.py | def f(x): # 2
# 3
if x == 0: # 4
return 1 # 5
return 1 + f(x - 1)
assert f(4) == 5 |
benchmark_functions_edited/f8385.py | def f(num_a, num_b):
return max(0, min(num_a, num_b))
assert f(1, 0) == 0 |
benchmark_functions_edited/f2610.py | def f(num1: int, num2: int) -> int:
return abs((num1) - (num2))
assert f(0, 1) == 1 |
benchmark_functions_edited/f8289.py | def f(part, key_name):
try:
return part[key_name]
except KeyError: #undefined field name
print("Error\t:wrong field\nCHECK!!!\n")
for field in part.items():
print(f"{field[0]:12}\t{field[1]}")
assert f(
{"foo": 1, "bar": 2},
"foo"
) == 1 |
benchmark_functions_edited/f1249.py | def f(bitboard, bit):
return bitboard | (1 << bit)
assert f(1, 2) == 5 |
benchmark_functions_edited/f8046.py | def f(t1, t2):
min_d = 9e4
t1, t2 = t1[:8], t2[:8]
for t in t2:
if abs(t1[0]-t)<min_d:
min_d = abs(t1[0]-t)
for t in t1:
if abs(t2[0]-t)<min_d:
min_d = abs(t2[0]-t)
return min_d
assert f(
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1]
) == 0 |
benchmark_functions_edited/f3563.py | def f(a, b):
s=0
for i in range(len(a)):
s=s+abs(a[i]-b[i])
return s
assert f([2, 3, 1], [2, 2, 2]) == 2 |
benchmark_functions_edited/f13251.py | def f(board, player, x, y, i, j, size):
captures = 1
other_player = -player
xc = x+i
yc = y+j
while size > xc >= 0 and size > yc >= 0 and board[yc][xc] == other_player:
xc += i
yc += j
captures += 1
if captures and size > xc >= 0 and size > yc >= 0 and board[yc][xc] == player:
return captures
return 0
assert f(
[[1, 1, 1, 1], [0, 0, 0, 1], [1, 0, 1, 1], [1, 1, 1, 1]],
1,
0,
0,
1,
1,
4) == 0 |
benchmark_functions_edited/f12990.py | def f(lst):
#initialize current min value and index to first element
minIndex = 0 # index of current minimal value
val = lst[0] # current minimal value
# loop through all elements
for i in range(1, len(lst)):
# if current value is smaller than current minimum -> update values
if lst[i] < val:
minIndex = i
val = lst[i]
return minIndex
assert f( [100,2,3] ) == 1 |
benchmark_functions_edited/f864.py | def f(v):
return sum(v_i ** 2 for v_i in v)
assert f([-1, 2]) == 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.