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
|
---|---|---|---|---|---|---|---|---|
41,357 |
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 |
b0c92748-3b02-4340-a9d8-2ebe9a693531
| 2,016 |
19,317 |
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 |
b0c92748-3b02-4340-a9d8-2ebe9a693531
| 2,016 |
19,717 |
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 |
b0c92748-3b02-4340-a9d8-2ebe9a693531
| 2,016 |
20,500 |
def quicksort(A, start, end):
if end - start < 1:
return
i = j = start
while i <= end:
if A[i] <= A[end]:
A[i], A[j] = A[j], A[i]
j += 1
i += 1
quicksort(A, start, j - 2)
quicksort(A, j, end)
|
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
40,303 |
def quicksort(A, start, end):
if end - start < 1:
return
i = j = start
while i <= end:
if A[i] <= A[end]:
A[i], A[j] = A[j], A[i]
j += 1
i += 1
quicksort(A, start, j - 2)
quicksort(A, j, end)
|
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
8,719 |
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
20,067 |
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
9,035 |
def power(n, p):
if p == 0:
return 1
else:
return power(n, p - 1) * 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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
26,312 |
def power(n, p):
if p == 0:
return 1
else:
return power(n, p - 1) * 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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
41,275 |
def minimum(l):
if len(l) == 1:
return l[0]
else:
min_ret = minimum(l[1:])
return l[0] if l[0] < min_ret else min_ret
|
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
26,728 |
def minimum(l):
if len(l) == 1:
return l[0]
else:
min_ret = minimum(l[1:])
return l[0] if l[0] < min_ret else min_ret
|
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
2,671 |
def maximum(l):
if len(l) == 1:
return l[0]
else:
max_ret = maximum(l[1:])
return l[0] if l[0] > max_ret else max_ret
|
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
853 |
def maximum(l):
if len(l) == 1:
return l[0]
else:
max_ret = maximum(l[1:])
return l[0] if l[0] > max_ret else max_ret
|
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
20,578 |
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
37,138 |
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
15,146 |
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
38,116 |
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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
33,027 |
def fibonacci(n):
if n == 0 or 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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
17,925 |
def fibonacci(n):
if n == 0 or 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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
28,294 |
def fibonacci(n):
if n == 0 or 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 |
7b251fef-3898-4dec-aa70-18b4a70042a3
| 2,016 |
18,022 |
def power(m, n):
if n == 0:
return 0
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
| false |
f98e9d61-9e86-4fed-86db-3cf718c5962d
| 2,016 |
13,255 |
def power(m, n):
if n == 0:
return 0
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
| false |
f98e9d61-9e86-4fed-86db-3cf718c5962d
| 2,016 |
28,399 |
def power(m, n):
if n == 0:
return 1
return m ** n
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
f98e9d61-9e86-4fed-86db-3cf718c5962d
| 2,016 |
29,768 |
def power(m, n):
if n == 0:
return 1
return m ** n
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
f98e9d61-9e86-4fed-86db-3cf718c5962d
| 2,016 |
19,238 |
def power(m, n):
if n == 0:
return 1
return m ** n
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
f98e9d61-9e86-4fed-86db-3cf718c5962d
| 2,016 |
13,702 |
def power(i, power):
if i == i ** power:
return i
power(i * i, power)
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
13,538 |
def power(i, power):
if i == i ** power:
print(i)
return i
power(i * i, power)
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
33,063 |
def power(i, power):
if i == i ** power:
return i
i *= i
power(i, power)
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
2,648 |
def power(i, n):
if i == i ** n:
print(i)
return i
i *= i
power(i, 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
34,710 |
def power(i, n):
return i ** 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
21,935 |
def power(i, n):
return i ** 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
12,694 |
def power(i, n):
if n == 0:
return 1
else:
return i * power(i, 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
28,792 |
def power(i, n):
if n == 0:
return 1
else:
return i * power(i, 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
20,218 |
def power(i, n):
if n == 0:
return 1
else:
return i * power(i, 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
15,035 |
def power(i, n):
if n == 0:
return 1
else:
return i * power(i, 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
6,488 |
def minimum(numbers):
count = 0
for i in numbers:
if i > count:
count = i
return count
|
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 |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
13,058 |
def minimum(numbers):
count = numbers[0]
for i in numbers:
if i < count:
count = i
return count
|
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 |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
37,465 |
def minimum(numbers):
count = numbers[0]
for i in numbers:
if i < count:
count = i
return count
|
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 |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
33,348 |
def power(n, p):
if p == 0:
return 1
else:
return power(n, p - 1) * 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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
12,124 |
def power(n, p):
if p == 0:
return 1
else:
return power(n, p - 1) * 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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
41,319 |
def fibonacci(n):
if n == 0 or 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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
34,544 |
def fibonacci(n):
if n == 0 or 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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
5,153 |
def maximum(l):
if len(l) == 1:
return l[0]
else:
max_ret = maximum(l[1:])
return l[0] if l[0] > max_ret else max_ret
|
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
28,743 |
def maximum(l):
if len(l) == 1:
return l[0]
else:
max_ret = maximum(l[1:])
return l[0] if l[0] > max_ret else max_ret
|
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
20,808 |
def power(m, n):
if n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
12,386 |
def power(m, n):
if n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
11,787 |
def power(m, n):
if n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
15,185 |
def minimum(l):
if len(l) == 1:
return l[0]
else:
min_ret = minimum(l[1:])
return l[0] if l[0] < min_ret else min_ret
|
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
38,815 |
def minimum(l):
if len(l) == 1:
return l[0]
else:
min_ret = minimum(l[1:])
return l[0] if l[0] < min_ret else min_ret
|
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
20,133 |
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
6,036 |
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
32,709 |
def quicksort(A, start, end):
if end - start < 1:
return
i = j = start
while i <= end:
if A[i] <= A[end]:
A[i], A[j] = A[j], A[i]
j += 1
i += 1
quicksort(A, start, j - 2)
quicksort(A, j, end)
|
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
190 |
def quicksort(A, start, end):
if end - start < 1:
return
i = j = start
while i <= end:
if A[i] <= A[end]:
A[i], A[j] = A[j], A[i]
j += 1
i += 1
quicksort(A, start, j - 2)
quicksort(A, j, end)
|
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
11,215 |
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
37,426 |
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
8,800 |
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
38,584 |
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
36,500 |
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 |
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
| 2,016 |
1,027 |
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 |
f463a026-5eb4-4a39-a858-3a798215a4ee
| 2,016 |
13,880 |
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 |
f463a026-5eb4-4a39-a858-3a798215a4ee
| 2,016 |
20,335 |
def count_letters(line=''):
print(len(line))
|
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
| false |
f463a026-5eb4-4a39-a858-3a798215a4ee
| 2,016 |
35,337 |
def count_letters(line=''):
return len(line)
|
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 |
f463a026-5eb4-4a39-a858-3a798215a4ee
| 2,016 |
26,407 |
def count_letters(line=''):
return len(line)
|
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 |
f463a026-5eb4-4a39-a858-3a798215a4ee
| 2,016 |
11,704 |
def count_letters(line=''):
return len(line)
|
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 |
f463a026-5eb4-4a39-a858-3a798215a4ee
| 2,016 |
15,902 |
def power(m, n):
if n == 1:
return m
if n < 1:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
41c113b8-6f57-4003-bed3-3587b2376170
| 2,016 |
41,517 |
def power(m, n):
if n == 1:
return m
if n < 1:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
41c113b8-6f57-4003-bed3-3587b2376170
| 2,016 |
41,533 |
def power(m, n):
if n == 1:
return m
if n < 1:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
41c113b8-6f57-4003-bed3-3587b2376170
| 2,016 |
11,553 |
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
39,680 |
def minimum(s):
min = s[0]
for c in s[1:]:
if c < min:
min = c
return min
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
10,999 |
def maximum(s):
max = s[0]
for c in s[1:]:
if c > max:
max = c
return max
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
22,299 |
def reverse_list(s):
return 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]
| true |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
1,119 |
def fibonacci(n):
if n == 0:
return 1
elif n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
3,802 |
def fibonacci(n):
if n == 0:
return 1
elif n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
38,442 |
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):
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
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
10,386 |
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):
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
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
10,196 |
def selectionsort(a):
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j = j + 1
tmp = a[p]
a[p] = a[i]
a[i] = tmp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
22,642 |
def selectionsort(a):
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j = j + 1
tmp = a[p]
a[p] = a[i]
a[i] = tmp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
8,514 |
def count_letters(s):
if len(s) == 0:
return 0
s = list(s)
s.remove(s[0])
return 1 + count_letters(s)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
6,939 |
def count_letters(s):
if len(s) == 0:
return 0
s = list(s)
s.remove(s[0])
return 1 + count_letters(s)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
17,540 |
def power(m, n):
if m == 1 or n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
34,636 |
def power(m, n):
if m == 1 or n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
22,709 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[0] < a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return minimum(a)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
18,391 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[0] < a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return minimum(a)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
22,649 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[0] > a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return maximum(a)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
23,774 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[0] > a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return maximum(a)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
23,891 |
def reverse_list(s):
if len(s) == 0:
return []
t = s[-1]
s.pop()
return [t] + reverse_list(s)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
29,652 |
def reverse_list(s):
if len(s) == 0:
return []
t = s[-1]
s.pop()
return [t] + reverse_list(s)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
5,333 |
def reverse_list(s):
if len(s) == 0:
return []
t = s[-1]
s.pop()
return [t] + reverse_list(s)
|
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 |
c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c
| 2,016 |
10,415 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
13,166 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
25,062 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
10,176 |
def power(m, n):
if n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
24,200 |
def power(m, n):
if n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
4,623 |
def power(m, n):
if n == 0:
return 1
return m * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
26,875 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[0] < a[1]:
a.remove(a[1])
return minimum(a)
else:
a.remove(a[0])
return minimum(a)
|
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 |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
32,109 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[0] < a[1]:
a.remove(a[1])
return minimum(a)
else:
a.remove(a[0])
return minimum(a)
|
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 |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
9,516 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[0] > a[1]:
a.remove(a[1])
return maximum(a)
else:
a.remove(a[0])
return maximum(a)
|
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 |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
4,252 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[0] > a[1]:
a.remove(a[1])
return maximum(a)
else:
a.remove(a[0])
return maximum(a)
|
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 |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
13,684 |
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 |
4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7
| 2,016 |
41,711 |
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 |
4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7
| 2,016 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.