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,756 |
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
38,598 |
def count_letters(s):
if s == '':
return 0
return 1 + count_letters(s[1:])
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
1,266 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
29,995 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
32,690 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
19,871 |
def reverse_list(l):
if l == []:
return l
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
26,316 |
def reverse_list(l):
if l == []:
return l
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
21,968 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
17,798 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
25,061 |
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:
print(0)
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, p + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
17,707 |
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 None
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
31,034 |
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 1
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, p + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
7,515 |
def fibonacci(n):
if n == 0:
return 1
elif n == 1:
return n
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
37,642 |
def fibonacci(n):
if n == 0:
return 1
elif n == 1:
return n
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
22,560 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[0] < a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return minimum(a)
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
32,077 |
def minimum(a):
if len(a) == 1:
return a[0]
if a[0] < a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return minimum(a)
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
30,224 |
def reverse_list(a):
if len(a) == 1:
return []
else:
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]
| false |
66e06699-d10a-47f1-a343-55edd72e95d2
| 2,016 |
8,615 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
24,725 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[0] > a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return maximum(a)
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
29,631 |
def maximum(a):
if len(a) == 1:
return a[0]
if a[0] > a[1]:
a.remove(a[1])
else:
a.remove(a[0])
return maximum(a)
|
maximum
|
maximum
|
Return the maximum element in a list of numbers.
|
assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9
| true |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
10,903 |
def reverse_list(a):
if len(a) == 0:
return []
else:
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 |
66e06699-d10a-47f1-a343-55edd72e95d2
| 2,016 |
29,678 |
def reverse_list(a):
if len(a) == 0:
return []
else:
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 |
66e06699-d10a-47f1-a343-55edd72e95d2
| 2,016 |
19,373 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
34,341 |
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):
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
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
2,037 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
12,119 |
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
def quicksort(A, p, r):
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| false |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
5,792 |
def minimum(s):
if len(s) == 1:
return 0
else:
max = maxElement(L[1:])
if L[0] > max:
return L[0]
else:
return max
|
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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
35,531 |
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
def quicksort(A, p, r):
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
if r <= p:
return
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
25,268 |
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
def quicksort(A, p, r):
def partition(A, p, r):
q = j = p
while j < r:
if A[j] <= A[r]:
A[q], A[j] = A[j], A[q]
q += 1
j += 1
A[q], A[r] = A[r], A[q]
return q
if r <= p:
return
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
11,691 |
def count_letters(s):
if s == ' ':
return 0
return 1 + count_letters(s)
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| false |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
16,142 |
def minimum(s):
if n == 1:
return s[0]
else:
min = minimum(s[1:], n - 1)
if s[0] < min:
return s[0]
else:
return min
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| false |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
11,515 |
def minimum(s):
if s == 1:
return s[0]
else:
min = minimum(s[1:], s - 1)
if s[0] < min:
return s[0]
else:
return min
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| false |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
20,747 |
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 |
66e06699-d10a-47f1-a343-55edd72e95d2
| 2,016 |
21,137 |
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 |
66e06699-d10a-47f1-a343-55edd72e95d2
| 2,016 |
18,759 |
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 |
66e06699-d10a-47f1-a343-55edd72e95d2
| 2,016 |
30,194 |
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
9,467 |
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
6,143 |
def selectionsort(A):
i = 0
while i < len(A):
j = i + 1
while j < len(A):
if A[j] < A[i]:
A[j], A[i] = A[i], A[j]
j += 1
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
6,237 |
def selectionsort(A):
i = 0
while i < len(A):
j = i + 1
while j < len(A):
if A[j] < A[i]:
A[j], A[i] = A[i], A[j]
j += 1
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
11,614 |
def selectionsort(A):
i = 0
while i < len(A):
j = i + 1
while j < len(A):
if A[j] < A[i]:
A[j], A[i] = A[i], A[j]
j += 1
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 |
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
| 2,016 |
5,346 |
def minimum(s):
if len(s) == 0:
return 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
| false |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
11,894 |
def minimum(s):
if len(s) == 0:
return 0
else:
min_ret = minimum(s[1:])
return s[0] if s[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
| false |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
32,111 |
def minimum(s):
if len(s) == 1:
return 0
else:
min_ret = minimum(s[1:])
return s[0] if s[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
| false |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
24,277 |
def reverse_list(a):
m = a[::-1]
return m
|
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
1,304 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
39,648 |
def reverse_list(a):
m = a[::-1]
return m
|
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
23,352 |
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
return A
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
| false |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
1,058 |
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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
15,098 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
else:
return fibonacci(n - 1) + fobonacci(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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
13,291 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
24,593 |
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
19,812 |
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
14,801 |
def selectionsort(A):
i = 0
while i < len(A):
p = i
j = i + 1
while j < len(A):
if A[j] < A[p]:
p = j
j = j + 1
tmp = A[p]
A[p] = A[i]
A[i] = tmp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
22,658 |
def selectionsort(A):
i = 0
while i < len(A):
p = i
j = i + 1
while j < len(A):
if A[j] < A[p]:
p = j
j = j + 1
tmp = A[p]
A[p] = A[i]
A[i] = tmp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
17,532 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
39,181 |
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 |
9a05c20e-2fde-40c1-948b-649e25b30e6e
| 2,016 |
5,060 |
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 |
9a05c20e-2fde-40c1-948b-649e25b30e6e
| 2,016 |
29,868 |
def minimum(s):
if len(s) == 1:
return s[0]
else:
min_ret = minimum(s[1:])
return s[0] if s[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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
3,979 |
def minimum(s):
if len(s) == 1:
return s[0]
else:
min_ret = minimum(s[1:])
return s[0] if s[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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
18,287 |
def quicksort(A, p, r):
print(len(A))
|
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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
20,972 |
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, r - 1)
quicksort(A, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
23,455 |
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
11,154 |
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 |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
38,263 |
def selectionsort(a):
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j = j + 1
tmp = a[p]
a[p] = a[i]
a[i] = tmp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
36,358 |
def selectionsort(a):
i = 0
while i < len(a):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j = j + 1
tmp = a[p]
a[p] = a[i]
a[i] = tmp
i = i + 1
|
selectionsort
|
selectionsort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None
| true |
75a32f49-710d-463f-8fee-0ae9b91a3034
| 2,016 |
7,678 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
4,056 |
def power(m, n):
return m ** n
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
39,767 |
def power(m, n):
return m ** n
|
power
|
power
|
Raise m to the power of n.
|
assert power(0,0)==1 and power(62,4)==14776336 and power(-14012,0)==1
| true |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
37,025 |
def minimum(a):
a_sorted = sorted(a)
return a
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| false |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
25,336 |
def minimum(a):
return sorted(a)
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| false |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
3,623 |
def minimum(a):
return sorted(a)[0]
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
19,197 |
def minimum(a):
return sorted(a)[0]
|
minimum
|
minimum
|
Return the minimum element in a list of numbers.
|
assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45
| true |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
40,691 |
def maximum(a):
return sorted(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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
23,998 |
def maximum(a):
return sorted(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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
32,665 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
34,985 |
def count_letters(s):
return len(s)
|
count_letters
|
count_letters
|
Return the number of lettres in a string.
|
assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13
| true |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
22,928 |
def count_letters(s):
total = 0
for x in s:
total += 1
return total
|
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
23,332 |
def count_letters(s):
total = 0
for x in s:
total += 1
return total
|
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
9,968 |
def reverse_list(a):
return 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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
38,280 |
def reverse_list(a):
return 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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
8,130 |
def maximum(s):
if len(s) == 1:
return s[0]
else:
maxi = maximum(s[1:])
return l[0] if l[0] > maxi else maxi
|
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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
5,612 |
def maximum(s):
if len(s) == 1:
return s[0]
else:
maxi = maximum(s[1:])
return s[0] if s[0] > maxi else maxi
|
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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
23,447 |
def maximum(s):
if len(s) == 1:
return s[0]
else:
maxi = maximum(s[1:])
return s[0] if s[0] > maxi else maxi
|
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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
12,267 |
def fibonacci(n):
if n == 0:
return 0
elif 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
| true |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
18,176 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
20,508 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
32,212 |
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, p + 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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
40,945 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
19,639 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
6,269 |
def quicksort(l, beg, fin):
if fin - beg < 1:
return
i = j = beg
while i <= fin:
if l[i] <= l[fin]:
l[i], l[j] = l[j], l[i]
j += 1
i += 1
quicksort(l, beg, j - 2)
quicksort(l, j, fin)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
2,346 |
def quicksort(l, beg, fin):
if fin - beg < 1:
return
i = j = beg
while i <= fin:
if l[i] <= l[fin]:
l[i], l[j] = l[j], l[i]
j += 1
i += 1
quicksort(l, beg, j - 2)
quicksort(l, j, fin)
|
quicksort
|
quicksort
|
Sort a list by recursively partitionioning list until sorted.
|
assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None
| true |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
3,239 |
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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
27,060 |
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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
38,647 |
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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
31,068 |
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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
4,156 |
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 |
45fe5d71-35bd-4b87-b28c-71b204939543
| 2,016 |
12,915 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
39,923 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
30,820 |
def power(n, p):
return n ** p
|
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 |
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
| 2,016 |
16,224 |
def power(n, p):
return n ** p
|
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 |
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
| 2,016 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.