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
|
|---|---|---|---|---|---|---|---|---|
31,156
|
def square_area(side):
sq = side * side
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
6,431
|
def square_area(side):
sq = side * side
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
b9e7e608-6036-4d44-8770-a7036176b53c
| 2,015
|
2,595
|
def square_area(side):
sq = side * side
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
25,266
|
def square_area(side):
sq = side * side
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
28,514
|
def square_perimeter(side):
par = side * 4
return par
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
24,843
|
def circle_area(radius):
cirarea = 3.14 * radius * radius
return cirarea
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| false
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
33,147
|
def rectangle_perimeter(length, width):
rectper = (length + width) * 2
return rectper
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
18,695
|
def circle_circumference(radius):
circum = 2 * 3.14 * radius
return circum
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
11,013
|
def circle_circumference(radius):
circum = 2 * 3.14 * radius
return circum
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
38,491
|
def square_perimeter(side):
par = side * 4
return par
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
33,558
|
def rectangle_perimeter(length, width):
rectper = (length + width) * 2
return rectper
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
34,545
|
def circle_area(radius):
cirarea = 3.14 * radius * radius
return cirarea
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| false
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
2,891
|
def rectangle_perimeter(length, width):
perimeter = length * 2 + width * 2
return perimeter
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
b9e7e608-6036-4d44-8770-a7036176b53c
| 2,015
|
5,582
|
def circle_circumference(radius):
circumference = 2 * 3.14 * radius
return circumference
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
b9e7e608-6036-4d44-8770-a7036176b53c
| 2,015
|
17,374
|
def circle_area(radius):
area = 3.14 * radius ** 2
return area
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| true
|
b9e7e608-6036-4d44-8770-a7036176b53c
| 2,015
|
32,435
|
def square_perimeter(side):
perimeter = side * 4
return perimeter
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
b9e7e608-6036-4d44-8770-a7036176b53c
| 2,015
|
22,500
|
def square_area(side):
sq = side * side
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
b9e7e608-6036-4d44-8770-a7036176b53c
| 2,015
|
28,205
|
def square_area(side):
return side * side
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
7c96bda5-98ec-4cff-a3e4-0118a7fafe5d
| 2,015
|
9,362
|
def square_perimeter(side):
par = side * 4
return par
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
34,989
|
def rectangle_perimeter(length, width):
rectper = (length + width) * 2
return rectper
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
27,054
|
def circle_circumference(radius):
circum = 2 * 3.14 * radius
return circum
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
32,459
|
def square_area(side):
sq = side * side
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
14,054
|
def circle_area(radius):
cirarea = 3.14 * radius * radius
return cirarea
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| false
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
1,974
|
def square_area(side):
sq = side * side
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
11,789
|
def rectangle_perimeter(length, width):
rectper = (length + width) * 2
return rectper
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
16,300
|
def square_perimeter(side):
par = side * 4
return par
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
10,222
|
def circle_area(radius):
cirarea = 3.14 * radius * radius
return cirarea
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| false
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
31,543
|
def circle_circumference(radius):
circum = 2 * 3.14 * radius
return circum
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
80965c2d-45d9-440d-b3c3-403c112145e9
| 2,015
|
15,210
|
def reverse(a):
b = []
i = 0
while i < len(a):
b.append(a[len(a) - i - 1])
i = i + 1
return b
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| true
|
df8dd1dd-a7c8-46c0-b89f-ec170a81f08a
| 2,015
|
30,147
|
def reverse(a):
i = 0
b = []
while i < len(a):
b.append(a[len(a) - 1 - i])
i += 1
return b
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| true
|
0cf3795f-3d4f-4c32-b52b-4a8e4a33e09a
| 2,015
|
9,559
|
def reverse(a):
i = 0
b = []
while i < len(a):
b.append(a[len(a) - 1 - i])
i += 1
return b
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| true
|
aaa0b462-c89e-49f8-8886-ec2961496a19
| 2,015
|
36,245
|
def reverse(a):
i = 0
while i < len(a):
print(a[len(a) - i - 1])
i = i + 1
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| false
|
72504244-3803-4754-91e3-5c7732106556
| 2,015
|
28,315
|
def reverse(a):
i = 0
while i < len(a):
print(a[len(a) - i - 1])
i = i + 1
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| false
|
72504244-3803-4754-91e3-5c7732106556
| 2,015
|
31,526
|
def reverse(a):
b = []
while len(a) != 0:
b.append(a.pop())
return b
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| true
|
fc19956d-3237-43b9-841d-e5882c3359f1
| 2,015
|
41,886
|
def reverse(lines):
import sys
lines = sys.stdin.readlines()
return lines
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| false
|
7761b9ac-f093-487b-8401-cf2d01636e78
| 2,015
|
8,463
|
def reverse(test):
b = []
i = 0
while i < len(test):
b.append(test[len(test) - 1 - i])
i = i + 1
return b
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| true
|
44c97823-e1ac-4434-b296-79fbeb51fa5a
| 2,015
|
28,470
|
def reverse(test):
b = []
i = 0
while i < len(test):
b.append(test[len(test) - 1 - i])
i = i + 1
return b
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| true
|
44c97823-e1ac-4434-b296-79fbeb51fa5a
| 2,015
|
35,792
|
def square_area(n):
return n ** 2
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
41,601
|
def circle_area(n):
return n * n * 3.14
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
21,849
|
def circle_circumference(n):
return 2 * 3.14 * n
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
5,944
|
def square_area(n):
return n ** 2
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
29,550
|
def circle_circumference(n):
return 2 * 3.14 * n
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
7,259
|
def circle_area(n):
return n * n * 3.14
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
32,724
|
def rectangle_perimeter(n, m):
return 2 * (n + m)
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
22,066
|
def square_area(n):
return n ** 2
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
16,408
|
def rectangle_perimeter(n, m):
return 2 * (n + m)
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
42,119
|
def square_perimeter(n):
return 4 * n
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
30,832
|
def square_perimeter(n):
return 4 * n
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
9,321
|
def reverse(a):
i = 0
while i < len(a):
return a[::-1]
i = i + 1
|
reverse_iter
|
reverse
|
Iteratively reverse a list of elements.
|
assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']
| false
|
2b978ca4-e1a6-4660-9bf9-39da09a92282
| 2,015
|
14,622
|
def square_area(side):
return side * side
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
77d2e8c4-7a6c-4b2b-a2c4-40bb9700563f
| 2,015
|
36,721
|
def circumference(r):
return 2 * 3.141 * r
|
circumference
|
circumference
|
Return the circumference of a circle.
|
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
| true
|
4733f087-f7f5-4b28-b898-9a23b2f59251
| 2,015
|
20,237
|
def area(n):
return 3.141 * n ** 2
|
area
|
area
|
Return the area of a circle with the given coordinates.
|
assert area(0)==0.0 and area(-14329)==644910876.981
| true
|
4733f087-f7f5-4b28-b898-9a23b2f59251
| 2,015
|
30,688
|
def reverse(a):
i = 0
tmp = ''
while i < len(a) / 2:
tmp = a[i]
a[i] = a[len(a) - i - 1]
a[len(a) - i - 1] = tmp
i += 1
|
reverse_by_swap
|
reverse
|
Reverse a list of elements by swapping its elements.
|
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
| false
|
29883390-7aa0-4484-9f1e-6fd0c1c8c420
| 2,015
|
13,565
|
def selection_sort(a):
i = 0
while i < len(a):
j = i + 1
while j < len(a):
if a[j] < a[i]:
tmp = a[j]
a[j] = a[i]
a[i] = tmp
j += 1
i += 1
return a
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| true
|
29883390-7aa0-4484-9f1e-6fd0c1c8c420
| 2,015
|
13,352
|
def selection_sort(a):
i = 0
while i < len(a):
j = i + 1
while j < len(a):
if a[j] < a[i]:
tmp = a[j]
a[j] = a[i]
a[i] = tmp
j += 1
i += 1
return a
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| true
|
29883390-7aa0-4484-9f1e-6fd0c1c8c420
| 2,015
|
3,205
|
def swapi(a, i, j):
if a[j] < a[i]:
tmp = a[i]
a[i] = a[j]
a[j] = tmp
def selection_sort(a):
i = 0
while i < len(a):
j = i
while j < len(a):
swapi(a, i, j)
j += 1
i += 1
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| false
|
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,015
|
23,622
|
def swapi(a, i, j):
if a[j] < a[i]:
tmp = a[i]
a[i] = a[j]
a[j] = tmp
def selection_sort(a):
i = 0
while i < len(a):
j = i
while j < len(a):
swapi(a, i, j)
j += 1
i += 1
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| false
|
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,015
|
28,475
|
def double(n):
return n * 2
|
double
|
double
|
Double a number or a string.
|
assert double(0)==0 and double(-7601)==-15202
| true
|
46954879-c4e4-4ce6-87d4-00184c62b522
| 2,015
|
27,759
|
def circumference(r):
return 2 * pi * r
|
circumference
|
circumference
|
Return the circumference of a circle.
|
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
| false
|
46954879-c4e4-4ce6-87d4-00184c62b522
| 2,015
|
23,480
|
def area(r):
return pi * r * r
|
area
|
area
|
Return the area of a circle with the given coordinates.
|
assert area(0)==0.0 and area(-14329)==644910876.981
| false
|
46954879-c4e4-4ce6-87d4-00184c62b522
| 2,015
|
16,395
|
def square_area(side):
return side * side
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
77d2e8c4-7a6c-4b2b-a2c4-40bb9700563f
| 2,015
|
37,547
|
def selection_sort(a):
i = 0
while i < len(a):
p = find_smallest_position(a, i)
swap(a, i, p)
i = i + 1
return a
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| false
|
46954879-c4e4-4ce6-87d4-00184c62b522
| 2,015
|
10,374
|
def selection_sort(a):
i = 0
while i < len(a):
p = find_smallest_position(a, i)
swap(a, i, p)
i = i + 1
return a
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| false
|
46954879-c4e4-4ce6-87d4-00184c62b522
| 2,015
|
40,460
|
def reverse(a):
return a.reverse()
|
reverse_by_swap
|
reverse
|
Reverse a list of elements by swapping its elements.
|
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
| false
|
2157ade0-6890-435b-8669-a884e3233bc7
| 2,015
|
1,689
|
def swap(a, i, j):
tmp = a[j]
a[j] = a[i]
a[i] = tmp
def find_smallest(a, i):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j = j + 1
return p
def selection_sort(a):
i = 0
while i < len(a):
p = find_smallest(a, i)
swap(a, i, p)
i = i + 1
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| false
|
2157ade0-6890-435b-8669-a884e3233bc7
| 2,015
|
10,354
|
def swap(a, i, j):
tmp = a[j]
a[j] = a[i]
a[i] = tmp
def find_smallest(a, i):
p = i
j = i + 1
while j < len(a):
if a[j] < a[p]:
p = j
j = j + 1
return p
def selection_sort(a):
i = 0
while i < len(a):
p = find_smallest(a, i)
swap(a, i, p)
i = i + 1
|
selection_sort
|
selection_sort
|
Sort a list by repeatedly move minimimum of remaining sublist to front.
|
assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]
| false
|
2157ade0-6890-435b-8669-a884e3233bc7
| 2,015
|
19,259
|
def double(x):
return x * 2
|
double
|
double
|
Double a number or a string.
|
assert double(0)==0 and double(-7601)==-15202
| true
|
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
| 2,015
|
39,732
|
def area(r):
return pi * r ** 2
|
area
|
area
|
Return the area of a circle with the given coordinates.
|
assert area(0)==0.0 and area(-14329)==644910876.981
| false
|
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
| 2,015
|
19,874
|
def circumference(r):
return 2 * pi * r
|
circumference
|
circumference
|
Return the circumference of a circle.
|
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
| false
|
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
| 2,015
|
4,559
|
def double(x):
return x * 2
|
double
|
double
|
Double a number or a string.
|
assert double(0)==0 and double(-7601)==-15202
| true
|
fac2ee37-8224-43e0-9c23-7cc249889343
| 2,015
|
24,595
|
def double(x):
return x * 2
|
double
|
double
|
Double a number or a string.
|
assert double(0)==0 and double(-7601)==-15202
| true
|
fac2ee37-8224-43e0-9c23-7cc249889343
| 2,015
|
23,704
|
def area(x):
return pie * (x * x)
|
area
|
area
|
Return the area of a circle with the given coordinates.
|
assert area(0)==0.0 and area(-14329)==644910876.981
| false
|
fac2ee37-8224-43e0-9c23-7cc249889343
| 2,015
|
33,085
|
def circumference(x):
return 2 * pie * x
|
circumference
|
circumference
|
Return the circumference of a circle.
|
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
| false
|
fac2ee37-8224-43e0-9c23-7cc249889343
| 2,015
|
13,159
|
def square_area(n):
sq = n * n
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
0b0c54f1-c900-465f-a33a-5c22b0497dc4
| 2,015
|
29,949
|
def square_perimeter(p):
sq_p = 4 * p
return sq_p
|
square_perimeter
|
square_perimeter
|
Returns the perimeter of a square.
|
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
| true
|
0b0c54f1-c900-465f-a33a-5c22b0497dc4
| 2,015
|
18,974
|
def rectangle_perimeter(a, b):
rp = 2 * a + 2 * b
return rp
|
rectangle_perimeter
|
rectangle_perimeter
|
Return the perimeter of a rectangle with the given coordinates.
|
assert rectangle_perimeter(0,0)==0 and rectangle_perimeter(7968917888512863576,-18677)==15937835777025689798
| true
|
0b0c54f1-c900-465f-a33a-5c22b0497dc4
| 2,015
|
5,497
|
def square_area(n):
sq = n * n
return sq
|
square_area
|
square_area
|
Return the area of a square.
|
assert square_area(0)==0 and square_area(21138)==446815044
| true
|
0b0c54f1-c900-465f-a33a-5c22b0497dc4
| 2,015
|
486
|
def circle_circumference(r):
cc = 2 * 3.14 * r
return cc
|
circle_circumference
|
circle_circumference
|
Return the circumference of a circle.
|
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
| true
|
0b0c54f1-c900-465f-a33a-5c22b0497dc4
| 2,015
|
23,752
|
def circle_area(r):
ca = r * r * 3.14
return ca
|
circle_area
|
circle_area
|
Return the area of a circle.
|
assert circle_area(0)==0.0 and circle_area(-1160877629)==4.231579770269758e+18
| true
|
0b0c54f1-c900-465f-a33a-5c22b0497dc4
| 2,015
|
8,308
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = low + (high - low) / 2
assert low <= mid < high
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
df8dd1dd-a7c8-46c0-b89f-ec170a81f08a
| 2,015
|
27,066
|
def double(n):
return n * 2
|
double
|
double
|
Double a number or a string.
|
assert double(0)==0 and double(-7601)==-15202
| true
|
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
| 2,015
|
252
|
def circumference(r):
return 2 * pi * r
|
circumference
|
circumference
|
Return the circumference of a circle.
|
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
| false
|
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
| 2,015
|
61
|
def area(r):
return pi * r ** 2
|
area
|
area
|
Return the area of a circle with the given coordinates.
|
assert area(0)==0.0 and area(-14329)==644910876.981
| false
|
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
| 2,015
|
11,391
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (high + low) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
a48376ed-7138-4481-a4da-74490838ea3e
| 2,015
|
38,128
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
dc42d7ae-53d0-4b49-988b-c619edf38a77
| 2,015
|
32,728
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (high + low) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
bd03ecd6-cea3-4854-803a-b14d429489a7
| 2,015
|
8,466
|
def swap(a, i, j):
tmp = a[j]
a[j] = a[i]
a[i] = tmp
def reverse(a):
i = 0
while i < len(a) / 2:
swap(a, i, len(a) - i - 1)
i += 1
|
reverse_by_swap
|
reverse
|
Reverse a list of elements by swapping its elements.
|
assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]
| false
|
b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782
| 2,015
|
7,118
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
assert low <= mid < high
if a[mid] < q:
low = mid + 1
assert low == 0 or a[low - 1] < q
else:
high = mid
assert q <= a[high]
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
98d44d17-92f8-4274-915e-b88bdd9dca26
| 2,015
|
27,458
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
fccb16a1-abd7-4ee8-a2c6-5b7653d7a7dc
| 2,015
|
11,679
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
48db4273-a21e-41be-bca6-9b6444a15cbf
| 2,015
|
42,468
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
a58f503b-2a5d-430c-aea3-11134a0daeb8
| 2,015
|
6,914
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
a58f503b-2a5d-430c-aea3-11134a0daeb8
| 2,015
|
22,913
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
4733f087-f7f5-4b28-b898-9a23b2f59251
| 2,015
|
28,731
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,015
|
27,041
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
assert low <= mid < high
if a[mid] < q:
low = mid + 1
assert low == 0 or a[low - 1] < q
else:
high = mid
assert q <= a[high]
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
17658437-97b1-4a8a-ac6f-a63a54536e33
| 2,015
|
2,928
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
422fe752-ca84-4537-b250-7de556e6ee94
| 2,015
|
412
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
e8eb24cb-1a57-439b-8705-aed3cec25793
| 2,015
|
33,496
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = low + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
e84cb3e0-5b98-4543-816e-a3570ba72e05
| 2,015
|
34,996
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
if a[mid] < q:
low = mid + 1
else:
high = mid
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,015
|
12,077
|
def bsearch(a, q):
low = 0
high = len(a)
while low < high:
mid = (low + high) / 2
assert low <= mid < high
if a[mid] < q:
low = mid + 1
assert low == 0 or a[low - 1] < q
else:
high = mid
assert q <= a[high]
return low
|
bsearch
|
bsearch
|
Search for element q in the sorted array a.
|
assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3
| false
|
573bd795-e55d-4f35-83cb-b4c309fb0d57
| 2,015
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.