id
stringlengths
35
39
content
stringlengths
44
3.85k
max_stars_repo_path
stringlengths
52
57
refactory_data_question_4_wrong_4_040
def sort_age(lst): sort_lst = [] while lst: smallest = lst[0] for element in lst: if element[1] < smallest[1]: smallest = element lst.remove(smallest) sort_lst.append(smallest) return sort_lst.reverse()
./refactory/data/question_4/code/wrong/wrong_4_040.py
refactory_data_question_4_wrong_4_146
def sort_age(lst): youngest = lst[0][1] sorted = [] while lst: for elem in lst: if elem[1] < youngest: youngest = elem[1] lst.remove(youngest) sorted.append(youngest) return sorted
./refactory/data/question_4/code/wrong/wrong_4_146.py
refactory_data_question_4_wrong_4_336
def sort_age(lst): if len(lst)==1: return lst else: temp=lst[0][1] count=0 for i in range(len(lst)): if lst[i][1]>temp: temp=lst[i][1] count=i result=[lst[count],] pop=lst.pop(count) return result+sort_age(lst) # Fill in your code here pass
./refactory/data/question_4/code/wrong/wrong_4_336.py
refactory_data_question_4_wrong_4_123
def sort_age(lst): firstnum = lst[0][1] result = (lst[0],) for x in lst[1:]: if x[1] < firstnum: result += (x,) else: result = (x,) + result return result pass
./refactory/data/question_4/code/wrong/wrong_4_123.py
refactory_data_question_4_wrong_4_001
def sort_age(lst): result = [] while lst !=[]: lowest = lst[0][1] index = 0 for i in range(1,len(lst)): if lst[i][1]<lowest: index = i lowest = lst[i][1] result = result +[lst[index]] lst.pop[index] return result
./refactory/data/question_4/code/wrong/wrong_4_001.py
refactory_data_question_4_wrong_4_285
def sort_age(lst): lst.sort(key = lambda x: x[1], reverse = True)
./refactory/data/question_4/code/wrong/wrong_4_285.py
refactory_data_question_4_wrong_4_033
def sort_age(lst): a=lst sort=[] while a: smallest=a[0] for element in a: if element[1]<smallest[1]: smallest=element a.remove(smallest) sort.append(smallest) sort.reverse return sort
./refactory/data/question_4/code/wrong/wrong_4_033.py
refactory_data_question_4_wrong_4_042
def sort_age(lst): return lst.sort(key = lambda x: x[1], reverse = True)
./refactory/data/question_4/code/wrong/wrong_4_042.py
refactory_data_question_4_wrong_4_078
def sort_age(lst): lst.sort(key=lambda x:x[1],reverse=True) return lst
./refactory/data/question_4/code/wrong/wrong_4_078.py
refactory_data_question_4_wrong_4_172
def sort_age(lst): lst.sort(key = lambda x: x[1], reverse = True) return lst
./refactory/data/question_4/code/wrong/wrong_4_172.py
refactory_data_question_4_wrong_4_229
def sort_age(lst): youngest = lst[0][1] for item in lst: if item[1] < youngest: youngest = item[1] lst.remove(item) lst = [item,] + lst return lst
./refactory/data/question_4/code/wrong/wrong_4_229.py
refactory_data_question_4_wrong_4_036
def sort_age(lst): """selection sort""" l = len(lst) for i in range(l): largest = lst[i] for j in range(i+1,l): if lst[j][1] > largest[1]: largest = lst[j] #assign new largest value lst[i],lst[j] = lst[j],lst[j] #swap positions if larger return lst
./refactory/data/question_4/code/wrong/wrong_4_036.py
refactory_data_question_4_wrong_4_090
def sort_age(lst): holder=[] if lst==[]: return [] for x in lst: if holder==[]: holder=x elif x[1]>holder[1]: holder=x return [holder]+sort_age(lst[1:])
./refactory/data/question_4/code/wrong/wrong_4_090.py
refactory_data_question_4_wrong_4_204
def sort_age(lst): agelist = [lst[0],] for i in range(1,len(lst)): if lst[i][1] > agelist[0][1]: agelist.insert(0, lst[i]) elif lst[i][1] < agelist[len(agelist)-1][1]: agelist.insert(len(agelist), lst[i]) else: for x in range(0,len(agelist)): if agelist[x][1]> lst[i][1] > agelist[x+1][1]: agelist.insert(x+1, lst[i]) break return agelist
./refactory/data/question_4/code/wrong/wrong_4_204.py
refactory_data_question_4_wrong_4_162
def sort_age(lst): lst.sort(key=lambda x:x[1],reverse=True) return lst
./refactory/data/question_4/code/wrong/wrong_4_162.py
refactory_data_question_4_wrong_4_139
def sort_age(lst): sort_list = [] while lst: # a is not [] smallest = lst[0] for element in lst: if element[1] < smallest[1]: smallest = element lst.remove(smallest) sort_list.append(smallest)
./refactory/data/question_4/code/wrong/wrong_4_139.py
refactory_data_question_4_wrong_4_327
def sort_age(lst): # Fill in your code here sorted = [] while lst: oldest = lst[0] for i in range(len(lst)): if lst[i][1] > oldest[1]: oldest = lst[i] sorted.append(lst.pop(i)) return sorted
./refactory/data/question_4/code/wrong/wrong_4_327.py
refactory_data_question_4_wrong_4_353
def sort_age(lst): # Fill in your code here A = map(lambda x:x[1],lst) a = [] counter =0 while counter<len(lst): for i in A: if i>a[0]: a = i.extend(a) elif i<a[-1]: a = a.extend(i) counter += 1 b = [] for i in a: for y in lst: if y[1] ==i: b.append(y) return b
./refactory/data/question_4/code/wrong/wrong_4_353.py
refactory_data_question_4_wrong_4_317
def sort_age(lst): a = [] for i in lst: a.append(i[1]) print(a) sort = [] while a: smallest = a[0] for element in a: if element < smallest: smallest = element a.remove(smallest) sort.append(smallest) print(sort) lst2 = [] counter = 0 for i in sort: for j in lst: if j[1] == i: lst2.append(j) counter += 1 return lst2
./refactory/data/question_4/code/wrong/wrong_4_317.py
refactory_data_question_4_wrong_4_239
def sort_age(lst): sort = [] while lst: oldest = lst[0] for x in lst: if x[1] > oldest[1]: oldest = x a.remove(oldest) sort.append(oldest) return sort
./refactory/data/question_4/code/wrong/wrong_4_239.py
refactory_data_question_4_wrong_4_117
def sort_age(lst): # Fill in your code here lst.sort(key=lambda x : x[1], reverse=T)
./refactory/data/question_4/code/wrong/wrong_4_117.py
refactory_data_question_4_wrong_4_273
def sort_age(lst): new = [] while lst: largest = lst[0] for ele in lst: if ele[1] > largest: largest = ele a.remove(largest) new.append(largest) return new
./refactory/data/question_4/code/wrong/wrong_4_273.py
refactory_data_question_4_wrong_4_189
def sort_age(lst): lst.sort(key=lambda x: x[1], reverse=True) return lst
./refactory/data/question_4/code/wrong/wrong_4_189.py
refactory_data_question_4_wrong_4_304
def sort_age(lst): lst.sort(key=lambda x:x[1]) lst.reverse() print(lst)
./refactory/data/question_4/code/wrong/wrong_4_304.py
refactory_data_question_4_wrong_4_055
def sort_age(lst): result = [] while lst: oldest = lst[0] for people in lst: if people[1] > oldest[1]: oldest = people lst.remove(oldest) result += (oldest,)
./refactory/data/question_4/code/wrong/wrong_4_055.py
refactory_data_question_4_wrong_4_184
def sort_age(lst): 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# Fill in your code here
./refactory/data/question_4/code/wrong/wrong_4_184.py
refactory_data_question_4_wrong_4_235
def sort_age(lst): return lst.sort(key=lambda x:x[1])
./refactory/data/question_4/code/wrong/wrong_4_235.py
refactory_data_question_4_wrong_4_018
def sort_age(lst): sample = lst[0] newlst = [] for i in lst: if i[1] > sample[1]: newlst = [i] + newlst else: newlst += [i] return newlst
./refactory/data/question_4/code/wrong/wrong_4_018.py
refactory_data_question_4_wrong_4_210
def sort_age(lst): return lst.sort(key=lambda x: x[1], reverse=True)
./refactory/data/question_4/code/wrong/wrong_4_210.py
refactory_data_question_4_wrong_4_216
def sort_age(lst): lst.sort(key= lambda x: x[1]) return lst
./refactory/data/question_4/code/wrong/wrong_4_216.py
refactory_data_question_4_wrong_4_339
def sort_age(lst): if lst == []: return lst else: age_lst, new_lst = [], [] for x in lst: age_lst.append(x[1]) while age_lst: max_age = max(age_lst) for i in lst: if i[1] == max_age: new_lst.append(i) return new_lst pass
./refactory/data/question_4/code/wrong/wrong_4_339.py
refactory_data_question_4_wrong_4_069
def sort_age(lst): store = [] oldest = lst[0] for i in lst[1:]: if i[1] > oldest[1]: oldest = i lst.remove(oldest) sort.append(oldest) return sort
./refactory/data/question_4/code/wrong/wrong_4_069.py
refactory_data_question_4_wrong_4_212
def sort_age(lst): n = len(lst) result = [] while n != 0: test = [] for counter in range(n): test.append(lst[counter][1]) first = max(test) for counter in range(n): if lst[counter][1] == first: result.append(lst.pop(counter)) n = len(lst) return result
./refactory/data/question_4/code/wrong/wrong_4_212.py
refactory_data_question_4_wrong_4_160
def sort_age(lst): return lst.sort(key = lambda x: x[1], reverse = True)
./refactory/data/question_4/code/wrong/wrong_4_160.py
refactory_data_question_4_wrong_4_274
def sort_age(lst): new = [] while lst: largest = lst[0] for ele in lst: if ele[1] > largest: largest = ele a.remove(largest) new.append(largest) return new
./refactory/data/question_4/code/wrong/wrong_4_274.py
refactory_data_question_4_wrong_4_102
def sort_age(lst): largest = lst[0][1] sort1 = [] for i in lst: if i > largest: largest = i sort1.append(i) return sort1
./refactory/data/question_4/code/wrong/wrong_4_102.py
refactory_data_question_4_wrong_4_288
def sort_age(lst): sort = [] while lst: largest = a[0] for element in a: if element > smallest: largest = element lst.remove(largest) sort.append(largest) print(lst)
./refactory/data/question_4/code/wrong/wrong_4_288.py
refactory_data_question_4_wrong_4_154
def sort_age(lst): new = [] while lst: small = lst[0][1] name =lst[0][0] for ele in lst: if ele[1]>small: small = ele[1] name = ele[0] new.append((name,small)) lst.remove((name,small)) return new.reverse
./refactory/data/question_4/code/wrong/wrong_4_154.py
refactory_data_question_4_wrong_4_311
def sort_age(lst): for i in range(len(lst-1)): for j in range(len(lst)-1-i): if lst[j][1] < lst[j+1][1]: lst[j][1],lst[j+1][1] = lst[j+1][1],lst[j][1] else: continue return lst pass
./refactory/data/question_4/code/wrong/wrong_4_311.py
refactory_data_question_4_wrong_4_241
def sort_age(lst): list1 = () i = 0 smallest = lst[0][1] s = lst[0] for i in range(1,len(lst)): if lst[i][1] < smallest: smallest = lst[i][1] s = lst[i] list1 += s return list1
./refactory/data/question_4/code/wrong/wrong_4_241.py
refactory_data_question_4_wrong_4_105
def sort_age(lst): sort1 = [] while lst: largest = lst[0][1] for i in lst: if i[1] > largest: largest = i[1] lst.remove(i) sort1.append(i) return sort1
./refactory/data/question_4/code/wrong/wrong_4_105.py
refactory_data_question_4_wrong_4_097
def sort_age(lst): lst.sort(key = lambda x: x[1], reverse = True) return lst
./refactory/data/question_4/code/wrong/wrong_4_097.py
refactory_data_question_4_wrong_4_142
def sort_age(lst): sort = [] while lst: oldest = lst[0] for i in lst: if i[1]<oldest[1]: oldest = i lst.remove(oldest) sort.append(oldest) return sort
./refactory/data/question_4/code/wrong/wrong_4_142.py
refactory_data_question_4_wrong_4_315
def sort_age(lst): lst.sort(key=lambda x: x[1],reverse = True) return lst
./refactory/data/question_4/code/wrong/wrong_4_315.py
refactory_data_question_4_wrong_4_275
def sort_age(lst): lst.sort(key = lambda x: x[1], reverse = True) return lst
./refactory/data/question_4/code/wrong/wrong_4_275.py
refactory_data_question_4_wrong_4_253
def sort_age(lst): list1 = [] while lst: biggest = lst[0] for i in lst: if i[1] > biggest[1]: biggest = i[1] lst.remove(biggest) list1.append(biggest) return list1
./refactory/data/question_4/code/wrong/wrong_4_253.py
refactory_data_question_4_wrong_4_187
def sort_age(lst): new = [] while lst: eldest = lst[0] for i in lst: if i > eldest: eldest = i lst.remove(eldest) new.append(eldest) return new
./refactory/data/question_4/code/wrong/wrong_4_187.py
refactory_data_question_4_wrong_4_345
def sort_age(lst): current=0 tup=() for i in lst: if i[1]>current: tup+=tuple(i) current=i[1] else: tuple(i)+tup return tup
./refactory/data/question_4/code/wrong/wrong_4_345.py
refactory_data_question_4_wrong_4_262
def sort_age(lst): s = [] while lst: smallest = lst[0] for element in lst: if element[1]<smallest[1]: smallest = element lst.remove(smallest) s.append(smallest) s.reverse() return s
./refactory/data/question_4/code/wrong/wrong_4_262.py
refactory_data_question_4_wrong_4_351
def sort_age(lst): lst.sort() new = [] for i in range(len(lst)): j = len(lst) - i- 1 new.append(lst[j]) return new
./refactory/data/question_4/code/wrong/wrong_4_351.py
refactory_data_question_4_wrong_4_088
def sort_age(lst): holder=[] for x in lst: if holder==[]: holder=x elif x[1]>holder[1]: holder=x return holder+sort_age(lst[1:])
./refactory/data/question_4/code/wrong/wrong_4_088.py
refactory_data_question_5_correct_5_291
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_291.py
refactory_data_question_5_correct_5_252
def top_k(lst,k): nlst = [] for x in range(k): b = max(lst) nlst.append(b) lst.remove(b) return nlst
./refactory/data/question_5/code/correct/correct_5_252.py
refactory_data_question_5_correct_5_378
def top_k(lst, k): lst2 = [] while lst: lst2.append(max(lst)) lst.remove(max(lst)) for x in lst: if x in lst2: lst2.append(x) lst.remove(x) return lst2[:k]
./refactory/data/question_5/code/correct/correct_5_378.py
refactory_data_question_5_correct_5_139
def top_k(lst, k): # Fill in your code here a = [] while len(a)<k: a += [max(lst),] lst.remove(max(lst)) return a
./refactory/data/question_5/code/correct/correct_5_139.py
refactory_data_question_5_correct_5_123
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_123.py
refactory_data_question_5_correct_5_188
def top_k(lst, k): newlist = [] counter = k while counter > 0: biggest = lst[0] for i in lst[1:]: if biggest > i: continue else: biggest = i continue newlist += [biggest] counter -= 1 lst.remove(biggest) return newlist
./refactory/data/question_5/code/correct/correct_5_188.py
refactory_data_question_5_correct_5_201
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 while len(lst) > k: lst.pop(-1) return lst
./refactory/data/question_5/code/correct/correct_5_201.py
refactory_data_question_5_correct_5_335
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_335.py
refactory_data_question_5_correct_5_213
def top_k(lst, k): sorted = [] while lst: biggest = lst[0] for elem in lst: if elem > biggest: biggest = elem lst.remove(biggest) sorted.append(biggest) return sorted[:k]
./refactory/data/question_5/code/correct/correct_5_213.py
refactory_data_question_5_correct_5_178
def top_k(lst, k): # Fill in your code here out = [lst[0],] for ele in lst[1:]: for indx in range(len(out)): if out[indx] <= ele: out.insert(indx, ele) break elif indx == len(out) - 1: out.append(ele) return out[0:k]
./refactory/data/question_5/code/correct/correct_5_178.py
refactory_data_question_5_correct_5_112
def top_k(lst,k): newlst=[] while lst: highest=lst[0] #first number for number in lst: if number>highest: highest=number for number in lst: if number==highest: newlst.append(number) lst.remove(number) return newlst[:k]
./refactory/data/question_5/code/correct/correct_5_112.py
refactory_data_question_5_correct_5_347
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_347.py
refactory_data_question_5_correct_5_365
def top_k(lst, k): sotsot = [] while lst: largest = lst[0] for element in lst: if element > largest: largest = element lst.remove(largest) sotsot.append(largest) return sotsot[:k]
./refactory/data/question_5/code/correct/correct_5_365.py
refactory_data_question_5_correct_5_045
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_045.py
refactory_data_question_5_correct_5_011
def magus_sort(lst): if len(lst) == 0: return [] elif len(lst) == 1: return lst elif len(lst) == 2: if lst[0] >= lst[1]: return lst else: return [lst[1], lst[0]] else: if lst[0] >= lst[1]: list1, list2 = [lst[0]], [lst[1]] else: list1, list2 = [lst[1]], [lst[0]] for i in lst[2:]: if i >= list1[0]: list1.append(i) else: list2.append(i) return magus_sort(list1) + magus_sort(list2) def top_k(lst, k): return magus_sort(lst)[0:k]
./refactory/data/question_5/code/correct/correct_5_011.py
refactory_data_question_5_correct_5_173
def top_k(lst, k): lst2 = [] lst3 = [] while lst: largest = lst[0] for i in lst: if i > largest: largest = i lst.remove(largest) lst2.append(largest) if len(lst2) <= k: k = len(lst2) for i2 in range(k): lst3.append(lst2[i2]) return lst3
./refactory/data/question_5/code/correct/correct_5_173.py
refactory_data_question_5_correct_5_136
def top_k(lst, k): new_lst = lst end = [] for a in range(k): end.append(max(new_lst)) new_lst.remove(max(new_lst)) return end
./refactory/data/question_5/code/correct/correct_5_136.py
refactory_data_question_5_correct_5_095
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(smallest) sorted_lst.append(smallest) sorted_lst.reverse() return sorted_lst
./refactory/data/question_5/code/correct/correct_5_095.py
refactory_data_question_5_correct_5_143
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_143.py
refactory_data_question_5_correct_5_192
def bubble_sort(seq): changed = True while changed: changed = False for i in range(len(seq) - 1): if seq[i] < seq[i+1]: seq[i], seq[i+1] = seq[i+1], seq[i] changed = True return None def top_k(lst, k): bubble_sort(lst) return lst[:k]
./refactory/data/question_5/code/correct/correct_5_192.py
refactory_data_question_5_correct_5_312
def top_k(lst, k): for start in range(len(lst)): minimum = start for i in range(start,len(lst)): if lst[i] < lst[minimum]: minimum = i lst[start], lst[minimum] = lst[minimum], lst[start] lst.reverse() return lst[:k]
./refactory/data/question_5/code/correct/correct_5_312.py
refactory_data_question_5_correct_5_116
def top_k(lst, k): # Fill in your code here a = [] while len(a)<k: a += [max(lst),] lst.remove(max(lst)) return a
./refactory/data/question_5/code/correct/correct_5_116.py
refactory_data_question_5_correct_5_012
def top_k(lst, k): if k == 1: return [max(lst)] else: answer = [] for i in range(min(k, len(lst))): largest = max(lst) answer.append(largest) lst.remove(largest) return answer
./refactory/data/question_5/code/correct/correct_5_012.py
refactory_data_question_5_correct_5_262
def top_k(lst, k): for x in range(k+1): max = x for i in range(x, len(lst)): if lst[i] > lst[max]: max = i if x <= (len(lst) - 1): lst[max], lst[x] = lst[x], lst[max] new = lst[:k] return new
./refactory/data/question_5/code/correct/correct_5_262.py
refactory_data_question_5_correct_5_126
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_126.py
refactory_data_question_5_correct_5_223
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_223.py
refactory_data_question_5_correct_5_388
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_388.py
refactory_data_question_5_correct_5_247
def bubble_sort(lst): swap = True while swap == True: 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 def top_k(lst, k): lst = bubble_sort(lst) return lst[:k]
./refactory/data/question_5/code/correct/correct_5_247.py
refactory_data_question_5_correct_5_113
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_113.py
refactory_data_question_5_correct_5_379
def top_k(lst, k): for i in range(len(lst)): for j in range(len(lst) - 1): if lst[j] > lst[j + 1]: lst[j], lst[j + 1] = lst[j + 1], lst[j] lst.reverse() return lst[:k] pass
./refactory/data/question_5/code/correct/correct_5_379.py
refactory_data_question_5_correct_5_019
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 result
./refactory/data/question_5/code/correct/correct_5_019.py
refactory_data_question_5_correct_5_317
def top_k(lst, k): for j in range(len(lst)): for i in range(len(lst)-1): if lst[i]<lst[1+i]: lst[i], lst[i+1] = lst[i+1], lst[i] return lst[:k]
./refactory/data/question_5/code/correct/correct_5_317.py
refactory_data_question_5_correct_5_323
def top_k(lst, k): result = [] length=len(lst) while len(lst)>length-k: biggest = lst[0] for element in lst: if element > biggest: biggest = element result.append(biggest) lst.remove(biggest) return result pass
./refactory/data/question_5/code/correct/correct_5_323.py
refactory_data_question_5_correct_5_402
def top_k(lst, k): # Fill in your code here sort_lst=sort(lst) return sort_lst[: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/correct/correct_5_402.py
refactory_data_question_5_correct_5_396
def top_k(lst, k): new_list = [] while k > 0: new_list.append(max(lst)) lst.remove(max(lst)) k = k-1 return new_list
./refactory/data/question_5/code/correct/correct_5_396.py
refactory_data_question_5_correct_5_168
def top_k(lst, k): new_lst = [] if k == 0 or lst == []: return [] else: while k > 0: new_lst.append(max(lst)) lst.remove(new_lst[-1]) k -= 1 return new_lst
./refactory/data/question_5/code/correct/correct_5_168.py
refactory_data_question_5_correct_5_405
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_405.py
refactory_data_question_5_correct_5_029
def quicksort(lst, f, comparator): if len(lst) <= 1: return lst pivot_index = len(lst) // 2 pivot = lst[pivot_index] flist, blist = [], [] for i in range(len(lst)): if i == pivot_index: continue if comparator(f(lst[i]), f(pivot)): flist.append(lst[i]) else: blist.append(lst[i]) return quicksort(flist, f, comparator) + [pivot] + quicksort(blist, f, comparator) def top_k(lst, k): sorted_lst = quicksort(lst, lambda x: x, lambda x, y: x > y) return sorted_lst[:k]
./refactory/data/question_5/code/correct/correct_5_029.py
refactory_data_question_5_correct_5_298
def top_k(lst,k): a = [] while lst: biggest = lst[0] for element in lst: if element > biggest: biggest = element lst.remove(biggest) a.append(biggest) return a[:k]
./refactory/data/question_5/code/correct/correct_5_298.py
refactory_data_question_5_correct_5_184
def top_k(lst, k): newlst = [] while lst: largest = lst[0] for number in lst: if number > largest: largest = number lst.remove(largest) newlst.append(largest) result = [] for counter in range(k): result = result + [newlst[counter],] return result
./refactory/data/question_5/code/correct/correct_5_184.py
refactory_data_question_5_correct_5_157
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_157.py
refactory_data_question_5_correct_5_215
def top_k(lst, k): lst2 = [] largest = lst[0] while lst: largest = lst[0] for element in lst: if element > largest: largest = element lst.remove(largest) lst2.append(largest) return lst2[0:k]
./refactory/data/question_5/code/correct/correct_5_215.py
refactory_data_question_5_correct_5_401
def top_k(lst, k): result=[] while k>0: result.append(max(lst)) lst.remove(max(lst)) k=k-1 return result
./refactory/data/question_5/code/correct/correct_5_401.py
refactory_data_question_5_correct_5_332
def top_k(lst, k): # Fill in your code here 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_332.py
refactory_data_question_5_correct_5_207
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_207.py
refactory_data_question_5_correct_5_115
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_115.py
refactory_data_question_5_correct_5_118
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_118.py
refactory_data_question_5_correct_5_063
def top_k(lst, k): newlst = [] while lst: largest = lst[0] for number in lst: if number > largest: largest = number lst.remove(largest) newlst.append(largest) result = [] for counter in range(k): result = result + [newlst[counter],] return result
./refactory/data/question_5/code/correct/correct_5_063.py
refactory_data_question_5_correct_5_308
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) return lst[:k]
./refactory/data/question_5/code/correct/correct_5_308.py