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
38,547
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
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
2,764
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
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
28,248
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
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
23,782
def double(n): return n * 2
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
37,805
def double(n): return n * 2
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
332
def area(r): return 3.14 * 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
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
26,249
def circumference(r): return 3.14 * r * 2
circumference
circumference
Return the circumference of a circle.
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
false
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
31,720
def circumference(r): return 3.141 * r * 2
circumference
circumference
Return the circumference of a circle.
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
4,436
def area(r): return 3.141 * r ** 2
area
area
Return the area of a circle with the given coordinates.
assert area(0)==0.0 and area(-14329)==644910876.981
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
5,182
def circumference(r): return 3.141 * r * 2
circumference
circumference
Return the circumference of a circle.
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
15,069
def area(r): return 3.141 * r ** 2
area
area
Return the area of a circle with the given coordinates.
assert area(0)==0.0 and area(-14329)==644910876.981
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
3,543
def circumference(r): return 3.141 * r * 2
circumference
circumference
Return the circumference of a circle.
assert circumference(0)==0.0 and circumference(-23091)==-145057.662
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
35,683
def area(r): return 3.141 * r ** 2
area
area
Return the area of a circle with the given coordinates.
assert area(0)==0.0 and area(-14329)==644910876.981
true
88e97329-9c3f-4e1a-8643-1311f4e801a9
2,016
5,913
def double(x): return 2 * x
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
30,617
def double(x): return 2 * x
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
17,163
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
19,402
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
21,001
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
41,909
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
24,546
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
19,683
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
4,534
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
39,510
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
f6343d5f-9ee0-441c-a67c-781ee180947e
2,016
30,233
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
39,172
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
10,300
def circle_circumference(r): return r * 2 * 3.14
circle_circumference
circle_circumference
Return the circumference of a circle.
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
true
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
17,956
def circle_area(r): return r * r * 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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
27,838
def circle_area(r): return r * r * 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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
10,274
def rectangle_perimeter(l, w): return 2 * (l + w)
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
41,720
def circle_area(r): return r * r * 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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
25,801
def square_perimeter(side): return 4 * side
square_perimeter
square_perimeter
Returns the perimeter of a square.
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
true
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
12,031
def square_perimeter(side): return 4 * side
square_perimeter
square_perimeter
Returns the perimeter of a square.
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
true
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
58
def rectangle_perimeter(l, w): return 2 * (l + w)
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
22,405
def circle_circumference(r): return r * 2 * 3.14
circle_circumference
circle_circumference
Return the circumference of a circle.
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
true
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
4,904
def rectangle_perimeter(l, w): return 2 * (l + w)
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
15,466
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
40,291
def circle_circumference(r): return r * 2 * 3.14
circle_circumference
circle_circumference
Return the circumference of a circle.
assert circle_circumference(0)==0.0 and circle_circumference(25619)==160887.32
true
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
42,281
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
4,447
def square_perimeter(side): return 4 * side
square_perimeter
square_perimeter
Returns the perimeter of a square.
assert square_perimeter(0)==0 and square_perimeter(-12684)==-50736
true
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
31,858
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
e45f938b-9d5c-4838-86ce-0755e3c97053
2,016
11,598
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
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
22,831
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
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
40,232
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
1caca58f-3988-4910-af7d-3a09c8ed5647
2,016
30,143
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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
266
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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
3,006
def double(n): m = n * 2 print(m)
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
false
336d0cd0-002e-4296-ba45-582077aac4a4
2,016
40,664
def double(n): m = n * 2
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
false
336d0cd0-002e-4296-ba45-582077aac4a4
2,016
41,700
def double(n): return n * 2
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
336d0cd0-002e-4296-ba45-582077aac4a4
2,016
33,051
def double(n): return n * 2
double
double
Double a number or a string.
assert double(0)==0 and double(-7601)==-15202
true
336d0cd0-002e-4296-ba45-582077aac4a4
2,016
9,079
def swap_keys_values(d): return dict([(v, k) for k, v in list(d.items())])
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
b1593687-e1b6-4969-bf98-9b229efc6797
2,016
1,681
def swap_keys_values(d): return dict([(v, k) for k, v in list(d.items())])
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
b1593687-e1b6-4969-bf98-9b229efc6797
2,016
30,791
def swap_unique_keys_values(d): return dict([(v, k) for k, v in list(d.items()) if list(d.values()). count(v) == 1])
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
b1593687-e1b6-4969-bf98-9b229efc6797
2,016
36,223
def swap_unique_keys_values(d): return dict([(v, k) for k, v in list(d.items()) if list(d.values()). count(v) == 1])
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
b1593687-e1b6-4969-bf98-9b229efc6797
2,016
11,297
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
20,046
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
6,316
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v not in list(d.values())}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
19,820
def swap_keys_values(d): d2 for key in d: d2[d[key]] = key return d2
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
20,458
def swap_keys_values(d): d2 = {} for key in d: d2[d[key]] = key return d2
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
5,117
def swap_unique_keys_values(d): new_d = {} for key, value in list(d.items()): if value not in list(d.values()): new_d[key] = value return new_d
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
38,686
def swap_keys_values(d): for key in d: d[key] = key return d
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
29,731
def swap_keys_values(d): d2 = {} for key in d: d2[d[key]] = key return d2
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
32,780
def swap_keys_values(d): d2 = {} for key in d: d2[d[key]] = key return d2
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
3,594
def swap_unique_keys_values(d): new_d = {} print(list(d.values())) for key, value in list(d.items()): print(value) return new_d
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
10,303
def swap_unique_keys_values(d): new_d = {} for key, value in list(d.items()): if value not in list(d.values()): new_d[value] = key return new_d
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
35,367
def swap_keys_values(d): return {k: v for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
23,700
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
23,653
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
9,979
def swap_unique_keys_values(d): d2 = {} for key in d: if d[key] in d2: del d2[d[key]] else: d2[d[key]] = key return d2
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
24,481
def swap_unique_keys_values(d): d2 = {} for key in d: if d[key] in d2: del d2[d[key]] else: d2[d[key]] = key return d2
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
13,510
def swap_unique_keys_values(d): d2 = {} for key in d: if d[key] in d2: del d2[d[key]] else: d2[d[key]] = key return d2
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
431d0ef6-9edd-464b-a5fa-cccf8b152f4e
2,016
5,407
def swap_unique_keys_values(d): new_d = {} for key, value in list(d.items()): if int(value) not in list(d.values()): new_d[value] = key return new_d
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
9a05c20e-2fde-40c1-948b-649e25b30e6e
2,016
33,199
def swap_keys_values(d): new_dict = {v: k for k, v in list(d.items())} return new_dict
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
2,016
18,984
def swap_keys_values(d): new_dict = {v: k for k, v in list(d.items())} return new_dict
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
2,016
36,176
def swap_unique_keys_values(d): new_d = {v: k for k, v in list(d.items())}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
7,594
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items())}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
28,327
def swap_keys_values(): print({v: k for k, v in list(d.items())})
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
f1c26f39-fb4c-4010-aaa3-142fb52f57b9
2,016
39,388
def swap_keys_values(k, v): print({v: k for k, v in list(d.items())})
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
f1c26f39-fb4c-4010-aaa3-142fb52f57b9
2,016
31,124
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if list(d.values()).count(v) != 1}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
1,977
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if list(d.values()).count(v) != 1}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
20,948
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if list(d.values()).count(v) == 1}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
39,045
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if list(d.values()).count(v) == 1}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
36,935
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if list(d.values()).count(v) == 1}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
932dfe81-cd49-4d41-8b87-456f3246e781
2,016
37,271
def swap_keys_values(d): return {(v, k) for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
5cf0f5b5-a91e-4c33-8ac1-92aa868cd3b0
2,016
2,194
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
5cf0f5b5-a91e-4c33-8ac1-92aa868cd3b0
2,016
27,085
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
5cf0f5b5-a91e-4c33-8ac1-92aa868cd3b0
2,016
37,521
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
9,304
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
12,972
def swap_keys_values(d): return {v: k for v, k in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
c0a5d565-4fbf-4274-85af-71162f38b8d4
2,016
4,424
def swap_keys_values(d): return {k: v for v, k in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
c0a5d565-4fbf-4274-85af-71162f38b8d4
2,016
18,464
def swap_keys_values(d): return {k: v for v, k in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
c0a5d565-4fbf-4274-85af-71162f38b8d4
2,016
29,580
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
66e06699-d10a-47f1-a343-55edd72e95d2
2,016
22,467
def swap_keys_values(d): return {v: k for k, v in list(d.items())}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
true
66e06699-d10a-47f1-a343-55edd72e95d2
2,016
15,010
def swap_unique_keys_values(d): lst = [x for x in list(d.values())] new_dict = {v: k for k, v in list(d.items()) if lst.count(v) == 1} return new_dict
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
2,016
4,538
def swap_unique_keys_values(d): lst = [x for x in list(d.values())] new_dict = {v: k for k, v in list(d.items()) if lst.count(v) == 1} return new_dict
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
2,016
36,217
def swap_unique_keys_values(d): lst = [x for x in list(d.values())] new_dict = {v: k for k, v in list(d.items()) if lst.count(v) == 1} return new_dict
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
true
ac1dec5e-a5eb-4183-ba72-3b639e82db3c
2,016
30,709
def swap_keys_values(d): return {v: k for k, v in d}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
6a42703e-da42-4824-8b83-b6f291ad71be
2,016
1,925
def swap_keys_values(d): return {v: k for k, v in d}
swap_keys_values
swap_keys_values
Swap the keys of a dictionary with its values.
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
false
6a42703e-da42-4824-8b83-b6f291ad71be
2,016
30,511
def swap_unique_keys_values(d): store = {} for key in d: for k in d: if d[key] == d[k]: 0 else: store[key] = d[key] return {v: k for k, v in list(store.items())}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
18,140
def swap_unique_keys_values(d): store = {} for key in d: for k in d: if d[key] == d[k]: continue else: store[key] = d[key] return {v: k for k, v in list(store.items())}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016
28,117
def swap_unique_keys_values(d): store = {} di = d for key in d: for k in di: if d[key] == di[k]: continue else: store[key] = d[key] return {v: k for k, v in list(store.items())}
swap_unique_keys_values
swap_unique_keys_values
Swap the keys of a dictionary with its unique values.
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
false
051d024e-69b1-48d1-ba77-a6f2d97a48bc
2,016