file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f10204.py | def f(value: str, char: str, start_index: int = 0) -> int:
for i in range(start_index, len(value)):
if value[i] != char:
return i
return -1
assert f('abcde', 'c', 2) == 3 |
benchmark_functions_edited/f2137.py | def f(x):
try:
return next(x)
except StopIteration:
return None
assert f(iter([4, 5, 6])) == 4 |
benchmark_functions_edited/f13030.py | def f(value, values):
if min(values) <= value <= max(values):
return value
elif value > max(values):
return max(values)
else:
return min(values)
assert f(9, range(10)) == 9 |
benchmark_functions_edited/f14067.py | def f(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
assert f(5, 0, 10, 0, 10) == 5 |
benchmark_functions_edited/f11774.py | def f(x1, y1, x2, y2, x3):
return y1 - 1.0 * (y1 - y2) * (x1 - x3) / (x1 - x2)
assert f(0, 0, 1, 0, 0) == 0 |
benchmark_functions_edited/f8499.py | def f(d, params):
import random
import math
if params == None:
b_min = 0.
b_max = 2*math.pi
else:
b_min = params['min']
b_max = params['max']
d_noise = random.uniform(b_min, b_max)
return d_noise
assert f(0, {'min':0,'max':0}) == 0 |
benchmark_functions_edited/f14101.py | def f(n, n1=0, n2=1):
if n < 1:
return n1
elif n == 1:
return n2
return f(n - 1, n1, n2) + f(n - 2, n1, n2)
assert f(6) == 8 |
benchmark_functions_edited/f3928.py | def f(vector_1, vector_2):
for i in range(len(vector_1)):
if vector_1[i] != vector_2[i]:
return 1
return 0
assert f(
[1, 1, 1, 1], [1, 1, 1, 1]) == 0 |
benchmark_functions_edited/f463.py | def f(i):
return i * 2 + 2
assert f(0) == 2 |
benchmark_functions_edited/f11886.py | def f(str1: str, str2: str) -> int:
if str1 == str2:
return -1
shorter, longer = sorted((str1, str2), key=len)
shorter_len = len(shorter)
return next(
(i for i in range(shorter_len) if shorter[i] != longer[i]),
shorter_len,
)
assert f(
"123456789",
"12345",
) == 5 |
benchmark_functions_edited/f8987.py | def f(items, pivot):
return min(items, key=lambda x: abs(x - pivot))
assert f(range(1, 10), -10) == 1 |
benchmark_functions_edited/f6960.py | def f(true_entities, pred_entities):
nb_correct = len(true_entities & pred_entities)
nb_pred = len(pred_entities)
score = nb_correct / nb_pred if nb_pred > 0 else 0
return score
assert f(set([('a', 100, 200)]), set([('a', 100, 200)])) == 1 |
benchmark_functions_edited/f1627.py | def f(N):
ct = 0
while N > 1:
ct += 1
N = N // 2
return ct
assert f(8) == 3 |
benchmark_functions_edited/f8593.py | def _gr_ymax_ ( graph ) :
ymx = None
np = len ( graph )
for ip in range ( np ) :
x , y = graph[ip]
if None == ymx or y >= ymx : ymx = y
return ymx
assert f( [(1, 2), (3, 4)] ) == 4 |
benchmark_functions_edited/f489.py | def f(a, b):
if a == b:
return 1
return -1
assert f(1, 1) == 1 |
benchmark_functions_edited/f5221.py | def f(icon_one, icon_two, player_icon):
if player_icon == icon_one:
return icon_two
else:
return icon_one
assert f(3,4,4) == 3 |
benchmark_functions_edited/f8952.py | def f(a, b):
if a == b:
return 1
else:
return 0
assert f(1, 1) == 1 |
benchmark_functions_edited/f5923.py | def f(clicks):
uniq_users = set()
for click in clicks:
uniq_users.add(click["user"])
return len(uniq_users)
assert f([]) == 0 |
benchmark_functions_edited/f5242.py | def f(public, private, modulus):
return pow(public, private, modulus)
assert f(2, 1, 2) == 0 |
benchmark_functions_edited/f5222.py | def f(n):
def acc_f(n, n_m2=0, n_m1=1):
for i in range(n):
n_m2, n_m1 = n_m1, n_m1+n_m2
return n_m2
return acc_f(n)
assert f(4) == 3 |
benchmark_functions_edited/f14527.py | def f(min_length, max_length, rng):
length = min_length
if max_length > min_length:
length = min_length + rng.randint(max_length - min_length)
return length
assert f(0, 0, 0) == 0 |
benchmark_functions_edited/f6579.py | def f(word):
count = 0
for letter in word:
if letter != ',' and letter !='-' and letter !=' ':
count += 1
return count
assert f('a,b,c') == 3 |
benchmark_functions_edited/f4852.py | def f(lst):
if len(lst) == 0:
return 0
out = lst[0]
for i in range(1,len(lst)):
out *= lst[i]
return out
assert f(range(3)) == 0 |
benchmark_functions_edited/f6594.py | def f(f, xs):
return f(*xs)
assert f(max, [1, 2, 3]) == 3 |
benchmark_functions_edited/f11375.py | def f(i):
n = 2
while n < i:
n *= 2
return n
assert f(8) == 8 |
benchmark_functions_edited/f540.py | def f(nr):
return (1 - nr) if nr < 1.0 else 0.0
assert f(100) == 0 |
benchmark_functions_edited/f5582.py | def f(a):
return a[0][0]*a[1][1]*a[2][2] + a[0][1]*a[1][2]*a[2][0] + a[0][2]*a[1][0]*a[2][1] - a[0][2]*a[1][1]*a[2][0] - a[0][1]*a[1][0]*a[2][2] - a[0][0]*a[1][2]*a[2][1]
assert f([[1,2,3],[4,5,6],[7,8,9]]) == 0 |
benchmark_functions_edited/f3291.py | def f(index, size):
if index < 0:
return size + index
else:
return index
assert f(-10, 10) == 0 |
benchmark_functions_edited/f11924.py | def f(num,baseNum,digitsList):
tmpList=[]
for x in digitsList:
if x*(baseNum)>num:
tmpList.append(x)
return max((set(digitsList)-set(tmpList)))
assert f(12345,5,list(range(5))) == 4 |
benchmark_functions_edited/f11162.py | def f(iter: list or range):
if type(iter) == list:
return iter[len(iter)-1]
elif type(iter) == range:
return iter.stop - (iter.stop - 1 - iter.start) % iter.step - 1 # Step-aware last element
else:
raise ValueError("iter must be of type list or range")
assert f(range(10)) == 9 |
benchmark_functions_edited/f4682.py | def f(string_of_ints):
answer = 0
for number in string_of_ints.split(" "):
answer += int(number)
return answer
assert f("1 2") == 3 |
benchmark_functions_edited/f1355.py | def f(monto=0):
total = ((monto * 12)/100)
return total
assert f(0) == 0 |
benchmark_functions_edited/f1122.py | def f(a, b):
if a > b:
return 3
return 2
assert f(2, 2) == 2 |
benchmark_functions_edited/f2998.py | def f(n):
weight = 0
while n:
weight += 1 & n
n = n >> 1
return weight
assert f(4) == 1 |
benchmark_functions_edited/f10521.py | def f(n):
if n == 0:
return 0
mn = n % 9
return 9 if mn == 0 else mn
assert f(16) == 7 |
benchmark_functions_edited/f9391.py | def f(time, sampling_rate):
index = int(round(time*sampling_rate))
return index
assert f(2.0, 1) == 2 |
benchmark_functions_edited/f1789.py | def f(input1, input2):
output = input1 + input2
return output
assert f(2, 3) == 5 |
benchmark_functions_edited/f14287.py | def f(dd, kk, default=0):
if kk in dd.keys():
return dd[kk]
else:
return default
assert f(dict(), "a") == 0 |
benchmark_functions_edited/f11835.py | def f(lst, idx, default=None):
if not lst:
return default
try:
return lst[idx]
except IndexError:
return default
assert f([1], 0, 2) == 1 |
benchmark_functions_edited/f7835.py | def f(lst):
if(len(lst) == 0):
return 0
min = lst[0]
minIndex = 0
for i in range(len(lst)):
if min > lst[i]:
min = lst[i]
minIndex = i
return minIndex
assert f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0 |
benchmark_functions_edited/f2740.py | def f(n):
fak = 1
for k in range(2,n+1):
fak = fak * k
return(fak)
assert f(1) == 1 |
benchmark_functions_edited/f8930.py | def f(l:list):
max_count = 1
count = 1
for i in range(1, len(l)):
if l[i] == l[i-1] + 1:
count += 1
else:
max_count = max(count, max_count)
count = 1
return max_count
assert f([1, 2, 3]) == 1 |
benchmark_functions_edited/f4614.py | def f(in_size,padding,dilation,kernel_size,stride):
return (in_size+2*padding-dilation*(kernel_size-1)-1)//stride +1
assert f(8, 1, 1, 3, 1) == 8 |
benchmark_functions_edited/f5603.py | def f(n):
k, m = 1, 1
if n < 2:
return n
for i in range(2, n):
k, m = m, k + m
return m
assert f(3) == 2 |
benchmark_functions_edited/f1024.py | def f(ex, meta):
return (meta['coord']['value'] + (meta['turn']['value'] + 1)) % 4
assert f(False, {'coord': {'value': 3}, 'turn': {'value': 1}}) == 1 |
benchmark_functions_edited/f928.py | def f(v, w):
return sum(v[i] * w[i] for i in range(len(v)))
assert f([0, 0, 1, 0, 0], range(5)) == 2 |
benchmark_functions_edited/f910.py | def f(period):
day = ((period - 1) // 24) + 1
return day
assert f(120) == 5 |
benchmark_functions_edited/f6071.py | def f(a, b, test_val):
diff_a = abs(a - test_val)
diff_b = abs(b - test_val)
if diff_a < diff_b:
return a
else:
return b
assert f(3, 5, 3) == 3 |
benchmark_functions_edited/f8760.py | def f(bytearray):
groups_of_3, leftover = divmod(len(bytearray), 3)
# 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
n = groups_of_3 * 4
if leftover:
n += 4
return n
assert f(b'====='[0:6]) == 8 |
benchmark_functions_edited/f12220.py | def f(err):
if isinstance(err, OSError):
return err.errno
else:
# on older versions of python select.error is a tuple like object
# with errno in first position
return err[0]
assert f(OSError(5, 'a')) == 5 |
benchmark_functions_edited/f10994.py | def f(dict_values_freq:dict):
max_value_ppi = max(dict_values_freq, key=int)
return max_value_ppi
assert f( {2:1} ) == 2 |
benchmark_functions_edited/f11017.py | def f(value, matrix):
for i, line in enumerate(matrix, 1):
if line == value:
return i
assert f(0.5, [0.2, 0.3, 0.4, 0.5]) == 4 |
benchmark_functions_edited/f7254.py | def f(value: float, min_value: float = 0.0, max_value: float = 1.0):
value = min(value, max_value)
value = max(value, min_value)
return value
assert f(1.5) == 1 |
benchmark_functions_edited/f6072.py | def f(s, download_rate):
if s == 0:
return 0
else:
return s / download_rate
assert f(0, 2000) == 0 |
benchmark_functions_edited/f7722.py | def f(thisdict):
total = 0
for dicttype in thisdict:
for dictval in thisdict[dicttype]:
total += 1
return total
assert f({}) == 0 |
benchmark_functions_edited/f8268.py | def f(bb):
return bb[2]-bb[0]+1
assert f( (10,10,14,10) ) == 5 |
benchmark_functions_edited/f1663.py | def f(timestamp: int) -> int:
return round(timestamp / 1000)
assert f(2000) == 2 |
benchmark_functions_edited/f13157.py | def f(byte_array, signed=True):
return int.from_bytes(byte_array, byteorder="big", signed=signed)
assert f(b"\x00\x00\x00\x06") == 6 |
benchmark_functions_edited/f164.py | def f(value, arg):
return float(value - arg)
assert f(1, 1) == 0 |
benchmark_functions_edited/f11707.py | def f(x, fragment):#{{{
if x <= fragment[0]:
dist = fragment[0]-x
elif x >= fragment[1]:
dist = x-fragment[1]+1
else:
d1 = x - fragment[0]
d2 = (fragment[1]-1) - x
dist = min(d1,d2)
return dist
assert f(5, (5, 1)) == 0 |
benchmark_functions_edited/f6119.py | def f(loc):
if loc == "Point":
return 0
if loc == "Cell":
return 1
if loc == "Field":
return 3
return 4
assert f("Field") == 3 |
benchmark_functions_edited/f8379.py | def f(n):
s = 0
while n:
s += n % 10
n //= 10
return s
assert f(42) == 6 |
benchmark_functions_edited/f2550.py | def f(a, p):
if a % p == 0: return 0
ls = pow(a, (p - 1)//2, p)
return -1 if ls == p - 1 else ls
assert f(9, 83) == 1 |
benchmark_functions_edited/f11067.py | def f(data, val, level=0):
left = 0
right = len(data)
while left < right:
mid = (left + right) // 2
if val <= data[mid][level]:
right = mid
else:
left = mid + 1
return left
assert f(
[
["0", "1"],
["0", "2"],
["0", "3"]
],
"0",
0
) == 0 |
benchmark_functions_edited/f10175.py | def f(name):
if name.startswith("__"):
return 3
elif name.startswith("_"):
return 2
elif name.isupper():
return 1
else:
return 0
assert f("") == 0 |
benchmark_functions_edited/f6599.py | def f(s):
try:
value = int(s)
except ValueError:
value = 0
return value
assert f("abc") == 0 |
benchmark_functions_edited/f8734.py | def f(s):
sum = 0
for c in s:
try:
sum += int(c)
except (TypeError, ValueError):
continue
return sum
assert f('!@#$%^&*()_+=-') == 0 |
benchmark_functions_edited/f8924.py | def f(c):
while callable(c):
c = c()
return c
assert f(lambda: lambda: 1) == 1 |
benchmark_functions_edited/f11040.py | def f(line):
low: int = 0
high: int = 7
for char in line[7:]:
diff: int = high - low
if char == 'L':
# lower half
high -= int(diff / 2 + 0.5)
elif char == 'R':
# upper half
low += int(diff / 2 + 0.5)
return high
assert f("FFFFFFFLLL") == 0 |
benchmark_functions_edited/f11274.py | def f(listInd):
i = len(listInd) - 1
while((listInd[i] == [] or listInd[i] == None) and i >= 0):
i = i - 1
if i == 0:
return None
else:
return listInd[i][0]
assert f([[1, 2], [1], None]) == 1 |
benchmark_functions_edited/f13535.py | def f(dy, dx):
return (dx/6)**2 * 12 * dy**2
assert f(0, 1) == 0 |
benchmark_functions_edited/f7723.py | def f(lst: list, letter: str) -> int:
return sum([1
for row in lst
for letters in row
if letter == letters]
)
assert f(
[["A"], ["A", "B"], ["A", "B", "C"], ["A", "B", "C", "D"]],
"A",
) == 4 |
benchmark_functions_edited/f5629.py | def f(fields):
for index, field in enumerate(fields):
if not hasattr(field, 'widget') or not field.widget.is_hidden:
return index
assert f(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']) == 0 |
benchmark_functions_edited/f8297.py | def f(s):
cnt = 0
while s > 0:
s -= s & (-s) # (s & (-s)) = 2^k, where k is the index of least significant bit 1 of s.
cnt += 1
return cnt
assert f(1024) == 1 |
benchmark_functions_edited/f1030.py | def f(x1, x2):
return abs(x1 - x2)
assert f(3, 3) == 0 |
benchmark_functions_edited/f4176.py | def f(exp):
if type(exp) == str:
return 1
else:
return sum(f(x) for x in exp)
assert f(str(2)) == 1 |
benchmark_functions_edited/f3674.py | def f(a,b):
if a is None:
a = ''
if b is None:
b = ''
return (a > b) - (a < b)
assert f('bb', 'aa') == 1 |
benchmark_functions_edited/f10659.py | def f(n, total):
# print(n)
# base case, if you reach n is 0 then you want to return it
print(total[0])
if n == 0:
return 0
total[0] = total[0] + f(n-1, total)
# else the previous value + (n - 1)
# return n + f(n-1)
assert f(0, [0]) == 0 |
benchmark_functions_edited/f7896.py | def f(a, b):
if len(a) > len(b):
return -1
if len(a) == len(b):
return 0
else:
return 1
assert f(
'test string 1', 'test string 1') == 0 |
benchmark_functions_edited/f12511.py | def f(word):
if word.isdigit(): # if a digit, only has one possibility
r = 1
else: # else its 2 to the power of the length
r = pow(2, len(word))
return r
assert f("II") == 4 |
benchmark_functions_edited/f7845.py | def f(cx, cy, maxiter):
c = complex(cx, cy)
z = 0
for i in range(0, maxiter):
if abs(z) > 2:
return i
z = z ** 3 + c
return 0
assert f(0, 0, 1) == 0 |
benchmark_functions_edited/f13502.py | def f(outputs): # outputs []*wire.TxOut) (serializeSize int) {
serializeSize = 0
for txOut in outputs:
serializeSize += txOut.serializeSize()
return serializeSize
assert f([]) == 0 |
benchmark_functions_edited/f8584.py | def f(items):
multiplier = 1
for data in (x[0] for x in items):
if data["config"]["algorithm"].get("align_split_size"):
multiplier += 50
return multiplier
assert f([]) == 1 |
benchmark_functions_edited/f10299.py | def f(margin: float, threshold: float) -> int:
root = int(margin)
if threshold < margin - root:
return root + 1
else:
return root
assert f(0.4, 0.2) == 1 |
benchmark_functions_edited/f7629.py | def f(x, lower, upper):
y = 0
if x > upper:
y = upper
elif x < lower:
y = lower
if x > 6500:
y = 0
else:
y = x
return y
assert f(2, 2, 2) == 2 |
benchmark_functions_edited/f6157.py | def f(lst=None):
if lst is None:
return 0
lengths = [len(i) for i in lst]
return min(lengths)
assert f([[1, 0], [0, 1]]) == 2 |
benchmark_functions_edited/f12317.py | def f(n, k):
def rangeprod(k, n):
res = 1
for t in range(k, n+1):
res *= t
return res
if (n < k):
return 0
else:
return (rangeprod(n-k+1, n) / rangeprod(1, k))
assert f(1,1) == 1 |
benchmark_functions_edited/f8612.py | def f(entry):
if isinstance(entry, (tuple, list)):
func, args = entry
return func(*args)
elif callable(entry):
return entry()
else:
return entry
assert f((lambda x: x, (1,))) == 1 |
benchmark_functions_edited/f9947.py | def f(steps, target):
position = 0
cur_value = 0
for number in range(1, target + 1):
position = (position + steps + 1) % number
if position == 0:
cur_value = number
return cur_value
assert f(3, 4) == 2 |
benchmark_functions_edited/f13067.py | def f(max_n, num_to_exceed):
prev_row = [1, 0]
res = 0
for n in range(1, max_n + 1):
curr_row = []
for k in range(0, n + 1):
curr_row += [prev_row[k - 1] + prev_row[k]]
if curr_row[-1] >= num_to_exceed:
res += 1
curr_row += [0]
prev_row = curr_row
return res
assert f(4, 5) == 1 |
benchmark_functions_edited/f7211.py | def f(string):
string = string.lower()
days = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday']
dayNumber = days.index(string) + 1
return dayNumber
assert f("monDAY") == 1 |
benchmark_functions_edited/f8949.py | def f(photons,
quantum_efficiency):
return int(photons * quantum_efficiency)
assert f(2, 1.0) == 2 |
benchmark_functions_edited/f12940.py | def f(n, idexs):
if len(idexs) == 1:
return n[idexs[0]]
return f(n[idexs[0]], idexs[1:])
assert f(
[
[
[
[
1,
2
],
[
3,
4
]
],
[
[
5,
6
],
[
7,
8
]
]
]
],
[
0,
1,
1,
1
]
) == 8 |
benchmark_functions_edited/f1661.py | def f(cube1,cube2):
return (cube1 > cube2)*cube2 + (cube1 <= cube2) * cube1
assert f(0, 0) == 0 |
benchmark_functions_edited/f13232.py | def f(value_max, value):
if value > value_max:
return value_max
elif value < -value_max:
return -value_max
else:
return value
assert f(3, 6) == 3 |
benchmark_functions_edited/f11240.py | def f(fahrenheit: float, ndigits: int = 2) -> float:
return round(fahrenheit + 459.67, ndigits)
assert f(-459.67) == 0 |
benchmark_functions_edited/f5649.py | def f(row):
if row[0] == row[1] and row[1] == row[2]:
return row[0]
return 0
assert f(
[1, 1, 1]) == 1 |
benchmark_functions_edited/f6902.py | def f(num):
if num < -0.5:
return 1
elif num < 0:
return 2
elif num < 0.5:
return 3
elif num < 1:
return 4
assert f(0.1) == 3 |
benchmark_functions_edited/f9970.py | def f(year):
if year%4:
return 0
elif year%100:
return 1
elif year%400:
return 0
else:
return 1
assert f(1976) == 1 |
benchmark_functions_edited/f12541.py | def f(n):
steps = 1
while ( n != 1 ):
if n % 2 == 0:
n = n / 2
steps = steps + 1
else:
n = n * 3 + 1
steps = steps + 1
return steps
assert f(1) == 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.