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
|
---|---|---|---|---|---|---|---|---|
20,688 |
def minimum(l):
biggest = l[0]
for c in l:
if c < biggest:
biggest = c
return biggest
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
24,944 |
def count_letters(s):
n = 0
if not s:
return 0
else:
n += 1
return n + 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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
31,502 |
def maximum(l):
biggest = l[0]
for c in l:
if c > biggest:
biggest = c
return biggest
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
8,484 |
def maximum(l):
biggest = l[0]
for c in l:
if c > biggest:
biggest = c
return biggest
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
22,852 |
def count_letters(s):
n = 0
print(n)
if not s:
return 0
else:
n += 1
return n + 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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
39,619 |
def count_letters(s):
n = 0
print(n)
if not s:
return 0
else:
n += 1
print(n)
return n + 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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
4,179 |
def count_letters(s):
n = 0
print(n)
if not s:
return 0
else:
n += 1
return n + 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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
1,522 |
def count_letters(s):
n = 0
if not s:
return 0
else:
n += 1
return n + 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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
25,013 |
def count_letters(s):
n = 0
if not s:
return 0
else:
n += 1
return n + 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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
37,696 |
def count_letters(s):
counter = 0
if s == '':
return 0
else:
for c in s:
counter += 1
return counter
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
4,096 |
def count_letters(s):
counter = 0
if s == '':
return 0
else:
for c in s:
counter += 1
return counter
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
22,551 |
def reverse_list(l):
l2 = []
i = 0
while l:
l2.append(l[len(l) - i - 1])
tmp = l.pop()
return l2
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
15,262 |
def reverse_list(l):
l2 = []
i = 0
while l:
l2.append(l[len(l) - i - 1])
tmp = l.pop()
return l2
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
5,786 |
def count_letters(m):
if m == '':
return 0
else:
return 1 + count_letters(m[:-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 |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
14,541 |
def count_letters(m):
if m == '':
return 0
else:
return 1 + count_letters(m[:-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 |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
7,936 |
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
def quicksort(A, p, r):
if r <= p:
return
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
38,347 |
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
37,742 |
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
a[p], a[i] = a[i], a[p]
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
22,986 |
def selectionsort(a):
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j += j
a[p], a[i] = a[i], a[p]
i += 1
return a
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| false |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
8,221 |
def power():
if x == 0:
return 1
return 2 * power(x - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| false |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
5,456 |
def power(x, n):
if x == 0:
return 1
return n * power(x - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| false |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
30,049 |
def power(n, x):
if x == 0:
return 1
return n * power(x - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| false |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
32,870 |
def power(n, x):
if x == 0:
return 1
return n * power(n, x - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
6,945 |
def power(n, x):
if x == 0:
return 1
return n * power(n, x - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
28,876 |
def minimum(l, m=None):
if not len(l):
return m
if not m or l[0] < m:
return minimum(l[1:], l[0])
return minimum(l[1:], m)
|
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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
21,961 |
def minimum(l, m=None):
if not len(l):
return m
if not m or l[0] < m:
return minimum(l[1:], l[0])
return minimum(l[1:], m)
|
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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
6,545 |
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
41,989 |
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
38,391 |
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
20,221 |
def reverse_list(a):
if len(a) == 0:
return []
return [a[-1]] + reverse_list(a[:-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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
15,237 |
def reverse_list(a):
if len(a) == 0:
return []
return [a[-1]] + reverse_list(a[:-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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
40,988 |
def minimum(a):
if len(a) == 1:
return a[-1]
elif a[0] < a[-1]:
return minimum(a[:-1])
elif a[0] > a[-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
| true |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
29,480 |
def minimum(a):
if len(a) == 1:
return a[-1]
elif a[0] < a[-1]:
return minimum(a[:-1])
elif a[0] > a[-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
| true |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
12,419 |
def count_letters(s, c=0):
if not s:
return c
return count_letters(s[:-1], c + 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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
37,990 |
def count_letters(s, c=0):
if not s:
return c
return count_letters(s[:-1], c + 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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
21,668 |
def reverse_list(l, r=None):
if not r:
r = []
if not l:
return r
r.append(l.pop())
return reverse_list(l, r)
|
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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
17,126 |
def reverse_list(l, r=None):
if not r:
r = []
if not l:
return r
r.append(l.pop())
return reverse_list(l, r)
|
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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
21,928 |
def maximum(a):
if len(a) == 1:
return a[-1]
elif a[0] > a[-1]:
return maximum(a[:-1])
elif a[0] < a[-1]:
return maximum(a[1:])
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
21,763 |
def maximum(a):
if len(a) == 1:
return a[-1]
elif a[0] > a[-1]:
return maximum(a[:-1])
elif a[0] < a[-1]:
return maximum(a[1:])
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
24,197 |
def fibonacci(n, l=0, c=1):
if not n:
return c
return fibonacci(n - 1, c, l + c)
|
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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
14,752 |
def fibonacci(n, l=0, c=1):
if not n:
return c
return fibonacci(n - 1, c, l + c)
|
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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
33,408 |
def fibonacci(n):
if n == 1 or n == 0:
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
1,599 |
def fibonacci(n):
if n == 1 or n == 0:
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
4,353 |
def fibonacci(n):
if n == (0 or 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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
14,432 |
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
14,254 |
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
34,670 |
def reverse_list(l, ding=None):
if not ding:
ding = []
if not l:
return ding
ding.append(l.pop())
return reverse_list(l, ding)
|
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
27,608 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
18,766 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
4,735 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
30,362 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
18,870 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
23,473 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
34,770 |
def count_letters(s):
n = 0
if not s:
return 0
else:
n += 1
return n + 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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
12,187 |
def count_letters(s):
n = 0
if not s:
return 0
else:
n += 1
return n + 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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
11,813 |
def count_letters(s):
n = 0
if not s:
return 0
else:
n += 1
return n + 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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
14,921 |
def reverse_list(a):
if len(a) == 0:
return []
return [a[-1]] + reverse_list(a[:-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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
18,073 |
def reverse_list(a):
if len(a) == 0:
return []
return [a[-1]] + reverse_list(a[:-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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
14,616 |
def reverse_list(a):
if len(a) == 0:
return []
return [a[-1]] + reverse_list(a[:-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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
28,167 |
def fibonacci(n):
if n == 1 or n == 0:
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
14,333 |
def fibonacci(n):
if n == 1 or n == 0:
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
29,005 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
27,663 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
10,729 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
37,029 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
30,630 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
29,383 |
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
16,983 |
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
41,737 |
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
35,213 |
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
7,143 |
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 |
3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5
| 2,016 |
17,690 |
def quicksort(l):
if len(l) < 2:
return l
pivot = l[0]
left = []
right = []
for n in l[1:]:
if n < pivot:
left.append(n)
else:
right.append(n)
return quicksort(left) + [pivot] + quicksort(right)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
42,257 |
def quicksort(l):
if len(l) < 2:
return l
pivot = l[0]
left = []
right = []
for n in l[1:]:
if n < pivot:
left.append(n)
else:
right.append(n)
return quicksort(left) + [pivot] + quicksort(right)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
37,788 |
def fibonacci(aaliyah, supercalifragilisticespialidotious=0, koppaberg=1):
if not aaliyah:
return koppaberg
return fibonacci(aaliyah - 1, koppaberg,
supercalifragilisticespialidotious + koppaberg)
|
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
25,167 |
def fibonacci(aaliyah, supercalifragilisticespialidotious=0, koppaberg=1):
if not aaliyah:
return koppaberg
return fibonacci(aaliyah - 1, koppaberg,
supercalifragilisticespialidotious + koppaberg)
|
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
33,670 |
def reverse_list(l, ding=None):
if not ding:
ding = []
if not l:
return ding
ding.append(l.pop())
return reverse_list(l, ding)
|
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
6,103 |
def reverse_list(l, ding=None):
if not ding:
ding = []
if not l:
return ding
ding.append(l.pop())
return reverse_list(l, ding)
|
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
3,943 |
def quicksort(cabbages):
if len(l) < 2:
return l
pivot = l[0]
left_side = []
right_side = []
for n in cabbages[1:]:
if n < pivot:
left_side.append(n)
else:
right_side.append(n)
return quicksort(left_side) + [pivot] + quicksort(right_side)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
8,379 |
def quicksort(cabbages):
if len(l) < 2:
return l
pivot = l[0]
left_side = []
right_side = []
for n in cabbages[1:]:
if n < pivot:
left_side.append(n)
else:
right_side.append(n)
return quicksort(left_side) + [pivot] + quicksort(right_side)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
16,731 |
def quicksort(l):
if len(l) < 2:
return l
pivot = l[0]
left = []
right = []
for n in l[1:]:
if n < pivot:
left.append(n)
else:
right.append(n)
return quicksort(left) + [pivot] + quicksort(right)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
30,017 |
def quicksort(l, first, last):
if first >= last:
return
i, j = first, last
pivot = l[random.randint(first, last)]
while i <= j:
while l[i] < pivot:
i += 1
while l[j] > pivot:
j -= 1
if i <= j:
l[i], l[j] = l[j], l[i]
i, j = i + 1, j - 1
quicksort(l, first, j)
quicksort(l, i, last)
return l
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
a493c80e-3567-462a-bcbe-7bd974d52d8a
| 2,016 |
29,079 |
def quicksort(l, first, last):
if first >= last:
return
i, j = first, last
pivot = l[random.randint(first, last)]
while i <= j:
while l[i] < pivot:
i += 1
while l[j] > pivot:
j -= 1
if i <= j:
l[i], l[j] = l[j], l[i]
i, j = i + 1, j - 1
quicksort(l, first, j)
quicksort(l, i, last)
return l
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
a493c80e-3567-462a-bcbe-7bd974d52d8a
| 2,016 |
1,979 |
def quicksort(l, first, last):
if first >= last:
return
i, j = first, last
pivot = l[random.randint(first, last)]
while i <= j:
while l[i] < pivot:
i += 1
while l[j] > pivot:
j -= 1
if i <= j:
l[i], l[j] = l[j], l[i]
i, j = i + 1, j - 1
quicksort(l, first, j)
quicksort(l, i, last)
return l
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
a493c80e-3567-462a-bcbe-7bd974d52d8a
| 2,016 |
17,210 |
def quicksort(l, start=0, end=None):
if len(l) < 2:
return l
pivot = l[0]
left = []
right = []
for n in l[1:]:
if n < pivot:
left.append(n)
else:
right.append(n)
return quicksort(left) + [pivot] + quicksort(right)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
11,938 |
def quicksort(l, start=0, end=None):
if len(l) < 2:
return l
pivot = l[1]
left = []
right = []
for n in l[1:]:
if n < pivot:
left.append(n)
else:
right.append(n)
return quicksort(left) + [pivot] + quicksort(right)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
42,471 |
def quicksort(l, p, r):
if r <= p:
return
q = j = p
while j < r:
if l[j] <= l[r]:
l[q], l[j] = l[j], l[q]
q += 1
j += 1
l[q], l[r] = l[r], l[q]
quicksort(l, p, q - 1)
quicksort(l, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
31,003 |
def quicksort(l, p, r):
if r <= p:
return
q = j = p
while j < r:
if l[j] <= l[r]:
l[q], l[j] = l[j], l[q]
q += 1
j += 1
l[q], l[r] = l[r], l[q]
quicksort(l, p, q - 1)
quicksort(l, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
25,312 |
def quicksort(l, p, r):
if r <= p:
return
q = j = p
while j < r:
if l[j] <= l[r]:
l[q], l[j] = l[j], l[q]
q += 1
j += 1
l[q], l[r] = l[r], l[q]
quicksort(l, p, q - 1)
quicksort(l, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
25,923 |
def quicksort(l, p, r):
if r <= p:
return
q = j = p
while j < r:
if l[j] <= l[r]:
l[q], l[j] = l[j], l[q]
q += 1
j += 1
l[q], l[r] = l[r], l[q]
quicksort(l, p, q - 1)
quicksort(l, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
26,406 |
def selectionsort(l, o=None):
if not o:
o = []
l = l[:]
if not len(l):
return o
small = min(l)
l.remove(small)
o.append(small)
return selectionsort(l, o)
|
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 |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
1,653 |
def selectionsort(l):
for i in range(len(l)):
j = i + 1
p = i
while j < len(l):
if l[j] < l[p]:
p = j
j += 1
l[p], l[i] = l[i], l[p]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
8,029 |
def selectionsort(l):
for i in range(len(l)):
j = i + 1
p = i
while j < len(l):
if l[j] < l[p]:
p = j
j += 1
l[p], l[i] = l[i], l[p]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
38,016 |
def selectionsort(l):
for i in range(len(l)):
j = i + 1
p = i
while j < len(l):
if l[j] < l[p]:
p = j
j += 1
l[p], l[i] = l[i], l[p]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
| 2,016 |
7,219 |
def selectionsort(a):
for i in range(len(a)):
j = i + 1
p = i
while j < len(a):
if a[j] < a[p]:
p = j
j += 1
a[p], a[i] = a[i], a[p]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
25,602 |
def selectionsort(a):
for i in range(len(a)):
j = i + 1
p = i
while j < len(a):
if a[j] < a[p]:
p = j
j += 1
a[p], a[i] = a[i], a[p]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
2,447 |
def quicksort(l, p, r):
if r <= p:
return
q = j = p
while j < r:
if l[j] <= l[r]:
l[q], l[j] = l[j], l[q]
q += 1
j += 1
l[q], l[r] = l[r], l[q]
quicksort(l, p, q - 1)
quicksort(l, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
24,994 |
def fibonacci(n, last=0, curr=1):
if not n:
return curr
return fibonacci(n - 1, curr, last + 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 |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
14,110 |
def fibonacci(n, last=0, curr=1):
if not n:
return curr
return fibonacci(n - 1, curr, last + 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 |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
38,061 |
def reverse_list(a, reverse=None):
if not reverse:
reverse = []
if len(a) < 1:
return reverse
reverse.append(a.pop())
return reverse_list(a, reverse)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
17,710 |
def reverse_list(a, reverse=None):
if not reverse:
reverse = []
if len(a) < 1:
return reverse
reverse.append(a.pop())
return reverse_list(a, reverse)
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.