file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f2485.py
|
def f(l):
if ".mpeg" in str(l):
return 1
else:
return 0
assert f(
[
"https://cdn.discordapp.com/attachments/834313780918417930/837388563155078184/test.mp3",
"https://cdn.discordapp.com/attachments/834313780918417930/837388563155078184/test.mp4",
"https://cdn.discordapp.com/attachments/834313780918417930/837388563155078184/test.mkv"
]
) == 0
|
benchmark_functions_edited/f8265.py
|
def f(text, word):
words = text.split()
return words.count(word)
assert f(
"one two one two three four", "three") == 1
|
benchmark_functions_edited/f5196.py
|
def f(a,b):
if a == 0:
return 1
if b == 0:
return 1
return (b-a)/a
assert f(1,1) == 0
|
benchmark_functions_edited/f3118.py
|
def f(x1, y1, x2, y2):
return int(max(abs(x2 - x1), abs(y2 - y1)))
assert f(-1, -1, 2, 2) == 3
|
benchmark_functions_edited/f10231.py
|
def f(a,b):
if b == 0:
return a
else:
return f(b, a % b)
assert f(2,1) == 1
|
benchmark_functions_edited/f5410.py
|
def f(n0, n1, nr, p):
h0 = 0.5 ** (n0 * p)
h1 = 0.5 ** (n1 * p)
hr = 0.5 ** (nr * p)
y = (h0 - hr) / (h1 - hr)
return y
assert f(1, 1, 3, 1) == 1
|
benchmark_functions_edited/f8835.py
|
def f(z, zone):
_min = 1e32
imin = None
for i, zz in enumerate(z):
if zone[i] == 2:
if zz < _min:
_min = zz
imin = i
return imin
assert f(
[1, 2, 3, 4, 5, 6, 7, 8],
[2, 2, 2, 2, 2, 2, 2, 2]
) == 0
|
benchmark_functions_edited/f3210.py
|
def f(a: int, b: int) -> int:
while b != 0:
a, b = b, a % b
return a
assert f(1, 0) == 1
|
benchmark_functions_edited/f8748.py
|
def f(n):
start_odd = n * (n - 1) + 1
end_odd = start_odd + 2 * (n - 1)
# return sum([odd for odd in range(start_odd, end_odd + 1, 2)])
return sum(range(start_odd, end_odd + 1, 2))
assert f(0) == 0
|
benchmark_functions_edited/f6865.py
|
def f(cin, dpi=600):
return int(float(cin) * dpi / 100)
assert f(0) == 0
|
benchmark_functions_edited/f1915.py
|
def f(nb_cards, position):
return (-position - 1) % nb_cards
assert f(1, 0) == 0
|
benchmark_functions_edited/f8430.py
|
def f(obj):
if "inf" in obj.lower().strip():
return obj
try:
return int(obj)
except ValueError:
try:
return float(obj)
except ValueError:
return obj
assert f("1") == 1
|
benchmark_functions_edited/f12810.py
|
def f(term):
return int(''.join(list(map(str, list(term)))), 2)
assert f([1, 0, 0]) == 4
|
benchmark_functions_edited/f13241.py
|
def totalCredits (theDictionary):
total = 0 # = sum (theDictionary.values ())
for i in theDictionary:
total += theDictionary[i]
return total
assert f({}) == 0
|
benchmark_functions_edited/f6100.py
|
def f(a, x, lo=0, hi=None):
if hi is None: hi = len(a)
while lo < hi:
mid = (lo + hi)//2
if a[mid] < x: lo = mid + 1
else: hi = mid
return lo
assert f(range(4), -2) == 0
|
benchmark_functions_edited/f10545.py
|
def f(*args):
if len(args) == 2:
text, subtext = args
return text.find(subtext)+1
else:
start, text, subtext = args
pos = text[start-1:].find(subtext)
if pos == -1:
return 0
else:
return pos + start
assert f( "hello world", "ello") == 2
|
benchmark_functions_edited/f7772.py
|
def f(es_norm, v_ratio, n):
return es_norm * (v_ratio)**n
assert f(1, 1, -1) == 1
|
benchmark_functions_edited/f2115.py
|
def f(length, pos):
return 0 if pos + 1 == length else pos + 1
assert f(2, 1) == 0
|
benchmark_functions_edited/f3673.py
|
def f(lst, w):
return [i for (i, sub) in enumerate(lst) if w in sub][0]
assert f(list('abc'), 'b') == 1
|
benchmark_functions_edited/f5447.py
|
def f(s_string):
s_value = eval(s_string)
return len(s_string) - len(s_value)
assert f(r'"aaa\"aaa"') == 3
|
benchmark_functions_edited/f4773.py
|
def f(n):
if n == 0 or n == 1:
return 1
else:
return f(n - 1) + f(n - 2)
assert f(3) == 3
|
benchmark_functions_edited/f6681.py
|
def f(index):
return index.to_timestamp() if hasattr(index, 'to_timestamp') else index
assert f(0) == 0
|
benchmark_functions_edited/f11641.py
|
def f(a_key, a_pair_list):
l_result = None
i = 0
while i >= 0 and a_pair_list[i][0] != a_key:
i = i + 1
if i >= 0:
l_result = a_pair_list[i][1]
return l_result
assert f(0, [(0, 3), (1, 2)]) == 3
|
benchmark_functions_edited/f12363.py
|
def f(n: int) -> int:
if n < 2:
return n
return f(n - 1) + f(n - 2)
assert f(6) == 8
|
benchmark_functions_edited/f1700.py
|
def f(a, b):
if a == 0 and b == 0:
return 0
return a / b
assert f(0, 0) == 0
|
benchmark_functions_edited/f12261.py
|
def f(triangle):
if not triangle:
return 0
n = len(triangle)
current_cache = triangle[-1]
for i in range(n-2, -1, -1):
for j in range(i+1):
current_cache[j] = triangle[i][j] + min(current_cache[j], current_cache[j+1])
return current_cache[0]
assert f([[1]]) == 1
|
benchmark_functions_edited/f6154.py
|
def f(number):
return (sum((9 - i) * int(n) for i, n in enumerate(number[:-1])) -
int(number[-1])) % 11
assert f('0') == 0
|
benchmark_functions_edited/f4372.py
|
def f(c, n, x):
x1 = (x * x) % n + c
if x1 >= n:
x1 -= n
assert x1 >= 0 and x1 < n
return x1
assert f(3, 13, 2) == 7
|
benchmark_functions_edited/f5031.py
|
def f(seq, f):
for s in seq:
if f(s):
return s
assert f(range(10), lambda x: x % 2 == 0) == 0
|
benchmark_functions_edited/f10690.py
|
def f(num):
if num & (num-1) == 0:
return num
bin_num = bin(num)
origin_bin_num = str(bin_num)[2:]
near_power2 = pow(10, len(origin_bin_num))
near_power2 = "0b" + str(near_power2)
near_power2 = int(near_power2, base=2)
return near_power2
assert f(1) == 1
|
benchmark_functions_edited/f13390.py
|
def f(key, data, default=list()):
if key in data:
if data[key] is None:
return default
else:
return data[key]
else:
return default
assert f(1, [1,2,3]) == 2
|
benchmark_functions_edited/f5534.py
|
def f(value):
result = 0
shift = 0
for byte in value:
result += byte << shift
shift += 8
return result
assert f(b'\x00') == 0
|
benchmark_functions_edited/f10025.py
|
def f(x, i):
if i < len(x):
return x[i]
else:
return ''
assert f( [1, 2, 3], 1 ) == 2
|
benchmark_functions_edited/f1123.py
|
def f(num_bits):
return (num_bits + 7) >> 3
assert f(39) == 5
|
benchmark_functions_edited/f10430.py
|
def f(tup):
if len(tup) == 1:
return tup[0]
return tup[0] if tup[0] > f(tup[1:]) else f(tup[1:])
assert f(
(1, 2, 3, 4)
) == 4
|
benchmark_functions_edited/f592.py
|
def f(val, n):
return (val >> n) & 1
assert f(0, 1) == 0
|
benchmark_functions_edited/f10860.py
|
def f(num, k):
if num == 1:
return 1
return (f(num - 1, k) + k - 1) % num + 1
assert f(5, 1) == 5
|
benchmark_functions_edited/f1882.py
|
def f(n: int) -> int:
return n * (3*n - 2)
assert f(0) == 0
|
benchmark_functions_edited/f14004.py
|
def f(depth, interval=300):
return depth * 3600 / interval
assert f(0.0, 300) == 0
|
benchmark_functions_edited/f13836.py
|
def f(vec):
Map = {} # Adding to hash
count = 0
val = 0
for i in vec: # O(n)
if i in Map.keys():
Map[i] += 1 # O(1)
else:
Map[i] = 1 # O(1)
for i in Map: # O(n)
if (count < Map[i]):
count = Map[i] # O(1)
val = i # O(1)
return val
assert f( [1,1,1,2,2,3] ) == 1
|
benchmark_functions_edited/f1444.py
|
def f(n):
if n < 2:
return n
else:
return f(n-1) + f(n-2)
assert f(3) == 2
|
benchmark_functions_edited/f4041.py
|
def f(minimum, t2):
if minimum > t2:
return t2
return minimum
assert f(10, 9) == 9
|
benchmark_functions_edited/f8323.py
|
def f(filename):
return int(filename.split('_')[-1].replace('.png', ''))
assert f(
'bird_1.png') == 1
|
benchmark_functions_edited/f9018.py
|
def f(value, resolution):
return round(value / resolution) * resolution
assert f(6, 5) == 5
|
benchmark_functions_edited/f11374.py
|
def f(M, edge):
try:
from_neighbors = set(M[edge[0]]) # if concept 0 not in network, false
to_neighbors = set(M[edge[1]]) # if concept 1 not in network, false
return len(from_neighbors & to_neighbors) # closes number of existing paths
except:
return 0
assert f({0: [1], 1: [0]}, (0, 1)) == 0
|
benchmark_functions_edited/f2523.py
|
def f(dtype):
if dtype == "float16":
dsize = 2
else:
dsize = 4
return dsize
assert f("float32") == 4
|
benchmark_functions_edited/f4755.py
|
def f(a, b):
if b == 0:
return a
else:
return f(b, a % b)
assert f(0, 0) == 0
|
benchmark_functions_edited/f2217.py
|
def f(i):
summe = 0
for digit in str(i):
summe += int(digit)
return summe
assert f(0) == 0
|
benchmark_functions_edited/f12864.py
|
def f(s):
symbols = ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
letter = s[-1:].strip().upper()
num = s[:-1]
assert letter in symbols
num = float(num)
prefix = {symbols[0]:1}
for i, s in enumerate(symbols[1:]):
prefix[s] = 1 << (i+1)*10
return int(num * prefix[letter])
assert f('1B') == 1
|
benchmark_functions_edited/f1036.py
|
def f(o,*k):
return f(o[k[0]],*k[1:]) if len(k)>1 else o[k[0]]
assert f(
{'a':{'b':{'c':1}}},
'a',
'b',
'c'
) == 1
|
benchmark_functions_edited/f7501.py
|
def f(pair):
def createArray(a,b):
array = []
array.append(a)
array.append(b)
return array
#perform closure
array = pair(createArray)
return array[1]
assert f(lambda x: (x, 1)) == 1
|
benchmark_functions_edited/f8337.py
|
def f(nom, denom=1):
if denom == 0:
return "r"
fraction = nom / denom
if fraction < .1:
return "r"
if fraction < .25:
return "y"
if fraction < .9:
return 0
return "g"
assert f(2.6, 5) == 0
|
benchmark_functions_edited/f4593.py
|
def f(hex_number: str) -> int:
return int(hex_number, 16)
assert f("1") == 1
|
benchmark_functions_edited/f5342.py
|
def f(alist, digits=1):
return round(sum(alist), digits)
assert f([1, 2], 1) == 3
|
benchmark_functions_edited/f4747.py
|
def f(desired_buyin: int):
fee = desired_buyin / 19
return round(desired_buyin + fee)
assert f(0) == 0
|
benchmark_functions_edited/f11533.py
|
def f(page, paginate_by, count):
if page is not None:
if page == 'last':
return paginate_by * (count / paginate_by) + 1
else:
return paginate_by * (int(page) - 1) + 1
else:
return 1
assert f(1, 20, 50) == 1
|
benchmark_functions_edited/f5091.py
|
def f(a,b):
# Hint: Type return a+b below
return(a+b)
assert f(1, 2) == 3
|
benchmark_functions_edited/f2249.py
|
def f(a, b, c, x):
return a*(x**2) + b*x + c
assert f(4, 1, 3, 0) == 3
|
benchmark_functions_edited/f4261.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(1,1,2,{'verbose':True}) == 2
|
benchmark_functions_edited/f5179.py
|
def f(op1, op2):
if op1 is None:
return op2
elif op2 is None:
return op1
else:
return op1 + op2
assert f(1, None) == 1
|
benchmark_functions_edited/f8135.py
|
def f(value):
try:
if int(value) == value:
return int(value)
except (TypeError, ValueError):
pass
return value
assert f(1.0) == 1
|
benchmark_functions_edited/f8007.py
|
def f(byte_val: int) -> int:
assert 0 <= byte_val <= 83
return byte_val
assert f(1) == 1
|
benchmark_functions_edited/f10440.py
|
def f(doc):
if 'stoichiometry' in doc:
return sum([elem[1] for elem in doc['stoichiometry']])
return sum([elem[1] for elem in doc])
assert f({'stoichiometry': set()}) == 0
|
benchmark_functions_edited/f3283.py
|
def f(number: int) -> int:
if (number % 2) == 0:
return number + 1
else:
return number
assert f(2) == 3
|
benchmark_functions_edited/f3249.py
|
def f(curr_layer, total_layers, p_l):
return 1 - (float(curr_layer) / total_layers) * p_l
assert f(0, 10, 0.1) == 1
|
benchmark_functions_edited/f14417.py
|
def f(sensible_heat_flux_W_m2, air_density_kg_m3):
cp = 1004.5
return sensible_heat_flux_W_m2 / (air_density_kg_m3 * cp)
assert f(0, 1.1) == 0
|
benchmark_functions_edited/f12335.py
|
def f(gappedseq, n):
nongapped = 0
for i, b in enumerate(gappedseq):
if b == '-':
continue
if nongapped == n:
return i
nongapped += 1
raise ValueError(
"Could not find {0}'th non-gapped base in sequence".format(n))
assert f(
"AT--CG-TA-TACG-CTT",
2) == 4
|
benchmark_functions_edited/f4207.py
|
def f(size, duration):
if duration != 0:
speed = size / duration / 10**6
else:
speed = 0
return speed
assert f(100, 0) == 0
|
benchmark_functions_edited/f2193.py
|
def f(seq):
if isinstance(seq, (list, tuple)):
return seq[0]
return next(seq)
assert f((3, 2, 1)) == 3
|
benchmark_functions_edited/f9054.py
|
def f(policy):
str_policy = str(policy).split(' ')
num = 0
for alpha in str_policy:
num = num + len(alpha)
return num
assert f(123) == 3
|
benchmark_functions_edited/f6.py
|
def f(x):
return sum(x) / len(x)
assert f([1, 2, 3, 4, 5]) == 3
|
benchmark_functions_edited/f3723.py
|
def f(pos1, pos2):
x1, y1 = pos1
x2, y2 = pos2
return abs(x1-x2) + abs(y1-y2)
assert f( (1,0), (2,2) ) == 3
|
benchmark_functions_edited/f11724.py
|
def f(spec):
assert isinstance(spec, int) or isinstance(spec, str), f"'input' has invalid type {type(spec)}."
if isinstance(spec, str):
try:
return int(spec)
except ValueError:
raise ValueError("'spec' does not contain an int.")
return spec
assert f("0") == 0
|
benchmark_functions_edited/f10774.py
|
def f(loc1, loc2):
# BEGIN_YOUR_CODE (our solution is 1 line of code, but don't worry if you deviate from this)
return ((loc1[0]-loc2[0])**2+(loc1[1]-loc2[1])**2)**.5
# END_YOUR_CODE
assert f( (0,0), (0,0) ) == 0
|
benchmark_functions_edited/f4948.py
|
def f(s: str) -> int:
count = 0
for x in s:
if x != ' ':
return count
count += 1
return count
assert f( "hi" ) == 0
|
benchmark_functions_edited/f8697.py
|
def f(attrs, attr_name):
return 1 if attrs.get(attr_name, 0) in ["True", "1"] else 0
assert f({}, "test_attribute") == 0
|
benchmark_functions_edited/f1347.py
|
def f(x, parameters):
y_hat = parameters['w'] * x + parameters['b']
return y_hat
assert f(0, {'w': 2, 'b': 0}) == 0
|
benchmark_functions_edited/f13877.py
|
def f(value):
try:
if int(value) < 0 or int(value) > 100:
raise RuntimeError("Quality argument must be of between 0 and 100.")
return 0 if int(value) == 100 else int(9 - (int(value) / 11))
except ValueError:
raise RuntimeError("Quality argument must be of type integer.")
assert f(0) == 9
|
benchmark_functions_edited/f838.py
|
def f(energy):
return 12398.0 / energy * 1e-10
assert f(f(1)) == 1
|
benchmark_functions_edited/f2953.py
|
def f(*args):
sum = 0
for arg in args:
sum += 1
return sum
assert f(1, 2, 3) == 3
|
benchmark_functions_edited/f6772.py
|
def f(bin):
dec=0.0
bin.reverse()
for i in range(0, len(bin)):
dec+=(bin[i]*(2**i))
return dec
assert f( [1,0,1] ) == 5
|
benchmark_functions_edited/f13040.py
|
def f(ts_vals):
MDD = 0
DD = 0
peak = -99999
for value in ts_vals:
if (value > peak):
peak = value
else:
DD = (peak - value) / peak
if (DD > MDD):
MDD = DD
return MDD
assert f([-2, -1, 0, 1, 2, 3]) == 0
|
benchmark_functions_edited/f13872.py
|
def f(X, Y, TimeleftIndex, TimeRightIndex,YValue):
Y1 = Y[TimeleftIndex]
Y2 = Y[TimeRightIndex]
X2 = X[TimeRightIndex]
X1 = X[TimeleftIndex]
slope = (Y2 - Y1) / (X2 - X1)
if slope != 0:
X0 = (YValue - Y1) / slope + X1
return X0
else:
return 0
assert f(range(10), range(10), 4, 6, 5) == 5
|
benchmark_functions_edited/f130.py
|
def f(a):
return max(abs(ai) for ai in a)
assert f({1, 2, 3}) == 3
|
benchmark_functions_edited/f18.py
|
def f(x, y):
return not (x ^ y)
assert f(0, 1) == 0
|
benchmark_functions_edited/f14517.py
|
def f(y, x, dx, f):
k1 = dx * f(y, x)
k2 = dx * f(y + 0.5*k1, x + 0.5*dx)
k3 = dx * f(y + 0.5*k2, x + 0.5*dx)
k4 = dx * f(y + k3, x + dx)
return y + (k1 + 2*k2 + 2*k3 + k4) / 6.
assert f(1, 1, 1, lambda y, x: 1) == 2
|
benchmark_functions_edited/f1531.py
|
def f(binString):
return int(binString,2)
assert f(bin(2)) == 2
|
benchmark_functions_edited/f1265.py
|
def f(vec):
return (vec + abs(vec)) / 2.
assert f(-1) == 0
|
benchmark_functions_edited/f7631.py
|
def f(weights,args = None):
if args == None: args = range(len(weights))
return min(zip(weights,args))[1]
assert f([0.1]) == 0
|
benchmark_functions_edited/f14273.py
|
def f(_, msg):
print(msg[:-1])
return 0
assert f(None, b"Hello, world!\n") == 0
|
benchmark_functions_edited/f2411.py
|
def f(individual):
return individual[0]**2 + 1e6 * sum(gene * gene for gene in individual)
assert f([0, 0]) == 0
|
benchmark_functions_edited/f5370.py
|
def f(tcp_flags):
if tcp_flags == 2:
return 1
else:
return 0
assert f(22) == 0
|
benchmark_functions_edited/f11525.py
|
def f(t_K, p_MPaa, gamma_gas, z):
m = gamma_gas * 0.029
p_Pa = 10 ** 6 * p_MPaa
rho_gas = p_Pa * m / (z * 8.31 * t_K)
return rho_gas
assert f(293.15, 101325, 0, 0.5) == 0
|
benchmark_functions_edited/f7032.py
|
def f(ds, fs):
total = 0
for d, f in zip(ds, fs):
total += (d**.3) * (f**.7)
return total
assert f(
[40, 50, 60, 70, 80],
[0, 0, 0, 0, 0],
) == 0
|
benchmark_functions_edited/f13376.py
|
def f( positions ):
fuel_per_target = dict()
for target in range( max(positions)+1 ):
fuel_per_submarine = [ sum( range(1,abs(target-position)+1) ) for position in positions ]
fuel_per_target[target] = sum( fuel_per_submarine )
return min( fuel_per_target.values() )
assert f( [2] ) == 0
|
benchmark_functions_edited/f9697.py
|
def f(element, value, score):
if element == value:
return score
assert f(100, 100, 1) == 1
|
benchmark_functions_edited/f10393.py
|
def f(overwriteable, overwriter):
return overwriteable if overwriter is None else overwriter
assert f(5, 3) == 3
|
benchmark_functions_edited/f4407.py
|
def f(number, digit):
return number % 10**digit // 10**(digit-1)
assert f(2345, 0) == 0
|
benchmark_functions_edited/f7650.py
|
def f(simplex, faces):
if simplex in faces:
idx = faces.index(simplex)
return 1 if idx%2==0 else -1
else:
return 0
assert f(4, [3]) == 0
|
benchmark_functions_edited/f1757.py
|
def f(i):
j = 2
while j * j < i:
j += 1
return j
assert f(5) == 3
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 5