id stringlengths 35 39 | content stringlengths 44 3.85k | max_stars_repo_path stringlengths 52 57 |
|---|---|---|
refactory_data_question_5_correct_5_218 | 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_218.py |
refactory_data_question_5_correct_5_108 | def top_k(lst, k):
if k == 0 or lst == []:
return []
else:
sort, output = [], []
while lst:
largest = lst[0]
for i in lst:
if i > largest:
largest = i
lst.remove(largest)
sort.append(largest)
for ... | ./refactory/data/question_5/code/correct/correct_5_108.py |
refactory_data_question_5_correct_5_314 | 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
return lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_314.py |
refactory_data_question_5_correct_5_187 | def top_k(lst, k):
if k>len(lst):
return None
def newsort(lsts):
l=[]
while lsts:
biggest=lsts[0]
for element in lsts:
if element>biggest:
biggest=element
l.append(biggest)
lsts.remove(biggest)
re... | ./refactory/data/question_5/code/correct/correct_5_187.py |
refactory_data_question_5_correct_5_165 | def top_k(lst, k):
result = []
for i in range(len(lst)):
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
result.append(largest)
return result[:k]
| ./refactory/data/question_5/code/correct/correct_5_165.py |
refactory_data_question_5_correct_5_354 | 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_354.py |
refactory_data_question_5_correct_5_181 | def top_k(lst, k):
a = lst
sort=[]
while a:
smallest = a[0]
for element in a:
if element<smallest:
smallest = element
a.remove(smallest)
sort.append(smallest)
sort.reverse()
return sort[0:k]
| ./refactory/data/question_5/code/correct/correct_5_181.py |
refactory_data_question_5_correct_5_035 | def top_k(lst, k):
result = []
while lst:
largest = lst[0]
for i in lst:
if i>largest:
largest = i
lst.remove(largest)
result.append(largest)
return result[:k]
#def sort_age(lst):
# sort = []... | ./refactory/data/question_5/code/correct/correct_5_035.py |
refactory_data_question_5_correct_5_269 | 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_269.py |
refactory_data_question_5_correct_5_087 | def top_k(lst,k):
n = len(lst)
result = []
while n !=0:
test =[]
for counter in range(n):
test.append(lst[counter])
first = max(test)
for counter in range(n):
if lst[counter] == first:
result.append(lst.pop(counter))
bre... | ./refactory/data/question_5/code/correct/correct_5_087.py |
refactory_data_question_5_correct_5_002 | 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_002.py |
refactory_data_question_5_correct_5_351 | def top_k(lst, k):
lst = sort_descending(lst)
return lst[:k]
def sort_descending(lst):
for i in range(len(lst)-1):
for j in range(i, len(lst)):
if lst[j] > lst[i]:
x = lst[i]
lst[i] = lst[j]
lst[j] = x
return lst
| ./refactory/data/question_5/code/correct/correct_5_351.py |
refactory_data_question_5_correct_5_283 | def top_k(lst,k):
n = len(lst)
result = []
while n !=0:
test =[]
for counter in range(n):
test.append(lst[counter])
first = max(test)
for counter in range(n):
if lst[counter] == first:
result.append(lst.pop(counter))
bre... | ./refactory/data/question_5/code/correct/correct_5_283.py |
refactory_data_question_5_correct_5_206 | def top_k(lst, k):
i=0
while i+1<len(lst):
if lst[i]<lst[i+1]:
lst.extend([lst[i]])
lst.pop(i)
i=0
else:
i+=1
return lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_206.py |
refactory_data_question_5_correct_5_052 | 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_052.py |
refactory_data_question_5_correct_5_374 | def top_k(lst, k):
result = []
while lst:
biggest = lst[0]
for elem in lst:
if elem > biggest:
biggest = elem
lst.remove(biggest)
result.append(biggest)
return result[:k]
# Fill in your code here
pass
| ./refactory/data/question_5/code/correct/correct_5_374.py |
refactory_data_question_5_correct_5_197 | def top_k(lst, k):
for item in range(len(lst)):
for test in range(len(lst)):
if lst[test] < lst[item]:
lst[test], lst[item] = lst[item], lst[test]
return lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_197.py |
refactory_data_question_5_correct_5_009 | def top_k(lst, k):
lst_res = lst
sort = []
while lst_res:
largest = lst_res[0]
for elements in lst_res:
if elements > largest:
largest = elements
lst_res.remove(largest)
sort.append(largest)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_009.py |
refactory_data_question_5_correct_5_346 | def top_k(lst, k):
new = []
while lst:
largest = lst[0]
for i in lst:
if i > largest:
largest = i
new.append(largest)
lst.remove(largest)
if k > len(new):
return new
else:
return new[:k]
| ./refactory/data/question_5/code/correct/correct_5_346.py |
refactory_data_question_5_correct_5_026 | def top_k(lst, k):
result = []
while len(result) < k:
biggest = lst[0]
for i in lst:
if i > biggest:
biggest = i
lst.remove(biggest)
result.append(biggest)
return result
| ./refactory/data/question_5/code/correct/correct_5_026.py |
refactory_data_question_5_correct_5_062 | def top_k(lst, k):
new = []
while lst:
largest = lst[0]
for i in lst:
if i > largest:
largest = i
new.append(largest)
lst.remove(largest)
if k > len(new):
return new
else:
return new[:k]
| ./refactory/data/question_5/code/correct/correct_5_062.py |
refactory_data_question_5_correct_5_021 | def top_k(lst, k):
product = []
while lst:
largest = lst[0]
for i in lst:
if i>largest:
largest = i
lst.remove(largest)
product.append(largest)
return product[:k]
| ./refactory/data/question_5/code/correct/correct_5_021.py |
refactory_data_question_5_correct_5_033 | 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_033.py |
refactory_data_question_5_correct_5_186 | def top_k(lst, k):
unsorted = lst
result = []
while True:
if len(result) == k:
break
result += [max(unsorted),]
unsorted.remove(max(unsorted))
return result
| ./refactory/data/question_5/code/correct/correct_5_186.py |
refactory_data_question_5_correct_5_180 | def top_k(lst, k):
def rank(lyst):
if len(lyst)==1:
return list(lyst)
else:
a = max(lyst)
lyst.remove(a)
return [a]+ rank(lyst)
new_list = rank(lst)
return new_list[:k]
| ./refactory/data/question_5/code/correct/correct_5_180.py |
refactory_data_question_5_correct_5_025 | def top_k(lst, k):
new_lst = []
while len(new_lst) < k:
maximum = max(lst)
new_lst.append(maximum)
lst.remove(maximum)
return new_lst
| ./refactory/data/question_5/code/correct/correct_5_025.py |
refactory_data_question_5_correct_5_286 | def top_k(lst, k):
n = len(lst)
new =[]
for i in range(0,n):
largest = max(lst)
lst.remove(largest)
new.append(largest)
return new[:k]
| ./refactory/data/question_5/code/correct/correct_5_286.py |
refactory_data_question_5_correct_5_018 | 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_018.py |
refactory_data_question_5_correct_5_305 | def top_k(lst, k):
new = []
for i in range(k):
top = max(lst)
new.append(top)
lst.remove(top)
return new
| ./refactory/data/question_5/code/correct/correct_5_305.py |
refactory_data_question_5_correct_5_306 | def top_k(lst, k):
result = []
while lst:
biggest = lst[0]
for item in lst:
if item > biggest:
biggest = item
lst.remove(biggest)
result.append(biggest)
return result[:k]
| ./refactory/data/question_5/code/correct/correct_5_306.py |
refactory_data_question_5_correct_5_079 | 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_079.py |
refactory_data_question_5_correct_5_131 | 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)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_131.py |
refactory_data_question_5_correct_5_034 | def top_k(lst, k):
sort = []
while lst:
biggest = lst[0]
for i in lst:
if i > biggest:
biggest = i
lst.remove(biggest)
sort.append(biggest)
return sort[0:k]
| ./refactory/data/question_5/code/correct/correct_5_034.py |
refactory_data_question_5_correct_5_050 | def top_k(lst, k):
new = []
while lst:
largest = lst[0]
for a in lst:
if a > largest:
largest = a
lst.remove(largest)
new.append(largest)
return new[0:k]
| ./refactory/data/question_5/code/correct/correct_5_050.py |
refactory_data_question_5_correct_5_348 | def top_k(lst, k):
for i in range(0,len(lst)-1):
for j in range(i+1,len(lst)):
if lst[i]<lst[j]:
lst[i],lst[j]=lst[j],lst[i]
return lst[0:k]
| ./refactory/data/question_5/code/correct/correct_5_348.py |
refactory_data_question_5_correct_5_030 | 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_030.py |
refactory_data_question_5_correct_5_068 | 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_068.py |
refactory_data_question_5_correct_5_391 | def sort(lst):
if lst==[]:
return []
new_lst=[lst[0],]
for x in lst[1:]:
if x > new_lst[-1]:
new_lst += [x,]
else:
count=0
while count<len(new_lst):
if x > new_lst[count]:
count+=1
continue
... | ./refactory/data/question_5/code/correct/correct_5_391.py |
refactory_data_question_5_correct_5_060 | def top_k(lst, k):
sorted_lst = []
while lst:
largest = lst[0]
for element in lst:
if element > largest:
largest = element
lst.remove(largest)
sorted_lst.append(largest)
return sorted_lst[:k]
pass
| ./refactory/data/question_5/code/correct/correct_5_060.py |
refactory_data_question_5_correct_5_032 |
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_032.py |
refactory_data_question_5_correct_5_214 | def top_k(lst, k):
new = []
counter = k
while counter > 0:
curr = 0
for i in range(len(lst)):
if lst[i] > lst[curr]:
curr = i
new.append(lst.pop(curr))
counter -= 1
return new
| ./refactory/data/question_5/code/correct/correct_5_214.py |
refactory_data_question_5_correct_5_212 | def top_k(lst, k):
new_lst = []
while lst:
largest = lst[0]
for i in lst:
if i > largest:
largest = i
lst.remove(largest)
new_lst.append(largest)
return new_lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_212.py |
refactory_data_question_5_correct_5_022 | def top_k(lst, k):
ret = []
for i in range(k):
max_int_pos = lst.index(max(lst))
ret.append(lst.pop(max_int_pos))
return ret
| ./refactory/data/question_5/code/correct/correct_5_022.py |
refactory_data_question_5_correct_5_101 | def top_k(lst, k):
klist = []
while len(klist) < k:
biggest = lst[0]
for i in lst:
if i > biggest:
biggest = i
klist.append(biggest)
lst.remove(biggest)
return klist
| ./refactory/data/question_5/code/correct/correct_5_101.py |
refactory_data_question_5_correct_5_270 | 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_270.py |
refactory_data_question_5_correct_5_240 | def top_k(lst, k):
l=lst.copy()
res=[]
while len(res)<k and l :
biggest=l[0]
for element in l:
if element>biggest:
biggest=element
l.remove(biggest)
res.append(biggest)
return res
| ./refactory/data/question_5/code/correct/correct_5_240.py |
refactory_data_question_5_correct_5_251 | def top_k(lst, k):
def sort(lst):
new = []
while lst:
greatest = lst[0]
for i in lst:
if i > greatest:
greatest = i
lst.remove(greatest)
new.append(greatest)
return new
return sort(lst)[:k]
| ./refactory/data/question_5/code/correct/correct_5_251.py |
refactory_data_question_5_correct_5_258 | def top_k(lst, k):
if k<=0:
return []
else:
maxi=max(lst)
length=len(lst)
for i in range(length):
if lst[i]==maxi:
pos=i
new_list=lst.copy()
new_list.pop(pos)
return [maxi]+top_k(new_list,k-1)
| ./refactory/data/question_5/code/correct/correct_5_258.py |
refactory_data_question_5_correct_5_411 | def top_k(lst, k):
a = mysort(lst)
return a[:k]
pass
def mysort(lst):
counter = 0
a = list(lst)
while counter<len(lst):
previous = a[0]
for i in range(1,len(lst)):
if a[i]>previous:
a[i-1]=a[i]
a[i]=previous
else:
previous = a[i]
counter += 1
return a
| ./refactory/data/question_5/code/correct/correct_5_411.py |
refactory_data_question_5_correct_5_390 | def top_k(lst, k):
def sort(lst):
if lst==[] or len(lst)==1:
return lst
else:
temp=lst[0]
count=0
for i in range(len(lst)):
if lst[i]>temp:
temp=lst[i]
count=i
pop=lst.pop(count)
... | ./refactory/data/question_5/code/correct/correct_5_390.py |
refactory_data_question_5_correct_5_083 | 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_083.py |
refactory_data_question_5_correct_5_044 | def top_k(lst, k):
result = []
while k > 0:
big = max(lst)
result.append(big)
lst.remove(big)
k -= 1
return result
| ./refactory/data/question_5/code/correct/correct_5_044.py |
refactory_data_question_5_correct_5_151 | def top_k(lst, k):
def merge_sort(lst):
if len(lst) < 2: # Base case!
return lst
mid = len(lst) // 2
left = merge_sort(lst[:mid]) #sort left
right = merge_sort(lst[mid:]) #sort right
return merge(left, right)
def merge(left, right):
results = []
... | ./refactory/data/question_5/code/correct/correct_5_151.py |
refactory_data_question_5_correct_5_110 | def top_k(lst, k):
results = []
counter = 0
while counter < k:
for i in range(-len(lst),0):
if lst[i] == max(lst):
results.append(lst.pop(i))
break
counter += 1
return results
| ./refactory/data/question_5/code/correct/correct_5_110.py |
refactory_data_question_5_correct_5_241 | def sort_descending(lst):
new_lst = []
while lst:
largest = lst[0]
for i in range(len(lst)):
if lst[i] > largest:
largest = lst[i]
lst.remove(largest)
new_lst.append(largest)
return new_lst
def top_k(lst, k):
lst = sort_descending(lst)
ret... | ./refactory/data/question_5/code/correct/correct_5_241.py |
refactory_data_question_5_correct_5_242 | 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_242.py |
refactory_data_question_5_correct_5_094 | 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_094.py |
refactory_data_question_5_correct_5_341 | def top_k(lst, k):
new_list = []
while k>0:
new_list.append(max(lst))
lst.remove(max(lst))
k-=1
return new_list
| ./refactory/data/question_5/code/correct/correct_5_341.py |
refactory_data_question_5_correct_5_208 | def top_k(lst, k):
a = []
while k > 0:
a.append(max(lst))
lst.remove(max(lst))
k -= 1
return a
| ./refactory/data/question_5/code/correct/correct_5_208.py |
refactory_data_question_5_correct_5_097 | def top_k(lst,k):
sort_list = []
while lst:
biggest = lst[0]
for e in lst:
if biggest < e:
biggest = e
lst.remove(biggest)
sort_list.append(biggest)
return sort_list[:k]
| ./refactory/data/question_5/code/correct/correct_5_097.py |
refactory_data_question_5_correct_5_190 | def sort_no(lst):
lst_len = len(lst) - 1
while lst_len > 0:
for i in range(lst_len):
if lst[i] > lst[i+1]:
lst[i], lst[i+1] = lst[i+1], lst[i]
lst_len -= 1
return lst[::-1]
def top_k(lst, k):
return sort_no(lst)[:k]
| ./refactory/data/question_5/code/correct/correct_5_190.py |
refactory_data_question_5_correct_5_265 | def top_k(lst, k):
def sort_num(lst):
for k in range(len(lst)-1):
for i in range(k+1, len(lst)):
if lst[k] < lst[i]:
lst[k], lst[i] = lst[i], lst[k]
else:
continue
return lst
slst = sort_num(lst)
return slst[:k]
| ./refactory/data/question_5/code/correct/correct_5_265.py |
refactory_data_question_5_correct_5_103 | def top_k(lst, k):
result = [lst[0]]
for i in lst[1:]:
if i > result[0]:
result.insert(0, i)
elif i <= result[-1]:
result.append(i)
else:
for j in range(1, len(result) - 1):
if i <= result[j] and i >= result[j+1]:
re... | ./refactory/data/question_5/code/correct/correct_5_103.py |
refactory_data_question_5_correct_5_307 | def top_k(lst, k):
n = len(lst) - 1
while n > 0:
for i in range(n):
if lst[i]> lst[i+1]:
lst[i], lst[i+1] = lst[i+1], lst[i]
n = n-1
lst.reverse()
return lst[:k]
| ./refactory/data/question_5/code/correct/correct_5_307.py |
refactory_data_question_5_correct_5_277 | def top_k(lst, k):
newlist = []
while len(newlist) < k:
newlist += [max(lst)]
for i in range(len(lst)):
if lst[i] == max(lst):
break
del lst[i]
return newlist
| ./refactory/data/question_5/code/correct/correct_5_277.py |
refactory_data_question_5_correct_5_010 | 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)
return sort[:k]
| ./refactory/data/question_5/code/correct/correct_5_010.py |
refactory_data_question_5_correct_5_235 | def top_k(lst, k):
a=[]
while lst:
for i in lst:
a.append(max(lst))
lst.remove(max(lst))
return a[0:k]
| ./refactory/data/question_5/code/correct/correct_5_235.py |
refactory_data_question_5_correct_5_368 | def top_k(lst, k):
a=[]
for i in range (0,k):
a=a+[max(lst)]
lst.remove(max(lst))
for i in range(len(a)):
for j in range(len(a)-1, i, -1):
if a[j] > a[j-1]:
a[j], a[j-1] = a[j-1], a[j]
return a
| ./refactory/data/question_5/code/correct/correct_5_368.py |
refactory_data_question_5_correct_5_017 | def top_k(lst, k):
sort = []
while lst:
biggest = lst[0]
for i in lst:
if i > biggest:
biggest = i
lst.remove(biggest)
sort.append(biggest)
return sort[0:k]
| ./refactory/data/question_5/code/correct/correct_5_017.py |
refactory_data_question_5_wrong_5_087 | def top_k(lst, k):
list = []
while len(lst) < k:
a = max(lst)
lst.remove(a)
new.append(a)
return list
| ./refactory/data/question_5/code/fail/wrong_5_087.py |
refactory_data_question_5_wrong_5_020 | def top_k(lst, k):
arranged = []
while k > 0:
lst.remove(max(lst))
arranged.append(max(lst))
k = k-1
return arranged
pass
| ./refactory/data/question_5/code/fail/wrong_5_020.py |
refactory_data_question_5_wrong_5_088 | def top_k(lst, k):
lst = sort_descending(lst)
return lst[:k-1]
def sort_descending(lst):
for i in range(len(lst)-1):
for j in range(i, len(lst)):
if lst[j][1] > lst[i][1]:
x = lst[i]
lst[i] = lst[j]
lst[j] = x
return lst
| ./refactory/data/question_5/code/fail/wrong_5_088.py |
refactory_data_question_5_wrong_5_011 | def sort_age(lst):
new=[]
while lst !=[]:
big=lst[0]
for i in lst:
if i[1]>big[1]:
big=i
lst.remove(big)
new.append(big)
return new
def top_k(lst, k):
return sort_age(lst)[:k]
pass
| ./refactory/data/question_5/code/fail/wrong_5_011.py |
refactory_data_question_5_wrong_5_066 | def top_k(lst, k):
# Fill in your code here
a = lst
sort = []
while a:
largest = a[0]
for item in a:
if item[1] >largest[1]:
largest = item
a.remove(largest)
sort.append(largest)
return(sort)[:k]
| ./refactory/data/question_5/code/fail/wrong_5_066.py |
refactory_data_question_5_wrong_5_084 | def top_k(lst, k):
new_list = []
for i in lst:
if k==0:
break
new_list+=max(lst)
k-1
return lst
pass
| ./refactory/data/question_5/code/fail/wrong_5_084.py |
refactory_data_question_5_wrong_5_103 | def top_k(lst, k):
counter=0
new_lst=[]
while counter<k:
maxi=max(lst)
new_lst.append(maxi)
lst.remove(maxi)
| ./refactory/data/question_5/code/fail/wrong_5_103.py |
refactory_data_question_5_wrong_5_101 | def top_k(lst, k):
# Fill in your code here
sort=sort(lst)
return sort[:k]
def sort(lst):
sort=[]
while lst:
largest=lst[0]
for elem in lst:
if elem > largest:
largest = elem
lst.remove(largest)
sort.append(largest)
return sort
| ./refactory/data/question_5/code/fail/wrong_5_101.py |
refactory_data_question_5_wrong_5_019 | def top_k(lst, k):
arranged = []
while k>0:
lst.remove(max(lst))
arranged.append(max(lst))
k -= 1
return arranged
pass
| ./refactory/data/question_5/code/fail/wrong_5_019.py |
refactory_data_question_5_wrong_5_106 | def top_k(lst, k):
new = []
lst.sort()
for i in range(k-1):
new.append(lst[i])
return new
| ./refactory/data/question_5/code/fail/wrong_5_106.py |
refactory_data_question_5_wrong_5_096 | def top_k(lst, k):
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[:k]
| ./refactory/data/question_5/code/fail/wrong_5_096.py |
refactory_data_question_5_wrong_5_052 | def top_k(lst, k):
a = sort_list(lst)
return a[0:k]
| ./refactory/data/question_5/code/fail/wrong_5_052.py |
refactory_data_question_5_wrong_5_040 | def top_k(lst, k):
i=0
while i+1<len(lst):
if lst[i]<lst[i+1]:
lst.extend([i])
lst.pop(i)
i=0
else:
i+=1
return lst[:k+1]
| ./refactory/data/question_5/code/fail/wrong_5_040.py |
refactory_data_question_5_wrong_5_046 | def top_k(lst, k):
new_list = []
while len(new_list) < k:
maximum = max(lst)
new_lst.append(lst)
lst.remove(maximum)
return new_lst
| ./refactory/data/question_5/code/fail/wrong_5_046.py |
refactory_data_question_5_wrong_5_086 | def top_k(lst, k):
list = []
while len(list) < k:
a = max(lst)
lst.remove(a)
new.append(a)
return list
| ./refactory/data/question_5/code/fail/wrong_5_086.py |
refactory_data_question_5_reference | 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/reference/reference.py |
refactory_data_question_5_wrong_5_097 | 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 + 1]
| ./refactory/data/question_5/code/wrong/wrong_5_097.py |
refactory_data_question_5_wrong_5_017 | 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(oldest)
return result[:k]
| ./refactory/data/question_5/code/wrong/wrong_5_017.py |
refactory_data_question_5_wrong_5_090 | def top_k(lst, k):
sort = []
while lst:
big = max(lst)
sort.append(big)
lst.remove(big)
output = [n for n in lst if lst.index(n) < k]
return output
| ./refactory/data/question_5/code/wrong/wrong_5_090.py |
refactory_data_question_5_wrong_5_056 | def top_k(lst, k):
values = []
while len(values) < k:
for item in lst:
greatest = lst[0]
if item > greatest:
greatest = item
lst.remove(greatest)
values.append(greatest)
return values
| ./refactory/data/question_5/code/wrong/wrong_5_056.py |
refactory_data_question_5_wrong_5_071 | def top_k(lst, k):
new = []
while len(lst) >= len(lst) - k:
top = max(lst)
new.append(lst.remove(top))
return new
| ./refactory/data/question_5/code/wrong/wrong_5_071.py |
refactory_data_question_5_wrong_5_067 | def top_k(lst, k):
new = []
while i in range(k-1):
new.append(lst.pop(max(lst)))
return new
| ./refactory/data/question_5/code/wrong/wrong_5_067.py |
refactory_data_question_5_wrong_5_108 | def top_k(lst, k):
new_lst = []
counter = 0
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/wrong/wrong_5_108.py |
refactory_data_question_5_wrong_5_034 | def top_k(lst, k):
final = []
while lst:
element = max(lst)
final += [element,]
lst.remove(element)
if len(final) == k:
break
return final
| ./refactory/data/question_5/code/wrong/wrong_5_034.py |
refactory_data_question_5_wrong_5_044 | def top_k(lst, k):
af_sort = []
while lst:
biggest = lst[0]
for element in a:
if element > biggest:
biggest = element
lst.remove(biggest)
af_sort.append(biggest)
return af_sort[0:k]
| ./refactory/data/question_5/code/wrong/wrong_5_044.py |
refactory_data_question_5_wrong_5_029 | def top_k(lst, k):
sorted_list = []
while lst:
smallest = lst[0]
for element in lst:
if element < smallest:
smallest = element
lst.remove(element)
sorted_list.append(element)
return list.reverse(sorted_list)[:k-1]
| ./refactory/data/question_5/code/wrong/wrong_5_029.py |
refactory_data_question_5_wrong_5_001 | def top_k(lst, k):
result = []
while k >= 0:
big = max(lst)
result.append(big)
lst.remove(big)
k -= 1
return result
| ./refactory/data/question_5/code/wrong/wrong_5_001.py |
refactory_data_question_5_wrong_5_074 | def top_k(lst, k):
results = []
counter = 0
while counter < k:
for i in range(-len(lst),0):
if lst[i] == max(lst):
results.append(lst.pop(i))
counter += 1
return results
| ./refactory/data/question_5/code/wrong/wrong_5_074.py |
refactory_data_question_5_wrong_5_105 | 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:3]
| ./refactory/data/question_5/code/wrong/wrong_5_105.py |
refactory_data_question_5_wrong_5_060 | def top_k(lst, k):
new_lst = []
while lst:
biggest = lst[0]
for x in lst:
if x < lst[0]:
biggest = x
lst.remove(biggest)
new_lst.append(biggest)
return new_lst[0:k]
| ./refactory/data/question_5/code/wrong/wrong_5_060.py |
refactory_data_question_5_wrong_5_002 | def top_k(lst, k):
lst_res = lst
sort = []
while lst_res:
largest = lst_res[0]
for elements in lst_res:
if element > largest:
largest = element
lst_res.remove(largest)
sort.append(largest)
return sort[:k]
| ./refactory/data/question_5/code/wrong/wrong_5_002.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.