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,883
def count_letters(s, count=0): if not s: return count return count_letters(s[:-1], count + 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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
7,186
def count_letters(s, count=0): if not s: return count return count_letters(s[:-1], count + 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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
39,449
def maximum(l, max_n=None): if not len(l): return max_n if not max_n or l[0] > max_n: return maximum(l[1:], l[0]) return maximum(l[1:], max_n)
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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
31,370
def maximum(l, max_n=None): if not len(l): return max_n if not max_n or l[0] > max_n: return maximum(l[1:], l[0]) return maximum(l[1:], max_n)
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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
831
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
28,915
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
41,662
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
21,262
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
25,258
def maximum(list): if len(list) == 1: return list[0] else: m = maximum(list[1:]) return m if m > list[0] else list[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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
3,669
def maximum(list): if len(list) == 1: return list[0] else: m = maximum(list[1:]) return m if m > list[0] else list[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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
23,197
def minimum(list): if len(list) == 1: return list[0] else: return min(list[0], minimum(list[1:]))
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
36,972
def minimum(list): if len(list) == 1: return list[0] else: return min(list[0], minimum(list[1:]))
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
27,272
def count_letters(str): return len(str)
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
33,787
def count_letters(str): return len(str)
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
13,023
def reverse_list(l): if len(l) == 0: return [] 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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
20,952
def reverse_list(l): if len(l) == 0: return [] 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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
34,269
def quicksort(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
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
23,222
def quicksort(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
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
18,489
def selectionsort(alist): for fillslot in range(len(alist) - 1, 0, -1): positionOfMax = 0 for location in range(1, fillslot + 1): if alist[location] > alist[positionOfMax]: positionOfMax = location temp = alist[fillslot] alist[fillslot] = alist[positionOfMax] alist[positionOfMax] = 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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
21,055
def selectionsort(alist): for fillslot in range(len(alist) - 1, 0, -1): positionOfMax = 0 for location in range(1, fillslot + 1): if alist[location] > alist[positionOfMax]: positionOfMax = location temp = alist[fillslot] alist[fillslot] = alist[positionOfMax] alist[positionOfMax] = 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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
27,174
def selectionsort(alist): for fillslot in range(len(alist) - 1, 0, -1): positionOfMax = 0 for location in range(1, fillslot + 1): if alist[location] > alist[positionOfMax]: positionOfMax = location temp = alist[fillslot] alist[fillslot] = alist[positionOfMax] alist[positionOfMax] = 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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
3,290
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
caddc359-e5b0-41d8-94ab-df712d5ea9ce
2,016
16,401
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
caddc359-e5b0-41d8-94ab-df712d5ea9ce
2,016
27,865
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
caddc359-e5b0-41d8-94ab-df712d5ea9ce
2,016
31,233
def minimum(lst): if len(lst) == 1: return lst[-1] elif lst[0] < lst[-1]: return minimum(lst[:-1]) elif lst[0] > lst[-1]: return minimum(lst[1:])
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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
26,945
def minimum(lst): if len(lst) == 1: return lst[-1] elif lst[0] < lst[-1]: return minimum(lst[:-1]) elif lst[0] > lst[-1]: return minimum(lst[1:])
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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
18,910
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
31,023
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
25,679
def power(n, x): if x == 0: return 1 return n * power(n, x - 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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
21,561
def power(n, x): if x == 0: return 1 return n * power(n, x - 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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
14,379
def power(n, x): if x == 0: return 1 return n * power(n, x - 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
4788f2f7-8b97-41a8-88ee-697183f85246
2,016
33,921
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
40,715
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
3,935
def quicksort(l, p, r): if r <= p: return q = j = p while j < r: if l[j] <= l[r]: l[q], l[j] = l[j], l[q] q += 1 j += 1 l[q], l[r] = l[r], l[q] quicksort(l, p, q - 1) quicksort(l, 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
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
18,620
def power(n, m): if m == 1: return n if m == 0: return 1 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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
9,188
def power(n, m): if m == 1: return n if m == 0: return 1 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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
38,678
def power(n, m): if m == 1: return n if m == 0: return 1 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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
14,498
def index(word, letter): i = 0 while i < len(word): if letter not in word: return -1 elif word[i] == letter: return i else: i = i + 1
index_iter
index
Iteratively search for the position of letter in str, return -1 if it is not there.
assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0
false
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
35,689
def fibonacci(n): a = 0 b = 1 for i in range(0, n): print(a) temp = a a = b b = temp + b return a
fibonacci_iter
fibonacci
Iteratively compute the value of the fibonacci series at position n.
assert fibonacci(1)==1 and fibonacci(41)==165580141 and fibonacci(3)==2 and fibonacci(91)==4660046610375530309
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
18,006
def search(word, letter): if letter in word: return True else: return False
search_iter
search
Iteratively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
36,231
def index(word, letter): i = 0 while i < len(word): if letter not in word: return -1 elif word[i] == letter: return i else: i = i + 1
index_iter
index
Iteratively search for the position of letter in str, return -1 if it is not there.
assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0
false
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
37,314
def search(word, letter): if letter in word: return True else: return False
search_iter
search
Iteratively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
17,934
def fibonacci(n): a = 0 b = 1 for i in range(0, n): print(a) temp = a a = b b = temp + b return a
fibonacci_iter
fibonacci
Iteratively compute the value of the fibonacci series at position n.
assert fibonacci(1)==1 and fibonacci(41)==165580141 and fibonacci(3)==2 and fibonacci(91)==4660046610375530309
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
33,599
def fibonacci(n): a = 0 b = 1 for i in range(0, n): print(a) temp = a a = b b = temp + b return a
fibonacci_iter
fibonacci
Iteratively compute the value of the fibonacci series at position n.
assert fibonacci(1)==1 and fibonacci(41)==165580141 and fibonacci(3)==2 and fibonacci(91)==4660046610375530309
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
20,934
def search(word, letter): if letter in word: return True else: return False
search_iter
search
Iteratively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
28,681
def index(word, letter): i = 0 while i < len(word): if letter not in word: return -1 elif word[i] == letter: return i else: i = i + 1
index_iter
index
Iteratively search for the position of letter in str, return -1 if it is not there.
assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0
false
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
13,466
def search(word, letter): if letter in word: return True else: return False
search_iter
search
Iteratively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
14,231
def fibonacci(n): a = 0 b = 1 for i in range(0, n): print(a) temp = a a = b b = temp + b return a
fibonacci_iter
fibonacci
Iteratively compute the value of the fibonacci series at position n.
assert fibonacci(1)==1 and fibonacci(41)==165580141 and fibonacci(3)==2 and fibonacci(91)==4660046610375530309
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
29,693
def index(word, letter): i = 0 while i < len(word): if letter not in word: return -1 elif word[i] == letter: return i else: i = i + 1
index_iter
index
Iteratively search for the position of letter in str, return -1 if it is not there.
assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0
false
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
27,169
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: a = 0 b = 1 i = 2 while i <= n: fib = a + b a = b b = fib i += 1 return fib
fibonacci_iter
fibonacci
Iteratively compute the value of the fibonacci series at position n.
assert fibonacci(1)==1 and fibonacci(41)==165580141 and fibonacci(3)==2 and fibonacci(91)==4660046610375530309
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
16,838
def index(word, letter): i = 0 while i < len(word): if letter not in word: return -1 elif word[i] == letter: return i else: i = i + 1
index_iter
index
Iteratively search for the position of letter in str, return -1 if it is not there.
assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0
false
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
14,282
def search(word, letter): if letter in word: return True else: return False
search_iter
search
Iteratively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
11,202
def search(word, letter): if letter in word: return True else: return False
search_iter
search
Iteratively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
3,560
def index(word, letter): i = 0 while i < len(word): if letter not in word: return -1 elif word[i] == letter: return i else: i = i + 1
index_iter
index
Iteratively search for the position of letter in str, return -1 if it is not there.
assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0
false
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
2,436
def search(word, letter): if letter in word: return True else: return False
search_iter
search
Iteratively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
23,670
def index(word, letter): i = 0 while i < len(word): if letter not in word: return -1 elif word[i] == letter: return i else: i = i + 1
index_iter
index
Iteratively search for the position of letter in str, return -1 if it is not there.
assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0
false
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
20,691
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: a = 0 b = 1 i = 2 while i <= n: fib = a + b a = b b = fib i += 1 return fib
fibonacci_iter
fibonacci
Iteratively compute the value of the fibonacci series at position n.
assert fibonacci(1)==1 and fibonacci(41)==165580141 and fibonacci(3)==2 and fibonacci(91)==4660046610375530309
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
4,846
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: a = 0 b = 1 i = 2 while i <= n: fib = a + b a = b b = fib i += 1 return fib
fibonacci_iter
fibonacci
Iteratively compute the value of the fibonacci series at position n.
assert fibonacci(1)==1 and fibonacci(41)==165580141 and fibonacci(3)==2 and fibonacci(91)==4660046610375530309
true
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
26,717
def double(n): return n * 2
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
25,256
def double(n): return n * 2
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
35,711
def circumference(r): return 2 * pi * r
circumference
circumference
Return the circumference of a circle.
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
24,654
def area(r): return pi * r ** 2
area
area
Return the area of a circle with the given coordinates.
assert area(0)==0.0 and area(-14329)==644910876.981
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
40,874
def area(r): return pi * r ** 2
area
area
Return the area of a circle with the given coordinates.
assert area(0)==0.0 and area(-14329)==644910876.981
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
925
def circumference(r): return 2 * pi * r
circumference
circumference
Return the circumference of a circle.
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
3,251
def reverse(a): a = a[::-1]
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
15,604
def reverse(a): return a[::-1]
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
22,358
def reverse(a): return a[::-1]
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
33,938
def reverse(a): return a[::-1]
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
35,622
def swap(a, i, j): tmp = a[i] a[i] = a[j] a[j] = tmp def reverse(a): return swap(a)
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
6,309
def reverse(a): return a[::-1]
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
4,032
def reverse(a): return a[::-1]
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
28,398
def reverse(a): return a[::-1]
reverse_by_swap
reverse
Reverse a list of elements by swapping its elements.
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
36,946
def selection_sort(a): for i in a: j = 0 while j < len(a): if i < a[j]: a[j] = i j += 1 return a
selection_sort
selection_sort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
14,105
def selection_sort(a): for i in range(len(a)): j = 1 if a[j] > a[i]: tmp = a[i] a[i] = a[j] a[j] = tmp j += 1 return a
selection_sort
selection_sort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
34,509
def selection_sort(a): for i in range(len(a)): j = 1 if a[j] > a[i]: tmp = a[i] a[i] = a[j] a[j] = tmp j += 1 return a
selection_sort
selection_sort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
false
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
27,876
def selection_sort(a): return sorted(a)
selection_sort
selection_sort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
28,262
def selection_sort(a): return sorted(a)
selection_sort
selection_sort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
27,498
def selection_sort(a): return sorted(a)
selection_sort
selection_sort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
true
a72d6534-1b96-4a41-95a5-f71f23e2bd99
2,016
9,423
def swap_unique_keys_values(d): return dict([(v, k) for k, v in list(d.items()) if list(d.values()). count(v) == 1])
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
31,615
def swap_unique_keys_values(d): return dict([(v, k) for k, v in list(d.items()) if list(d.values()). count(v) == 1])
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
46954879-c4e4-4ce6-87d4-00184c62b522
2,016
3,060
def search(str, letter): if str == '': return False elif str[0] == letter: return True else: return search(str[1:], letter)
search_recur
search
Recursively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
2,296
def index(str, letter, pos): if pos == len(str): return -1 elif str[pos] == letter: return pos else: return index(str, letter, pos + 1)
index_recur
index
Recursively search for the position of letter in str, return -1 if it is not there.
assert index('','0',0)==-1 and index('0','0',0)==0 and index('a','8',0)==-1 and index('tV2','2',0)==2
true
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
17,804
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
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
20,189
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
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
18,157
def search(str, letter): if str == '': return False elif str[0] == letter: return True else: return search(str[1:], letter)
search_recur
search
Recursively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
10,717
def index(str, letter, pos): if pos == len(str): return -1 elif str[pos] == letter: return pos else: return index(str, letter, pos + 1)
index_recur
index
Recursively search for the position of letter in str, return -1 if it is not there.
assert index('','0',0)==-1 and index('0','0',0)==0 and index('a','8',0)==-1 and index('tV2','2',0)==2
true
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
19,714
def search(str, letter): if str == '': return False elif str[0] == letter: return True else: return search(str[1:], letter)
search_recur
search
Recursively search for a letter in a string
assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True
true
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
38,367
def index(str, letter, pos): if pos == len(str): return -1 elif str[pos] == letter: return pos else: return index(str, letter, pos + 1)
index_recur
index
Recursively search for the position of letter in str, return -1 if it is not there.
assert index('','0',0)==-1 and index('0','0',0)==0 and index('a','8',0)==-1 and index('tV2','2',0)==2
true
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
11,138
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
b8085080-0ead-4e7d-88a1-f66d565aea2e
2,016
35,066
def power(m, n): if n == 0: return 1 else: return m * power(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
false
a49f3af8-fb92-43d5-945c-abc11916e319
2,016
652
def power(m, n): if n == 0: return 1 else: 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
a49f3af8-fb92-43d5-945c-abc11916e319
2,016
38,369
def power(m, n): if n == 0: return 1 else: 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
a49f3af8-fb92-43d5-945c-abc11916e319
2,016
4,685
def power(m, n): if n == 0: return 1 else: 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
a49f3af8-fb92-43d5-945c-abc11916e319
2,016
38,126
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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
13,308
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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
2,158
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
fc73b043-0c96-4ce3-8b8f-2c4c98785aa6
2,016
40,272
def minimum(list): if len(list) == 1: return list[0] else: if list[-1] < list[0]: list.remove[-1] else: list.remove[0] return minmum(list)
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
a49f3af8-fb92-43d5-945c-abc11916e319
2,016
20,295
def minimum(list): if len(list) == 1: return list[0] else: if list[-1] < list[0]: list.pop(0) else: list.pop(-1) return minimum(list)
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
a49f3af8-fb92-43d5-945c-abc11916e319
2,016
10,326
def minimum(list): if len(list) == 1: return list[0] else: if list[-1] < list[0]: list.pop(0) else: list.pop(-1) return minimum(list)
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
a49f3af8-fb92-43d5-945c-abc11916e319
2,016
11,025
def maximum(list): if len(list) == 1: return list[0] else: if list[-1] < list[0]: list.pop(-1) else: list.pop(0) return maximum(list)
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
a49f3af8-fb92-43d5-945c-abc11916e319
2,016