id stringlengths 35 39 | content stringlengths 44 3.85k | max_stars_repo_path stringlengths 52 57 |
|---|---|---|
refactory_data_question_5_correct_5_349 | def top_k(lst, k):
list = []
while len(list) < k:
a = max(lst)
lst.remove(a)
list.append(a)
return list
| ./refactory/data/question_5/code/correct/correct_5_349.py |
refactory_data_question_5_correct_5_267 | def top_k(lst, k):
new, a = [], lst[0]
while lst:
for i in range(len(lst)):
new.append(max(lst))
lst.remove(max(lst))
return new[:k]
pass
| ./refactory/data/question_5/code/correct/correct_5_267.py |
refactory_data_question_5_correct_5_200 | def top_k(lst, k):
sorted_list = []
biggest = []
while lst:
largest = 0
for i in lst:
if i >= largest:
largest = i
lst.remove(largest)
sorted_list.append(largest) # from biggest to smallest
for j in range (k):
biggest.append(sorted_list... | ./refactory/data/question_5/code/correct/correct_5_200.py |
refactory_data_question_5_correct_5_275 | def top_k(lst, k):
sorted_lst = []
while lst:
biggest = lst[0]
for n in range(len(lst)):
if lst[n] >= biggest:
biggest = lst[n]
lst.remove(biggest)
sorted_lst.append(biggest)
return sorted_lst[0:k]
| ./refactory/data/question_5/code/correct/correct_5_275.py |
refactory_data_question_5_correct_5_361 | def top_k(lst, k):
sort = []
while lst:
big = max(lst)
sort.append(big)
lst.remove(big)
output = []
for i in range(k):
output.append(sort[i])
return output
| ./refactory/data/question_5/code/correct/correct_5_361.py |
refactory_data_question_5_correct_5_129 | def top_k(lst, k):
sort = []
while lst:
largest = lst[0]
for i in lst:
if i > largest:
largest = i
sort.append(largest)
lst.remove(largest)
top = sort[:k]
return top
| ./refactory/data/question_5/code/correct/correct_5_129.py |
refactory_data_question_5_correct_5_387 |
def top_k(lst, k):
x = []
for i in range(k):
a = 0
for ele in lst:
if ele >= a:
a = ele
lst.remove(a)
x.append(a)
return x
| ./refactory/data/question_5/code/correct/correct_5_387.py |
refactory_data_question_5_correct_5_279 | def top_k(lst, k):
new = []
for i in range(k):
largest = max(lst)
new += [largest]
lst.remove(largest)
return new
| ./refactory/data/question_5/code/correct/correct_5_279.py |
refactory_data_question_5_correct_5_318 | def top_k(lst, k):
# Fill in your code here
sort_lst = []
while lst:
biggest = lst[0]
for element in lst:
if element > biggest:
biggest = element
lst.remove(biggest)
sort_lst.append(biggest)
return sort_lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_318.py |
refactory_data_question_5_correct_5_117 | def sort(lst):
newlst=[]
while lst:
minimum=lst[0]
for x in lst:
if x>minimum:
minimum=x
newlst.append(minimum)
lst.remove(minimum)
return newlst
def top_k(lst, k):
lst=sort(lst)
return lst[:k]
# Fill in your code here
| ./refactory/data/question_5/code/correct/correct_5_117.py |
refactory_data_question_5_correct_5_311 |
def top_k(lst, k):
# Fill in your code here
result = []
while lst:
minimum = lst[0] # arbitrary number in list
for x in lst:
if x > minimum:
minimum = x
result.append(minimum)
lst.remove(minimum)
return result[:k]
| ./refactory/data/question_5/code/correct/correct_5_311.py |
refactory_data_question_5_correct_5_225 | def top_k(lst, k):
a=[]
while lst:
largest = lst[0]
for i in lst:
if i > largest:
largest = i
lst.remove(largest)
a.append(largest)
return a[:k]
| ./refactory/data/question_5/code/correct/correct_5_225.py |
refactory_data_question_5_correct_5_204 | def top_k(lst, k):
sort = []
counter = 0
while counter != k:
sort.append(max(lst))
lst.remove(max(lst))
counter += 1
return sort
| ./refactory/data/question_5/code/correct/correct_5_204.py |
refactory_data_question_5_correct_5_310 |
def top_k(lst, k):
# Fill in your code here
data_list = lst
new_list = []
while data_list:
minimum = data_list[0] # arbitrary number in list
for x in data_list:
if x > minimum:
minimum = x
new_list.append(minimum)
data_list.remove(minimum) ... | ./refactory/data/question_5/code/correct/correct_5_310.py |
refactory_data_question_5_correct_5_008 | def top_k(lst, k):
stop = False
result = []
while k>0:
highest = 0
index = 0
for i in range(0,len(lst)):
if lst[i]>highest:
index = i
highest = lst[i]
result = result + [highest]
lst.pop(index)
k = k - 1
return r... | ./refactory/data/question_5/code/correct/correct_5_008.py |
refactory_data_question_5_correct_5_171 | def top_k(lst, k):
final = []
while lst:
biggest = lst[0]
for i in lst:
if i>biggest:
biggest = i
lst.remove(biggest)
final.append(biggest)
return final[:k]
| ./refactory/data/question_5/code/correct/correct_5_171.py |
refactory_data_question_5_correct_5_090 | def top_k(lst, k):
result = []
while lst:
biggest = lst[0]
for number in lst:
if number > biggest:
biggest = number
lst.remove(biggest)
result.append(biggest)
return result[:k]
| ./refactory/data/question_5/code/correct/correct_5_090.py |
refactory_data_question_5_correct_5_176 | def top_k(lst, k):
def sort(lst2):
holder=[]
if lst==[]:
return []
for x in lst:
if holder==[]:
holder=x
elif x>holder:
holder=x
lst.remove(holder)
return [holder]+sort(lst)
counter=k
final=[]
new... | ./refactory/data/question_5/code/correct/correct_5_176.py |
refactory_data_question_5_correct_5_149 | def top_k(lst, k):
def sortme(lst):
sort=[]
while lst:
largest=lst[0]
for i in lst:
if i>largest:
largest=i
lst.remove(largest)
sort.append(largest)
return sort
return sortme(lst)[:k]
| ./refactory/data/question_5/code/correct/correct_5_149.py |
refactory_data_question_5_correct_5_400 | def top_k(lst, k):
l = []
if k > len(lst):
return False
elif k == 1:
return lst
else:
while len(l) < k:
a = max(lst)
lst.remove(a)
l.append(a)
return l
# Fill in your code here
pass
| ./refactory/data/question_5/code/correct/correct_5_400.py |
refactory_data_question_5_correct_5_144 | def top_k(lst, k):
sort = []
while lst:
largest = lst[0]
for e in lst:
if e > largest:
largest = e
lst.remove(largest)
sort.append(largest)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_144.py |
refactory_data_question_5_correct_5_140 | def top_k(lst, k):
new_list = []
while len(new_list) != k:
largest = lst[0]
for i in lst:
if largest < i:
largest = i
else:
continue
new_list += [largest]
lst.remove(largest)
return new_list
| ./refactory/data/question_5/code/correct/correct_5_140.py |
refactory_data_question_5_correct_5_093 | def top_k(lst, k):
# Fill in your code here
sort = []
while lst:
largest = lst[0]
for i in range(len(lst)):
if lst[i] > largest:
largest = lst[i]
sort.append(largest)
lst.remove(largest)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_093.py |
refactory_data_question_5_correct_5_155 | def top_k(lst, k):
result = 0
new_list = []
while result < k:
temp = max(lst)
new_list.append(temp)
lst.remove(temp)
result = result + 1
return new_list
| ./refactory/data/question_5/code/correct/correct_5_155.py |
refactory_data_question_5_correct_5_138 | def top_k(lst, k):
rs=[]
for qwerty in range(0,k):
biggest=lst[0]
for k in lst:
if biggest<k:
biggest=k
rs.append(biggest)
lst.remove(biggest)
return rs
| ./refactory/data/question_5/code/correct/correct_5_138.py |
refactory_data_question_5_correct_5_170 | def top_k(lst, k):
new = []
i = 1
while i <= k:
element = find_largest(lst)
new.append(element)
lst.remove(element)
i = i+1
return new
def find_largest(lst):
largest = lst[0]
for element in lst:
if element > largest:
largest = element
retu... | ./refactory/data/question_5/code/correct/correct_5_170.py |
refactory_data_question_5_correct_5_321 | def top_k(lst, k):
new_lst=[]
def bubble_sort(lst):
swap = True
while swap:
swap = False
for i in range(len(lst)-1):
if lst[i]<lst[i+1]:
lst[i],lst[i+1]=lst[i+1],lst[i]
swap =True
return lst
sorted_lst = ... | ./refactory/data/question_5/code/correct/correct_5_321.py |
refactory_data_question_5_correct_5_273 | def top_k(lst, k):
product = []
while k > 0:
product += [max(lst)]
k = k -1
lst.remove(max(lst))
return product
| ./refactory/data/question_5/code/correct/correct_5_273.py |
refactory_data_question_5_correct_5_260 | def top_k(lst, k):
af_sort = []
while lst:
biggest = lst[0]
for element in lst:
if element > biggest:
biggest = element
lst.remove(biggest)
af_sort.append(biggest)
return af_sort[0:k]
| ./refactory/data/question_5/code/correct/correct_5_260.py |
refactory_data_question_5_correct_5_336 |
def biggest(lst):
big=lst[0]
for i in range (len(lst)):
if lst[i]>big:
big=lst[i]
else:
continue
return big
def top_k(lst, k):
l=len(lst)
new_list=[]
for i in range (l):
new_list.append(biggest(lst))
lst.remove(biggest(lst))
retur... | ./refactory/data/question_5/code/correct/correct_5_336.py |
refactory_data_question_5_correct_5_076 | def top_k(lst, k):
"""
sorts list in descending order
returns the greatest k number of values (last k elements)
"""
def merge(left,right):
merged = []
while left and right:
if left[0] > right[0]:
merged.append(left.pop(0))
else:
... | ./refactory/data/question_5/code/correct/correct_5_076.py |
refactory_data_question_5_correct_5_119 | def top_k(lst, k):
def sorter(lst):
newlst = []
while lst:
current = lst[0]
for element in lst:
if element > current:
current = element
newlst.append(current)
lst.remove(current)
return newlst
return sort... | ./refactory/data/question_5/code/correct/correct_5_119.py |
refactory_data_question_5_correct_5_163 | def top_k(lst, k):
n= []
while lst:
big = lst[0]
for ele in lst:
if ele>big:
big = ele
if len(n)==k:
break
else:
n.append(big)
lst.remove(big)
return n
pass
| ./refactory/data/question_5/code/correct/correct_5_163.py |
refactory_data_question_5_correct_5_331 | def top_k(lst, k):
count=0
newlst=[]
while lst:
newlst+=[max(lst)]
lst.remove(max(lst))
for i in range(k):
lst.append(newlst[i])
return lst
| ./refactory/data/question_5/code/correct/correct_5_331.py |
refactory_data_question_5_correct_5_271 | def top_k(lst, n):
for j in range(len(lst)):
maxi=lst[j]
for k in range(j+1,len(lst)):
if lst[k]>maxi:
maxi=lst[k]
lst[j],lst[k]=lst[k],lst[j]
result=lst[0:n]
return result
| ./refactory/data/question_5/code/correct/correct_5_271.py |
refactory_data_question_5_correct_5_385 | def top_k(lst, k):
newlst=[]
while lst:
largest=lst[0]
for i in lst:
if largest<i:
largest=i
newlst.append(largest)
lst.remove(largest)
return newlst[:k]
| ./refactory/data/question_5/code/correct/correct_5_385.py |
refactory_data_question_5_correct_5_415 | def top_k(lst, k):
new_lst = []
counter = 1
while counter <= k:
highest = lst[0] # arbitrary number in list
for x in lst:
if x > highest:
highest = x
new_lst.append(highest)
lst.remove(highest)
counter +=1
return new_lst
| ./refactory/data/question_5/code/correct/correct_5_415.py |
refactory_data_question_5_correct_5_232 | def top_k(lst, k):
for start in range(len(lst)-1):
maximum = start
for i in range(start, len(lst)):
if lst[i] > lst[maximum]:
maximum = i
lst[maximum], lst[start] = lst[start], lst[maximum]
return lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_232.py |
refactory_data_question_5_correct_5_086 | def top_k(lst, k):
new_lst = []
while len(new_lst) != k:
new_lst.append(max(lst))
lst.remove(max(lst))
return new_lst
| ./refactory/data/question_5/code/correct/correct_5_086.py |
refactory_data_question_5_correct_5_124 | def top_k(lst, k):
# Fill in your code here
def ins_sort(a):
i = 1
while i < len(a):
j = i
while j>0 and a[j-1] > a[j]:
a[j], a[j-1] = a[j-1], a[j]
j-=1
i+=1
return a[::-1]
lst_sorted = ins_sort(lst)
... | ./refactory/data/question_5/code/correct/correct_5_124.py |
refactory_data_question_5_correct_5_038 | def top_k(lst, k):
tmp = []
while len(lst) > 0:
tmp.append(max(lst))
lst.remove(max(lst))
return tmp[:k]
| ./refactory/data/question_5/code/correct/correct_5_038.py |
refactory_data_question_5_correct_5_148 | def top_k(lst, k):
if lst==[]:
return []
sort=[]
while lst:
largest = lst[0]
for i in lst:
if i > largest:
largest = i
lst.remove(largest)
sort.append(largest)
return sort[:k]
pass
| ./refactory/data/question_5/code/correct/correct_5_148.py |
refactory_data_question_5_correct_5_359 | def top_k(lst,k):
result=[]
while lst:
minimum=lst[0]
for i in lst:
if i<minimum:
minimum=i
result.append(minimum)
lst.remove(minimum)
result=result[::-1]
return result[:k]
| ./refactory/data/question_5/code/correct/correct_5_359.py |
refactory_data_question_5_correct_5_344 | def top_k(lst, k):
#assumes not nested lists
new = []
count = 0
while count < k:
largest = lst[0]
for ele in lst:
if ele > largest:
largest = ele
lst.remove(largest)
new.append(largest)
count = count + 1
return new
| ./refactory/data/question_5/code/correct/correct_5_344.py |
refactory_data_question_5_correct_5_234 | def top_k(lst, k):
results = []
for i in range(k):
results.append(max(lst))
lst.remove(max(lst))
return results
| ./refactory/data/question_5/code/correct/correct_5_234.py |
refactory_data_question_5_correct_5_001 | def top_k(lst, k):
res = []
for i in range(k):
res.append(max(lst))
lst.remove(max(lst))
return res
| ./refactory/data/question_5/code/correct/correct_5_001.py |
refactory_data_question_5_correct_5_329 | def top_k(lst, k):
swap = True
while swap:
swap = False
for i in range(len(lst)-1):
if lst[i] < lst[i+1]:
lst[i], lst[i+1] = lst[i+1], lst[i]
swap = True
#lst order done
return lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_329.py |
refactory_data_question_5_correct_5_037 | def top_k(lst, k):
sort_list = []
counter = 0
while counter < k:
sort_list.append(max(lst))
lst.remove(max(lst))
counter = counter + 1
return sort_list
| ./refactory/data/question_5/code/correct/correct_5_037.py |
refactory_data_question_5_correct_5_280 | def top_k(lst, k):
sort = []
i = 0
while i < k:
smallest = lst[0]
for element in lst:
if element > smallest:
smallest = element
lst.remove(smallest)
sort.append(smallest)
i += 1
return sort
| ./refactory/data/question_5/code/correct/correct_5_280.py |
refactory_data_question_5_correct_5_088 | def top_k(lst, k):
final = []
while len(final) != k:
a = max(lst)
final.append(a)
lst.remove(a)
return final
| ./refactory/data/question_5/code/correct/correct_5_088.py |
refactory_data_question_5_correct_5_352 | def top_k(lst, k):
res=[]
while len(res)<k:
res.append(max(lst))
lst.remove(max(lst))
return res
| ./refactory/data/question_5/code/correct/correct_5_352.py |
refactory_data_question_5_correct_5_326 | def top_k(lst,k):
sort = []
while lst:
biggest = lst[0]
for element in lst:
if element > biggest:
biggest = element
lst.remove(biggest)
sort.append(biggest)
new_sort = []
for i in range (k):
new_sort += [sort[i]]
return new_sort
| ./refactory/data/question_5/code/correct/correct_5_326.py |
refactory_data_question_5_correct_5_027 | def top_k(lst, k):
sortedlst = []
while len(sortedlst) != k:
largest = lst[0]
for el in lst:
if el > largest:
largest = el
sortedlst.append(largest)
lst.remove(largest)
return sortedlst
| ./refactory/data/question_5/code/correct/correct_5_027.py |
refactory_data_question_5_correct_5_081 | def top_k(lst, k):
# Fill in your code here
new = []
for i in range(k):
a = max(lst)
lst.remove(a)
new.append(a)
return new
| ./refactory/data/question_5/code/correct/correct_5_081.py |
refactory_data_question_5_correct_5_106 | def top_k(lst, k):
if lst == []:
return lst
def sorting(nlist):
if nlist == []:
return nlist
lower = []
higher = []
plist = []
pivot = nlist[0]
for e in nlist:
if e < pivot:
lower.append(e)
elif e ==... | ./refactory/data/question_5/code/correct/correct_5_106.py |
refactory_data_question_5_correct_5_177 | def top_k(lst, k):
sort = []
while lst:
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
sort.append(largest)
return sort[0:k]
| ./refactory/data/question_5/code/correct/correct_5_177.py |
refactory_data_question_5_correct_5_199 | def top_k(lst, k):
sorted_list = []
biggest = []
while lst:
largest = 0
for i in lst:
if i >= largest:
largest = i
lst.remove(largest)
sorted_list.append(largest) # from biggest to smallest
for j in range (k):
biggest.append(sorted_list... | ./refactory/data/question_5/code/correct/correct_5_199.py |
refactory_data_question_5_correct_5_166 | def top_k(lst, k):
new_lst = []
while lst:
largest = lst[0]
for numbers in lst:
if numbers > largest:
largest = numbers
new_lst.append(largest)
lst.remove(largest)
return new_lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_166.py |
refactory_data_question_5_correct_5_041 | def top_k(lst, k):
new_lst = []
while lst:
maxi = lst[0]
for item in lst:
if item > maxi:
maxi = item
new_lst.append(maxi)
lst.remove(maxi)
return new_lst[0:k]# Fill in your code here
| ./refactory/data/question_5/code/correct/correct_5_041.py |
refactory_data_question_5_correct_5_386 | def top_k(lst, k):
num, result = max(lst), []
while len(result) < k:
if num in lst:
result.append(num)
lst.remove(num)
elif num not in lst:
num -= 1
continue
return result
| ./refactory/data/question_5/code/correct/correct_5_386.py |
refactory_data_question_5_correct_5_196 | def top_k(lst, k):
if lst == [] or k == 0:
return []
else:
final = []
while lst:
element = max(lst)
final += [element,]
lst.remove(element)
if len(final) == k:
break
return final
| ./refactory/data/question_5/code/correct/correct_5_196.py |
refactory_data_question_5_correct_5_209 | def top_k(lst, k):
newlist = []
while len(newlist)<k:
newlist.append(max(lst))
lst.remove(max(lst))
return newlist
| ./refactory/data/question_5/code/correct/correct_5_209.py |
refactory_data_question_5_correct_5_226 | def top_k(lst, k):
sort = []
while lst:
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
sort.append(largest)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_226.py |
refactory_data_question_5_correct_5_244 | def top_k(lst,k):
sort = []
while lst:
largest = lst[0]
for element in lst:
if largest < element:
largest = element
lst.remove(largest)
sort.append(largest)
return sort[0:k]
| ./refactory/data/question_5/code/correct/correct_5_244.py |
refactory_data_question_5_correct_5_360 | def sort_list(lst):
if len(lst) < 2:
return lst
for i in range(len(lst)-1):
min = i
for j in range(i+1, len(lst)):
if lst[min] > lst[j]:
min = j
lst[i], lst[min] = lst[min], lst[i]
lst.reverse()
return lst
def top_k(lst, k):
ans = sort_l... | ./refactory/data/question_5/code/correct/correct_5_360.py |
refactory_data_question_5_correct_5_169 | def top_k(lst, k):
result = []
for x in range(k):
result.append(max(lst))
lst.remove(max(lst))
return result
| ./refactory/data/question_5/code/correct/correct_5_169.py |
refactory_data_question_5_correct_5_145 | def top_k(lst, k):
sort = []
while lst:
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
sort.append(largest)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_145.py |
refactory_data_question_5_correct_5_315 | def top_k(lst, k):
def sortedd(lst):
for j in range(len(lst)-1):
for i in range(len(lst)-1):
if lst[i] < lst[i+1]:
lst[i], lst[i+1] = lst[i+1], lst[i]
return lst
return sortedd(lst)[:k]
| ./refactory/data/question_5/code/correct/correct_5_315.py |
refactory_data_question_5_correct_5_338 | def top_k(lst, k):
result = []
for x in range(k):
result.append(max(lst))
lst.remove(max(lst))
return result
| ./refactory/data/question_5/code/correct/correct_5_338.py |
refactory_data_question_5_correct_5_122 | def top_k(lst, k):
# Fill in your code here
sort = []
while lst: # a is not []
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
sort.append(largest)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_122.py |
refactory_data_question_5_correct_5_073 | def top_k(lst, k):
newlst = []
for i in range(k):
newlst.append(max(lst))
lst.remove(max(lst))
return newlst
| ./refactory/data/question_5/code/correct/correct_5_073.py |
refactory_data_question_5_correct_5_005 | def top_k(lst, k):
ls=[]
for i in range(k):
ls.append(max(lst))
lst.remove(max(lst))
return ls
| ./refactory/data/question_5/code/correct/correct_5_005.py |
refactory_data_question_5_correct_5_243 | def top_k(lst, k):
if lst == [] or k == 0:
return []
sort = []
while lst:
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
sort.append(largest)
if len(sort) > k-1:
break
return sort
| ./refactory/data/question_5/code/correct/correct_5_243.py |
refactory_data_question_5_correct_5_255 | def top_k(lst, k):
list = []
while len(list) < k:
a = max(lst)
lst.remove(a)
list.append(a)
return list
| ./refactory/data/question_5/code/correct/correct_5_255.py |
refactory_data_question_5_correct_5_043 | def top_k(lst, k):
sort = []
if k==0 or lst==[]:
return []
while lst:
biggest = lst[0]
for element in lst:
if element > biggest:
biggest = element
lst.remove(biggest)
sort.append(biggest)
if len(sort)==k:
... | ./refactory/data/question_5/code/correct/correct_5_043.py |
refactory_data_question_5_correct_5_381 | def top_k(lst, k):
newlst=[]
while lst:
largest=lst[0]
for i in lst:
if largest<i:
largest=i
newlst.append(largest)
lst.remove(largest)
return newlst[:k]
| ./refactory/data/question_5/code/correct/correct_5_381.py |
refactory_data_question_5_correct_5_304 | def top_k(lst, k):
for j in range(len(lst)-1):
for i in range(len(lst)-1):
if lst[i] < lst[i+1]:
lst[i], lst[i+1] = lst[i+1], lst[i]
return lst[0:k]
pass
| ./refactory/data/question_5/code/correct/correct_5_304.py |
refactory_data_question_5_correct_5_266 | def top_k(lst, k):
n= []
while lst:
big = lst[0]
for ele in lst:
if ele>big:
big = ele
if len(n)==k:
break
else:
n.append(big)
lst.remove(big)
return n
pass
| ./refactory/data/question_5/code/correct/correct_5_266.py |
refactory_data_question_5_correct_5_203 | def top_k(lst, k):
def sort(lst):
sort_list = []
while lst: # a is not []
biggest = lst[0]
for element in lst:
if element > biggest:
biggest = element
lst.remove(biggest)
sort_list.append(biggest)
return sort... | ./refactory/data/question_5/code/correct/correct_5_203.py |
refactory_data_question_5_correct_5_082 | def top_k(lst, k):
new_lst = []
for i in range(k):
new_lst.append(max(lst))
lst.remove(max(lst))
return new_lst
pass
| ./refactory/data/question_5/code/correct/correct_5_082.py |
refactory_data_question_5_correct_5_071 | def top_k(lst, k):
sort_list = []
counter = 0
while counter < k:
sort_list.append(max(lst))
lst.remove(max(lst))
counter = counter + 1
return sort_list
| ./refactory/data/question_5/code/correct/correct_5_071.py |
refactory_data_question_5_correct_5_238 | def top_k(lst, k):
lst = sorting(lst)
new = []
for i in range(k):
new.append(lst[0])
del lst[0]
return new
def sorting(lst):
sorted_lst = []
while lst:
smallest = lst[0]
for i in lst:
if i < smallest:
smallest = i
lst.remove(sm... | ./refactory/data/question_5/code/correct/correct_5_238.py |
refactory_data_question_5_correct_5_355 | def top_k(lst, k):
for start in range (len(lst) - 1):
for i in range(start, len(lst)):
if lst[i] > lst[start]:
lst[i], lst[start] = lst[start], lst[i]
return lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_355.py |
refactory_data_question_5_correct_5_353 | def top_k(lst, k):
newlist = []
while lst:
biggest = lst[0]
for i in lst:
if i > biggest:
biggest = i
else:
continue
lst.remove(biggest)
if len(newlist) == k:
break
else:
newlist.append(bigges... | ./refactory/data/question_5/code/correct/correct_5_353.py |
refactory_data_question_5_correct_5_161 | def top_k(lst, k):
sorted_list = []
while lst:
smallest = lst[0]
for element in lst:
if element < smallest:
smallest = element
lst.remove(smallest)
sorted_list.append(smallest)
final = sorted_list[::-1]
return final[:k]
| ./refactory/data/question_5/code/correct/correct_5_161.py |
refactory_data_question_5_correct_5_301 | def top_k(lst, k):
def pos(seq,i):
n = len(seq)
for j in range(n):
if seq[j] == i:
return j
def largest(seq):
largest = seq[0]
for i in seq:
if i > largest:
largest = i
return pos(seq,largest)
n_list =[]
if k... | ./refactory/data/question_5/code/correct/correct_5_301.py |
refactory_data_question_5_correct_5_217 | def top_k(lst, k):
descending_list=[]
while lst:
largest=lst[0]
for i in lst:
if i>largest:
largest=i
descending_list.append(largest)
lst.remove(largest)
return descending_list[:k]
| ./refactory/data/question_5/code/correct/correct_5_217.py |
refactory_data_question_5_correct_5_104 | def top_k(lst, k):
new=[]
for i in range(k):
biggest=lst[0]
for element in lst:
if element>biggest:
biggest=element
new.append(biggest)
lst.remove(biggest)
return new
| ./refactory/data/question_5/code/correct/correct_5_104.py |
refactory_data_question_5_correct_5_398 | def top_k(lst, k):
final = []
while lst:
biggest = lst[0]
for i in lst:
if i>biggest:
biggest = i
lst.remove(biggest)
final.append(biggest)
return final[:k]
| ./refactory/data/question_5/code/correct/correct_5_398.py |
refactory_data_question_5_correct_5_185 | def sort(lst):
sort = []
while lst:
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
sort.append(largest)
return sort
def top_k(lst, k):
sorted_list = sort(lst)
result = sorted_list[:k]
return result
| ./refactory/data/question_5/code/correct/correct_5_185.py |
refactory_data_question_5_correct_5_259 | def top_k(lst, k):
newlst = []
while len(newlst) < k:
newlst += (lst.pop(lst.index(max(lst))),)
return newlst
| ./refactory/data/question_5/code/correct/correct_5_259.py |
refactory_data_question_5_correct_5_412 | def top_k(lst, k):
sort = []
sort_top_k = []
while lst:
biggest = lst[0]
for element in lst:
if element > biggest:
biggest = element
lst.remove(biggest)
sort.append(biggest)
if len(sort) < k:
k = len(sort)
for i in range(k):
... | ./refactory/data/question_5/code/correct/correct_5_412.py |
refactory_data_question_5_correct_5_078 | def top_k(lst,k): #k is the number of values in the lst
lst2 = []
while lst:
a = max(lst)
lst2.append(a)
lst.remove(a)
return lst2[0:k]
| ./refactory/data/question_5/code/correct/correct_5_078.py |
refactory_data_question_5_correct_5_080 | def top_k(lst, k):
# Fill in your code here
sorted = []
while lst:
smallest = lst[0] # smallest has to exist within this step
for i in lst:
if i < smallest:
smallest = i # take note: you must not reverse this step
sorted.append(smallest)
... | ./refactory/data/question_5/code/correct/correct_5_080.py |
refactory_data_question_5_correct_5_048 | def top_k(lst, k):
sort = []
if k==0 or lst==[]:
return []
while lst:
biggest = lst[0]
for element in lst:
if element > biggest:
biggest = element
lst.remove(biggest)
sort.append(biggest)
if len(sort)==k:
... | ./refactory/data/question_5/code/correct/correct_5_048.py |
refactory_data_question_5_correct_5_410 | def top_k(lst, k):
newlst = []
for i in range(k):
newlst.append(max(lst))
lst.remove(max(lst))
return newlst
| ./refactory/data/question_5/code/correct/correct_5_410.py |
refactory_data_question_5_correct_5_413 | def top_k(lst,k):
output = []
for i in range(k):
largest = max(lst)
lst.remove(largest)
output.append(largest)
return output
| ./refactory/data/question_5/code/correct/correct_5_413.py |
refactory_data_question_5_correct_5_111 | def merge_sort(lst):
if len(lst) < 2:
return lst
mid = len(lst) // 2
left = merge_sort(lst[:mid])
right = merge_sort(lst[mid:])
return merge(left, right)
def merge(left, right):
results = []
while left and right:
if left[0] < right[0]:
results.append(le... | ./refactory/data/question_5/code/correct/correct_5_111.py |
refactory_data_question_5_correct_5_249 | def top_k(lst, k):
sort = []
while lst:
largest = lst[0]
for x in lst:
if x > largest:
largest = x
lst.remove(largest)
sort.append(largest)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_249.py |
refactory_data_question_5_correct_5_024 | def top_k(lst, k):
max_lst =[]
i = 0
while i < k:
max_lst.append(max(lst))
lst.remove(max(lst))
i += 1
return max_lst
| ./refactory/data/question_5/code/correct/correct_5_024.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.