id
stringlengths 35
39
| content
stringlengths 44
3.85k
| max_stars_repo_path
stringlengths 52
57
|
|---|---|---|
refactory_data_question_1_correct_1_719
|
def search(x, seq):
if not seq:
return 0
elif x < seq[0]:
return 0
for i in range(len(seq)):
if i == len(seq) - 1:
return len(seq)
if x >= seq[i] and x <= seq[i+1]:
return i+1
|
./refactory/data/question_1/code/correct/correct_1_719.py
|
refactory_data_question_1_correct_1_206
|
def search(x, seq):
for i, elem in enumerate(seq):
if elem>=x:
return i
else:
continue
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_206.py
|
refactory_data_question_1_correct_1_075
|
def search(x, seq):
if len(seq)==0:
return 0
a = list(enumerate(seq))
for item in a:
if x <= item[1]:
return item[0]
if x > seq[-1]:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_075.py
|
refactory_data_question_1_correct_1_182
|
def search(x, seq):
if type(seq) == tuple:
lst = list(seq)
else:
lst = seq
counter = 0
for i in lst:
if x <= i:
continue
else:
counter += 1
return counter
|
./refactory/data/question_1/code/correct/correct_1_182.py
|
refactory_data_question_1_correct_1_155
|
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 """
enumerated_list =()
res= 0
for i, elem in enumerate(seq):
enumerated_list = enumerated_list + ((i,elem),)
for number in enumerated_list:
if x <= number[1]:
res = number[0]
break
else:
res = len(seq)
return res
|
./refactory/data/question_1/code/correct/correct_1_155.py
|
refactory_data_question_1_correct_1_240
|
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
result = 0
while counter < len(seq):
if x < min(seq):
result = 0
break
elif x > max(seq):
result = len(seq)
break
elif x <= seq[counter]:
result = counter
break
counter += 1
return result
|
./refactory/data/question_1/code/correct/correct_1_240.py
|
refactory_data_question_1_correct_1_340
|
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):
if x <= j:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_340.py
|
refactory_data_question_1_correct_1_339
|
def search(x, seq):
for position in range(len(seq)):
if x < seq[position] or x == seq[position]:
return position
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_339.py
|
refactory_data_question_1_correct_1_013
|
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,e in enumerate(seq):
if x <= e:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_013.py
|
refactory_data_question_1_correct_1_084
|
def search(x, seq):
holder=0
for value in seq:
if x>value:
holder+=1
return holder
|
./refactory/data/question_1/code/correct/correct_1_084.py
|
refactory_data_question_1_correct_1_295
|
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 seq == () or seq == []:
return 0
else:
if x <= seq[0]:
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/correct/correct_1_295.py
|
refactory_data_question_1_correct_1_132
|
def search(x, seq):
if seq == () or 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/correct/correct_1_132.py
|
refactory_data_question_1_correct_1_712
|
def search(x, seq):
pos = 0
for ele in seq:
if x <= ele:
return pos
else:
pos += 1
return pos
|
./refactory/data/question_1/code/correct/correct_1_712.py
|
refactory_data_question_1_correct_1_169
|
def search(x, seq):
if seq==[]or seq==():
return 0
for count, ele in enumerate(seq):
if x<=ele:
return count
for ele in seq:
if x>ele:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_169.py
|
refactory_data_question_1_correct_1_697
|
def search(x, seq):
counter = 0
for i in seq:
if x <= i:
return len(seq[:counter])
counter = counter + 1
else:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_697.py
|
refactory_data_question_1_correct_1_026
|
def search(x, seq):
for i, elem in enumerate (seq):
if x <= elem:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_026.py
|
refactory_data_question_1_correct_1_746
|
def search(x, seq):
for i, elem in enumerate(seq):
if x > elem and i == len(seq) - 1:
# specifies case where i has reached the last element in the tuple or list
return i + 1
elif x > elem:
continue
else:
return i
if len(seq) == 0:
return 0
# this is if seq is empty
# if not defined, task 3(a) won't work
|
./refactory/data/question_1/code/correct/correct_1_746.py
|
refactory_data_question_1_correct_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, elem in enumerate(seq):
if x <= elem:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_259.py
|
refactory_data_question_1_correct_1_633
|
def search(x, seq):
result = 0
for i in range(len(seq)):
if seq[i] >= x:
result = i
break
elif x > seq[i]:
result = i + 1
return result
|
./refactory/data/question_1/code/correct/correct_1_633.py
|
refactory_data_question_1_correct_1_510
|
def search(x, seq):
for i,elem in enumerate(seq):
if x<=elem:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_510.py
|
refactory_data_question_1_correct_1_474
|
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 """
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_474.py
|
refactory_data_question_1_correct_1_670
|
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 len(seq) == 0:
return 0
else:
index = -1
for i in seq:
if x <= i:
index += 1
return index
elif x > seq[-1]:
return len(seq)
else:
index += 1
|
./refactory/data/question_1/code/correct/correct_1_670.py
|
refactory_data_question_1_correct_1_040
|
def search(x, seq):
counter = 0
while counter < len(seq):
if x <= seq[counter]:
return counter
counter += 1
return counter
|
./refactory/data/question_1/code/correct/correct_1_040.py
|
refactory_data_question_1_correct_1_630
|
def search(x, seq):
index = 0
for i in range (len(seq)):
if x <= seq[i]:
break
elif x > seq[i]:
index = i + 1
return index
|
./refactory/data/question_1/code/correct/correct_1_630.py
|
refactory_data_question_1_correct_1_170
|
def search(x, seq):
if seq == () or seq == []:
return 0
for i in range (0, len(seq)):
if x <= seq[i]:
pos = i
return pos
if x > seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_170.py
|
refactory_data_question_1_correct_1_096
|
def search(x, seq):
if type(seq) == list:
a = seq.copy()
a.append(x)
a.sort()
for i, elem in enumerate(a):
if elem == x:
return i
else:
temp_list = list(seq)
temp_list.append(x,)
temp_list.sort()
for i, elem in enumerate(temp_list):
if elem == x:
return i
|
./refactory/data/question_1/code/correct/correct_1_096.py
|
refactory_data_question_1_correct_1_520
|
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, p in enumerate(seq):
if x <= p:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_520.py
|
refactory_data_question_1_correct_1_102
|
def search(x, seq):
y = 0
for z in seq:
if x > z:
y += 1
return y
|
./refactory/data/question_1/code/correct/correct_1_102.py
|
refactory_data_question_1_correct_1_545
|
def search(x, seq):
n = len(seq)
if n == 0:
return 0
else:
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/correct/correct_1_545.py
|
refactory_data_question_1_correct_1_080
|
def search(x, seq):
if seq == ():
return 0
elif seq == []:
return 0
else:
next
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/correct/correct_1_080.py
|
refactory_data_question_1_correct_1_378
|
def search(x, seq):
for i in enumerate(seq):
if x <= i[1]:
if i[0] == 0:
return 0
else:
return i[0]
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_378.py
|
refactory_data_question_1_correct_1_164
|
def search(x, seq):
pos = len(seq)
for i, elem in enumerate(seq):
if x <= elem:
pos = i
break
return pos
|
./refactory/data/question_1/code/correct/correct_1_164.py
|
refactory_data_question_1_correct_1_761
|
def search(x, seq):
if seq==():
return 0
elif seq==[]:
return 0
else:
pos=0
for i, elem in enumerate(seq):
if elem >= x:
return i
return i+1
|
./refactory/data/question_1/code/correct/correct_1_761.py
|
refactory_data_question_1_correct_1_723
|
def search(x, seq):
index = 0
for i in range (len(seq)):
if x <= seq[i]:
break
elif x > seq[i]:
index = i + 1
return index
|
./refactory/data/question_1/code/correct/correct_1_723.py
|
refactory_data_question_1_correct_1_103
|
def search(x, seq):
if len(seq) == 0 or x <= seq[0]:
return 0
elif x > seq[len(seq) - 1]:
return len(seq)
else:
for i in range(len(seq)):
if x <= seq[i]:
return i
|
./refactory/data/question_1/code/correct/correct_1_103.py
|
refactory_data_question_1_correct_1_473
|
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, elem in enumerate(seq):
if x <= elem:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_473.py
|
refactory_data_question_1_correct_1_629
|
def search(x, seq):
if len(seq) == 0:
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/correct/correct_1_629.py
|
refactory_data_question_1_correct_1_594
|
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 seq == []:
return 0
elif x > max(seq):
return len(seq)
else:
enumerated = list(enumerate(seq))
for i in range(len(enumerated)):
if enumerated[i][1] >= x:
return enumerated[i][0]
break
|
./refactory/data/question_1/code/correct/correct_1_594.py
|
refactory_data_question_1_correct_1_141
|
def search(x, seq):
seq_len = len(seq)
for i in range(seq_len):
if x <= seq[i]: return i
return seq_len
|
./refactory/data/question_1/code/correct/correct_1_141.py
|
refactory_data_question_1_correct_1_171
|
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
for i in seq:
if x > i:
counter += 1
continue
else:
break
return counter
|
./refactory/data/question_1/code/correct/correct_1_171.py
|
refactory_data_question_1_correct_1_041
|
def search(x, seq):
counter = 0
while counter < len(seq):
if x <= seq[counter]:
return counter
counter += 1
return counter
|
./refactory/data/question_1/code/correct/correct_1_041.py
|
refactory_data_question_1_correct_1_232
|
def search(x, seq):
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_232.py
|
refactory_data_question_1_correct_1_180
|
def search(x, seq):
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_180.py
|
refactory_data_question_1_correct_1_689
|
def search(x, seq):
counter = 0
for i in seq:
if x > i:
counter += 1
else:
continue
return counter
|
./refactory/data/question_1/code/correct/correct_1_689.py
|
refactory_data_question_1_correct_1_738
|
def search(x, seq):
list2 = list(enumerate(seq))
if list2 == []:
return 0
else:
for i in list2:
if x <= (i[1]):
return i[0]
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_738.py
|
refactory_data_question_1_correct_1_195
|
def search(x, seq):
counter = 0
for i in seq:
if x > i:
counter = counter + 1
return counter
|
./refactory/data/question_1/code/correct/correct_1_195.py
|
refactory_data_question_1_correct_1_501
|
def search(x, seq):
n = len(seq)
for i in range(n):
next_element = seq[i]
if x <= next_element:
return i
return n
|
./refactory/data/question_1/code/correct/correct_1_501.py
|
refactory_data_question_1_correct_1_056
|
def search(x, seq):
if len(seq)==0:
return 0
for i in range(0,len(seq)):
if x<seq[i]:
return i
elif x==seq[i]:
return i
elif x>seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_056.py
|
refactory_data_question_1_correct_1_213
|
def search(x, seq):
for i, elem in enumerate(seq):
if x <= elem:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_213.py
|
refactory_data_question_1_correct_1_742
|
def search(x, seq):
if len(seq)==0:
return 0
for i in range(len(seq)):
if seq[i]>=x:
break
elif seq[-1]<x:
return len(seq)
return i
|
./refactory/data/question_1/code/correct/correct_1_742.py
|
refactory_data_question_1_correct_1_126
|
def search(x, seq):
count = 0
for i in seq:
if x > i:
count += 1
return count
""" 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/correct/correct_1_126.py
|
refactory_data_question_1_correct_1_412
|
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
for i in seq:
if x > i:
count = count + 1
return count
|
./refactory/data/question_1/code/correct/correct_1_412.py
|
refactory_data_question_1_correct_1_694
|
def search(x, seq):
enum_seq = enumerate(seq)
new_seq = tuple(map(lambda x: x[0], enum_seq))
if seq == ():
return 0
for a in range(len(seq)):
if x < seq[a]:
return new_seq[a]
elif x == seq[a]:
return new_seq[a]
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_694.py
|
refactory_data_question_1_correct_1_406
|
def search(x, seq):
if seq == () or seq == []:
return 0
for i in range (0, len(seq)):
if x <= seq[i]:
pos = i
return pos
if x > seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_406.py
|
refactory_data_question_1_correct_1_101
|
def search(x, seq):
if len(seq) == 0:
return False
else:
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/correct/correct_1_101.py
|
refactory_data_question_1_correct_1_481
|
def search(x, seq):
n = len(seq)
for i in range(n):
next_element = seq[i]
if x <= next_element:
return i
return n
|
./refactory/data/question_1/code/correct/correct_1_481.py
|
refactory_data_question_1_correct_1_582
|
def search(x, seq):
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_582.py
|
refactory_data_question_1_correct_1_060
|
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[-1]:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_060.py
|
refactory_data_question_1_correct_1_595
|
def search(x, seq):
if seq == () or seq == []:
return 0
for i in seq:
if x <= i:
return seq.index(i)
elif x > seq[-1]:
return (seq.index(seq[-1])) + 1
|
./refactory/data/question_1/code/correct/correct_1_595.py
|
refactory_data_question_1_correct_1_008
|
def search(x, seq):
for i, e in enumerate(seq):
if x <= e:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_008.py
|
refactory_data_question_1_correct_1_370
|
def search(x, seq):
if len(seq) == 0:
return 0
elif x <= seq[-1]:
for i in range(len(seq)):
if seq[i] < x:
continue
else:
return i
else:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_370.py
|
refactory_data_question_1_correct_1_298
|
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 """
n = 0
for num in seq:
if x>num:
n +=1
else:
return n
return n
|
./refactory/data/question_1/code/correct/correct_1_298.py
|
refactory_data_question_1_correct_1_734
|
def search(x, seq):
for i, elem in enumerate(seq):
if x > elem and i == len(seq) - 1:
# specifies case where i has reached the last element in the tuple or list
return i + 1
elif x > elem:
continue
else:
return i
if len(seq) == 0:
return 0
# this is if seq is empty
# if not defined, task 3(a) won't work
|
./refactory/data/question_1/code/correct/correct_1_734.py
|
refactory_data_question_1_correct_1_521
|
def search(x, seq):
if seq == () or 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/correct/correct_1_521.py
|
refactory_data_question_1_correct_1_265
|
def search(x, seq):
count = 0
for i in seq:
if x > i:
count = count + 1
else:
break
return count
|
./refactory/data/question_1/code/correct/correct_1_265.py
|
refactory_data_question_1_correct_1_185
|
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 seq==[]:
return 0
else:
for i in range(len(seq)):
if x<=seq[i]:
return i
return i+1
|
./refactory/data/question_1/code/correct/correct_1_185.py
|
refactory_data_question_1_correct_1_187
|
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 len(seq) ==1:
if x < seq[0]:
return 0
else:
return 1
for i in range(len(seq)):
if i == 0:
if x < seq[0]:
return 0
if x == seq[i]:
return i
if seq[i-1] < x < seq[i]:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_187.py
|
refactory_data_question_1_correct_1_703
|
def search(x, seq):
if len(seq) == 0 or x < seq[0] :
return 0
elif x > seq[len(seq)-1]:
return len(seq)
else:
result = 0
for i, element in enumerate(seq):
if x < (element + 1):
result = i
break
return result
|
./refactory/data/question_1/code/correct/correct_1_703.py
|
refactory_data_question_1_wrong_1_213
|
def search(x, seq):
index = 0
def helper(index):
if not seq:
return 0
elif x <= seq[index]:
return index
else:
if index + 1 >= len(seq):
return index + 1
else:
return helper(index+1)
|
./refactory/data/question_1/code/fail/wrong_1_213.py
|
refactory_data_question_1_wrong_1_434
|
def search2(x,seq):
for i,elem in enumerate(seq):
counter = 0
if x<= elem:
counter = i
else:
counter = len(seq)
return counter
|
./refactory/data/question_1/code/fail/wrong_1_434.py
|
refactory_data_question_1_reference
|
def search(x, seq):
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
|
./refactory/data/question_1/code/reference/reference.py
|
refactory_data_question_1_wrong_1_250
|
def search(x, seq):
if x <= seq[0]:
position = 0
for i in range(len(seq)):
if x <= seq[i] and x > seq[i-1]:
position = i
else:
position = len(seq)
return position
|
./refactory/data/question_1/code/wrong/wrong_1_250.py
|
refactory_data_question_1_wrong_1_078
|
def search(x, seq):
for count, ele in enumerate(seq):
if x<=ele:
return count
for ele in seq:
if x>ele:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_078.py
|
refactory_data_question_1_wrong_1_201
|
def search(x, seq):
if seq == ():
return (x,)
elif seq == []:
return [x,]
else:
for i,elem in enumerate(seq):
if x < seq[-1]:
if x > elem:
continue
elif x < elem and type(seq) == tuple:
seq = seq[:i] + (x,) + seq[i:]
elif x < elem and type(seq) == list:
seq = seq[:i] + [x,] + seq[i:]
elif x > seq[-1]:
if type(seq) == tuple:
seq += (x,)
elif type(seq) == list:
seq += [x,]
return seq.index(x)
|
./refactory/data/question_1/code/wrong/wrong_1_201.py
|
refactory_data_question_1_wrong_1_154
|
def search(x, seq):
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_154.py
|
refactory_data_question_1_wrong_1_347
|
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 x in seq:
if x < seq[i]:
return i
i+=1
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_347.py
|
refactory_data_question_1_wrong_1_295
|
def search(x,seq):
for i in range(len(seq)):
if x > seq[i]:
continue
elif x <= seq[i]:
break
return i
|
./refactory/data/question_1/code/wrong/wrong_1_295.py
|
refactory_data_question_1_wrong_1_106
|
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 x > seq[i] and x <= seq[i+1]:
return i+1
return None
|
./refactory/data/question_1/code/wrong/wrong_1_106.py
|
refactory_data_question_1_wrong_1_026
|
def search(x, seq):
for i, elem in enumerate(seq):
if x <= elem:
return i
elif x > seq[-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_026.py
|
refactory_data_question_1_wrong_1_493
|
def search(x, seq):
for i, elem in enumerate (seq):
if x<=elem:
return i
elif x>seq[-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_493.py
|
refactory_data_question_1_wrong_1_423
|
def search(x, seq):
for i in range (len(seq)):
if seq == ():
return 0
if x <= seq[i]:
return i
elif x > seq[len(seq)-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_423.py
|
refactory_data_question_1_wrong_1_511
|
def search(x, seq):
for i in seq:
if x<i:
return seq.index(i)
elif x == i:
return seq.index(i)
elif x>seq[-1]:
return (seq.index(seq[-1]))+1
|
./refactory/data/question_1/code/wrong/wrong_1_511.py
|
refactory_data_question_1_wrong_1_016
|
def search(x, seq):
if x < seq[0]:
return 0
elif x > seq[-1]:
return len(seq)
for i, elem in enumerate(seq):
if elem <= x:
return i
|
./refactory/data/question_1/code/wrong/wrong_1_016.py
|
refactory_data_question_1_wrong_1_128
|
def search(x, seq):
if x <= seq[0] or not seq:
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_128.py
|
refactory_data_question_1_wrong_1_066
|
def search(x, seq):
for i in range(0,len(seq)):
if x<seq[i]:
return i
break
elif x==seq[i]:
return i
break
elif x>seq[len(seq)-1]:
return len(seq)
break
|
./refactory/data/question_1/code/wrong/wrong_1_066.py
|
refactory_data_question_1_wrong_1_235
|
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_235.py
|
refactory_data_question_1_wrong_1_288
|
def search(x, seq):
if x<seq[0]:
return 0
elif x>seq[-1]:
return len(seq)
elif len(seq)==0:
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_288.py
|
refactory_data_question_1_wrong_1_176
|
def search(x, seq):
if list(seq) == []:
return 0
elif seq == ():
return 0
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_176.py
|
refactory_data_question_1_wrong_1_563
|
def search(x,seq):
if max(seq) < x:
return len(seq)
if x <= min(seq):
return 0
|
./refactory/data/question_1/code/wrong/wrong_1_563.py
|
refactory_data_question_1_wrong_1_127
|
def search(x, seq):
if 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_127.py
|
refactory_data_question_1_wrong_1_187
|
def search(x, seq):
if 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_187.py
|
refactory_data_question_1_wrong_1_028
|
def search(x, seq):
for i in range(len(seq)):
if x<=seq[i]:
return i
elif x>=seq[len(seq)-1]:
return len(seq)
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_028.py
|
refactory_data_question_1_wrong_1_383
|
def search(x, seq):
lst1 = list(seq)
if lst1 == []:
return 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_383.py
|
refactory_data_question_1_wrong_1_567
|
def search(x, seq):
for i, elem in enumerate(seq):
if seq == False:
return 0
elif x <= elem:
return i
elif i == (len(seq)-1):
return i+1
else:
continue
|
./refactory/data/question_1/code/wrong/wrong_1_567.py
|
refactory_data_question_1_wrong_1_221
|
def search(x, seq):
for i in len(seq):
if x <= seq[i]:
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_221.py
|
refactory_data_question_1_wrong_1_258
|
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 """
enumerated_list =()
for i, elem in enumerate(seq):
enumerated_list = enumerated_list + ((i,elem),)
for number in enumerated_list:
if x <= number[1]:
res = number[0]
break
else:
res = len(seq)
return res
|
./refactory/data/question_1/code/wrong/wrong_1_258.py
|
refactory_data_question_1_wrong_1_395
|
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_395.py
|
refactory_data_question_1_wrong_1_162
|
def search(x, seq):
for i in range(len(seq)-1):
if x<=seq[0]:
return 0
if seq[i]<=x<=seq[i+1]:
return i+1
if x>=seq[-1]:
return len(seq)
|
./refactory/data/question_1/code/wrong/wrong_1_162.py
|
refactory_data_question_1_wrong_1_469
|
def search(x, seq):
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_469.py
|
refactory_data_question_1_wrong_1_040
|
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_040.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.