file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f14496.py
|
def f(old_status):
if old_status in [0, 3, 4]:
return old_status
if old_status == 1:
return 2
if old_status == 2:
return 1
assert f(2) == 1
|
benchmark_functions_edited/f28.py
|
def f(x):
return int(x < 0)
assert f(1) == 0
|
benchmark_functions_edited/f13785.py
|
def f(m,n):
#print "%s cmp %s" % (bin(m), bin(n))
i = 8 # bits in a number
r = 0 # return value
for i in range(8, -1, -1):
# get the ith bit of the two numbers
mi = (1<<i) & m
ni = (1<<i) & n
#print "%d bit: %s, %s" % (i, bin(mi), bin(ni))
# fake a comparison using boolean operators
r = r or (mi and not ni and 1) or (ni and not mi and -1)
return r
assert f(1, 0) == 1
|
benchmark_functions_edited/f302.py
|
def f(x):
return 10.0**(0.1*x)
assert f(0) == 1
|
benchmark_functions_edited/f9618.py
|
def f(group_idx):
cmp_pos = 0
steps = 1
if len(group_idx) < 1:
return 0
for i in range(len(group_idx)):
if group_idx[cmp_pos] != group_idx[i]:
cmp_pos = i
steps += 1
return steps
assert f([]) == 0
|
benchmark_functions_edited/f2059.py
|
def f(a, b):
return int(a['first_commit'] - b['first_commit'])
assert f(
{'first_commit': 1605290800},
{'first_commit': 1605290800}
) == 0
|
benchmark_functions_edited/f689.py
|
def f(lst):
return sum(lst) / len(lst)
assert f((1, 2, 3)) == 2
|
benchmark_functions_edited/f7210.py
|
def f(outputFormat, article_len, wrd):
if outputFormat == "word_count":
return int(wrd)
else:
return article_len * float(wrd)
assert f(None, 10, 0.5) == 5
|
benchmark_functions_edited/f11110.py
|
def f(arr, N, x):
L = 0
R = N-1
done = False
m = (L+R)//2
while not done:
if arr[m] < x:
L = m + 1
elif arr[m] > x:
R = m - 1
elif arr[m] == x:
done = True
m = (L+R)//2
if L>R:
done = True
return L
assert f( [1, 1, 1], 3, 1) == 0
|
benchmark_functions_edited/f5341.py
|
def f(file, message):
with open(file, "a", encoding="utf8") as output:
output.write(message+'\n')
output.close()
return 1
assert f(
"test.txt",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
) == 1
|
benchmark_functions_edited/f7928.py
|
def f(vals):
counter = 0
num = len(vals)
for i in range(1, num-1):
if (vals[i]-vals[i-1])*(vals[i]-vals[i+1])<0:
counter = counter + 1
return counter
assert f([1, 1, 1, 1, 1, 1, 1]) == 0
|
benchmark_functions_edited/f13619.py
|
def f(bits):
size = bits >> 24
word = bits & 0x007fffff
if size < 3:
word >>= 8 * (3 - size)
else:
word <<= 8 * (size - 3)
if bits & 0x00800000:
word = -word
return word
assert f(0) == 0
|
benchmark_functions_edited/f10915.py
|
def f(option):
try:
total_donations = option.ticket.feature.total_donations
except:
total_donations = 0
return total_donations
assert f(5) == 0
|
benchmark_functions_edited/f11289.py
|
def f(track_width, distance_from_center):
# make sure not negative, in case distance_from_center is over the track_width
distance = distance_from_center / (track_width/2.0)
return max(min(1.0 - distance, 1.0), 0.0)
assert f(2, 2.0) == 0
|
benchmark_functions_edited/f9414.py
|
def f(c,h,phi=0.3): # equation 1
u = (c**(1-phi))*(h**phi)
return u
assert f(0,0) == 0
|
benchmark_functions_edited/f8840.py
|
def f(rpm, chipLoad, numTeeth):
feedRate = rpm*chipLoad*numTeeth
return feedRate
assert f(1, 1, 1) == 1
|
benchmark_functions_edited/f13259.py
|
def f(nested_dict, path_list):
value = nested_dict
for k in path_list:
value = value[k]
return value
assert f( {'a': 1, 'b': {'c': 2}}, ['a'] ) == 1
|
benchmark_functions_edited/f11960.py
|
def f(text):
if not isinstance(text, str):
raise TypeError("only accepts strings")
special_characters = ['-', '+', '\n']
for character in special_characters:
text = text.replace(character, " ")
words = text.split()
return len(words)
assert f(" ") == 0
|
benchmark_functions_edited/f9952.py
|
def f(to_search_min):
greather_than_0 = [each for each in to_search_min if each > 0]
lower_or_eq_0 = [each for each in to_search_min if each <= 0]
if greather_than_0:
m = min(greather_than_0)
else:
m = min(lower_or_eq_0)
return m
assert f([1]) == 1
|
benchmark_functions_edited/f12597.py
|
def f(side1, side2, side3):
if side1 > side2 and side1 > side3:
return side1
elif side2 > side1 and side2 > side3:
return side2
elif side3 > side2 and side3 > side1:
return side3
assert f(3, 4, 5) == 5
|
benchmark_functions_edited/f1170.py
|
def f(x, xmin, xrng, xres):
return int((x-xmin) * (xres-1) / xrng)
assert f(9, 10, 10, 10) == 0
|
benchmark_functions_edited/f3957.py
|
def f(x, a, b, c, d):
y = (float(x) - float(a))/(float(b) - float(a)) * \
(float(d) - float(c)) + float(c)
return y
assert f(0, 0, 10, 5, 15) == 5
|
benchmark_functions_edited/f9836.py
|
def f(values):
count = 0
prev_v = 0
for i, v in enumerate(values):
if i == 0:
prev_v = v
else:
if prev_v * v < 0:
count += 1
prev_v = v
return count
assert f([]) == 0
|
benchmark_functions_edited/f1820.py
|
def f(nums) -> float:
return sum(nums) / len(nums)
assert f([1,2,3]) == 2
|
benchmark_functions_edited/f2037.py
|
def f(cond, body, orelse):
return body() if cond else orelse()
assert f(True, lambda: 1, lambda: 1) == 1
|
benchmark_functions_edited/f9945.py
|
def f(operand, modulus):
if modulus == 0:
raise ValueError("Modulus cannot be 0")
if operand >= modulus:
raise OverflowError("operand cannot be greater than modulus")
non_zero = operand != 0
return (modulus - operand) & (-int(non_zero))
assert f(2**32 - 1, 2**32) == 1
|
benchmark_functions_edited/f6065.py
|
def f(list=[]):
element = None
if list:
element = 0
for object in list:
element += object
return element
assert f([1,2,3]) == 6
|
benchmark_functions_edited/f3199.py
|
def f(n):
return max(n * 2, 1)
assert f(1) == 2
|
benchmark_functions_edited/f5009.py
|
def f(n):
n *= 2
if n < 1:
return 0.5 * n**3
else:
n -= 2
return 0.5 * (n**3 + 2)
assert f(0) == 0
|
benchmark_functions_edited/f14002.py
|
def f(s):
bytes_list = s.encode()
#bytes_list = str(s).encode() this will take of numbers if they're gonna be used as a key
total = 0
for b in bytes_list: #O(n) over the length of the key not the hash data, O(1) over the Hash data table
total += b
return total
#total &= oxffffff #force it to 32 bit (8 f's)
#total &= 0xffffffffffffffff #32 bit (19f's)
assert f('') == 0
|
benchmark_functions_edited/f13298.py
|
def f(astring):
aline = astring.split(':')
d = float(aline[0])
m = float(aline[1])
s = float(aline[2])
hour_or_deg = (s/60.+m)/60.+d
return hour_or_deg
assert f("00:00:00") == 0
|
benchmark_functions_edited/f1899.py
|
def f(events):
return sum([len(e) for e in events])
assert f(
[
[],
[],
]
) == 0
|
benchmark_functions_edited/f11436.py
|
def f(bit):
cnt = (bit & 0xAAAAAAAAAAAAAAAA) != 0
cnt |= ((bit & 0xCCCCCCCCCCCCCCCC) != 0) << 1
cnt |= ((bit & 0xF0F0F0F0F0F0F0F0) != 0) << 2
cnt |= ((bit & 0xFF00FF00FF00FF00) != 0) << 3
cnt |= ((bit & 0xFFFF0000FFFF0000) != 0) << 4
cnt |= ((bit & 0xFFFFFFFF00000000) != 0) << 5
return cnt
assert f(0b00000000000000000000000000010000) == 4
|
benchmark_functions_edited/f904.py
|
def f(iterable):
return next(iterable, None)
assert f(iter([1])) == 1
|
benchmark_functions_edited/f10300.py
|
def f(nvols):
mod = int(int(nvols) % 2)
if mod == 1:
return 0
else:
return 1
assert f(1) == 0
|
benchmark_functions_edited/f1340.py
|
def f(it):
return sum(1 for _value in it)
assert f(range(3)) == 3
|
benchmark_functions_edited/f13320.py
|
def f(n):
return str(n).count('7')
assert f(12345) == 0
|
benchmark_functions_edited/f11318.py
|
def f(a, b):
if a is None:
return b
elif b is None:
return a
else:
return min(a, b)
assert f(3, None) == 3
|
benchmark_functions_edited/f4586.py
|
def f(data, item):
for index, val in enumerate(data):
if val == item:
return index
return None
assert f(range(10), 8) == 8
|
benchmark_functions_edited/f3905.py
|
def f(string_unsorted_list):
num_lengths = []
for num in string_unsorted_list:
num_lengths.append(len(num))
return max(num_lengths)
assert f(list('1')) == 1
|
benchmark_functions_edited/f6791.py
|
def f(N_STS):
table_20_13 = {1 : 1,
2: 2,
3: 4,
4: 4}
return table_20_13[N_STS]
assert f(1) == 1
|
benchmark_functions_edited/f8751.py
|
def f(psum):
mingain = psum
minpgain = psum
hpi = 0
return hpi
assert f(50) == 0
|
benchmark_functions_edited/f11198.py
|
def f(collection):
count = 0
for t in collection:
count += 1
return count
assert f({1: 1, 2: 2, 3: 3}) == 3
|
benchmark_functions_edited/f6358.py
|
def f(val, res, decimals=None):
if decimals is None and "." in str(res):
decimals = len(str(res).split('.')[1])
return round(round(val / res) * res, decimals)
assert f(3, 1) == 3
|
benchmark_functions_edited/f11963.py
|
def f(x, y): # from: https://portingguide.readthedocs.io/en/latest/comparisons.html
return (x > y) - (x < y)
assert f(1, float('-inf')) == 1
|
benchmark_functions_edited/f804.py
|
def f(cm):
return int(2770 / 2.29 * cm)
assert f(0) == 0
|
benchmark_functions_edited/f6272.py
|
def f(skierposition,userinput):
if userinput == "j":
skierposition = skierposition - 1
if userinput == "k":
skierposition = skierposition + 1
return skierposition
assert f(4,"j") == 3
|
benchmark_functions_edited/f11542.py
|
def f(results):
transcriptome_length = 0
for gene_result in results:
if gene_result is not None:
transcriptome_length += int(gene_result['loc'].attrs['effective_length'])
return transcriptome_length
assert f([None, None]) == 0
|
benchmark_functions_edited/f11215.py
|
def f(base_stat, level, iv, effort, nature=None):
# Shedinja's base stat of 1 is special; its HP is always 1
if base_stat == 1:
return 1
return (base_stat * 2 + iv + effort // 4) * level // 100 + 10 + level
assert f(1, 1, 1, 1) == 1
|
benchmark_functions_edited/f10390.py
|
def f(b1, b2, g1, g2, r0):
def f(a, b, c):
return (a ** (c - 1.0)) * (b ** (3.0 - c))
return (b1 ** 2) / (f(b1, r0, g1) + f(b2, b1, g2) - f(b2, r0, g2))
assert f(1, 1, 1, 1, 1) == 1
|
benchmark_functions_edited/f12175.py
|
def f(data_sorted):
length = len(data_sorted)
if length % 2 == 1:
return data_sorted[((length + 1) // 2) - 1]
half = length // 2
a = data_sorted[half - 1]
b = data_sorted[half]
return (a + b) / 2
assert f(range(5)) == 2
|
benchmark_functions_edited/f773.py
|
def f(jet):
return(jet[0])
assert f(
[4, [4, 3]]) == 4
|
benchmark_functions_edited/f2189.py
|
def f(cell1, cell2):
return abs(cell1[0] - cell2[0]) + abs(cell1[1] - cell2[1])
assert f( (0, 0), (-1, -1) ) == 2
|
benchmark_functions_edited/f6636.py
|
def f(numbers_list):
min_val = min(numbers_list)
max_val = max(numbers_list)
return max_val - min_val
assert f([88,89,90]) == 2
|
benchmark_functions_edited/f12899.py
|
def f(lines):
running_sum = 0
memory = {0}
while True:
for value in lines:
running_sum += int(value)
if running_sum in memory:
return running_sum
memory.add(running_sum)
assert f([+1, -1]) == 0
|
benchmark_functions_edited/f1112.py
|
def f(lst):
return sum(lst) / len(lst)
assert f(list(range(5))) == 2
|
benchmark_functions_edited/f511.py
|
def f(a, b):
return -(-a // b)
assert f(2, 1) == 2
|
benchmark_functions_edited/f7412.py
|
def f(r, Rmax):
if r < Rmax:
b = 10 * r / Rmax
elif r >= 1.2*Rmax:
b = 10
else:
b = (75 * r / Rmax) - 65
return b
assert f(0, 10) == 0
|
benchmark_functions_edited/f1253.py
|
def f(a,b):
if a == b:
return 2
elif a != b:
return -1
assert f(1, 1) == 2
|
benchmark_functions_edited/f3387.py
|
def f(loan):
unlimited = loan.get("extension_count", 0) + 1
return unlimited
assert f({"extension_count": 0, "foo": "bar"}) == 1
|
benchmark_functions_edited/f801.py
|
def f(x, y, z):
return (x & y) ^ (~x & z)
assert f(1, 1, 1) == 1
|
benchmark_functions_edited/f348.py
|
def f(num):
return int(str(num)[::-1])
assert f(0) == 0
|
benchmark_functions_edited/f1087.py
|
def f(s, pos):
while s[pos] == " ":
pos += 1
return pos
assert f( " a ", 0) == 1
|
benchmark_functions_edited/f12076.py
|
def f(a,loc=False):
maxval = a[0]
indicii = 0
for i in range(1, len(a)):
if a[i] > maxval:
maxval = a[i]
indicii = i
large = sorted(a)
index = len(a)
if loc == True:
#return large[index-1]
return maxval,indicii
else:
return maxval
assert f([1, 3, 4, 2]) == 4
|
benchmark_functions_edited/f6363.py
|
def f(s, o=0):
if len(s) == 0:
return 0
elif s[0] == '<':
return f(s[1:], o + 1)
elif s[0] == '>' and o > 0:
return 1 + f(s[1:], o - 1)
else:
return 0
assert f('>----<>>--', 5) == 1
|
benchmark_functions_edited/f5607.py
|
def f(base, exponent, modulus):
if modulus == 1:
return 0
c = 1
for i in range(0, exponent):
c = (c * base) % modulus
return c
assert f(5, 3, 2) == 1
|
benchmark_functions_edited/f7526.py
|
def f(tbin,T):
return 1/2 * T/tbin
assert f(1,2) == 1
|
benchmark_functions_edited/f13344.py
|
def f(line: str, spec: list) -> int:
lines = line.split()
if len(lines) >= 2:
mz, intensity = lines[0], lines[1]
spec.append([float(mz), float(intensity)])
return 0
else:
return 1
assert f(
'710.09289 1000',
[
[1.1, 2.2],
[3.3, 4.4],
[5.5, 6.6],
[7.7, 8.8],
]
) == 0
|
benchmark_functions_edited/f10676.py
|
def f(seq1, seq2):
set1, set2 = set(seq1), set(seq2)
return 1 - (2 * len(set1 & set2) / float(len(set1) + len(set2)))
assert f('abc', 'xyz') == 1
|
benchmark_functions_edited/f7623.py
|
def f(x):
if x == 0:
return 0
else:
p = 16.6666666 / x # 1 m/s --> min/km
return ':'.join([str(int(p)),
str(int((p * 60) % 60)).zfill(2)])
assert f(0) == 0
|
benchmark_functions_edited/f6069.py
|
def f(func, arg):
if len(arg) == 0:
return ('empty', func(arg))
else:
return func(arg)
assert f(len, [1, 2, 3]) == 3
|
benchmark_functions_edited/f4478.py
|
def f(data):
mean = sum(data)/len(data)
tot = 0.0
for d in data:
tot += (d - mean)**2
return tot/mean
assert f([1]) == 0
|
benchmark_functions_edited/f10192.py
|
def f(weeklyRtn):
#print('in weektype')
if abs(weeklyRtn)<0.015:
return 1
elif weeklyRtn>0.015:
return 2
else:
return 3
assert f(0.010) == 1
|
benchmark_functions_edited/f7624.py
|
def f(v1, v2):
if v1 < v2:
return -1
elif v1 == v2:
return 0
else:
return 1
assert f(1, 1) == 0
|
benchmark_functions_edited/f5546.py
|
def f(n):
if n == 1 or n == 2:
return 1
n1 = n - 1
n2 = n - 2
fibr1 = f(n1)
fibr2 = f(n2)
res = fibr1 + fibr2
return res
assert f(2) == 1
|
benchmark_functions_edited/f10101.py
|
def f(name):
if name.startswith("__"):
return 3
elif name.startswith("_"):
return 2
elif name.isupper():
return 1
else:
return 0
assert f("b") == 0
|
benchmark_functions_edited/f13557.py
|
def f(n):
# Accumulator
total = 0
print('Before while')
x = 0
while x < n:
print('Start loop '+str(x))
total = total + x*x
x = x+1
print('End loop ')
print('After while')
return total
assert f(1) == 0
|
benchmark_functions_edited/f9016.py
|
def f(temp, pressure, sg, z):
temp = temp + 459.67
R = 10.732 # gas constant in (ft3*psi)/(lb-mol*R)
rhogas = (28.97 * sg * pressure) / (z * R * temp)
return rhogas
assert f(15, 15, 0, 1) == 0
|
benchmark_functions_edited/f10330.py
|
def f(meals):
unique_ingre = []
for meal in meals:
ingre = sorted(meal["ingredients"])
if ingre not in unique_ingre:
print(meal["name"])
unique_ingre.append(ingre)
return len(unique_ingre)
assert f([{"name": "Burger", "ingredients": ["beef"]}, {"name": "Burger", "ingredients": ["beef"]}]) == 1
|
benchmark_functions_edited/f7812.py
|
def f(stim, color_control):
# print('stim: ', stim)
# print("Color control: ", color_control)
return stim * (1 - color_control)
assert f(2, 0) == 2
|
benchmark_functions_edited/f9100.py
|
def f(point1, point2):
result = 0
for i in range(len(point1)):
result = result + point1[i]*point2[i]
return result
assert f( (1,1,1), (1,0,0) ) == 1
|
benchmark_functions_edited/f9118.py
|
def f(cote, boost_selon_cote=True, boost=1):
if not boost_selon_cote:
return boost
if cote < 2:
return 0
if cote < 2.51:
return 0.25
if cote < 3.51:
return 0.5
return 1
assert f(3.5, False) == 1
|
benchmark_functions_edited/f6741.py
|
def f(strg):
words = strg.split()
min_size = float('inf')
for word in words:
if len(word) < min_size:
min_size = len(word)
return min_size
assert f(
"turns out random test cases are easier than writing out basic ones"
) == 3
|
benchmark_functions_edited/f5208.py
|
def f(data, length):
if len(data) < length:
return "Not enough Data"
subset = data[-length:]
return sum(subset) / len(subset)
assert f(list(range(10)), 1) == 9
|
benchmark_functions_edited/f1760.py
|
def f(x):
if type(x) in [list, tuple]:
return len(x)
return x.shape
assert f([1]) == 1
|
benchmark_functions_edited/f8464.py
|
def f(point1_x, point1_y, point2_x, point2_y):
return abs(point1_x - point2_x) + abs(point1_y-point2_y)
assert f(1, 1, 0, 0) == 2
|
benchmark_functions_edited/f14029.py
|
def f(bs: bytes) -> int:
assert len(bs) == 32
return int.from_bytes(bs, 'big')
assert f(b'\x00' * 32) == 0
|
benchmark_functions_edited/f13453.py
|
def f(ver1, ver2):
if not ver1 or not ver2:
return 0
if ver1[0] < ver2[0]:
return -1
if ver1[0] > ver2[0]:
return 1
return f(ver1[1:], ver2[1:])
assert f(tuple([1, 2]), tuple([1, 1])) == 1
|
benchmark_functions_edited/f12049.py
|
def f(value, epoch, reduction_rate):
return value / (1 + epoch / reduction_rate)
assert f(10, 1, 1) == 5
|
benchmark_functions_edited/f13659.py
|
def f(n, max_num):
if n == 0: # Base case
return max_num
# If the digit is 9, it is already the biggest digit from 0 to 9.
elif n == 9:
return 9
else:
if n % 10 > max_num:
max_num = n % 10
# To check the next digit of the number
if n > 0:
n //= 10
return f(n, max_num)
assert f(12345, 0) == 5
|
benchmark_functions_edited/f9051.py
|
def f(x):
n = 1
while True:
try:
v = x[n]
except IndexError:
return n
n *= 2
assert f([1]) == 1
|
benchmark_functions_edited/f2939.py
|
def f(records):
return sum(1 for record in records if record["did_bring_lunch"])
assert f([]) == 0
|
benchmark_functions_edited/f12250.py
|
def f(n: int) -> int:
return (1 << n) - 1
assert f(3) == 7
|
benchmark_functions_edited/f9835.py
|
def f(arr_1, arr_2):
result = set(arr_1).intersection(set(arr_2))
return len(result)
assert f(
[],
[]
) == 0
|
benchmark_functions_edited/f3406.py
|
def f(array, value):
idx,val = min(enumerate(array), key=lambda x: abs(x[1]-value))
return val
assert f( [1,2,3,4,5], 6) == 5
|
benchmark_functions_edited/f6645.py
|
def f(x):
approx = None
guess = x / 2
while approx != guess:
approx = guess
guess = (approx + x / approx) / 2
return approx
assert f(25) == 5
|
benchmark_functions_edited/f10298.py
|
def f(ca, cb, n1, n2):
return ((n1*ca - n2*cb)/(n1*ca + n2*cb))**2
assert f(1, 0, 1, 1) == 1
|
benchmark_functions_edited/f6192.py
|
def f(pccf_vec):
for i in range(len(pccf_vec)):
if i == 0:
continue
if pccf_vec[i] < pccf_vec[i-1]:
return i - 1
assert f(
[5,4,3,2,1]
) == 0
|
benchmark_functions_edited/f13354.py
|
def f(n, k):
if not k:
return 1
else:
output = n
while k != 1:
output = output * (n - 1)
n = n - 1
k -= 1
return output
assert f(4, 0) == 1
|
benchmark_functions_edited/f5471.py
|
def f(a, b):
if b > a:
return 1
elif b < a:
return -1
return 0
assert f(10, 10) == 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.