submission_id
int32
10
42.5k
func_code
stringlengths
22
782
assignment_id
stringlengths
4
23
func_name
stringlengths
4
23
description
stringlengths
26
128
test
stringlengths
45
1.22k
correct
bool
2 classes
user
stringlengths
36
36
academic_year
int32
2.02k
2.02k
18,485
def selectionsort(A): i = 0 while i < len(A): p = i j = i + 1 while j < len(A): if A[j] < A[p]: p = j j += 1 tmp = A[p] A[p] = A[i] A[i] = tmp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
2eb2f93d-3491-4b0b-bad9-894c90595058
2,016
17,693
def selectionsort(A): i = 0 while i < len(A): p = i j = i + 1 while j < len(A): if A[j] < A[p]: p = j j += 1 tmp = A[p] A[p] = A[i] A[i] = tmp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
2eb2f93d-3491-4b0b-bad9-894c90595058
2,016
26,492
def selectionsort(A): i = 0 while i < len(A): p = i j = i + 1 while j < len(A): if A[j] < A[p]: p = j j += 1 tmp = A[p] A[p] = A[i] A[i] = tmp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
2eb2f93d-3491-4b0b-bad9-894c90595058
2,016
20,334
def power(m, n): return m ** n
power
power
Raise m to the power of n.
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
17,683
def power(m, n): return m ** n
power
power
Raise m to the power of n.
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
39,803
def fibonacci(n): if n == 1 or n == 0: return 1 else: return fibonacci(n - 1) + fibonacci(n - 2)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
35,892
def fibonacci(n): if n == 1 or n == 0: return 1 else: return fibonacci(n - 1) + fibonacci(n - 2)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
13,334
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 tmp = a[p] a[p] = a[i] a[i] = tmp i = i + 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
18,204
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 tmp = a[p] a[p] = a[i] a[i] = tmp i = i + 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
20,671
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q = q + 1 j = j + 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
39,455
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q = q + 1 j = j + 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
21,071
def reverse_list(n): if len(n) == 1: return n else: return [n[0]] + reverse_list(n[1:])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
19,369
def reverse_list(n): if len(n) == 1: return n else: return [n[-1]] + reverse_list(n[:-1])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
33,907
def reverse_list(n): if len(n) == 0: return [] else: return [n[-1]] + reverse_list(n[:-1])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
24,275
def reverse_list(n): if len(n) == 0: return [] else: return [n[-1]] + reverse_list(n[:-1])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
17,627
def count_letters(word): if len(word) == 0: return 0 else: return 1 + count_letters(word[1:])
count_letters
count_letters
Return the number of lettres in a string.
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
35,055
def count_letters(word): if len(word) == 0: return 0 else: return 1 + count_letters(word[1:])
count_letters
count_letters
Return the number of lettres in a string.
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
7,855
def fibonacci(n): if n == 0: return 1 elif n == 1: return 1 else: return fibonacci(n - 2) + fibonacci(n - 1)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
13,774
def fibonacci(n): if n == 0: return 1 elif n == 1: return 1 else: return fibonacci(n - 2) + fibonacci(n - 1)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
21,255
def power(m, n): if n == 0: return 1 return m ** n
power
power
Raise m to the power of n.
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
26,950
def power(m, n): if n == 0: return 1 return m ** n
power
power
Raise m to the power of n.
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
663
def minimum(n): n.sort() return n[0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
1,472
def minimum(n): n.sort() return n[0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
21,704
def maximum(n): n.sort() return n[-1]
maximum
maximum
Return the maximum element in a list of numbers.
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
38,826
def maximum(n): n.sort() return n[-1]
maximum
maximum
Return the maximum element in a list of numbers.
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
40,903
def maximum(n): n.sort() return n[-1]
maximum
maximum
Return the maximum element in a list of numbers.
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
26,765
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q += 1 j += 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
41,409
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q += 1 j += 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
11,948
def minimum(l): if len(l) == 1: return l[0] return min(l)
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
36,155
def minimum(l): if len(l) == 1: return l[0] return [s for s in l if all(s <= i for i in l)][0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
2,256
def minimum(l): if len(l) == 1: return l[0] return [s for s in l if all(s <= i for i in l)][0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
22,893
def maximum(l): if len(l) == 1: return l[0] return [s for s in l if all(s >= i for i in l)][0]
maximum
maximum
Return the maximum element in a list of numbers.
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
35,751
def maximum(l): if len(l) == 1: return l[0] return [s for s in l if all(s >= i for i in l)][0]
maximum
maximum
Return the maximum element in a list of numbers.
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
8,631
def recursive_selectionsort(A, i): if i >= len(a) - 1: return else: p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 tmp = a[p] a[p] = a[i] a[i] = tmp recursive_selectionsort(A, i + 1) def selectionsort(A): recursive_selectionsort(A, 0)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
2,229
def recursive_selectionsort(A, i): if i >= len(a) - 1: return else: p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 tmp = a[p] a[p] = a[i] a[i] = tmp recursive_selectionsort(A, i + 1) def selectionsort(A): recursive_selectionsort(A, 0)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
39,994
def recursive_selectionsort(A, i): if i >= len(a) - 1: return else: p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 tmp = a[p] a[p] = a[i] a[i] = tmp recursive_selectionsort(A, i + 1) def selectionsort(A): recursive_selectionsort(A, 0)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
21,126
def recursive_selectionsort(A, i): if i >= len(A) - 1: return else: p = i j = i + 1 while j < len(A): if A[j] < A[p]: p = j j = j + 1 tmp = A[p] A[p] = A[i] A[i] = tmp recursive_selectionsort(A, i + 1) def selectionsort(A): recursive_selectionsort(A, 0)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
25,353
def recursive_selectionsort(A, i): if i >= len(A) - 1: return else: p = i j = i + 1 while j < len(A): if A[j] < A[p]: p = j j = j + 1 tmp = A[p] A[p] = A[i] A[i] = tmp recursive_selectionsort(A, i + 1) def selectionsort(A): recursive_selectionsort(A, 0)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
5,146
def recursive_selectionsort(A, i): if i >= len(A) - 1: return else: p = i j = i + 1 while j < len(A): if A[j] < A[p]: p = j j = j + 1 tmp = A[p] A[p] = A[i] A[i] = tmp recursive_selectionsort(A, i + 1) def selectionsort(A): recursive_selectionsort(A, 0)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
2,016
33,890
def count_letters(s): if s == '': return 0 a = 0 for letter in s: a += 1 return a
count_letters
count_letters
Return the number of lettres in a string.
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
23,176
def count_letters(s): if s == '': return 0 a = 0 for letter in s: a += 1 return a
count_letters
count_letters
Return the number of lettres in a string.
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
9,500
def reverse_list(l): if l == []: return none return l[::-1]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
29,364
def reverse_list(l): if l == []: return None return l[::-1]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
38,841
def reverse_list(l): if l == []: return [] return l[::-1]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
10,086
def reverse_list(l): if l == []: return [] return l[::-1]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
40,216
def fibonacci(n): if n <= 1: return 1 return fibonacci(n - 1) + fibonacci(n - 2)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
4,215
def fibonacci(n): if n <= 1: return 1 return fibonacci(n - 1) + fibonacci(n - 2)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
15,105
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q += 1 j += 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
9,487
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q += 1 j += 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
2,446
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q += 1 j += 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
11,294
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q += 1 j += 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
42,143
def partition(A, p, r): q = j = p while j < r: if A[j] <= A[r]: A[q], A[j] = A[j], A[q] q += 1 j += 1 A[q], A[r] = A[r], A[q] return q def quicksort(A, p, r): if r <= p: return q = partition(A, p, r) quicksort(A, p, q - 1) quicksort(A, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
3,491
def selectionsort(a): a = a[:] out = [] while a: smallest = min(a) a.remove(smallest) out.append(smallest) return out
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
35,795
def power(m, n): if n == 0: return 1 return m ** n
power
power
Raise m to the power of n.
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
10,800
def power(m, n): if n == 0: return 1 return m * power(m, n - 1)
power
power
Raise m to the power of n.
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
27,612
def power(m, n): if n == 0: return 1 return m * power(m, n - 1)
power
power
Raise m to the power of n.
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
26,827
def selectionsort(a): a = a[:] out = [] if a: smallest = min(a) a.remove(smallest) out.append(smallest) return out
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
1,670
def minimum(l): if len(l) == 1: return l[0] tmp = minimum(l[1:]) return tmp if tmp > l[0] else l[0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
7,215
def minimum(l): if len(l) == 1: return l[0] tmp = minimum(l[1:]) return tmp if tmp < l[0] else l[0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
2,643
def minimum(l): if len(l) == 1: return l[0] m = minimum(l[1:]) return m if m < l[0] else l[0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
35,229
def minimum(l): if len(l) == 1: return l[0] m = minimum(l[1:]) return m if m < l[0] else l[0]
minimum
minimum
Return the minimum element in a list of numbers.
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
12,476
def maximum(l): if len(l) == 1: return l[0] m = maximum(l[1:]) return m if m > l[0] else l[0]
maximum
maximum
Return the maximum element in a list of numbers.
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
16,085
def maximum(l): if len(l) == 1: return l[0] m = maximum(l[1:]) return m if m > l[0] else l[0]
maximum
maximum
Return the maximum element in a list of numbers.
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
14,487
def selectionsort(a): a = a[:] sortedlist = [] while a: smallest = min(a) a.remove(smallest) sortedlist.append(smallest) return sortedlist
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
41,571
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 timp = a[p] a[p] = a[i] a[i] = temp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
40,013
def count_letters(s): if s == '': return 0 return count_letters(s[1:]) + 1
count_letters
count_letters
Return the number of lettres in a string.
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
31,241
def count_letters(s): if s == '': return 0 return count_letters(s[1:]) + 1
count_letters
count_letters
Return the number of lettres in a string.
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
31,842
def reverse_list(l): if l == []: return [] return reverse_list(l[1]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
35,340
def reverse_list(l): if l == []: return [] return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
11,348
def reverse_list(l): if l == []: return [] return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
711
def reverse_list(l): if l == []: return [] return l[1:].append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
32,660
def reverse_list(l): if l == []: return [] return l.append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
17,286
def reverse_list(l): if l == []: return [] return l
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
26,250
def reverse_list(l): if l == []: return [] return l[0]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
27,681
def reverse_list(l): if l == []: return [] return l.append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
35,230
def reverse_list(l): if l == []: return [] return [1, 2].append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
37,874
def swap(A, x, y): tmp = A[x] A[x] = A[y] A[y] = tmp def selectionsort(a): for i in range(len(a)): least = i for k in range(i + 1, len(a)): if a[k] < a[least]: least = k swap(a, least, i)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
41,794
def swap(A, x, y): tmp = A[x] A[x] = A[y] A[y] = tmp def selectionsort(a): for i in range(len(a)): least = i for k in range(i + 1, len(a)): if a[k] < a[least]: least = k swap(a, least, i)
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
a379289f-2b57-4917-ac63-01ab37fb3785
2,016
1,017
def reverse_list(l): if l == []: return [] new = reverse_list(l[1:]).append(l[0]) return new
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
40,759
def reverse_list(l): if l == []: return [] new = l.append(l[0]) return new
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
14,650
def reverse_list(l): if l == []: return [] new = l[1:] return new
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
6,915
def reverse_list(l): if l == []: return [] return l[1:] + l[0]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
15,947
def reverse_list(l): if l == []: return [] return reverse_list(l[1:]) + [l[0]]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
18,082
def reverse_list(l): return reverse_list(l[1:]) + [l[0]] if l else []
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
41,116
def reverse_list(l): return reverse_list(l[1:]) + [l[0]] if l else []
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
34,477
def fibonacci(n): if n < 2: return 1 return fibonacci(n - 1) + fibonacci(n - 2)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
36,943
def fibonacci(n): if n < 2: return 1 return fibonacci(n - 1) + fibonacci(n - 2)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
17,831
def partition(a, p, r): q = j = p while j < r: if a[j] <= a[r]: a[q], a[j] = a[j], a[q] q += 1 j += 1 a[q], a[r] = a[r], a[q] return q def quicksort(a, q, r): if r <= q: return q = partition(a, p, r) quicksort(a, p, q - 1) quicksort(a, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
23,929
def partition(a, p, r): q = j = p while j < r: if a[j] <= a[r]: a[q], a[j] = a[j], a[q] q += 1 j += 1 a[q], a[r] = a[r], a[q] return q def quicksort(a, p, r): if r <= q: return q = partition(a, p, r) quicksort(a, p, q - 1) quicksort(a, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
false
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
19,523
def partition(a, p, r): q = j = p while j < r: if a[j] <= a[r]: a[q], a[j] = a[j], a[q] q += 1 j += 1 a[q], a[r] = a[r], a[q] return q def quicksort(a, p, r): if r <= p: return q = partition(a, p, r) quicksort(a, p, q - 1) quicksort(a, q + 1, r)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
22,386
def partition(a, p, pivot): q = j = p while j < pivot: if a[j] <= a[pivot]: a[q], a[j] = a[j], a[q] q += 1 j += 1 a[q], a[pivot] = a[pivot], a[q] return q def quicksort(a, p, pivot): if pivot <= p: return q = partition(a, p, pivot) quicksort(a, p, q - 1) quicksort(a, q + 1, pivot)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
13,733
def partition(a, start, pivot): lower = upper = start while upper < pivot: if a[upper] <= a[pivot]: a[lower], a[upper] = a[upper], a[lower] lower += 1 upper += 1 a[lower], a[pivot] = a[pivot], a[lower] return lower def quicksort(a, start, pivot): if pivot <= start: return lower = partition(a, start, pivot) quicksort(a, start, lower - 1) quicksort(a, lower + 1, pivot)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
24,629
def partition(a, start, pivot): lower = upper = start while upper < pivot: if a[upper] <= a[pivot]: a[lower], a[upper] = a[upper], a[lower] lower += 1 upper += 1 a[lower], a[pivot] = a[pivot], a[lower] return lower def quicksort(a, start, pivot): if pivot <= start: return mid = partition(a, start, pivot) quicksort(a, start, mid - 1) quicksort(a, mid + 1, pivot)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
12,652
def partition(a, start, pivot): lower = upper = start while upper < pivot: if a[upper] <= a[pivot]: a[lower], a[upper] = a[upper], a[lower] lower += 1 upper += 1 a[lower], a[pivot] = a[pivot], a[lower] return lower def quicksort(a, start, pivot): if pivot <= start: return mid = partition(a, start, pivot) quicksort(a, start, mid - 1) quicksort(a, mid + 1, pivot)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
35,956
def partition(a, start, pivot): lower = upper = start while upper < pivot: if a[upper] <= a[pivot]: a[lower], a[upper] = a[upper], a[lower] lower += 1 upper += 1 a[lower], a[pivot] = a[pivot], a[lower] return lower def quicksort(a, start, pivot): if pivot <= start: return mid = partition(a, start, pivot) quicksort(a, start, mid - 1) quicksort(a, mid + 1, pivot)
quicksort
quicksort
Sort a list by recursively partitionioning list until sorted.
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
21,574
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 tmp = a[p] a[p] = a[i] a[i] = tmp i = i + 1 k = 0 while k < len(a): print(a[k]) k = k + 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
29,645
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 tmp = a[p] a[p] = a[i] a[i] = tmp i = i + 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
2,512
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 a[p], a[i] = a[i], a[p] i = i + 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
32,119
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j = j + 1 a[p], a[i] = a[i], a[p] i = i + 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
a6392e0c-005c-4131-a7bb-80cf6af877de
2,016
1,945
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 tmp = a[p] a[p] = a[i] a[i] = tmp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
712c50ed-0c17-44f1-a863-183f2d9a5e14
2,016