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
|
---|---|---|---|---|---|---|---|---|
7,857 |
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 |
40,030 |
def reverse_list(n=[]):
if len(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 |
164 |
def reverse_list(n=[]):
if len(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 |
719 |
def reverse_list(n):
if len(n) == 0:
return []
else:
return [n[-1]] + 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]
| true |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
9,495 |
def reverse_list(n):
if len(n) == 0:
return []
else:
return [n[-1]] + 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]
| true |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
37,907 |
def reverse_list(n):
if len(n) == 0:
return []
else:
return [n[-1]] + 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]
| true |
31fe4020-d4b7-4bf5-ac95-b28807a90ae8
| 2,016 |
38,540 |
def count_letters(s, i=0):
if s == '':
return 0
return 1 + count_letters(s[:-1])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
27,689 |
def count_letters(s, i=0):
if s == '':
return 0
return 1 + count_letters(s[:-1])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
12,792 |
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
else:
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 |
6668ebd6-a850-4666-b8cc-5c934a67601a
| 2,016 |
12,559 |
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
else:
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 |
6668ebd6-a850-4666-b8cc-5c934a67601a
| 2,016 |
36,440 |
def count_letters(word):
if 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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
24,421 |
def count_letters(word):
if 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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
26,130 |
def count_letters(word):
if 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 |
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,016 |
21,026 |
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 |
6668ebd6-a850-4666-b8cc-5c934a67601a
| 2,016 |
28,591 |
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 |
6668ebd6-a850-4666-b8cc-5c934a67601a
| 2,016 |
4,599 |
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 |
6668ebd6-a850-4666-b8cc-5c934a67601a
| 2,016 |
1,506 |
def selectionsort(n):
i = 0
while i < len(n):
p = i
j = i + 1
while j < len(n):
if n[j] < n[p]:
p = j
j = j + 1
temp = n[p]
n[p] = n[i]
n[i] = temp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
2,756 |
def selectionsort(n):
i = 0
while i < len(n):
p = i
j = i + 1
while j < len(n):
if n[j] < n[p]:
p = j
j = j + 1
temp = n[p]
n[p] = n[i]
n[i] = temp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
15,001 |
def selectionsort(n):
i = 0
while i < len(n):
p = i
j = i + 1
while j < len(n):
if n[j] < n[p]:
p = j
j = j + 1
temp = n[p]
n[p] = n[i]
n[i] = temp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
3d19e1db-d496-420c-b077-41631364e4f7
| 2,016 |
24,604 |
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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
33,134 |
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 |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
27,709 |
def fibonacci(n, first_number=0, second_number=1, counter=0):
if n == 0:
return 0
elif n == 1:
return 1
elif n == counter:
return second_number
else:
holder = second_number
second_number += first_number
first_number = holder
return fibonacci(n, first_number, second_number, counter + 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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
178 |
def fibonacci(n, first_number=0, second_number=1, counter=0):
if n == 0:
return 0
elif n == 1:
return 1
elif n == counter:
return second_number
else:
holder = second_number
second_number += first_number
first_number = holder
return fibonacci(n, first_number, second_number, counter + 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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
13,056 |
def fibonacci(n, first_number=0, second_number=1, counter=0):
if n == 0:
print('HEYA')
return 0
elif n == 1:
return 1
elif n == counter:
return second_number
else:
holder = second_number
second_number += first_number
first_number = holder
return fibonacci(n, first_number, second_number, counter + 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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
38,310 |
def fibonacci(n, first_number=0, second_number=1, counter=0):
if n == 0:
return 1
elif n == 1:
return 1
elif n == counter:
return second_number
else:
holder = second_number
second_number += first_number
first_number = holder
return fibonacci(n, first_number, second_number, counter + 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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
39,579 |
def fibonacci(n, first_number=0, second_number=1, counter=0):
if n == 0:
return 1
elif n == 1:
return 1
elif n == counter:
return second_number
else:
holder = second_number
second_number += first_number
first_number = holder
return fibonacci(n, first_number, second_number, counter + 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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
23,598 |
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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
41,735 |
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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
13,749 |
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 |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
13,692 |
def maximum(l):
if len(l) == 1:
return l[0]
if l[0] > l[1]:
l.remove(l[1])
else:
l.remove(l[0])
return maximum(l)
|
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 |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
28,120 |
def maximum(l):
if len(l) == 1:
return l[0]
if l[0] > l[1]:
l.remove(l[1])
else:
l.remove(l[0])
return maximum(l)
|
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 |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
17,873 |
def power(n, m):
if m == 1:
return n
if m == 0:
return 1
return n * power(n, m - 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 |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
38,278 |
def power(n, m):
if m == 1:
return n
if m == 0:
return 1
return n * power(n, m - 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 |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
3,730 |
def minimum(l):
if len(l) == 1:
return l[0]
if l[0] < l[1]:
l.remove(l[1])
else:
l.remove(l[0])
return minimum(l)
|
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 |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
26,713 |
def minimum(l):
if len(l) == 1:
return l[0]
if l[0] < l[1]:
l.remove(l[1])
else:
l.remove(l[0])
return minimum(l)
|
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 |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
9,187 |
def fibonacci(n):
if n == 0:
return 1
elif n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
39,322 |
def fibonacci(n):
if n == 0:
return 1
elif n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
30,016 |
def fibonacci(n):
if n == 0:
return 1
elif n == 1:
return 1
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
422fe752-ca84-4537-b250-7de556e6ee94
| 2,016 |
23,703 |
def reverse_list(a):
if a == []:
return a
return reverse_list(a[1:]) + [a[0]]
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
27,927 |
def reverse_list(a):
if a == []:
return a
return reverse_list(a[1:]) + [a[0]]
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
26,112 |
def reverse_list(a):
if a == []:
return a
return reverse_list(a[1:]) + [a[0]]
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
ba8a7560-aac9-45ef-b6fd-730b60e73e8c
| 2,016 |
285 |
def selectionsort(array):
for i in range(len(array)):
for j in range(i, len(array)):
if array[i] > array[j]:
array[i], array[j] = array[j], array[i]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
4,971 |
def selectionsort(array):
for i in range(len(array)):
for j in range(i, len(array)):
if array[i] > array[j]:
array[i], array[j] = array[j], array[i]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
1,306 |
def selectionsort(array):
for i in range(len(array)):
for j in range(i, len(array)):
if array[i] > array[j]:
array[i], array[j] = array[j], array[i]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
| 2,016 |
27,055 |
def power(n, m):
if m == 1:
return n
if m == 0:
return 1
return n * (n, m - 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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
30,159 |
def power(n, m):
if m == 1:
return n
if m == 0:
return 1
return n * power(n, m - 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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
37,152 |
def power(n, m):
if m == 1:
return n
if m == 0:
return 1
return n * power(n, m - 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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
25,008 |
def minimum(lst):
if len(lst) == 1:
return lst[0]
if lst[0] < lst[1]:
lst.remove(lst[1])
else:
lst.remove(lst[0])
return minimum(lst)
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
18,829 |
def minimum(lst):
if len(lst) == 1:
return lst[0]
if lst[0] < lst[1]:
lst.remove(lst[1])
else:
lst.remove(lst[0])
return minimum(lst)
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
29,672 |
def maximum(lst):
if len(lst) == 1:
return lst[0]
if lst[0] > lst[1]:
lst.remove(lst[q])
else:
lst.remove(lst[0])
return maximum(lst)
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
6,664 |
def maximum(lst):
if len(lst) == 1:
return lst[0]
if lst[0] > lst[1]:
lst.remove(lst[0])
else:
lst.remove(lst[0])
return maximum(lst)
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
18,416 |
def maximum(lst):
if len(lst) == 1:
return lst[0]
if lst[0] > lst[1]:
lst.remove(lst[1])
else:
lst.remove(lst[0])
return maximum(lst)
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
26,121 |
def maximum(lst):
if len(lst) == 1:
return lst[0]
if lst[0] > lst[1]:
lst.remove(lst[1])
else:
lst.remove(lst[0])
return maximum(lst)
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
18,531 |
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
26,919 |
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
5,529 |
def reverse_list(lst):
l = lst[::-1]
return l
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
8,083 |
def reverse_list(lst):
l = lst[::-1]
return l
|
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 |
05f63619-1095-4d15-8436-1f0832a593bc
| 2,016 |
37,980 |
def count_letters(s):
if s == '':
return 0
return 1 + count_letters(s[:-1])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
36,133 |
def count_letters(s):
if s == '':
return 0
return 1 + count_letters(s[:-1])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
4,384 |
def reverse_list(l):
if len(l) == 0:
return []
a = l[1]
return reverse_list(l[1:]).append(a)
|
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
22,442 |
def reverse_list(l):
if len(l) == 0:
return []
a = l[0]
return reverse_list(l[1:]).append(a)
|
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
41,742 |
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
4,497 |
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
10,781 |
def reverse_list(l):
if len(l) == 0:
return []
return [l[-1]] + reverse_list(l[:-1])
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
14,517 |
def reverse_list(l):
if len(l) == 0:
return []
return [l[-1]] + reverse_list(l[:-1])
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
9,613 |
def reverse_list(l):
if len(l) == 0:
return []
return [l[-1]] + reverse_list(l[:-1])
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
6,397 |
def minimum(l):
if len(l) == 1:
return l[0]
if l[0] > l[1]:
return minimum(l[1:])
else:
return minimum(l[0] + l[2:])
|
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
11,315 |
def minimum(l):
if len(l) == 1:
return l[0]
if l[0] > l[1]:
return minimum(l[1:])
else:
return minimum([l[0]] + l[2:])
|
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
7,475 |
def minimum(l):
if len(l) == 1:
return l[0]
if l[0] > l[1]:
return minimum(l[1:])
else:
return minimum([l[0]] + l[2:])
|
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
41,554 |
def maximum(l):
if len(l) == 1:
return l[0]
if l[0] < l[1]:
return maximum(l[1:])
else:
return maximum([l[0]] + l[2:])
|
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
38,255 |
def maximum(l):
if len(l) == 1:
return l[0]
if l[0] < l[1]:
return maximum(l[1:])
else:
return maximum([l[0]] + l[2:])
|
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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
20,079 |
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
a[i], a[p] = a[p], a[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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
33,640 |
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
a[i], a[p] = a[p], a[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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
17,296 |
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
a[i], a[p] = a[p], a[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 |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
33,214 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
37,063 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
|
fibonacci_recur
|
fibonacci
|
Recursively compute the value of the fibonacci series at position n.
|
assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657
| false |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
14,163 |
def quicksort(A, start, end):
if end - start < 1:
return
i = j = start
while i <= end:
if A[i] <= A[end]:
A[i], A[j] = A[j], A[i]
j += 1
i += 1
quicksort(A, start, j - 2)
quicksort(A, j, end)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
33,492 |
def quicksort(A, start, end):
if end - start < 1:
return
i = j = start
while i <= end:
if A[i] <= A[end]:
A[i], A[j] = A[j], A[i]
j += 1
i += 1
quicksort(A, start, j - 2)
quicksort(A, j, end)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
40,240 |
def selectionsort(A):
for i in range(len(A)):
min_j = i
for j in range(i, len(A)):
if A[j] < A[min_j]:
min_j = j
A[i], A[min_j] = A[min_j], A[i]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
14 |
def selectionsort(A):
for i in range(len(A)):
min_j = i
for j in range(i, len(A)):
if A[j] < A[min_j]:
min_j = j
A[i], A[min_j] = A[min_j], A[i]
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
41,580 |
def power(n, p):
if p == 0:
return 1
else:
return power(n, p - 1) * n
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
8,222 |
def power(n, p):
if p == 0:
return 1
else:
return power(n, p - 1) * n
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
41,338 |
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 |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
5,808 |
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 |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
34,644 |
def minimum(l):
if len(l) == 1:
return l[0]
else:
min_ret = minimum(l[1:])
return l[0] if l[0] < min_ret else min_ret
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
5,426 |
def minimum(l):
if len(l) == 1:
return l[0]
else:
min_ret = minimum(l[1:])
return l[0] if l[0] < min_ret else min_ret
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
681 |
def maximum(l):
if len(l) == 1:
return l[0]
else:
max_ret = maximum(l[1:])
return l[0] if l[0] > max_ret else max_ret
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
32,882 |
def maximum(l):
if len(l) == 1:
return l[0]
else:
max_ret = maximum(l[1:])
return l[0] if l[0] > max_ret else max_ret
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
17,503 |
def reverse_list(l):
if len(l) == 0:
return []
else:
return [l[-1]] + reverse_list(l[:-1])
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
14,748 |
def reverse_list(l):
if len(l) == 0:
return []
else:
return [l[-1]] + reverse_list(l[:-1])
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
4,164 |
def reverse_list(l):
if len(l) == 0:
return []
else:
return [l[-1]] + reverse_list(l[:-1])
|
reverse_recur
|
reverse_list
|
Recursively reverse a list of elements.
|
assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]
| true |
794362b7-cbcd-4bea-bafb-7967c266e248
| 2,016 |
32,668 |
def partition(a, start, end):
j = q = start
while j < end:
if a[j] < a[end]:
a[j], a[q] = a[q], a[j]
q += 1
j += 1
a[end], a[q] = a[q], a[end]
return q
def quicksort(a, start, end):
if end <= start:
return
q = partition(a, start, end)
quicksort(a, start, q - 1)
quicksort(a, q + 1, end)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
41,776 |
def partition(a, start, end):
j = q = start
while j < end:
if a[j] < a[end]:
a[j], a[q] = a[q], a[j]
q += 1
j += 1
a[end], a[q] = a[q], a[end]
return q
def quicksort(a, start, end):
if end <= start:
return
q = partition(a, start, end)
quicksort(a, start, q - 1)
quicksort(a, q + 1, end)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
41,217 |
def partition(a, start, end):
j = q = start
while j < end:
if a[j] < a[end]:
a[j], a[q] = a[q], a[j]
q += 1
j += 1
a[end], a[q] = a[q], a[end]
return q
def quicksort(a, start, end):
if end <= start:
return
q = partition(a, start, end)
quicksort(a, start, q - 1)
quicksort(a, q + 1, end)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
| 2,016 |
28,362 |
def power(m, n):
if n == 1:
return m
if n == 0:
return 1
return n * power(m, n - 1)
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| false |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
21,720 |
def power(m, n):
if n == 1:
return m
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
27,276 |
def power(m, n):
if n == 1:
return m
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
27,140 |
def minimum(n):
if len(n) == 1:
return n[0]
if n[0] < n[1]:
n.remove(n[1])
else:
n.remove(n[0])
return minimum(n)
|
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
29,047 |
def minimum(n):
if len(n) == 1:
return n[0]
if n[0] < n[1]:
n.remove(n[1])
else:
n.remove(n[0])
return minimum(n)
|
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
12,175 |
def maximum(n):
if len(n) == 1:
return n[0]
if n[0] > n[1]:
n.remove(n[1])
else:
n.remove(n[0])
return maximum(n)
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.