file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f6770.py | def f(scale:list,aspect_ratio:list):
return len([ar+s for ar in aspect_ratio for s in scale])
assert f([1,2,3],[0.1,0.2]) == 6 |
benchmark_functions_edited/f3940.py | def f(ammount):
if ammount > 1000:
return ammount - ammount * 0.98
return ammount - ammount * 0.985
assert f(0) == 0 |
benchmark_functions_edited/f6203.py | def f(rating_scores):
return sum(rating_scores) / len(rating_scores)
assert f(
[1, 2, 3]) == 2 |
benchmark_functions_edited/f11785.py | def f(word, greek_text):
# if we run out of words, just keep going...
if len(greek_text) == 0:
return "ERROR"
pop_off = greek_text.pop(0)
return pop_off
assert f(1, [1, 2]) == 1 |
benchmark_functions_edited/f10454.py | def f(pattern, motiv):
if len(pattern) != len(motiv):
return -1
hamming_distance = 0
for i in range(len(motiv)):
if pattern[i] != motiv[i]:
hamming_distance += 1
return hamming_distance
assert f('GACAGACTACTGGACCACG','GACAGACTACTGGACCACA') == 1 |
benchmark_functions_edited/f11357.py | def f(controller_input, dead_zone):
if controller_input <= dead_zone and controller_input >= -dead_zone:
return 0
elif controller_input > 0:
return ((controller_input-dead_zone)/(1-dead_zone))
else:
return ((-controller_input-dead_zone)/(dead_zone-1))
assert f(0.49, 1) == 0 |
benchmark_functions_edited/f5609.py | def f(dic, keys, default):
for key in keys:
if key in dic:
return dic[key]
else:
return default
assert f(
{0: 1},
[1],
0
) == 0 |
benchmark_functions_edited/f12455.py | def f(n, r):
if n < 0 or r < 0:
print('Negative values not allowed')
return 0
if r > n:
print('r must not be greater than n')
return 0
combin = 1
if r > n / 2:
r1 = n - r
else:
r1 = r
for k in range(r1):
combin = combin * (n - k) // (k + 1)
return combin
assert f(5, 5) == 1 |
benchmark_functions_edited/f8049.py | def f(num, num_bits):
if num & (1 << (num_bits - 1)) != 0: # if sign bit set
return num - (1 << num_bits)
else:
return num
assert f(0b00000000, 8) == 0 |
benchmark_functions_edited/f446.py | def f(lst):
return len(lst)/sum([1/num for num in lst])
assert f([1]) == 1 |
benchmark_functions_edited/f10759.py | def f(title, name): # pylint: disable=unused-argument
print("Good morning, {title} {name}.".format(**locals()))
return 0
assert f("Mr.", "Smith") == 0 |
benchmark_functions_edited/f2861.py | def f(year):
y = year - 1
return y * 365 + y // 4 - y // 100 + y // 400
assert f(1) == 0 |
benchmark_functions_edited/f9479.py | def f(test, lower, upper, bins):
# No, I don't remember why this works. It's not hard to figure out though.
bins -= 1
ul = upper-lower
bs = ul/bins
return max(0, int(round(min(bins, bins*(test-lower)/ul), 0)))
assert f(0, 0, 10, 100) == 0 |
benchmark_functions_edited/f2761.py | def f(i):
try:
i = int(i)
except ValueError:
pass
return i
assert f("1") == 1 |
benchmark_functions_edited/f11637.py | def f(reduced_time: float) -> float:
if reduced_time < 7.5:
angle_of_attack = -3.3 * reduced_time
else:
angle_of_attack = 2 * reduced_time - 40
return angle_of_attack
assert f(0) == 0 |
benchmark_functions_edited/f10808.py | def f(raw_table, base_index):
if (raw_table[base_index] == 0xFFFF
or raw_table[base_index+1] == 0xFFFF
or raw_table[base_index+2] == 0xFFFF):
return None
return (raw_table[base_index] * 1000 + raw_table[base_index+1]) * 1000 + raw_table[base_index+2]
assert f(b'\x01\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF', 2) == 0 |
benchmark_functions_edited/f5489.py | def f(num):
return -num if num < 0 else num
assert f(1) == 1 |
benchmark_functions_edited/f6949.py | def f(N):
count = 0
for i in range(1,N+1):
i = str(i)
if '3'in i or '4'in i or '7' in i:
continue
if '2'in i or '5'in i or '9' in i or '6' in i:
count +=1
return count
assert f(10) == 4 |
benchmark_functions_edited/f6831.py | def f(string):
SPACE = " "
return string.count(" ")
assert f(" ") == 2 |
benchmark_functions_edited/f6805.py | def f(p_bytes):
l_ix = 0
l_int = 0
while l_ix < len(p_bytes):
l_b = int(p_bytes[l_ix])
l_int = l_int * 256 + l_b
l_ix += 1
return l_int
assert f(b'\x00\x00') == 0 |
benchmark_functions_edited/f2284.py | def f(k,n):
phi = (n - 1.0)/n
return (1 - phi**k)
assert f(1,1) == 1 |
benchmark_functions_edited/f7145.py | def f(value, _min, _max):
return max(_min, min(value, _max))
assert f(-89, 0, 100) == 0 |
benchmark_functions_edited/f12992.py | def f(x, gamma, PML_start, PML_thk):
return 1 + 3*(gamma - 1)*((abs(x - PML_start))/PML_thk)**2
assert f(0, 0, 0, 1) == 1 |
benchmark_functions_edited/f212.py | def f(sym):
return sym["st_size"]
assert f(
{
"st_name": "my_symbol",
"st_size": 0,
"st_info": 0,
"st_other": 0,
}
) == 0 |
benchmark_functions_edited/f7633.py | def f(a, b):
if a < 0 or b < 0:
print("invalid arguments")
return a * a + b * b
assert f(0, 0) == 0 |
benchmark_functions_edited/f5070.py | def f(a: int, b: int) -> int:
# Rekursiv
if b == 0:
return a
else:
r = a % b
return f(b, r)
assert f(4, 13) == 1 |
benchmark_functions_edited/f10764.py | def f(x, theta):
hypothesis = 0.0
for t in range(len(theta)):
# compute prediction by raising x to each power t
hypothesis += theta[t] * (x ** t)
return hypothesis
assert f(0, [1, 1]) == 1 |
benchmark_functions_edited/f4405.py | def f(n1, n2, n3):
list = [n1, n2, n3]
list.sort()
return list[1]
assert f(1, 1, 3) == 1 |
benchmark_functions_edited/f6088.py | def f(s):
if not len(s):
return 0
try:
enc = s.encode("hex")
except LookupError:
enc = "".join("%02x" % ord(c) for c in s)
return int(enc, 16)
assert f(b"") == 0 |
benchmark_functions_edited/f9103.py | def f(t, thresholds):
for index in range(len(thresholds) - 1):
if thresholds[index] <= t < thresholds[index + 1]:
return index
return len(thresholds) - 1
assert f(0.3, [0.0, 0.1, 0.2]) == 2 |
benchmark_functions_edited/f1571.py | def vflip (val=None):
global _vflip
if val is not None:
_vflip = val
return _vflip
assert f(1) == 1 |
benchmark_functions_edited/f1059.py | def f(P1, P2):
return P1[0]*P2[0]-P1[1]*P2[1]-P1[2]*P2[2]-P1[3]*P2[3]
assert f( (1, 2, 3, 4), (0, 0, 0, 0) ) == 0 |
benchmark_functions_edited/f14485.py | def f(itemList, item):
itemList = sorted(itemList, reverse = False)
first = 0
last = len(itemList) - 1
while(first <= last):
mid = (first + last) // 2
if itemList[mid] == item:
return mid
else:
if item < itemList[mid]:
last = mid -1
else:
first = mid + 1
return False
assert f([0], 0) == 0 |
benchmark_functions_edited/f13536.py | def f(n, k):
c = [0] * (n + 1)
c[0] = 1
for i in range(1, n + 1):
c[i] = 1
j = i - 1
while j > 0:
c[j] += c[j - 1]
j -= 1
return c[k]
assert f(3, 3) == 1 |
benchmark_functions_edited/f10356.py | def f(predicted_cui, golden_cui):
return int(
len(set(predicted_cui.split("|")).intersection(set(golden_cui.split("|")))) > 0
)
assert f(
"C0024161|C0003902", "C0003902|C0024161"
) == 1 |
benchmark_functions_edited/f10882.py | def f(age):
group = 0
while age >= 22:
group += 1
age -= 3
return group
assert f(30) == 3 |
benchmark_functions_edited/f11247.py | def f(x: float, exponent: float) -> int:
return int(round(x**exponent))
assert f(3, 0) == 1 |
benchmark_functions_edited/f2918.py | def f(iterable, or_=None):
return next(iterable, or_)
assert f(iter(range(1)), 1) == 0 |
benchmark_functions_edited/f5364.py | def f(iterable):
for elem in iterable:
return elem
raise IndexError
assert f(range(1, 6)) == 1 |
benchmark_functions_edited/f8259.py | def f(num):
f=1
for n in range(num,0,-1):
f*=n
return f
assert f(2) == 2 |
benchmark_functions_edited/f13765.py | def f(n, a):
if n <= 0 or a <= 0:
raise ValueError('Both arguments to _sqrt_nearest should be positive.')
b = 0
while a != b:
b, a = a, a - -n // a >> 1
return a
assert f(1, 2) == 1 |
benchmark_functions_edited/f1759.py | def f(a, b):
return sum([(xa - xb) ** 2 for xa, xb in zip(a, b)])
assert f([1, 1, 1, 1, 1], [1, 1, 1, 1, 1]) == 0 |
benchmark_functions_edited/f3787.py | def f(r1, r2):
return sum([min(a, b) for a, b in zip(r1["hist_c"], r2["hist_c"])])
assert f(
{"hist_c": [0, 0, 0, 1, 1, 1, 2, 2]},
{"hist_c": [0, 0, 0, 0, 0, 1, 1, 1]},
) == 3 |
benchmark_functions_edited/f413.py | def f(x, a, b):
return a * x / (b + x)
assert f(0, 1, 1) == 0 |
benchmark_functions_edited/f10148.py | def f(paths):
maxdist = 0
for k in paths:
lastnode = list(k[1])[-1]
dist = len(k[1][lastnode])
if dist > maxdist:
maxdist = dist
return maxdist
assert f([]) == 0 |
benchmark_functions_edited/f6548.py | def f(disk_size):
return disk_size >> 30 if disk_size else disk_size
assert f(1024 ** 3) == 1 |
benchmark_functions_edited/f3114.py | def f(n):
l = n.bit_length()
c = 0
x = 1
for _ in range(0, l):
if n & x:
c = c + 1
x = x << 1
return c
assert f(18) == 2 |
benchmark_functions_edited/f6821.py | def f(parselist, current):
for index in range(len(parselist)):
if current <= parselist[index]:
return parselist[index]
return 100
assert f(range(10), 0) == 0 |
benchmark_functions_edited/f1831.py | def f(func, obj):
if obj is None:
return obj
return func(obj)
assert f(len, "abcd") == 4 |
benchmark_functions_edited/f4329.py | def f(hour):
if '07' < hour < '10':
return 1
elif '16' < hour < '19':
return 1
else:
return 0
assert f("14") == 0 |
benchmark_functions_edited/f12699.py | def f(L):
sizeL=len(L)
max_so_far,max_ending_here=0,0
for i in range(sizeL):
max_ending_here+=L[i]
if max_ending_here<0:
max_ending_here=0
elif max_so_far<max_ending_here:
max_so_far=max_ending_here
return max_so_far
assert f(list([1])) == 1 |
benchmark_functions_edited/f10867.py | def f(x, y, op):
if (x is None) and (y is None):
return None
x = x if (x is not None) else 0
y = y if (y is not None) else 0
return op(x,y)
assert f(6, 5, min) == 5 |
benchmark_functions_edited/f19.py | def f(x, y):
return (y-x)
assert f(2, 2) == 0 |
benchmark_functions_edited/f10207.py | def f(searchList, target):
for i in range(0, len(searchList)):
if searchList[i] == target:
return i
return None
# The above is a linear runtime algorithm: O(n) - sequentially goes through the list.
assert f( [2, 4, 5, 6, 7, 8], 5 ) == 2 |
benchmark_functions_edited/f9116.py | def f(x, y):
return (x > y) - (x < y)
assert f(4, 4) == 0 |
benchmark_functions_edited/f9719.py | def f(school_type):
teaching_hours = {
'primary':4,
'primary_dc':4,
'lower_secondary':6,
'lower_secondary_dc':6,
'upper_secondary':8,
'secondary':8,
'secondary_dc':8
}
return teaching_hours[school_type]
assert f('secondary_dc') == 8 |
benchmark_functions_edited/f3676.py | def f(intstr):
try:
num = int(intstr.strip())
except ValueError:
num = 0
return num
assert f(" ") == 0 |
benchmark_functions_edited/f12877.py | def f(x, baseline, amplitude, unitarity):
return baseline + amplitude * unitarity ** (x-1)
assert f(1, 0, 1, 1) == 1 |
benchmark_functions_edited/f1573.py | def f(u, v):
assert len(u) == len(v)
return sum(map(lambda x, y: x * y, u, v))
assert f( [1000, 1000, 1000], [0, 0, 0] ) == 0 |
benchmark_functions_edited/f5323.py | def f(gray_lin):
if gray_lin <= .0031308:
return 12.92 * gray_lin
else:
return 1.055 * gray_lin ** (1 / 2.4) - 0.055
assert f(0) == 0 |
benchmark_functions_edited/f1881.py | def f(arr):
return arr.max() if arr is not None and len(arr) > 0 else 1
assert f(None) == 1 |
benchmark_functions_edited/f3601.py | def f(source, target):
return sum(abs(val1 - val2) for val1, val2 in zip(source, target))
assert f((-3, -4), (0, 0)) == 7 |
benchmark_functions_edited/f3097.py | def f(num):
m = 1
while num % 10 == 0:
num = num / 10
m *= 10
return m
assert f(12) == 1 |
benchmark_functions_edited/f6421.py | def f(original, substr):
idx = original.find(substr)
if idx != -1:
idx += len(substr)
return idx
assert f(
"abcdef",
"abc") == 3 |
benchmark_functions_edited/f5701.py | def f(func):
try:
return func.div
except AttributeError:
return 0
assert f(1) == 0 |
benchmark_functions_edited/f11278.py | def f(gpuCount):
if gpuCount:
intGpuCount = int("0"+gpuCount.split(":")[1])
return intGpuCount
else:
return int(0)
assert f("gpu:6") == 6 |
benchmark_functions_edited/f7062.py | def f(disc):
if disc < -4:
return 2
elif disc == -4:
return 4
elif disc == -3:
return 6
else:
raise ValueError
assert f(-4) == 4 |
benchmark_functions_edited/f1244.py | def f(obj): # pylint: disable=redefined-builtin,invalid-name
return obj['__id']
assert f({'__id': 2}) == 2 |
benchmark_functions_edited/f12282.py | def f(pos: float, min_value: float, cell_len: float) -> int:
return int((pos - min_value) / cell_len)
assert f(0.5, 1.0, 2.0) == 0 |
benchmark_functions_edited/f8034.py | def f(nhyd_str):
if nhyd_str == 'H':
nhyd = 1
else:
nhyd = int(nhyd_str[1:])
return nhyd
assert f('H') == 1 |
benchmark_functions_edited/f2357.py | def f(a,b):
return max(0,min(a[1],b[1]) - max(a[0],b[0]))
assert f(
(3,4),
(4,6)
) == 0 |
benchmark_functions_edited/f10833.py | def f(data):
countSentences = 0
for character in data:
if (character == '!' or character == '.' or character == '?'):
countSentences += 1
return countSentences
assert f(
"Hello! My name is Annabelle. You're a very nice person!") == 3 |
benchmark_functions_edited/f7398.py | def f(row, name, mapping={}, default=None):
if name in mapping:
return row.get(mapping[name], default)
else:
return row.get(name, default)
assert f(
{
'fred': 1,
'barney': 2,
'wilma': 3
},
'barney') == 2 |
benchmark_functions_edited/f6384.py | def f(a, b):
return int(a / b)
assert f(2, 3) == 0 |
benchmark_functions_edited/f8336.py | def f(n):
shells = [4,10,18,28,40,54,70,88,108,130,154,180,208,238]
return min([i+1 for i in range(len(shells)) if shells[i] >= n])
assert f(2) == 1 |
benchmark_functions_edited/f12122.py | def f(param, i):
if len(param) > i:
return param[i]
else:
return param[0]
assert f([1, 2], 3) == 1 |
benchmark_functions_edited/f6657.py | def f(start: int, loop_size: int) -> int:
if start - 1 < 0:
result = loop_size - 1
else:
result = start - 1
return result
assert f(2, 5) == 1 |
benchmark_functions_edited/f4416.py | def f(lvl: int) -> int:
if lvl <= 1:
lvl = lvl * -10 + 20
else:
lvl = 11 - lvl
return lvl
assert f(5) == 6 |
benchmark_functions_edited/f8192.py | def f(inputs): # DO NOT CHANGE THIS LINE
output = inputs
return output # DO NOT CHANGE THIS LINE
assert f(0) == 0 |
benchmark_functions_edited/f6228.py | def f(update_result):
return sum(
len(settings_in_a_group)
for settings_in_a_group in update_result.values()
)
assert f(
{
"a": {"b": 1, "c": 2},
"d": {"e": 3},
},
) == 3 |
benchmark_functions_edited/f298.py | def f(a):
if a > 3:
return 3 * a
return 0
assert f(3) == 0 |
benchmark_functions_edited/f3695.py | def f(level):
if level == "surface":
return str(level)
else:
return int(level)
assert f(3) == 3 |
benchmark_functions_edited/f13399.py | def f(raw_adc, arid_value, sodden_value):
a_lower = min(arid_value, sodden_value)
a_range = abs(sodden_value - arid_value)
inverted = arid_value > sodden_value
fraction = (raw_adc - a_lower) / a_range
if inverted:
fraction = 1.0 - fraction
return min(100.0, max(0.0, fraction * 100.0))
assert f(0, 0, 1024) == 0 |
benchmark_functions_edited/f4022.py | def f(start, stop, step):
if start < stop:
return ((stop - start - 1) // step + 1)
return 0
assert f(0, 10, 2) == 5 |
benchmark_functions_edited/f8750.py | def f(num):
t = 0
p = 0
for r in num:
n = 10 ** (205558 % ord(r) % 7) % 9995
t += n - 2 * p % n
p = n
return t
assert f("VI") == 6 |
benchmark_functions_edited/f7793.py | def f(char_a, char_b):
if char_a == char_b:
return 0
if char_a == 'V' and char_b != 'U' or char_b == 'V' and char_a != 'U':
return 2
return 1
assert f('M', 'M') == 0 |
benchmark_functions_edited/f8935.py | def f(id_prefix=1, proxmox_node_scale=3, node=None):
if not node:
return id_prefix
for i in range(1, proxmox_node_scale + 1):
if str(i) in node:
return i
return id_prefix
assert f(1, 3, 'node-1') == 1 |
benchmark_functions_edited/f3706.py | def f(p, r):
return (2*p*r/(p+r)) if p != 0 and r != 0 else 0
assert f(1, 1) == 1 |
benchmark_functions_edited/f12444.py | def f(current: list, target: list):
count = 0
curr_1d = []
tgt_1d = []
for i in range(3):
for j in range(3):
curr_1d.append(current[i][j])
tgt_1d.append(target[i][j])
for x in tgt_1d:
count += abs(tgt_1d.index(x) - curr_1d.index(x))
return count
assert f(
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0 |
benchmark_functions_edited/f9349.py | def f(pos_neg, off_on):
return 10 * pos_neg + 5 * off_on
assert f(0, 0) == 0 |
benchmark_functions_edited/f88.py | def f(rho, phi):
return 2 * rho**2 - 1
assert f(1, 0) == 1 |
benchmark_functions_edited/f11342.py | def f(function, derivative, initial_guess=1, error=1e-5):
px = initial_guess
nx = initial_guess - function(initial_guess)/derivative(initial_guess)
while abs(nx - px)/abs(nx) > error:
px = nx
nx = nx - function(nx)/derivative(nx)
return nx
assert f(lambda x: x**2 - 1, lambda x: 2*x) == 1 |
benchmark_functions_edited/f13622.py | def f(s, threshold):
for i in range(len(s)):
if (s[i] < threshold):
return i
return len(s)
assert f(sorted([-1, -2, -3, -4]), -2.5) == 0 |
benchmark_functions_edited/f3710.py | def f(first_number, second_number):
return_value = first_number + second_number
return return_value
assert f(4, 3) == 7 |
benchmark_functions_edited/f10776.py | def f(im_name, parse_type='id'):
assert parse_type in ('id', 'cam')
if parse_type == 'id':
parsed = -1 if im_name.startswith('-1') else int(im_name[:4])
else:
parsed = int(im_name[4]) if im_name.startswith('-1') \
else int(im_name[6])
return parsed
assert f(
'0001_c1s1_000001_00.jpg') == 1 |
benchmark_functions_edited/f6779.py | def f(heading):
i = 0
while( i < len(heading) and heading[i] == '#' ):
i += 1
return i
assert f( "## Header" ) == 2 |
benchmark_functions_edited/f6222.py | def f(vec1, vec2):
return vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2]
assert f( (0,0,0), (0,0,0) ) == 0 |
benchmark_functions_edited/f5245.py | def f(x, bkg, bkg_slp, skw, mintrans, res_f, Q):
return bkg + bkg_slp*(x-res_f)-(mintrans+skw*(x-res_f))/\
(1+4*Q**2*((x-res_f)/res_f)**2)
assert f(1, 1, 0, 0, 0, 1, 1) == 1 |
benchmark_functions_edited/f7641.py | def f(iterable):
return next((x for x in iterable), None)
assert f([0, 1, 2]) == 0 |
benchmark_functions_edited/f11917.py | def f(sev):
sev = sev.capitalize()
if sev == 'Critical':
return 4
elif sev == 'High':
return 3
elif sev == 'Important':
return 3
elif sev == 'Medium':
return 2
elif sev == 'Low':
return 1
return 0
assert f('None') == 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.