id
stringlengths 35
39
| content
stringlengths 44
3.85k
| max_stars_repo_path
stringlengths 52
57
|
|---|---|---|
refactory_data_question_1_correct_1_337
|
def search(x, seq):
result = 0
for i in range (len(seq)):
if seq[i] >= x:
result = i
break
else:
result = i + 1
return result
|
./refactory/data/question_1/code/correct/correct_1_337.py
|
refactory_data_question_1_correct_1_137
|
def search(x, seq):
lst = []
for i, elem in enumerate(seq):
lst.append((i, elem))
for i in lst:
if x <= i[1]:
return i[0]
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_137.py
|
refactory_data_question_1_correct_1_503
|
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_503.py
|
refactory_data_question_1_correct_1_199
|
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==[] 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/correct/correct_1_199.py
|
refactory_data_question_1_correct_1_498
|
def search(x, seq):
counter=0
for i in seq:
if x > i:
counter+=1
else:
break
return counter
|
./refactory/data/question_1/code/correct/correct_1_498.py
|
refactory_data_question_1_correct_1_044
|
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_044.py
|
refactory_data_question_1_correct_1_765
|
def search(x, seq):
n = 0
for i in seq:
if x <= i:
return n
else:
n += 1
return n
|
./refactory/data/question_1/code/correct/correct_1_765.py
|
refactory_data_question_1_correct_1_042
|
def search(x, seq):
listseq=list(seq)
n=len(seq)
for i in listseq:
if x<=i:
return listseq.index(i)
return n
""" 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_042.py
|
refactory_data_question_1_correct_1_403
|
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 i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_403.py
|
refactory_data_question_1_correct_1_565
|
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 """
position = 0
if seq == ():
#Terminates if there is no list of tuple at all
return position
else:
for i in range(len(seq)):
if x <= seq[i]:
#Termniates once the sorted position is found
position = i
break
elif i == len(seq)-1:
#Teminates when it finished sorting through and all are smaller
position = len(seq)
return position
|
./refactory/data/question_1/code/correct/correct_1_565.py
|
refactory_data_question_1_correct_1_071
|
def search(x, seq):
i=0
while i<len(seq):
if x<=seq[i]:
break
i=i+1
return i
|
./refactory/data/question_1/code/correct/correct_1_071.py
|
refactory_data_question_1_correct_1_181
|
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_181.py
|
refactory_data_question_1_correct_1_659
|
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 """
length = len(seq)
if length == 0:
return 0
else:
for i, elem in enumerate(seq):
if x < elem:
return i
else:
if x == elem:
return i
if (i == length-1):
return i+1
|
./refactory/data/question_1/code/correct/correct_1_659.py
|
refactory_data_question_1_correct_1_698
|
def search(x, seq):
if seq == []:
return 0
for elem in seq:
if x < elem:
return seq.index(elem)
elif x == elem:
return seq.index(elem)
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_698.py
|
refactory_data_question_1_correct_1_189
|
def search(x, seq):
if not seq:
return 0
if x <= seq[0]:
return 0
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/correct/correct_1_189.py
|
refactory_data_question_1_correct_1_360
|
def search(x, seq):
for i in range(len(seq)):
if x <= seq[i]:
return i
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_360.py
|
refactory_data_question_1_correct_1_658
|
def search(x, seq):
if seq:
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
else:
return 0
|
./refactory/data/question_1/code/correct/correct_1_658.py
|
refactory_data_question_1_correct_1_422
|
def search(x, seq):
counter = 0
new_seq = list(seq)
if new_seq == []:
return 0
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/correct/correct_1_422.py
|
refactory_data_question_1_correct_1_090
|
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 len(seq)
|
./refactory/data/question_1/code/correct/correct_1_090.py
|
refactory_data_question_1_correct_1_638
|
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_638.py
|
refactory_data_question_1_correct_1_246
|
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 index in range(len(seq)):
if x<= seq[index]:
return index
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_246.py
|
refactory_data_question_1_correct_1_002
|
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 """
output = 0
while output < len(seq):
if x > seq[output]:
output += 1
else:
break
return output
|
./refactory/data/question_1/code/correct/correct_1_002.py
|
refactory_data_question_1_correct_1_018
|
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 len(seq)
|
./refactory/data/question_1/code/correct/correct_1_018.py
|
refactory_data_question_1_correct_1_517
|
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 """
lst = list(seq)
lst.append(x)
lst.sort()
tup = tuple(enumerate(lst))
for i in range(len(tup)):
if tup[i][1]==x:
return tup[i][0]
|
./refactory/data/question_1/code/correct/correct_1_517.py
|
refactory_data_question_1_correct_1_344
|
def search(x, seq):
if seq == [] or seq==():
return 0
elif x<seq[0]:
return 0
elif x>seq[0] and len(seq) == 1:
return 1
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/correct/correct_1_344.py
|
refactory_data_question_1_correct_1_029
|
def search(x, seq):
for i, elem in enumerate(seq):
if elem == x:
return i
elif x > elem:
continue
elif x < elem:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_029.py
|
refactory_data_question_1_correct_1_745
|
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 ele in seq:
if ele>=x:
break
i += 1
return i
|
./refactory/data/question_1/code/correct/correct_1_745.py
|
refactory_data_question_1_correct_1_362
|
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/correct/correct_1_362.py
|
refactory_data_question_1_correct_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
i =0
for p in seq:
if x <= p:
return i
i += 1
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_082.py
|
refactory_data_question_1_correct_1_468
|
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_468.py
|
refactory_data_question_1_correct_1_221
|
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 i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_221.py
|
refactory_data_question_1_correct_1_553
|
def search(x, seq):
counter=0
for i in seq:
if x>i:
counter+=1
return counter
|
./refactory/data/question_1/code/correct/correct_1_553.py
|
refactory_data_question_1_correct_1_375
|
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 """
seq2 = list(enumerate(seq,0))
value = 0
for element in seq2:
if x > element[1]:
value = element[0]+1
return value
|
./refactory/data/question_1/code/correct/correct_1_375.py
|
refactory_data_question_1_correct_1_091
|
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 len(seq)
|
./refactory/data/question_1/code/correct/correct_1_091.py
|
refactory_data_question_1_correct_1_460
|
def search(x, seq):
for i in range(0, len(seq) + 1):
if len(seq) == 0:
return 0
elif x < seq[0]:
return 0
elif seq[i] < x <= seq[i+1]:
return i + 1
elif seq[len(seq)-1] < x:
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_460.py
|
refactory_data_question_1_correct_1_140
|
def search(x, seq):
if len(seq)==0:
return 0
for i in range(len(seq)):
if x<= seq[i]:
a=i
break
elif x> seq[len(seq)-1]:
a=len(seq)
return a
|
./refactory/data/question_1/code/correct/correct_1_140.py
|
refactory_data_question_1_correct_1_357
|
def search(x, seq):
result = 0
""" 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/correct/correct_1_357.py
|
refactory_data_question_1_correct_1_319
|
def search(x, seq):
count=0
while count<len(seq):
if x>seq[count]:
count+=1
continue
else:
return count
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_319.py
|
refactory_data_question_1_correct_1_707
|
def search(x, seq):
position = 0
for i in seq:
if x > i:
position +=1
else:
return position
if position ==len(seq)-1:
return position+1
else:
return position
|
./refactory/data/question_1/code/correct/correct_1_707.py
|
refactory_data_question_1_correct_1_016
|
def search(x, seq):
if seq==() or 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/correct/correct_1_016.py
|
refactory_data_question_1_correct_1_721
|
def search(x, seq):
counter=0
for i in seq:
if i>=x:
break
counter=counter+1
return counter
|
./refactory/data/question_1/code/correct/correct_1_721.py
|
refactory_data_question_1_correct_1_383
|
def search(x, seq):
new = list(enumerate(seq))
for n in new:
if x <= n[1]:
return n[0]
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_383.py
|
refactory_data_question_1_correct_1_005
|
def search(x, seq):
index = 0
for i in range(0,len(seq)):
if x > seq[i]:
index = i + 1
return index
|
./refactory/data/question_1/code/correct/correct_1_005.py
|
refactory_data_question_1_correct_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 """
for i,ele in enumerate(seq):
if x<=ele: #if x is less/equal to the specific element in the list
return i #return the index to be inserted in
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_098.py
|
refactory_data_question_1_correct_1_563
|
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_563.py
|
refactory_data_question_1_correct_1_404
|
def search(x, seq):
count = 0
for i in seq:
if x > i:
count += 1
return count
|
./refactory/data/question_1/code/correct/correct_1_404.py
|
refactory_data_question_1_correct_1_726
|
###########
# Task 1a #
###########
# The enumerate function should be helpful for you here.
# It takes in a sequence (either a list or a tuple)
# and returns an iteration of pairs each of which
# contains the index of the element and the element itself.
# Here's how to use it.
# for i, elem in enumerate((4, 10, 1, 3)):
# print("I am in the", i ,"position and I am", elem)
#
# I am in the 0 position and I am 4
# I am in the 1 position and I am 10
# I am in the 2 position and I am 1
# I am in the 3 position and I am 3
def search(x, seq):
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
print("## Q1a ##")
print(search(-5, (1, 5, 10)))
# => 0
print(search(3, (1, 5, 10)))
# => 1
print(search(7, [1, 5, 10]))
# => 2
print(search(5, (1, 5, 10)))
# => 1
print(search(42, [1, 5, 10]))
# => 3
print(search(42, (-5, 1, 3, 5, 7, 10)))
|
./refactory/data/question_1/code/correct/correct_1_726.py
|
refactory_data_question_1_correct_1_392
|
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_392.py
|
refactory_data_question_1_correct_1_654
|
def search(x, seq):
counter = 0
for elem in seq:
if x > elem:
counter += 1
else:
break
return counter
|
./refactory/data/question_1/code/correct/correct_1_654.py
|
refactory_data_question_1_correct_1_326
|
def search(x, seq):
value = 0
for i in range(0, len(seq)):
if (x > seq[i]):
value += 1
elif (x <= seq[i]):
break
return value
|
./refactory/data/question_1/code/correct/correct_1_326.py
|
refactory_data_question_1_correct_1_205
|
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(0,len(seq)):
if seq[i] >= x:
return max(i, 0)
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_205.py
|
refactory_data_question_1_correct_1_487
|
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 len(seq)
|
./refactory/data/question_1/code/correct/correct_1_487.py
|
refactory_data_question_1_correct_1_154
|
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_154.py
|
refactory_data_question_1_correct_1_231
|
def search(x, seq):
if len(seq) == 0:
return 0
else:
for i in range(len(seq)):
if 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/correct/correct_1_231.py
|
refactory_data_question_1_correct_1_123
|
def search(x, seq):
ns = tuple(enumerate(seq))
for y in ns:
if x <= y[1]:
return y[0]
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_123.py
|
refactory_data_question_1_correct_1_439
|
def search(x, seq):
position = 0
while position < len(seq):
if seq[position] == x:
break
elif seq[position] > x:
break
position = position + 1
return position
|
./refactory/data/question_1/code/correct/correct_1_439.py
|
refactory_data_question_1_correct_1_332
|
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_332.py
|
refactory_data_question_1_correct_1_048
|
def search(x, seq):
if seq == () or seq == []:
return 0
elif x <= seq[0]:
return 0
elif x > seq[-1]:
return len(seq)
else:
seq_enum = [i for i in enumerate(seq)]
for j in range(len(seq_enum) - 1):
if x >= seq_enum[j][1] and x <= seq_enum[j+1][1]:
return j+1
|
./refactory/data/question_1/code/correct/correct_1_048.py
|
refactory_data_question_1_correct_1_695
|
def search(x, seq):
if seq == []:
return 0
else:
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_695.py
|
refactory_data_question_1_correct_1_354
|
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
for i, elem in enumerate(seq):
if x <= elem:
return i
if i == (len(seq)-1):
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_354.py
|
refactory_data_question_1_correct_1_574
|
def search(x,seq):
for index in range(len(seq)):
if x <= seq[index]:
return index
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_574.py
|
refactory_data_question_1_correct_1_673
|
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 """
lst = list(seq)
lst.append(x)
lst.sort()
y = tuple(enumerate(lst))
for i in range(len(y)):
if y[i][1]==x:
return y[i][0]
|
./refactory/data/question_1/code/correct/correct_1_673.py
|
refactory_data_question_1_correct_1_676
|
def search(x, seq):
for i in range(len(seq)):
if seq[i] >= x:
return i
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_676.py
|
refactory_data_question_1_correct_1_021
|
def search(x, seq):
seq = list(seq)
if seq == []: return 0
else:
for i in range(len(seq)):
if x <= seq[i]:
return i
else: continue
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_021.py
|
refactory_data_question_1_correct_1_583
|
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_583.py
|
refactory_data_question_1_correct_1_591
|
def search(x, seq):
counter = 0
for i in range(len(seq)):
if x > seq[i]:
counter += 1
else:
break
return counter
|
./refactory/data/question_1/code/correct/correct_1_591.py
|
refactory_data_question_1_correct_1_218
|
def search(x, seq):
position = 0
for i in range(len(seq)):
if x <= seq[i]:
position = i
break
else:
position = len(seq)
return position
|
./refactory/data/question_1/code/correct/correct_1_218.py
|
refactory_data_question_1_correct_1_641
|
def search(x, seq):
if seq:
for i in range(len(seq)):
if x <= seq[i]:
return i
return len(seq)
else:
return 0
|
./refactory/data/question_1/code/correct/correct_1_641.py
|
refactory_data_question_1_correct_1_601
|
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_601.py
|
refactory_data_question_1_correct_1_317
|
def search(x, seq):
n = len(seq)
if n == 0:
return 0
else:
for counter in range(n):
if x > seq[n-1]:
result = n
break
elif seq[counter] >= x:
result = counter
break
else:
continue
return result
|
./refactory/data/question_1/code/correct/correct_1_317.py
|
refactory_data_question_1_correct_1_380
|
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_380.py
|
refactory_data_question_1_correct_1_308
|
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_308.py
|
refactory_data_question_1_correct_1_388
|
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_388.py
|
refactory_data_question_1_correct_1_561
|
def search(x, seq):
for i, elem in enumerate(seq):
if elem >= x:
return i
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_561.py
|
refactory_data_question_1_correct_1_718
|
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/correct/correct_1_718.py
|
refactory_data_question_1_correct_1_120
|
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_120.py
|
refactory_data_question_1_correct_1_277
|
def search(x, seq):
result = 0
for i in range(len(seq)):
if x > seq[i]:
result += 1
return result
|
./refactory/data/question_1/code/correct/correct_1_277.py
|
refactory_data_question_1_correct_1_416
|
def search(x, seq):
position = 0
for ele in seq:
if x > ele:
position = position + 1
return position
|
./refactory/data/question_1/code/correct/correct_1_416.py
|
refactory_data_question_1_correct_1_760
|
def search(x, seq):
if seq==():
return 0
elif seq==[]:
return 0
else:
for i in range(len(seq)):
if seq[i] >= x:
return i
return len(seq)
return
|
./refactory/data/question_1/code/correct/correct_1_760.py
|
refactory_data_question_1_correct_1_015
|
def search(x, seq):
y = len(seq)
if y == 0 or x < seq[0]:
return 0
else:
for i in range(y-1):
if x > seq[i] and x <= seq[i+1]:
return i + 1
return y
|
./refactory/data/question_1/code/correct/correct_1_015.py
|
refactory_data_question_1_correct_1_483
|
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 """
index_for_x = 0
for index, element in enumerate(seq) :
if element < x:
index_for_x+=1
else:
break
return index_for_x
|
./refactory/data/question_1/code/correct/correct_1_483.py
|
refactory_data_question_1_correct_1_089
|
def search(x, seq):
for index, element in enumerate(seq):
if x <= element:
return index
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_089.py
|
refactory_data_question_1_correct_1_527
|
def search(x, seq):
if len(seq)==0 or x < seq[0]:
return 0
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/correct/correct_1_527.py
|
refactory_data_question_1_correct_1_050
|
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_050.py
|
refactory_data_question_1_correct_1_486
|
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_486.py
|
refactory_data_question_1_correct_1_322
|
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 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_322.py
|
refactory_data_question_1_correct_1_653
|
def search(x, seq):
counter = 0
for i in range(len(seq)):
if x <= seq[i]:
break
else:
counter += 1
return counter
|
./refactory/data/question_1/code/correct/correct_1_653.py
|
refactory_data_question_1_correct_1_327
|
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_327.py
|
refactory_data_question_1_correct_1_763
|
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
if x < seq[0]:
return 0
elif x > seq[len(seq)-1]:
return len(seq)
else:
for i in range(len(seq)):
if seq[i] == x:
return i
elif seq[i] <= x and seq[i+1] > x:
return i+1
|
./refactory/data/question_1/code/correct/correct_1_763.py
|
refactory_data_question_1_correct_1_348
|
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
a = 0
while n < len(seq):
if seq[n] < x:
n = n + 1
a = n
else:
break
return a
|
./refactory/data/question_1/code/correct/correct_1_348.py
|
refactory_data_question_1_correct_1_263
|
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_263.py
|
refactory_data_question_1_correct_1_413
|
def search(x, seq):
if seq == () or seq == []:
return 0
elif x < seq[0]:
return 0
elif x > seq[-1]:
return len(seq)
for i, elem in enumerate(seq):
if x <= elem:
return i
|
./refactory/data/question_1/code/correct/correct_1_413.py
|
refactory_data_question_1_correct_1_612
|
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 """
length = len(seq)
if length == 0:
return 0
else:
for i, elem in enumerate(seq):
if x < elem:
return i
else:
if x == elem:
return i
if (i == length-1):
return i+1
|
./refactory/data/question_1/code/correct/correct_1_612.py
|
refactory_data_question_1_correct_1_751
|
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 """
lst = list(seq)
lst.append(x)
lst.sort()
tup = tuple(enumerate(lst))
for i in range(len(tup)):
if tup[i][1]==x:
return tup[i][0]
|
./refactory/data/question_1/code/correct/correct_1_751.py
|
refactory_data_question_1_correct_1_097
|
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 len(seq)
|
./refactory/data/question_1/code/correct/correct_1_097.py
|
refactory_data_question_1_correct_1_129
|
def search(x, seq):
if len(seq) == 0:
return 0
else:
for i in seq:
if x <= i:
return seq.index(i)
elif x > max(seq):
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_129.py
|
refactory_data_question_1_correct_1_178
|
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_178.py
|
refactory_data_question_1_correct_1_609
|
def search(x, seq):
if len(seq)==0:
return 0
for i in range(len(seq)):
if x<=seq[i]:
return i
return i+1
|
./refactory/data/question_1/code/correct/correct_1_609.py
|
refactory_data_question_1_correct_1_200
|
def search(x, seq):
i=0
while i<len(seq):
if x<=seq[i]:
return i
else:
i+=1
return len(seq)
|
./refactory/data/question_1/code/correct/correct_1_200.py
|
refactory_data_question_1_correct_1_333
|
def search(x, seq):
if seq == ():
return 0
elif seq == []:
return 0
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/correct/correct_1_333.py
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.