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
14,189
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
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
14,936
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
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
12,531
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 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
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
6,589
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 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
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
37,438
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 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
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
19,175
def minimum(l): if len(l) == 1: return l[0] else: minv = minimum(l[1:]) return l[0] if l[0] < minv else minv
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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
29,466
def minimum(l): if len(l) == 1: return l[0] else: minv = minimum(l[1:]) return l[0] if l[0] < minv else minv
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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
41,145
def maximum(l): if len(l) == 1: return l[0] else: maxv = maximum(l[1:]) return l[0] if l[0] > maxv else maxv
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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
7,265
def maximum(l): if len(l) == 1: return l[0] else: maxv = maximum(l[1:]) return l[0] if l[0] > maxv else maxv
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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
7,570
def count_letters(s): if s == '': return 0 else: return 1 + count_letters(s[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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
14,860
def count_letters(s): if s == '': return 0 else: return 1 + count_letters(s[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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
40,503
def selectionsort(l): i = 0 while i < len(l): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 tmp = a[p] a[p] = a[i] a[i] = tmp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
false
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
15,496
def reverse_list(l): if len(l) == 0: return [] else: return l[-1].append(reverse_list(s[:-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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
206
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 tmp = a[p] a[p] = a[i] a[i] = tmp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
38,539
def selectionsort(a): i = 0 while i < len(a): p = i j = i + 1 while j < len(a): if a[j] < a[p]: p = j j += 1 tmp = a[p] a[p] = a[i] a[i] = tmp i += 1
selectionsort
selectionsort
Sort a list by repeatedly move minimimum of remaining sublist to front.
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
true
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
5,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 += 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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
16,959
def reverse_list(l): if len(l) == 0: return [] else: return [l[-1]].append(reverse_list(s[:-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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
1,768
def reverse_list(l): if len(l) == 0: return [] else: return [l[-1]].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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
31,476
def reverse_list(l): if len(l) == 0: return [] else: 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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
26,379
def reverse_list(l): if len(l) == 0: return [] else: 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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
2,729
def fibonacci(n): if 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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
19,693
def fibonacci(n): if 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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
39,135
def minimum(ints): if len(ints) == 1: return ints[0] elif ints[0] > ints[1]: ints.remove(ints[0]) else: ints.remove(ints[1]) return minimum(ints)
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
19,153
def minimum(ints): if len(ints) == 1: return ints[0] elif ints[0] > ints[1]: ints.remove(ints[0]) else: ints.remove(ints[1]) return minimum(ints)
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
24,521
def minimum(ints): if len(ints) == 1: return ints[0] elif ints[0] > ints[1]: ints.remove(ints[0]) else: ints.remove(ints[1]) return minimum(ints)
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
35,482
def maximum(ints): if len(ints) == 1: return ints[0] elif ints[0] < ints[1]: ints.remove(ints[0]) else: ints.remove(ints[1]) return maximum(ints)
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
16,280
def maximum(ints): if len(ints) == 1: return ints[0] elif ints[0] < ints[1]: ints.remove(ints[0]) else: ints.remove(ints[1]) return maximum(ints)
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
20,932
def count_letters(string, count=0): if string == '': return count else: string = string[1:] return count_letters(string, 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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
17,269
def count_letters(string, count=0): if string == '': return count else: string = string[1:] return count_letters(string, 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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
25,043
def reverse_list(l, reverse=None): if reverse is None: reverse = [] if not l: return reverse else: reverse.append(l[-1]) l.remove(l[-1]) return reverse_list(l, reverse)
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
35,334
def reverse_list(l, reverse=None): if reverse is None: reverse = [] if not l: return reverse else: reverse.append(l[-1]) l.remove(l[-1]) return reverse_list(l, reverse)
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
5,143
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
8,813
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
8,879
def selectionsort(a): for done in range(len(a) - 1): min_value = a[done] min_index = done for i in range(done + 1, len(a)): if a[i] < min_value: min_value = a[i] min_index = i a[min_index], a[done] = a[done], a[min_index]
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
35,556
def selectionsort(a): for done in range(len(a) - 1): min_value = a[done] min_index = done for i in range(done + 1, len(a)): if a[i] < min_value: min_value = a[i] min_index = i a[min_index], a[done] = a[done], a[min_index]
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
1a650795-f8bf-47db-90f0-c896555da6d7
2,016
24,783
def quicksort(l, beg, fin): if fin - beg < 1: return i = j = beg while i <= fin: if l[i] <= l[fin]: l[i], l[j] = l[j], l[i] j += 1 i += 1 quicksort(l, beg, j - 2) quicksort(l, j, fin)
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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
18,703
def quicksort(l, beg, fin): if fin - beg < 1: return i = j = beg while i <= fin: if l[i] <= l[fin]: l[i], l[j] = l[j], l[i] j += 1 i += 1 quicksort(l, beg, j - 2) quicksort(l, j, fin)
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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
35,298
def selectionsort(A): for i in range(len(A)): min_j = i for j in range(i, len(A)): if A[j] < A[min_j]: min_j = j A[i], A[min_j] = A[min_j], 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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
40,785
def selectionsort(A): for i in range(len(A)): min_j = i for j in range(i, len(A)): if A[j] < A[min_j]: min_j = j A[i], A[min_j] = A[min_j], 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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
7,373
def selectionsort(A): for i in range(len(A)): min_j = i for j in range(i, len(A)): if A[j] < A[min_j]: min_j = j A[i], A[min_j] = A[min_j], 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
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
2,016
14,131
def power(n, p): if p == 0: return 1 return n * power(n, p - 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
262b3841-5158-4b0c-be99-57281e73f267
2,016
29,699
def power(n, p): if p == 0: return 1 return n * power(n, p - 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
262b3841-5158-4b0c-be99-57281e73f267
2,016
5,455
def minimum(l, c=None): if c == None: return minimum(l[1:], l[0]) if l == []: return c if l[0] < c: return minimum(l[1:], l[0]) else: return minimum(l[1:], c)
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
17,266
def minimum(l, c=None): if c == None: return minimum(l[1:], l[0]) if l == []: return c if l[0] < c: return minimum(l[1:], l[0]) else: return minimum(l[1:], c)
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
33,238
def maximum(l, c=None): if c == None: return minimum(l[1:], l[0]) if l == []: return c if l[0] > c: return minimum(l[1:], l[0]) else: return minimum(l[1:], c)
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
41,840
def maximum(l, c=None): if c == None: return maximum(l[1:], l[0]) if l == []: return c if l[0] > c: return maximum(l[1:], l[0]) else: return maximum(l[1:], c)
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
7,101
def maximum(l, c=None): if c == None: return maximum(l[1:], l[0]) if l == []: return c if l[0] > c: return maximum(l[1:], l[0]) else: return maximum(l[1:], c)
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
27,988
def count_letters(word, current=0): if word == '': return current return count_letters(word[1:], current=current + 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
262b3841-5158-4b0c-be99-57281e73f267
2,016
20,170
def count_letters(word, current=0): if word == '': return current return count_letters(word[1:], current=current + 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
262b3841-5158-4b0c-be99-57281e73f267
2,016
23,659
def power(m, n): if n == 1: return m 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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
22,348
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
33,118
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
23,784
def reverse_list(l, n=None): if l == []: return n if n == None: return reverse_list(l[:-1], [l[-1]]) return reverse_list(l[:-1], n + [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
262b3841-5158-4b0c-be99-57281e73f267
2,016
18,526
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
34,217
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
17,838
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
22,520
def minimum(l): a = l[len(l)] if len(a) == 1: return l[0] if a >= minimum(l): return minimum([j for j in l[:-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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
16,495
def minimum(l): a = l[len(l) - 1] if len(a) == 1: return l[0] if a >= minimum(l): return minimum([j for j in l[:-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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
39,828
def minimum(l): a = l[len(l) - 1] if len(l) == 1: return l[0] if a >= minimum(l): return minimum([j for j in l[:-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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
34,587
def minimum(l): a = l[len(l) - 1] if len(l) == 1: return l[0] if a >= minimum(l[:-1]): return minimum(l[-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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
17,575
def minimum(l): a = l[0] if len(l) == 1: return l[0] if a >= minimum(l[:-1]): return minimum(l[:-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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
33,566
def minimum(l): a = l[0] if len(l) == 2: if l[1] >= l[0]: return l[0] else: return l[1] if a >= minimum(l[:-1]): return minimum(l[:-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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
1,533
def minimum(l): a = l[0] if len(l) == 1: return l[0] elif a >= minimum(l): return minimum(l[:-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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
21,491
def minimum(l): if len(l) == 1: return l[0] else: for i in l: if i >= minimum(l[1:]): return minimum(l[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
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
2,489
def minimum(l): if len(l) == 1: return l[0] if minimum(l[:-1]) >= minimum(l[1:]): return minimum(l[1:]) else: return minimum(l[:-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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
29,107
def minimum(l): if len(l) == 1: return l[0] if minimum(l[:-1]) >= minimum(l[1:]): return minimum(l[1:]) else: return minimum(l[:-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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
34,998
def maximum(l): if len(l) == 1: return l[0] if maximum(l[:-1]) >= maximum(l[1:]): return maximum(l[:-1]) else: return maximum(l[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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
10,506
def maximum(l): if len(l) == 1: return l[0] if maximum(l[:-1]) >= maximum(l[1:]): return maximum(l[:-1]) else: return maximum(l[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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
37,664
def count_letters(s): if s == '': return 0 return 1 + count_letters(s[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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
36,598
def count_letters(s): if s == '': return 0 return 1 + count_letters(s[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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
29,779
def reverse_list(l): if len(l) == 2: return l[1] + l[0] else: return reverse_list(l[1:]) + l[0]
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
26,465
def reverse_list(l): if len(l) == 2: return list(''.join(l[1], l[0])) else: return list(''.join(reverse_list(l[1:]), l[0]))
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
7,850
def reverse_list(l): if len(l) == 2: return ''.join(l[1], l[0]).split() else: return ''.join(reverse_list(l[1]), l[0]).split()
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
7,445
def reverse_list(l): if len(l) == 2: return ' '.join(l[1], l[0]).split(' ') else: return ''.join(reverse_list(l[1]), l[0]).split()
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
12,588
def reverse_list(l): if len(l) == 2: return l[1].append(l[0]) return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
39,444
def reverse_list(l): if len(l) == 2: a = [] a.append(l[1]) a.append(l[0]) return a return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
37,201
def reverse_list(l): if len(l) == 0: return [] return reverse_list(l).append(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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
12,539
def reverse_list(l): if len(l) == 0: return [] return reverse_list(l).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
5,472
def reverse_list(l): if len(l) == 0: return [] return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
32,541
def reverse_list(l): if len(l) == 0: return [] else: return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
4,072
def reverse_list(l): if len(l) == 0: return [] elif len(l) == 1: return l[0] else: return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
39,489
def reverse_list(l): if len(l) == 0: return [] elif len(l) == 1: return reverse_list(l[1:]).append(l[0]) else: return reverse_list(l[1:]).append(l[0])
reverse_recur
reverse_list
Recursively reverse a list of elements.
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
26,111
def fibonacci(n): if n == 1 or n == 1: return 1 else: return fibonacci(n - 2) + fibonacci(n - 1)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
22,466
def fibonacci(n): if n == 1 or n == 0: return 1 else: return fibonacci(n - 2) + fibonacci(n - 1)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
627
def fibonacci(n): if n == 1 or n == 0: return 1 else: return fibonacci(n - 2) + fibonacci(n - 1)
fibonacci_recur
fibonacci
Recursively compute the value of the fibonacci series at position n.
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
33,540
def selectionsort(a): i = 0 while i < len(a): j = i + 1 p = i while j < len(a): if a[p] >= a[j]: p = j j += 1 tmp = a[i] a[i] = a[p] a[p] = 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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
39,907
def selectionsort(a): i = 0 while i < len(a): j = i + 1 p = i while j < len(a): if a[p] >= a[j]: p = j j += 1 tmp = a[i] a[i] = a[p] a[p] = 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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
23,810
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
6,092
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
32,011
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
39,492
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
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
23,626
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
31,952
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
2,112
def minimum(list_1): i = 0 total = '1000000' while i < len(list_1): if int(list_1[i]) <= int(total): total = list_1[i] else: 0 i = i + 1 return total
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
33,468
def minimum(list_1): i = 0 total = '1000000' while i < len(list_1): if int(list_1[i]) <= int(total): total = list_1[i] else: 0 i = i + 1 return total
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
8,798
def maximum(list_1): i = 0 total = 0 while i < len(list_1): if int(list_1[i]) >= int(total): total = list_1[i] else: 0 i = i + 1 return total
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
17,233
def maximum(list_1): i = 0 total = 0 while i < len(list_1): if int(list_1[i]) >= int(total): total = list_1[i] else: 0 i = i + 1 return total
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
11,457
def count_letters(string): return len(string)
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
1,934
def count_letters(string): return len(string)
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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
27,700
def reverse_list(list_1): return list_1[::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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016