{"submission_id":4270,"assignment_id":5,"func_code":"def top_k(lst, k):\n result = []\n while k >= 0:\n big = max(lst)\n result.append(big)\n lst.remove(big)\n k -= 1\n return result\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n result = []\n while k > 0:\n big = max(lst)\n result.append(big)\n lst.remove(big)\n k -= 1\n return result\n","comments":"# KC# wrong operand \/ wrong number of iterations"} {"submission_id":4271,"assignment_id":5,"func_code":"def top_k(lst, k):\n lst_res = lst\n sort = []\n while lst_res:\n largest = lst_res[0]\n for elements in lst_res:\n if element > largest:\n largest = element\n lst_res.remove(largest)\n sort.append(largest)\n return sort[:k]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n lst_res = lst\n sort = []\n while lst_res:\n largest = lst_res[0]\n for element in lst_res:\n if element > largest:\n largest = element\n lst_res.remove(largest)\n sort.append(largest)\n return sort[:k]\n","comments":"# typo"} {"submission_id":4272,"assignment_id":5,"func_code":"def top_k(lst, k):\n tmp = []\n while len(lst) > 0:\n tmp.append(max(lst))\n lst.remove(max(lst))\n return tmp[:5]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n tmp = []\n while len(lst) > 0:\n tmp.append(max(lst))\n lst.remove(max(lst))\n return tmp[:k]\n","comments":"# typo"} {"submission_id":4273,"assignment_id":5,"func_code":"def top_k(lst, k):\n sort = []\n while lst: \n biggest = lst[0]\n for element in lst:\n if ele > biggest:\n biggest = ele\n \n lst.remove(element)\n sort.append(element)\n if len(sort)==k:\n break\n return sort\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n sort = []\n while lst and k:\n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n lst.remove(biggest)\n sort.append(biggest)\n if len(sort) == k:\n break\n return sort\n","comments":"# wrong variable usage# missing input case"} {"submission_id":4274,"assignment_id":5,"func_code":"def top_k(lst, k):\n sort = []\n while lst: \n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n \n lst.remove(element)\n sort.append(element)\n if len(sort)==k:\n break\n return sort\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n sort = []\n while lst and k:\n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n lst.remove(biggest)\n sort.append(biggest)\n if len(sort) == k:\n break\n return sort\n","comments":"# wrong variable usage# missing input case"} {"submission_id":4275,"assignment_id":5,"func_code":"def top_k(lst, k):\n sort = []\n while lst: \n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n \n lst.remove(biggest)\n sort.append(biggest)\n if len(sort)==k:\n break\n return sort\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n sort = []\n while lst and k:\n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n lst.remove(biggest)\n sort.append(biggest)\n if len(sort) == k:\n break\n return sort\n","comments":""} {"submission_id":4276,"assignment_id":5,"func_code":"def top_k(lst, k):\n lst1 = []\n for i in lst:\n if i >= k:\n lst1.append(i) \n sort = []\n while lst1: \n biggest = lst[0]\n for element in lst1:\n if element > biggest:\n biggest = element\n lst1.remove(biggest)\n sort.append(biggest)\n return sort\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n sort = []\n while lst and k > 0:\n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n lst.remove(biggest)\n sort.append(biggest)\n k -= 1\n return sort\n","comments":"# wrong-strategy# missing input case handling"} {"submission_id":4277,"assignment_id":5,"func_code":"def top_k(lst, k):\n sort = []\n while lst: \n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n lst.remove(biggest)\n sort.append(biggest)\n return sort[:k+1]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n sort = []\n while lst:\n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n lst.remove(biggest)\n sort.append(biggest)\n return sort[:k]\n","comments":""} {"submission_id":4278,"assignment_id":5,"func_code":"def top_k(lst, k):\n n = len(lst) - k\n counter = 0\n while counter < k:\n lst.remove(min(lst))\n counter = counter + 1\n sort_list = []\n while lst != []:\n sort_lst.append(max(lst))\n lst.remove(max(lst))\n return sort_list\n \n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n n = len(lst) - k\n counter = 0\n while counter < n:\n lst.remove(min(lst))\n counter = counter + 1\n sort_list = []\n while lst != []:\n sort_list.append(max(lst))\n lst.remove(max(lst))\n return sort_list\n","comments":"# wrong variable usage"} {"submission_id":4279,"assignment_id":5,"func_code":"def top_k(lst, k):\n n = len(lst) - k\n counter = 0\n while counter < k:\n lst.remove(min(lst))\n counter = counter + 1\n sort_list = []\n while lst != []:\n sort_list.append(max(lst))\n lst.remove(max(lst))\n return sort_list\n \n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n n = len(lst) - k\n counter = 0\n while counter < n:\n lst.remove(min(lst))\n counter = counter + 1\n sort_list = []\n while lst != []:\n sort_list.append(max(lst))\n lst.remove(max(lst))\n return sort_list\n","comments":"# wrong variable usage"} {"submission_id":4287,"assignment_id":5,"func_code":"def top_k(lst, k):\n # Fill in your code here\n sort = []\n while lst: # a is not []\n largest = lst[0]\n for element in lst:\n if element > largest:\n largest = element\n lst.remove(largest)\n sort.append(largest)\n return sort[:k+1]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n sort = []\n while lst:\n biggest = lst[0]\n for element in lst:\n if element > biggest:\n biggest = element\n lst.remove(biggest)\n sort.append(biggest)\n return sort[:k]\n","comments":""} {"submission_id":4281,"assignment_id":5,"func_code":"def top_k(lst, k):\n \n if lst == []:\n return lst\n \n lower = []\n higher = []\n plist = []\n \n pivot = lst[0]\n for e in lst:\n if e < pivot:\n lower.append(e)\n if x == pivot:\n plist.append(e)\n if x > pivot:\n higher.append(e)\n sort_list = lower + plist + higher\n \n return sort_list[:k]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"","comments":"# KC# complex strategy# partial solution"} {"submission_id":4282,"assignment_id":5,"func_code":"def top_k(lst, k):\n \n if lst == []:\n return lst\n \n lower = []\n higher = []\n plist = []\n \n pivot = lst[0]\n for e in lst:\n if e < pivot:\n lower.append(e)\n if x == pivot:\n plist.append(e)\n if x > pivot:\n higher.append(e)\n sort_list = higher + plist + lower\n \n return sort_list[:k]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"","comments":"# KC# complex strategy# partial solution"} {"submission_id":4283,"assignment_id":5,"func_code":"def top_k(lst, k):\n \n if lst == []:\n return lst\n \n lower = []\n higher = []\n plist = []\n \n pivot = lst[0]\n for e in lst:\n if e < pivot:\n lower.append(e)\n if e == pivot:\n plist.append(e)\n if e > pivot:\n higher.append(e)\n sort_list = higher + plist + lower\n \n return sort_list[:k]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"","comments":"# KC# complex strategy# partial solution"} {"submission_id":4284,"assignment_id":5,"func_code":"def top_k(lst, k):\n \n if lst == []:\n return lst\n \n lower = []\n higher = []\n plist = []\n \n pivot = lst[0]\n for e in lst:\n if e < pivot:\n lower.append(e)\n if e == pivot:\n plist.append(e)\n if e > pivot:\n higher.append(e)\n sort_list = lower + plist + higher\n sort_list = sort_list[::-1]\n \n return sort_list[:k]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"","comments":"# KC# complex strategy# partial solution"} {"submission_id":4285,"assignment_id":5,"func_code":"def top_k(lst, k):\n \n if lst == []:\n return lst\n \n lower = []\n higher = []\n plist = []\n \n pivot = lst[0]\n for e in lst:\n if e < pivot:\n lower.append(e)\n if e == pivot:\n plist.append(e)\n if e > pivot:\n higher.append(e)\n sort_list = lower + plist + higher\n sort_list = sort_list[::-1]\n \n if k == len(lst):\n return sort_list[:k-1]\n elif k > len(lst):\n return sort_list\n else:\n return sort_list[:k]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"","comments":"# KC# complex strategy# partial solution"} {"submission_id":4286,"assignment_id":5,"func_code":"def top_k(lst, k):\n result = []\n while lst:\n biggest = lst[0]\n for number in lst:\n if number > biggest:\n biggest = number\n lst.remove(biggest)\n result.append(oldest)\n return result[:k]\n","func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted.","annotation":"def top_k(lst, k):\n result = []\n while lst:\n biggest = lst[0]\n for number in lst:\n if number > biggest:\n biggest = number\n lst.remove(biggest)\n result.append(biggest)\n return result[:k]\n","comments":"# wrong variable usage"} {"submission_id":4291,"assignment_id":5,"func_code":"def top_k(lst, k):\n rs=[]\n for qwerty in range(0,k):\n biggest=lst[0]\n for k in lst:\n if biggest