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
|
---|---|---|---|---|---|---|---|---|
6,863 |
def selectionsort(a):
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j += 1
tmp = a[p]
a[p] = a[i]
a[i] = tmp
i += 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
712c50ed-0c17-44f1-a863-183f2d9a5e14
| 2,016 |
10,131 |
def selectionsort(a):
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j += 1
tmp = a[p]
a[p] = a[i]
a[i] = tmp
i += 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
712c50ed-0c17-44f1-a863-183f2d9a5e14
| 2,016 |
25,722 |
def sort(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 = sort(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 |
712c50ed-0c17-44f1-a863-183f2d9a5e14
| 2,016 |
40,228 |
def sort(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 = sort(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 |
712c50ed-0c17-44f1-a863-183f2d9a5e14
| 2,016 |
16,646 |
def sort(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 = sort(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 |
712c50ed-0c17-44f1-a863-183f2d9a5e14
| 2,016 |
39,872 |
def fibonacci(n):
prev = 0
cur = 1
i = 0
while i < n:
tmp = cur
cur = cur + prev
prev = tmp
i = i + 1
return cur
|
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 |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
32,484 |
def fibonacci(n):
prev = 0
cur = 1
i = 0
while i < n:
tmp = cur
cur = cur + prev
prev = tmp
i = i + 1
return cur
|
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 |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
30,806 |
def power(a, b):
if b == 0:
return 1
return a * power(b - 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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
40,611 |
def power(a, b):
if b == 0:
return 1
return a * power(a, b - 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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
31,995 |
def power(a, b):
if b == 0:
return 1
return a * power(a, b - 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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
18,959 |
def minimum(a):
if a == []:
return 1
tmp = a.pop()
if tmp < minimun(a):
return tmp
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
17,326 |
def minimum(a):
if a.pop() < a[-1]:
tmp = a.pop()
if a == []:
return tmp
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
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
14,121 |
def minimum(a):
if a == []:
return tmp
if a.pop() < a[-1]:
tmp = a.pop()
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
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
41,534 |
def minimum(a):
if a == []:
return tmp
if a.pop() < a[-1]:
print(a[-1])
tmp = a.pop()
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
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
42,135 |
def minimum(a):
if a == []:
return tmp
if a.pop() < a[-1]:
print(a.pop())
tmp = a.pop()
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
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
23,053 |
def minimum(a):
if a == []:
return b[0]
if a[-1] < a[-2]:
b.append(a[-1])
if len(b) > 1:
if b[0] > b[1]:
b.remove(b[0])
else:
b.remove(b[1])
return minimum(a[:-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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
9,796 |
def minimum(a, flag=True):
if a == []:
return tmp
if flag == True:
tmp = a.pop()
print(tmp)
if a[-1] < tmp:
tmp = a[-1]
return minimum(a[:-1], flag=False)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
39,331 |
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 |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
11,782 |
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 |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
2,651 |
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
def quicksort(A, p, r):
if r <= p:
return
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
23,041 |
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 |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
20,881 |
def minimum(a, flag=True):
if a == []:
return tmp
if flag == True:
tmp = a.pop()
if a[-1] < tmp:
tmp = a[-1]
return minimum(a[:-1], flag=False)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
29,747 |
def minimum(a, flag=True):
if a == []:
return tmp
if flag == True:
tmp = a.pop()
if a[-1] < tmp:
tmp = a[-1]
return minimum(a[:-1], flag=False)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
30,204 |
def minimum(a, tmp=0):
if a == []:
return tmp
if a[-1] < tmp:
tmp = a[-1]
return minimum(a[:-1], tmp)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
19,844 |
def minimum(a, tmp=0):
if a == []:
return tmp
if tmp == 0 or a[-1] < tmp:
tmp = a[-1]
return minimum(a[:-1], tmp)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
1,010 |
def minimum(a, tmp=0):
if a == []:
return tmp
if tmp == 0 or a[-1] < tmp:
tmp = a[-1]
return minimum(a[:-1], tmp)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
9,895 |
def maximum(a, tmp=0):
if a == []:
return tmp
if tmp == 0 or a[-1] > tmp:
tmp = a[-1]
return minimum(a[:-1], tmp)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
36,252 |
def maximum(a, tmp=0):
if a == []:
return tmp
if tmp == 0 or a[-1] > tmp:
tmp = a[-1]
return maximum(a[:-1], tmp)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
39,231 |
def maximum(a, tmp=0):
if a == []:
return tmp
if tmp == 0 or a[-1] > tmp:
tmp = a[-1]
return maximum(a[:-1], tmp)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
24,492 |
def count_letters(a, count=0):
if len(a) == 0:
return count
count += 1
return count_letters(a - 1, count)
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
9,557 |
def count_letters(a, count=0):
if len(a) == 0:
return count
count += 1
return count_letters(a[:-1], count)
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
35,107 |
def reverse_list(a, b=[]):
if a == []:
return b
b.append(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
31,079 |
def reverse_list(a, b=[]):
if a == []:
return b
b.append(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
19,334 |
def reverse_list(a, b=[]):
if a == []:
tmp = b
b = []
return tmp
b.append(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
5,576 |
def count_letters(a, count=0):
if len(a) == 0:
return count
count += 1
return count_letters(a[:-1], count)
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
398 |
def count_letters(a, count=0):
if len(a) == 0:
return count
count += 1
return count_letters(a[:-1], count)
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
25,607 |
def reverse_list(a, b=''):
if a == []:
return b.split('')
b += ' ' + a[-1]
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
12,830 |
def reverse_list(a, b=''):
if a == []:
return b.split('')
b += ' ' + str(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
11,863 |
def reverse_list(a, b=''):
if a == []:
return b.split(' ')
b += ' ' + str(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
2,480 |
def reverse_list(a, b=''):
if a == []:
return b.split('')
b += ' ' + str(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
6,553 |
def reverse_list(a, b=''):
if a == []:
return b.split(' ')
b += ' ' + str(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
39,910 |
def reverse_list(a, b=''):
if a == []:
return b.strip.split(' ')
b += ' ' + str(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
4,358 |
def reverse_list(a, b=''):
if a == []:
return b.split(' ').strip()
b += ' ' + str(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
1,220 |
def reverse_list(a, b=''):
if a == []:
return b.strip().split(' ')
b += ' ' + str(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
15,410 |
def reverse_list(a, b=''):
if a == []:
return b
b.append(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
39,816 |
def reverse_list(a, b=[]):
if a == []:
return b
b.append(a[-1])
return reverse_list(a[:-1], b)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
36,814 |
def reverse_list(a, b=[], flag=True):
if flag == True:
b = []
if a == []:
return b
b.append(a[-1])
return reverse_list(a[:-1], b, flag=False)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
38,577 |
def reverse_list(a, b=[], flag=True):
if flag == True:
b = []
if a == []:
return b
b.append(a[-1])
return reverse_list(a[:-1], b, flag=False)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
10,554 |
def fibonacci(a):
if a == 0:
return 0
return 1 + fibonacci(a - 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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
25,853 |
def fibonacci(a):
if a == 0:
return 1
return 1 + fibonacci(a - 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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
36,655 |
def fibonacci(a, curr=1):
if a == 0:
return curr
return curr + fibonacci(a - 1, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
10,394 |
def power(m, n):
if n == 0:
return 1
else:
return power(m, n - 1) * m
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
33,231 |
def power(m, n):
if n == 0:
return 1
else:
return power(m, n - 1) * m
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
10,586 |
def power(m, n):
if n == 0:
return 1
else:
return power(m, n - 1) * m
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
26,196 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return 0
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
4,613 |
def minimum(mylist):
if len(mylist) == 1:
return mylist[0]
if mylist[0] > mylist[1]:
mylist.remove(mylist[0])
return minimum(mylist)
else:
mylist.remove(mylist[1])
return minimum(mylist)
|
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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
1,581 |
def minimum(mylist):
if len(mylist) == 1:
return mylist[0]
if mylist[0] > mylist[1]:
mylist.remove(mylist[0])
return minimum(mylist)
else:
mylist.remove(mylist[1])
return minimum(mylist)
|
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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
6,543 |
def minimum(l):
if len(l) == 1:
return l[0]
m = minimum(l[1:])
return m if m < l[0] else l[0]
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
10,014 |
def minimum(l):
if len(l) == 1:
return l[0]
m = minimum(l[1:])
return m if m < l[0] else l[0]
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
10,122 |
def fibonacci(a, prev=0, curr=1):
if a == 0:
return 1
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
38,858 |
def fibonacci(a, prev=0, curr=1):
if a == 0:
return 0
prev = curr
return 1 + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
24,920 |
def maximum(mylist):
if len(mylist) == 1:
return mylist[0]
if mylist[0] < mylist[1]:
mylist.remove(mylist[0])
return minimum(mylist)
else:
mylist.remove(mylist[1])
return minimum(mylist)
|
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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
150 |
def maximum(l):
if len(l) == 1:
return l[0]
m = minimum(l[1:])
return m if m > l[0] else l[0]
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| false |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
39,421 |
def fibonacci(a, prev=0, curr=1):
if a == 0:
return 1
prev = curr
return 1 + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
22,073 |
def maximum(l):
if len(l) == 1:
return l[0]
m = minimum(l[1:])
return m if m > l[0] else l[0]
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| false |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
18,777 |
def fibonacci(a, prev=0, curr=1):
if a == 0:
return prev
prev = curr
return 1 + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
15,042 |
def maximum(l):
if len(l) == 1:
return l[0]
m = minimum(l[1:])
return m if m > l[0] else l[0]
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| false |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
11,266 |
def fibonacci(a, prev=0, curr=1):
if a == 0:
return prev
prev = curr
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
42,148 |
def maximum(l):
if len(l) == 1:
return l[0]
m = maximum(l[1:])
return m if m > l[0] else l[0]
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
42,228 |
def maximum(l):
if len(l) == 1:
return l[0]
m = maximum(l[1:])
return m if m > l[0] else l[0]
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
24,206 |
def fibonacci(a, prev=0, curr=1):
if a == 0:
return prev
tmp = curr
curr += tmp
prev = curr
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
1,296 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return prev
tmp = curr
curr += tmp
prev = curr
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
32,257 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return prev
tmp = curr
curr += pev
prev = curr
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
39,870 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return prev
tmp = curr
curr += prev
prev = curr
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
6,400 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return prev
tmp = curr
curr += prev
prev = tmp
return prev + fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
39,250 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return prev
tmp = curr
curr += prev
prev = tmp
return fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
9,408 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return prev
tmp = curr
curr += prev
prev = tmp
return fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
24,326 |
def fibonacci(a, prev=1, curr=1):
if a == 0:
return prev
tmp = curr
curr += prev
prev = tmp
return fibonacci(a - 1, prev, curr)
|
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 |
a48376ed-7138-4481-a4da-74490838ea3e
| 2,016 |
37,467 |
def maximum(mylist):
if len(mylist) == 1:
return mylist[0]
if mylist[0] < mylist[1]:
mylist.remove(mylist[0])
return maximum(mylist)
else:
mylist.remove(mylist[1])
return maximum(mylist)
|
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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
12,781 |
def maximum(mylist):
if len(mylist) == 1:
return mylist[0]
if mylist[0] < mylist[1]:
mylist.remove(mylist[0])
return maximum(mylist)
else:
mylist.remove(mylist[1])
return maximum(mylist)
|
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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
25,111 |
def count_letters(word):
if not word:
return 0
else:
return 1 + count_letters(word[1:])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
25,042 |
def count_letters(word):
if not word:
return 0
else:
return 1 + count_letters(word[1:])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
14,683 |
def count_letters(word):
if not word:
return 0
else:
return 1 + count_letters(word[1:])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
40,823 |
def count_letters(word):
if not word:
return 0
else:
return 1 + count_letters(word[1:])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,016 |
36,561 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[-2] > a[-1]:
a[-2], a[-1] = a[-1], a[-2]
a.pop()
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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
25,265 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[-2] > a[-1]:
a[-2], a[-1] = a[-1], a[-2]
a.pop()
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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
326 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[-2] > a[-1]:
a[-2], a[-1] = a[-1], a[-2]
a.pop()
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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
17,364 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[-2] < a[-1]:
a[-2], a[-1] = a[-1], a[-2]
a.pop()
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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
10,031 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[-2] < a[-1]:
a[-2], a[-1] = a[-1], a[-2]
a.pop()
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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
18,794 |
def power(a, b):
if b == 0:
return 1
return a * power(a, b - 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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
25,846 |
def power(a, b):
if b == 0:
return 1
return a * power(a, b - 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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
31,131 |
def count_letters(word, count=0):
if word == '':
return count
else:
word = word[1:]
return count_letters(word, 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 |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
25,109 |
def count_letters(word, count=0):
if word == '':
return count
else:
word = word[1:]
return count_letters(word, 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 |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
1,959 |
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 |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
36,361 |
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 |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
26,147 |
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 |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
31,529 |
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 |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
11,687 |
def reverse_list(n):
if n == 1:
return 0
else:
return reverse_list(n - 1)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
13,589 |
def reverse_list(n):
if n == 1:
return 0
else:
return reverse_list(n[-1:])
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| false |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
30,193 |
def reverse_list(n):
if n == 1:
return 0
else:
return reverse_list(n)
|
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 |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.