id
stringlengths 35
39
| content
stringlengths 44
3.85k
| max_stars_repo_path
stringlengths 52
57
|
|---|---|---|
refactory_data_question_1_wrong_1_327
|
def search(x, seq):
for i, elem in enumerate(seq):
if x <= elem:
return i
elif x > max(seq):
return len(seq)
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
|
./refactory/data/question_1/code/wrong/wrong_1_327.py
|
refactory_data_question_1_wrong_1_104
|
def search(x, seq):
if seq == ():
return 0
else:
for i in range (len(seq)):
if x < seq[i]:
return i
elif x ==seq[i]:
return i
else:
continue
return i + 1
|
./refactory/data/question_1/code/wrong/wrong_1_104.py
|
refactory_data_question_1_wrong_1_241
|
def search(x, seq):
n = len(seq)
for i in range(0,n):
currentvalue = seq[i]
position = i
if position >= 0 and x>currentvalue:
position = i+1
elif position >= 0 and x<= currentvalue:
return position
return position
|
./refactory/data/question_1/code/wrong/wrong_1_241.py
|
refactory_data_question_1_wrong_1_352
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
largest=seq[0]
for i in range(len(seq)):
if x<=seq[i]:
return i
elif x>seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_352.py
|
refactory_data_question_1_wrong_1_502
|
def search(x, seq):
while (x<seq[i] and i < len(seq)):
i += 1
if i==len(seq):
seq.append(x)
else:
seq.insert(i, x)
return seq
|
./refactory/data/question_1/code/wrong/wrong_1_502.py
|
refactory_data_question_1_wrong_1_075
|
def search(x, seq):
for i in range(len(seq)):
pos = len(seq)
if x <= seq[i]:
pos = i
break
return pos
|
./refactory/data/question_1/code/wrong/wrong_1_075.py
|
refactory_data_question_1_wrong_1_365
|
def search(x, seq):
if x <= seq[0] or len(seq)==0:
return 0
elif x >= seq[-1]:
return len(seq)
else:
for i in range(0, len(seq)-1):
if seq[i] <= x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_365.py
|
refactory_data_question_1_wrong_1_083
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
if seq==():
return 0
else:
for i in range(len(seq)):
if x<=seq[i]:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_083.py
|
refactory_data_question_1_wrong_1_394
|
def search(x, seq):
n = len(seq)
for i in range(len(seq)):
if x < seq[0]:
return 0
elif x <= seq[i] and x >= seq[i-1]:
return i
elif x > seq[n-1]:
return n
|
./refactory/data/question_1/code/wrong/wrong_1_394.py
|
refactory_data_question_1_wrong_1_362
|
def search(x, seq):
if len(seq)==0:
return 0
else:
if x <= seq[0]:
return 0
elif x >= seq[-1]:
return len(seq)
else:
for i in range(0, len(seq)-1):
if seq[i] <= x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_362.py
|
refactory_data_question_1_wrong_1_189
|
def search(x, seq):
if seq ==[]:
return 0
elif x<0:
return 0
elif x<max(seq):
for i in range(len(seq)):
if (x>=seq[i]) and (x<=seq[i+1]):
return i+1
else:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_189.py
|
refactory_data_question_1_wrong_1_527
|
def search(x, seq):
if seq == ():
return ()
for i, elem in enumerate(seq):
if x <= elem:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_527.py
|
refactory_data_question_1_wrong_1_320
|
def search(x, seq):
for i, elem in enumerate(seq):
if x <= elem:
return i
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
|
./refactory/data/question_1/code/wrong/wrong_1_320.py
|
refactory_data_question_1_wrong_1_126
|
def search(x, seq):
if x <= seq[0]:
return 0
else:
for i in range(len(seq)):
if seq[i] < x <= seq[i+1]:
return i+1
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_126.py
|
refactory_data_question_1_wrong_1_497
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
seq = tuple(seq)
if x > seq[len(seq)-1]:
return len(seq)
else:
i = 0
while i <= len(seq)-1:
if x <= seq[i]:
return i
elif x > seq[i]:
i += 1
|
./refactory/data/question_1/code/wrong/wrong_1_497.py
|
refactory_data_question_1_wrong_1_233
|
def search(x, seq):
if seq == () or seq == []:
return 0
else:
for i, elem in enumerate(seq):
if x <= elem:
return i
elif x >= seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_233.py
|
refactory_data_question_1_wrong_1_001
|
def search(x, seq):
for i, e in enumerate(seq):
if x < e:
return i
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_001.py
|
refactory_data_question_1_wrong_1_255
|
def search(x, seq):
a = list(enumerate(seq))
seq = list(seq)
i = 0
while i < len(seq):
if x < seq[i] and i == 0:
return 0
elif x <= a[i][1] and x >= a[i-1][1]:
return a[i][0]
elif x > a[len(seq)-1][1]:
return len(seq)
else:
i = i + 1
return seq
|
./refactory/data/question_1/code/wrong/wrong_1_255.py
|
refactory_data_question_1_wrong_1_535
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
counter = 0
if len(seq) == 0:
return 0
for i in seq:
if x < i:
return counter
else:
counter += 1
return counter
|
./refactory/data/question_1/code/wrong/wrong_1_535.py
|
refactory_data_question_1_wrong_1_149
|
#def search(x, seq):
# """ Takes in a value x and a sorted sequence seq, and returns the
# position that x should go to such that the sequence remains sorted """
# return
def search(val,seq):
if val <= seq[0]:
position = 0
elif val >= seq[-1]:
position = len(seq)
else:
for item in seq:
if val <= item:
position = seq.index(item)-1
return position
|
./refactory/data/question_1/code/wrong/wrong_1_149.py
|
refactory_data_question_1_wrong_1_047
|
def search(x, seq):
for i in range(len(seq)):
if x < seq[i]:
return i
elif seq[i] == seq[-1] and seq[i]<x:
return i+1
elif seq[i]<x<=seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_047.py
|
refactory_data_question_1_wrong_1_345
|
def search(x, seq):
if seq == ():
return 0
for i in range(len(seq)):
if x > seq[-1]:
return len(seq)
elif x == seq[i]:
return i
elif x < seq[i]:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_345.py
|
refactory_data_question_1_wrong_1_207
|
def search(x, seq):
if x < seq[0]:
return 0
elif x > seq[-1]:
return len(seq)
else:
for i in range(len(seq) - 1):
if seq[i] == x:
return i
elif seq[i] < x < seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_207.py
|
refactory_data_question_1_wrong_1_131
|
def search(x, seq):
if seq == 0:
return 0
elif x <= seq[0]:
return 0
else:
for i in range(len(seq)-1):
if seq[i] < x <= seq[i+1]:
return i+1
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_131.py
|
refactory_data_question_1_wrong_1_436
|
def search(x,seq):
tup = ()
if type(seq) == tuple:
for i in seq:
if i < x:
tup = tup + (i,)
else:
tup = tup + (x,)
break
return len(tup) - 1
|
./refactory/data/question_1/code/wrong/wrong_1_436.py
|
refactory_data_question_1_wrong_1_338
|
def search(x, seq):
for i,elem in enumerate(seq):
if x<elem:
return i
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_338.py
|
refactory_data_question_1_wrong_1_059
|
def search(x, seq):
for i in range(0, len(seq)):
if seq[i] < x:
continue
elif seq[len(seq) - 1] < x:
return len(seq)
else:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_059.py
|
refactory_data_question_1_wrong_1_082
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
for i in range(len(seq)):
if x<=seq[i]:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_082.py
|
refactory_data_question_1_wrong_1_441
|
def search(x, seq):
for i in range(len(seq)):
if x<=seq[i]:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_441.py
|
refactory_data_question_1_wrong_1_524
|
def search(x, seq):
for i, elem in enumerate(seq):
if x <= elem:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_524.py
|
refactory_data_question_1_wrong_1_405
|
def search(x, seq):
for i in range(len(seq)):
if seq[i] >= x:
return i
if seq[len(seq) - 1] < x:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_405.py
|
refactory_data_question_1_wrong_1_159
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
count = 0
if x <= seq[0] or not seq:
return 0
elif x > seq[len(seq)-1]:
return len(seq)
else:
while x > seq[count]:
count += 1
return count
|
./refactory/data/question_1/code/wrong/wrong_1_159.py
|
refactory_data_question_1_wrong_1_296
|
def search(x,seq):
for i in range(len(seq)):
if x > seq[i]:
continue
elif x <= seq[i]:
break
elif x > max(seq):
return len(seq)
return i
|
./refactory/data/question_1/code/wrong/wrong_1_296.py
|
refactory_data_question_1_wrong_1_276
|
def search(x, seq):
t = 0
for i in seq:
if x >= i:
return t
t += 1
return len(seq)-1
|
./refactory/data/question_1/code/wrong/wrong_1_276.py
|
refactory_data_question_1_wrong_1_184
|
def search(x, seq):
for i in seq:
if x>i:
continue
else:
return ((seq).index(i))-1
|
./refactory/data/question_1/code/wrong/wrong_1_184.py
|
refactory_data_question_1_wrong_1_363
|
def search(x, seq):
if len(seq)==0:
return 0
elif x <= seq[0]:
return 0
elif x >= seq[-1]:
return len(seq)
else:
for i in range(0, len(seq)-1):
if seq[i] <= x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_363.py
|
refactory_data_question_1_wrong_1_226
|
def search(x, seq):
if seq == ():
return -1
for i, elem in enumerate(seq):
if x <= elem:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_226.py
|
refactory_data_question_1_wrong_1_045
|
def search(x, seq):
for i in range(len(seq)):
if x < seq[i]:
return i
elif seq[i] == seq[-1] and seq[i]<x:
return i+1
elif seq[i]<x<=seq[i+1]:
return i
return len(seq)+1
|
./refactory/data/question_1/code/wrong/wrong_1_045.py
|
refactory_data_question_1_wrong_1_301
|
def search(x,seq):
for i in range(len(seq)):
if len(seq) == 0:
return 0
elif x > max(seq):
return len(seq)
elif x > seq[i]:
continue
elif x <= seq[i]:
break
return i
|
./refactory/data/question_1/code/wrong/wrong_1_301.py
|
refactory_data_question_1_wrong_1_488
|
def search(x, seq):
l=len(seq)
for i in range(l):
if x<=seq[i]:
break
return i
|
./refactory/data/question_1/code/wrong/wrong_1_488.py
|
refactory_data_question_1_wrong_1_003
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
i = 0
for i in range(len(seq)):
if x <= seq[i]:
return i
return i + 1
|
./refactory/data/question_1/code/wrong/wrong_1_003.py
|
refactory_data_question_1_wrong_1_471
|
def search(x, seq):
for i, element in enumerate(seq):
for element in seq:
if seq == ():
return 0
elif x > element:
i+=1
return i
|
./refactory/data/question_1/code/wrong/wrong_1_471.py
|
refactory_data_question_1_wrong_1_308
|
def search(x, seq):
seq = []
n = len(seq)
if seq: #if seq is not an empty list/tuple
for i in range(n):
next_element = seq[i]
if x <= next_element:
return i
return n
|
./refactory/data/question_1/code/wrong/wrong_1_308.py
|
refactory_data_question_1_wrong_1_137
|
def search(x, seq):
for i, elem in enumerate(seq):
if len(seq) == 0:
return 0
elif i == 0 and x < elem:
return 0
elif x <= elem:
return i
elif i == len(seq) - 1:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_137.py
|
refactory_data_question_1_wrong_1_269
|
def search(x, seq):
counter = 0
new_seq = list(seq)
if seq == ():
return (x,)
for element in seq:
if x <=element:
return counter
if x > seq[len(seq)-1]:
return len(seq)
else:
counter += 1
continue
|
./refactory/data/question_1/code/wrong/wrong_1_269.py
|
refactory_data_question_1_wrong_1_569
|
def search(x, seq):
for elem in seq:
if x <= elem:
break
position += 1
return position
|
./refactory/data/question_1/code/wrong/wrong_1_569.py
|
refactory_data_question_1_wrong_1_465
|
def search(x, seq):
if seq == [] or ():
return 0
elif len(seq) == 1:
if seq[0] < x:
return 0
else:
return 1
elif seq[-1] <= x:
return len(seq)
elif seq[0] >= x:
return 0
else:
for i in range(len(seq)):
if x >= seq[i] and x <= seq[i+1]:
return i + 1
|
./refactory/data/question_1/code/wrong/wrong_1_465.py
|
refactory_data_question_1_wrong_1_259
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
for i in range(len(seq)):
if seq[i] < x:
return x
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_259.py
|
refactory_data_question_1_wrong_1_172
|
def search(x, seq):
if seq == ():
return None
else:
for element in seq:
if x <= element:
return list(seq).index(element)
elif x >= max(seq):
return (list(seq).index(max(seq)))+1
|
./refactory/data/question_1/code/wrong/wrong_1_172.py
|
refactory_data_question_1_wrong_1_199
|
def search(x, seq):
l=len(seq)
if len(seq)==0:
return 0
elif x<=seq[0]:
return 0
elif x>=seq[l-1]:
return l
else:
for i in range (l):
if x>=seq[i] and x<=seq[i+1]:
return i+1
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_199.py
|
refactory_data_question_1_wrong_1_041
|
def search(x, seq):
for i in range(1, len(seq)+1):
if x < seq[i-1]:
return i-1
elif seq[i-1]<x<=seq[i]:
return i
return i
|
./refactory/data/question_1/code/wrong/wrong_1_041.py
|
refactory_data_question_1_wrong_1_089
|
def search(x, seq):
if seq == () or seq == []:
return None
else:
count = 0
for i in range (0, len(seq)):
if seq[count] < x:
count += 1
return count if seq[-1] > x else len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_089.py
|
refactory_data_question_1_wrong_1_157
|
def search(x, seq):
if seq==[]:
return 0
for a,b in enumerate(seq):
if x<=b:
return a
for i in seq:
if x>i:
return a+1
|
./refactory/data/question_1/code/wrong/wrong_1_157.py
|
refactory_data_question_1_wrong_1_287
|
def search(x, seq):
if x<seq[0]:
return 0
elif x>seq[-1]:
return len(seq)
elif seq is ():
return 0
else:
for i in range(len(seq)-1):
if x>seq[i] and x<seq[i+1]:
return i+1
elif x==seq[i]:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_287.py
|
refactory_data_question_1_wrong_1_110
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
for i,j in enumerate(seq[:len(seq)-1]):
if x < seq[0]:
return 0
elif x > j and x <= seq[i+1]:
return i+1
elif x > seq[len(seq)-1]:
return len(seq)
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_110.py
|
refactory_data_question_1_wrong_1_044
|
def search(x, seq):
for i in range(1, len(seq)+1):
if x < seq[i-1]:
return i-1
elif seq[i-1]<x<=seq[i]:
return i
return len(seq)+1
|
./refactory/data/question_1/code/wrong/wrong_1_044.py
|
refactory_data_question_1_wrong_1_113
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
if seq == () or x <= seq[0]:
return 0
elif x > seq[-1]:
return len(seq)
else:
for i,j in enumerate(seq[:len(seq)-1]):
if x > j and x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_113.py
|
refactory_data_question_1_wrong_1_033
|
def search(x, seq):
for i in range(1, len(seq)+1):
if x < seq[i-1]:
return i-1
elif seq[i-1]<x<seq[i]:
return i
else:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_033.py
|
refactory_data_question_1_wrong_1_463
|
def search(x, seq):
if seq == ():
return 0
elif x < seq[0]:
return 0
elif x > seq[len(seq)-1]:
return len(seq)
else:
product = 0
for i in range(len(seq)-1):
if x == seq[i]:
product = i
elif (seq[i] <= x and x <= seq[i+1]):
product = product + i + 1
return product
|
./refactory/data/question_1/code/wrong/wrong_1_463.py
|
refactory_data_question_1_wrong_1_011
|
def search(x, seq):
for i, elem in enumerate(seq):
if elem <= x <= elem + 1:
return i + 1
|
./refactory/data/question_1/code/wrong/wrong_1_011.py
|
refactory_data_question_1_wrong_1_253
|
def search(x, seq):
if seq == [] or seq == ():
position = 0
if x <= seq[0]:
position = 0
if x >= seq[len(seq) - 1]:
position = len(seq)
for i in range(len(seq)):
if x <= seq[i] and x > seq[i-1]:
position = i
return position
|
./refactory/data/question_1/code/wrong/wrong_1_253.py
|
refactory_data_question_1_wrong_1_448
|
def search(x, seq):
count=0
for i in seq:
if x<i:
return count
count+=1
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_448.py
|
refactory_data_question_1_wrong_1_115
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
if seq == () or x <= seq[0] or seq == []:
return 0
elif x > seq[-1]:
return len(seq)
else:
for i,j in enumerate(seq[:len(seq)-1]):
if x > j and x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_115.py
|
refactory_data_question_1_wrong_1_195
|
def search(x, seq):
for i, elem in enumerate(seq):
if seq == ():
return (i,)
elif seq == []:
return [i,]
elif x <= elem:
return i
elif x > seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_195.py
|
refactory_data_question_1_wrong_1_230
|
def search(x, seq):
if x <= seq[0]:
return 0
elif x >= seq[len(seq)-1]:
return len(seq)
elif seq == [] or ():
return 0
else:
for i, elem in enumerate(seq):
if elem <= x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_230.py
|
refactory_data_question_1_wrong_1_024
|
def search(x, seq):
if seq == ():
return 0
elif x < int(seq[0]):
return 0
elif x > int(seq[len(seq)-1]):
return len(seq)
else:
for i in range(len(seq)):
if x > seq[i] and x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_024.py
|
refactory_data_question_1_wrong_1_373
|
def search(x, seq):
for i in len(seq):
if seq[i] < x:
continue
else:
return i-1
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
return
|
./refactory/data/question_1/code/wrong/wrong_1_373.py
|
refactory_data_question_1_wrong_1_239
|
def search(x, seq):
if list(seq) == []:
return 0
else:
for element in seq:
if x <= element:
return list(seq).index(element)
elif x == element:
return list(seq).index(element)
elif x >= max(seq):
return (list(seq).index(max(seq)))+1
|
./refactory/data/question_1/code/wrong/wrong_1_239.py
|
refactory_data_question_1_wrong_1_476
|
def search(x, seq):
if seq == () and []:
return 0
else:
for i, element in enumerate(seq):
for element in seq:
if x > element:
i+=1
return i
|
./refactory/data/question_1/code/wrong/wrong_1_476.py
|
refactory_data_question_1_wrong_1_453
|
def search(x, seq):
for i in range(len(seq)):
if seq[i] >= x:
return i-1
else:
return len(seq)
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
|
./refactory/data/question_1/code/wrong/wrong_1_453.py
|
refactory_data_question_1_wrong_1_381
|
def search(x, seq):
lst1 = list(seq)
if lst1 == [] or seq == ():
i = 0
else:
length = len(lst1)
lst2 = []
if x < seq[0]:
lst2 = [x] + lst1
elif x > seq[length -1]:
lst2 = lst1 + [x]
else:
for i in range(0, length):
if seq[i] <= x <= seq[i+1]:
lst2 = lst1[:i+1] + [x] + lst1[i+1:]
for i in range(len(lst2)):
if x == lst2[i]:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_381.py
|
refactory_data_question_1_wrong_1_302
|
def search(x,seq):
for i in range(len(seq)):
if len(seq) == 0:
return 0
elif x > max(seq):
return len(seq)
elif x > seq[i]:
continue
elif x <= seq[i]:
break
return i
|
./refactory/data/question_1/code/wrong/wrong_1_302.py
|
refactory_data_question_1_wrong_1_525
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
counter = -1
for i in seq:
if len(seq) == 0:
return 0
if x <= i:
counter += 1
return counter
elif x > i:
counter += 1
else:
counter += 1
if x > seq[counter]:
return counter + 1
|
./refactory/data/question_1/code/wrong/wrong_1_525.py
|
refactory_data_question_1_wrong_1_470
|
def search(x, seq):
if seq == [] or ():
return 0
else:
for i, element in enumerate(seq):
for element in seq:
if x > element:
i+=1
return i
|
./refactory/data/question_1/code/wrong/wrong_1_470.py
|
refactory_data_question_1_wrong_1_300
|
def search(x,seq):
for i in range(len(seq)):
if x > max(seq):
return len(seq)
elif x > seq[i]:
continue
elif x <= seq[i]:
break
return i
|
./refactory/data/question_1/code/wrong/wrong_1_300.py
|
refactory_data_question_1_wrong_1_114
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
if seq == () or x <= seq[0] or seq == []:
return 0
elif x > seq[-1]:
return len(seq)
else:
for i,j in enumerate(seq[:len(seq)-1]):
if x > j and x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_114.py
|
refactory_data_question_1_wrong_1_228
|
def search(x, seq):
result = None
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
if seq == () or seq == []:
return result
for i, elem in enumerate(seq):
if x <= elem:
result = i
break
else:
result = len(seq)
return result
|
./refactory/data/question_1/code/wrong/wrong_1_228.py
|
refactory_data_question_1_wrong_1_326
|
def search(x, seq):
for i, elem in enumerate(seq):
if seq == ():
return 1
if x <= elem:
return i
elif x > max(seq):
return len(seq)
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
|
./refactory/data/question_1/code/wrong/wrong_1_326.py
|
refactory_data_question_1_wrong_1_545
|
def search(x, seq):
if not seq:
indx = 0
else:
if x < seq[0]:
indx = 0
elif x > seq[-1]:
indx = seq.index(seq[-1]) + 1
else:
for i in seq:
if x <= i:
indx = (seq.index(i))
break
return indx
|
./refactory/data/question_1/code/wrong/wrong_1_545.py
|
refactory_data_question_1_wrong_1_432
|
def search(x, seq):
if type(seq) == tuple:
for i in range(len(seq)):
if x <= seq[i]:
seq = seq[:i] + (x,) + seq[i:]
elif seq[len(seq)-1] < x:
seq = seq + (x,)
elif type(seq) == list:
for i in range(len(seq)):
if x <= seq[i]:
seq = seq[:i] + [x,] + seq[i:]
elif seq[len(seq)-1] < x:
seq = seq + [x,]
for i in enumerate(seq):
if x == i[1]:
return i[0]
|
./refactory/data/question_1/code/wrong/wrong_1_432.py
|
refactory_data_question_1_wrong_1_325
|
def search(x, seq):
for i, elem in enumerate(seq):
if seq == ():
return None
if x <= elem:
return i
elif x > max(seq):
return len(seq)
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
|
./refactory/data/question_1/code/wrong/wrong_1_325.py
|
refactory_data_question_1_wrong_1_133
|
def search(x, seq):
for i in range(len(seq)):
if len(seq) == 0:
return 0
elif x <= seq[i] and i == 0:
return 0
elif seq[i-1] < x <= seq[i]:
return i
elif x > seq[i] and i == len(seq)-1:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_133.py
|
refactory_data_question_1_wrong_1_006
|
def search(x, seq):
lst1 = list(seq)
if len(lst1) == 0:
i = 0
else:
length = len(lst1)
lst2 = []
if x < seq[0]:
lst2 = [x] + lst1
elif x > seq[length -1]:
lst2 = lst1 + [x]
else:
for i in range(0, length):
if seq[i] <= x <= seq[i+1]:
lst2 = lst1[:i+1] + [x] + lst1[i+1:]
for i in range(len(lst2)):
if x == lst2[i]:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_006.py
|
refactory_data_question_1_wrong_1_289
|
def search(x, seq):
if len(seq)==0:
return 0
elif x<seq[0]:
return 0
elif x>seq[-1]:
return len(seq)
else:
for i in range(len(seq)-1):
if x>seq[i] and x<seq[i+1]:
return i+1
elif x==seq[i]:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_289.py
|
refactory_data_question_1_wrong_1_294
|
def search(x, seq):
for i in range(len(seq)):
if x >= seq[i]:
break
else:
continue
return i
|
./refactory/data/question_1/code/wrong/wrong_1_294.py
|
refactory_data_question_1_wrong_1_245
|
def search(x, seq):
for i in range(len(sorted_seq)):
if x <= sorted_seq[i]:
return i
else:
return len(sorted_seq)
|
./refactory/data/question_1/code/wrong/wrong_1_245.py
|
refactory_data_question_1_wrong_1_556
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
if seq == []:
return 0
elif type(seq) == tuple:
new_seq = list(seq)
sort = []
for i in range(len(new_seq)):
if max(new_seq) < x:
sort.extend(new_seq)
sort.append(x)
elif new_seq[i] >=x:
sort.append(x)
sort.extend(new_seq[i:])
break
elif new_seq[i]<x:
sort.append(new_seq[i])
else:
sort = []
for i in range(len(seq)):
if max(seq) < x:
sort.extend(seq)
sort.append(x)
elif seq[i] >=x:
sort.append(x)
sort.extend(seq[i:])
break
elif seq[i]<x:
sort.append(seq[i])
positions = list(enumerate(sort))
for i in positions:
if i[1] == x:
return i[0]
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_556.py
|
refactory_data_question_1_wrong_1_206
|
def search(x, seq):
if x < seq[0]:
return 0
elif x > seq[-1]:
return len(seq)
else:
for i in range(len(seq) - 1):
if seq[i] < x < seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_206.py
|
refactory_data_question_1_wrong_1_529
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
counter = -1
for i in seq:
if len(seq) == 0:
return 0
elif x <= i:
counter += 1
return counter
else:
counter += 1
if x > seq[counter]:
return counter + 1
|
./refactory/data/question_1/code/wrong/wrong_1_529.py
|
refactory_data_question_1_wrong_1_112
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
for i,j in enumerate(seq[:len(seq)-1]):
if seq == ():
return 0
elif x < seq[0]:
return 0
elif x > j and x <= seq[i+1]:
return i+1
elif x > seq[len(seq)-1]:
return len(seq)
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_112.py
|
refactory_data_question_1_wrong_1_410
|
def search(x,seq):
for i, elem in enumerate(seq):
if x <= elem:
return i
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_410.py
|
refactory_data_question_1_wrong_1_314
|
def search(x, seq):
for i in range(len(seq)):
if not seq:
return 0
elif x<=seq[i]:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_314.py
|
refactory_data_question_1_wrong_1_481
|
def search(x, seq):
for i, elem in enumerate(seq):
if x < elem:
return i
elif x == elem:
return i
elif i == len(seq)-1:
return i+1
elif seq == []:
return 0
|
./refactory/data/question_1/code/wrong/wrong_1_481.py
|
refactory_data_question_1_wrong_1_098
|
def search(x, seq):
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
if seq==() or x<=seq[0]:
return 0
elif x>seq[-1]:
return len(seq)
else:
for i,elem in enumerate(seq):
if x>elem and x<=seq[i+1]:
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_098.py
|
refactory_data_question_1_wrong_1_012
|
def search(x, seq):
for i, elem in enumerate(seq):
if elem <= x <= elem + 1:
return i - 1
|
./refactory/data/question_1/code/wrong/wrong_1_012.py
|
refactory_data_question_1_wrong_1_442
|
def search(x, seq):
if seq==():
return None
for i in range(len(seq)):
if x<=seq[i]:
return i
return i+1
|
./refactory/data/question_1/code/wrong/wrong_1_442.py
|
refactory_data_question_1_wrong_1_152
|
def search(x, seq):
for i in range(len(seq)):
if x <= seq[i]:
return seq.index(seq[i])
elif seq[-1] < x:
return seq.index(seq[-1])+1
else:
return 0
|
./refactory/data/question_1/code/wrong/wrong_1_152.py
|
refactory_data_question_1_wrong_1_203
|
def search(x, seq):
l=len(seq)
if x<=seq[0]:
return 0
elif x>=seq[l-1]:
return l
else:
for i in range (l):
if x>=seq[i] and x<=seq[i+1]:
return i+1
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_203.py
|
refactory_data_question_1_wrong_1_424
|
def search(x, seq):
if seq == () or []:
return 0
for i in range (len(seq)):
if x <= seq[i]:
return i
elif x > seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_424.py
|
refactory_data_question_1_wrong_1_468
|
def search(x, seq):
if x < seq[0]:
return 0
else:
i = 0
while i in range(len(seq)):
if x <= seq[i]:
return i
elif x > seq[len(seq)-1]:
return len(seq)
else:
i += 1
""" Takes in a value x and a sorted sequence seq, and returns the
position that x should go to such that the sequence remains sorted """
return
|
./refactory/data/question_1/code/wrong/wrong_1_468.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.