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
13,552
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 += 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
b13f3dba-a06b-4528-a4d8-c2ee1a5bb34d
2,016
20,136
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 += 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
b13f3dba-a06b-4528-a4d8-c2ee1a5bb34d
2,016
12,806
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 += 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
b13f3dba-a06b-4528-a4d8-c2ee1a5bb34d
2,016
10,550
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
9550e418-a019-49c2-a2e9-8322a300fb6f
2,016
27,710
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
9550e418-a019-49c2-a2e9-8322a300fb6f
2,016
20,523
def fibonacci(n): a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 return l[int(len(l) - 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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
805
def reverse_list(l): if not l: return [] return [l[0]].append(reverse_list(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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
7,763
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
72de96bc-40bc-48ca-b1c3-91150748b31a
2,016
27,470
def reverse_list(l): if not l: return [] return [l[0]].append(reverse_list(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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
26,061
def reverse_list(a): if a == []: return a else: return reverse_list(a[1:]).append(a[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
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
31,548
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
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
34,094
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
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
4,855
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
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
33,000
def reverse_list(a): b = [] i = 0 while i < len(a): b.append(a[-i - 1]) i += 1 return b
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
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
11,002
def reverse_list(a): b = [] i = 0 while i < len(a): b.append(a[-i - 1]) i += 1 return b
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
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
33,997
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
72de96bc-40bc-48ca-b1c3-91150748b31a
2,016
19,481
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
72de96bc-40bc-48ca-b1c3-91150748b31a
2,016
27,219
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
72de96bc-40bc-48ca-b1c3-91150748b31a
2,016
28,437
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
0473ca8a-3862-4046-a34c-16eb754fdfff
2,016
25,278
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
0473ca8a-3862-4046-a34c-16eb754fdfff
2,016
5,021
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
0473ca8a-3862-4046-a34c-16eb754fdfff
2,016
9,504
def fibonacci(n): try: a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 return l[int(len(l) - 1)] except: return 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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
7,872
def selectionsort(l): N = len(l) p = 0 j = 1 while j < N: if l[j] < l[p]: p = j j += 1 return p
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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
40,955
def selectionsort(l): N = len(l) p = 0 j = 1 while j < N: if l[j] < l[p]: p = j j += 1 return p
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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
27,855
def selectionsort(l): N = len(l) p = 0 j = 1 while j < N: if l[j] < l[p]: p = j j += 1 return p
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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
25,716
def reverse_list(l): if not l: return [] return [l[0]].append(reverse_list(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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
41,318
def selectionsort(l): i = 0 while i < len(l): p = i j = i + 1 while j < len(l): if l[j] < l[p]: p = j j = j + 1 tmp = l[p] l[p] = l[i] l[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
9550e418-a019-49c2-a2e9-8322a300fb6f
2,016
6,742
def selectionsort(l): i = 0 while i < len(l): p = i j = i + 1 while j < len(l): if l[j] < l[p]: p = j j = j + 1 tmp = l[p] l[p] = l[i] l[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
9550e418-a019-49c2-a2e9-8322a300fb6f
2,016
36,236
def fibonacci(n): a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 return l[-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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
11,135
def reverse_list(l): if not l or len(l) == 1: return l return [l[-1]] + reverse_list(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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
8,584
def reverse_list(l): if not l or len(l) == 1: return l return [l[-1]] + reverse_list(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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
22,377
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
98d44d17-92f8-4274-915e-b88bdd9dca26
2,016
40,598
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
98d44d17-92f8-4274-915e-b88bdd9dca26
2,016
17,954
def power(n, m): return n ** m
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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
26,319
def power(n, m): return n ** m
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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
24,651
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
false
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
25,097
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
false
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
25,088
def fibonacci(n): if n == 0: return 1 a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 print(l) return l[-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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
8,858
def fibonacci(n): if n == 0: return 1 a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 return l[-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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
5,427
def fibonacci(n): if n == 0: return 1 a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 return l[-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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
35,680
def fibonacci(n): if n == 0: return 1 a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 return l[-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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
34,733
def fibonacci(n): if n == 0: return 1 a = 0 b = 1 l = [] c = 0 while c != n: a += b a, b = b, a l.append(a) c += 1 return l[-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
1c2a27a6-b2a2-47c9-b19f-39d39288a873
2,016
13,289
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
fe81d9d2-29fa-4a6b-abc0-109c9697b557
2,016
23,507
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
fe81d9d2-29fa-4a6b-abc0-109c9697b557
2,016
35,654
def minimum(n=[]): List = sorted(n) return List[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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
16,810
def minimum(n=[]): List = sorted(n) return List[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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
2,060
def maximum(n=[]): List = sorted(n) return List[-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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
16,001
def maximum(n=[]): List = sorted(n) return List[-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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
9,505
def power(x, y): return x ** y
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
21,135
def power(x, y): return x ** y
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
2,201
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[i], a[p] = a[p], a[i] 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
false
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
8,986
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
false
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
16,457
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
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
23,382
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[i], a[p] = a[p], a[i] 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
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
883
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[i], a[p] = a[p], a[i] 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
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
36,347
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[i], a[p] = a[p], a[i] 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
3bcffc16-908f-42c5-9ac3-f685ae6eca33
2,016
27,701
def selectionsort(l): for i in range(1, len(l)): for j in range(i, 0, -1): if l[j] < l[j - 1]: temp = l[j] l[j] = l[j - 1] l[j - 1] = temp
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
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
28,784
def selectionsort(l): for i in range(1, len(l)): for j in range(i, 0, -1): if l[j] < l[j - 1]: temp = l[j] l[j] = l[j - 1] l[j - 1] = temp
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
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
24,004
def selectionsort(l): for i in range(1, len(l)): for j in range(i, 0, -1): if l[j] < l[j - 1]: temp = l[j] l[j] = l[j - 1] l[j - 1] = temp
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
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
27,649
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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
21,266
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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
35,793
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
a493c80e-3567-462a-bcbe-7bd974d52d8a
2,016
313
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n - 1) + fib(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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
17,012
def fibonacci(n): if n == 0: return 0 elif n == 1: 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
true
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
13,478
def fibonacci(n): if n == 0: return 1 elif n == 1: 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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
30,472
def fibonacci(n): if n == 0: return 1 elif n == 1: 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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
31,033
def fibonacci(n): if n == 0: return 1 elif n == 1: 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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
7,341
def minimum(l): min = sum(l) for i in l: if i < min: min = i return min
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
26,663
def minimum(l): min = sum(l) for i in l: if i < min: min = i return min
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
15,440
def maximum(l): max = -1 * sum(l) for i in l: if i > max: max = i return max
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
false
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
10,884
def maximum(l): max = -1 * sum(l) for i in l: if i > max: max = i return max
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
false
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
28,664
def count_letters(s): count = 0 for i in s: count += 1 return count
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
21,031
def count_letters(s): count = 0 for i in s: count += 1 return count
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
12,660
def reverse_list(l): 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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
17,421
def reverse_list(l): 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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
29,518
def fibonacci(n): fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] return fibonacci[n]
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
34,986
def fibonacci(n): fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] return fibonacci[n]
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
26,356
def selectionsort(a): if len(a) != 2: a = [[], a] mini = min(a[1]) a[1].remove(mini) a[0].append(mini) if len(a[1]) == 0: return a[0] else: return selectionsort(a)
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
98d44d17-92f8-4274-915e-b88bdd9dca26
2,016
42,177
def smallest(a, i): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 return p def swap(a, i, p): tmp = a[p] a[p] = a[i] a[i] = tmp def selectionsort(a): i = 0 while i < len(a): p = smallest(a, i) swap(a, i, p) i += 1 return a
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
98d44d17-92f8-4274-915e-b88bdd9dca26
2,016
2,555
def smallest(a, i): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 return p def swap(a, i, p): tmp = a[p] a[p] = a[i] a[i] = tmp def selectionsort(a): i = 0 while i < len(a): p = smallest(a, i) swap(a, i, p) i += 1 return a
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
98d44d17-92f8-4274-915e-b88bdd9dca26
2,016
7,716
def smallest(a, i): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 return p def swap(a, i, p): tmp = a[p] a[p] = a[i] a[i] = tmp def selectionsort(a): i = 0 while i < len(a): p = smallest(a, i) swap(a, i, p) i += 1 return a
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
98d44d17-92f8-4274-915e-b88bdd9dca26
2,016
1,410
def quicksort(a, n, b): a = sorted(a)
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
41,927
def quicksort(a, n, b): a = sorted(a)
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
37,454
def quicksort(a, n, b): a = sorted(a)
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
9e18f731-fa38-496b-927b-db0cd1aa3409
2,016
28,074
def selectionsort(A): for i in range(len(A)): mini = i for j in range(i, len(A)): if A[j] < A[mini]: mini = j A[i], A[mini] = A[mini], A[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
fe81d9d2-29fa-4a6b-abc0-109c9697b557
2,016
16,941
def selectionsort(A): for i in range(len(A)): mini = i for j in range(i, len(A)): if A[j] < A[mini]: mini = j A[i], A[mini] = A[mini], A[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
fe81d9d2-29fa-4a6b-abc0-109c9697b557
2,016
18,363
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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
24,482
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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
27,875
def minimum(l): if len(l) == 1: return l[0] if l[0] < l[1]: l.remove(l[1]) else: l.remove(l[0]) return minimum(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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
2,438
def minimum(l): if len(l) == 1: return l[0] if l[0] < l[1]: l.remove(l[1]) else: l.remove(l[0]) return minimum(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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
34,333
def maximum(l): if len(l) == 1: return l[0] if l[0] > l[1]: l.remove(l[1]) else: l.remove(l[1]) return maximum(l)
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
false
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
37,184
def maximum(l): if len(l) == 1: return l[0] if l[0] > l[1]: l.remove(l[1]) else: l.remove(l[0]) return maximum(l)
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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
27,115
def maximum(l): if len(l) == 1: return l[0] if l[0] > l[1]: l.remove(l[1]) else: l.remove(l[0]) return maximum(l)
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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
41,636
def count_letters(word): total = 0 for c in word: total += 1 return total
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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
19,598
def count_letters(word): total = 0 for c in word: total += 1 return total
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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
40,362
def reverse_list(l): new = [] i = 0 while i < len(l): new.append(l[len(l) - i - 1]) i += 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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
31,684
def reverse_list(l): new = [] i = 0 while i < len(l): new.append(l[len(l) - i - 1]) i += 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]
true
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
6,320
def reverse_list(l): new = [] i = 0 while i < len(l): new.append(l[len(l) - i - 1]) i += 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]
true
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
71
def fibonacci(n): if n == 0: return 1 elif 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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
41,316
def fibonacci(n): if n == 0: return 1 elif 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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016