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
28,560
def swap_keys_values(d): new_dict = 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
6f8302a0-5974-4b36-a8e9-6b3968a8fce1
2,016
42,029
def swap_unique_keys_values(d): new_dict = {} for k in d: v = d[k] if v not in new_dict: new_dict[v] = k else: del new_dict[v] 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
6f8302a0-5974-4b36-a8e9-6b3968a8fce1
2,016
27,842
def swap_unique_keys_values(d): new_dict = {} for k in d: v = d[k] if v not in new_dict: new_dict[v] = k else: del new_dict[v] 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
6f8302a0-5974-4b36-a8e9-6b3968a8fce1
2,016
19,522
def swap_unique_keys_values(d): keys = [] values = [] dict_keys = [] dict_values = [] dump = [] for k, v in list(d.items()): keys.append(k) values.append(v) for num in values: test = num values = values[1:] if test in values: dump.append(test) elif test not in values and test not in dump: dict_keys.append(test) dict_values.append(keys[0]) keys = keys[1:] d = {} for i in range(0, len(dict_keys)): d[dict_keys[i]] = dict_values[i] return 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'}
true
b13f3dba-a06b-4528-a4d8-c2ee1a5bb34d
2,016
24,847
def swap_unique_keys_values(d): keys = [] values = [] dict_keys = [] dict_values = [] dump = [] for k, v in list(d.items()): keys.append(k) values.append(v) for num in values: test = num values = values[1:] if test in values: dump.append(test) elif test not in values and test not in dump: dict_keys.append(test) dict_values.append(keys[0]) keys = keys[1:] d = {} for i in range(0, len(dict_keys)): d[dict_keys[i]] = dict_values[i] return 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'}
true
b13f3dba-a06b-4528-a4d8-c2ee1a5bb34d
2,016
18,732
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
e84cb3e0-5b98-4543-816e-a3570ba72e05
2,016
10,763
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
e84cb3e0-5b98-4543-816e-a3570ba72e05
2,016
2,113
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
e84cb3e0-5b98-4543-816e-a3570ba72e05
2,016
41,629
def swap_keys_values(d): n_d = {} for k in d: n_d[d[k]] = k return n_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'}
true
420bf3b7-f5e7-4d7a-9cbb-fd46a8b4e956
2,016
5,820
def swap_keys_values(d): n_d = {} for k in d: n_d[d[k]] = k return n_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'}
true
420bf3b7-f5e7-4d7a-9cbb-fd46a8b4e956
2,016
2,137
def swap_keys_values(d): n_d = {} for k in d: n_d[d[k]] = k return n_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'}
true
420bf3b7-f5e7-4d7a-9cbb-fd46a8b4e956
2,016
24,775
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
41,990
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
9,836
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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
30,491
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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
1,524
def swap_keys_values(my_dict): new_dict = 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'}
false
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
38,182
def swap_keys_values(my_dict): new_dict = dict((v, k) for k, v in list(my_dict.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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
19,309
def swap_keys_values(my_dict): new_dict = dict((v, k) for k, v in list(my_dict.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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
4,711
def swap_keys_values(d): d = {v: k for k, v in list(d.items())} 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'}
true
caddc359-e5b0-41d8-94ab-df712d5ea9ce
2,016
11,307
def swap_keys_values(d): d = {v: k for k, v in list(d.items())} 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'}
true
caddc359-e5b0-41d8-94ab-df712d5ea9ce
2,016
32,876
def swap_keys_values(d): d = {v: k for k, v in list(d.items())} 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'}
true
caddc359-e5b0-41d8-94ab-df712d5ea9ce
2,016
5,721
def swap_keys_values(d): new = {} for z, q in list(d.items()): new[q] = z return list(new.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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
2,419
def swap_unique_keys_values(my_dict): d = {} for key in my_dict: value = my_dict.get(k) if value in d: del d[v] else: d[v] = k return 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
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
32,161
def swap_unique_keys_values(d): return set({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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
13,268
def swap_keys_values(d): new = {} for z, q in list(d.items()): new[q] = z return list(new.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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
6,835
def swap_unique_keys_values(my_dict): d = {} for key in my_dict: value = my_dict.get(key) if value in d: del d[value] else: d[value] = key return 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'}
true
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
21,209
def swap_unique_keys_values(my_dict): d = {} for key in my_dict: value = my_dict.get(key) if value in d: del d[value] else: d[value] = key return 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'}
true
b0c92748-3b02-4340-a9d8-2ebe9a693531
2,016
14,170
def swap_keys_values(d): new = {} for z, q in list(d.items()): new[q] = z return list(new.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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
10,792
def swap_keys_values(d): new = {} for z, q in list(d.items()): new[q] = z return list(new.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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
14,187
def swap_keys_values(d): new_dict = {} for z, q in list(d.items()): new[q] = z return list(new_dict.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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
31,362
def swap_keys_values(d): new_dict = {} for z, q in list(d.items()): new_dict[q] = z return list(new_dict.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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
7,506
def swap_keys_values(d): new_dict = {} for z, q in list(d.items()): new_dict[q] = z 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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
26,895
def swap_keys_values(d): new_dict = {} for z, q in list(d.items()): new_dict[q] = z 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
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
38,907
def swap_unique_keys_values(d): return set({v: k for k, v in 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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
3,165
def swap_unique_keys_values(d): return {v: k for k, v in set(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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
40,758
def swap_unique_keys_values(d): return {v: k for k, v in set(d.items()) if v not in list(d.keys())}
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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
40,763
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v not in list(d.keys())}
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
20,894
def swap_keys_values(d): return {v: k for k, in 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
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
2,016
36,400
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
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
2,016
7,529
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
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
2,016
22,857
def swap_unique_keys_values(d): return {v: k for k, v in set(d.items()) if v not in set.intersection( 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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
14,632
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v not in list(d.keys())}
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
4,070
def swap_unique_keys_values(d): return {v: k for k, v in set.intersection(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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
13,945
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v not in list(d.keys())}
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
3,394
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v not in list(d.keys())}
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
27,934
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v not in list(d.keys())}
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
4,656
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v in list(d.keys())}
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
26,942
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if (k, v) not in set. intersection(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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
2,138
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
989
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
14,691
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
75a32f49-710d-463f-8fee-0ae9b91a3034
2,016
21,943
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if list(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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
37,412
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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
12,380
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
f98e9d61-9e86-4fed-86db-3cf718c5962d
2,016
27,662
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
32a14d12-9054-46cd-aa7e-4bf97d33fa10
2,016
30,906
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
32a14d12-9054-46cd-aa7e-4bf97d33fa10
2,016
38,605
def swap_keys_values(d): new_dict = 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
61b5b70e-4e9d-424d-ba4b-cab01b8c205f
2,016
33,289
def swap_keys_values(d): new_dict = 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
61b5b70e-4e9d-424d-ba4b-cab01b8c205f
2,016
11,776
def swap_unique_keys_values(d): new_dict = {} for k in d: v = d.get(k) if v in new_dict: del new_dict[v] else: new_dict[v] = k 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
61b5b70e-4e9d-424d-ba4b-cab01b8c205f
2,016
157
def swap_unique_keys_values(d): new_dict = {} for k in d: v = d.get(k) if v in new_dict: del new_dict[v] else: new_dict[v] = k 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
61b5b70e-4e9d-424d-ba4b-cab01b8c205f
2,016
4,459
def swap_unique_keys_values(d): new_dict = {} seen = [] for z, q in list(d.items()): if q not in seen: new_dict[q] = z seen.append(q) 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'}
false
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
36,424
def swap_unique_keys_values(d): new_dict = {} seen = [] for z, q in list(d.items()): if q not in seen: new_dict[q] = z seen.append(q) 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'}
false
6ae36e81-5a79-4a87-a484-a86635591a14
2,016
13,917
def swap_unique_keys_values(d): new_d = {} for k, v in list(d.items()): if not v in new_d: new_d[v] = k else: del new_d[v] 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'}
true
32a14d12-9054-46cd-aa7e-4bf97d33fa10
2,016
16,818
def swap_unique_keys_values(d): new_d = {} for k, v in list(d.items()): if not v in new_d: new_d[v] = k else: del new_d[v] 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'}
true
32a14d12-9054-46cd-aa7e-4bf97d33fa10
2,016
25,362
def swap_unique_keys_values(d): new_d = {} for k, v in list(d.items()): if not v in new_d: new_d[v] = k else: del new_d[v] 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'}
true
32a14d12-9054-46cd-aa7e-4bf97d33fa10
2,016
20,558
def swap_keys_values(x): new = {v: k for k, v in list(x.items())} return new
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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
4,634
def swap_keys_values(x): new = {v: k for k, v in list(x.items())} return new
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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
1,563
def swap_unique_keys_values(x): new = {} for k in x: c = x.get(k) if c in new: del new[v] else: new[v] = k return new
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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
8,657
def swap_unique_keys_values(x): new = {} for k in x: c = x.get(k) if c in new: del new[c] else: new[c] = k return new
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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
1,755
def swap_unique_keys_values(x): new = {} for k in x: c = x.get(k) if c in new: del new[c] else: new[c] = k return new
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
422fe752-ca84-4537-b250-7de556e6ee94
2,016
6,314
def swap_keys_values(d): new_d = {v: k for k, v in list(d.items())} return new_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'}
true
2157ade0-6890-435b-8669-a884e3233bc7
2,016
33,733
def swap_keys_values(d): new_d = {v: k for k, v in list(d.items())} return new_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'}
true
2157ade0-6890-435b-8669-a884e3233bc7
2,016
27,202
def swap_unique_keys_values(d): seen = {} result = {} for k, v in d.items(): if v in seen: del seen[v] else: seen[v] = k result[v] = k return seen
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
2157ade0-6890-435b-8669-a884e3233bc7
2,016
19,695
def swap_unique_keys_values(d): seen = {} result = {} for k, v in list(d.items()): if v in seen: del seen[v] else: seen[v] = k result[v] = k return seen
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
2157ade0-6890-435b-8669-a884e3233bc7
2,016
11,277
def swap_unique_keys_values(d): seen = {} result = {} for k, v in list(d.items()): if v in seen: del seen[v] else: seen[v] = k result[v] = k return seen
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
2157ade0-6890-435b-8669-a884e3233bc7
2,016
26,153
def swap_unique_keys_values(d): A = False keys = [] values = [] uniqueness = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: uniqueness.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: uniqueness[i] = A uniqueness[p] = A p += 1 i += 1 j = 0 while j < len(uniqueness): if uniqueness[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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'}
true
41c113b8-6f57-4003-bed3-3587b2376170
2,016
7,022
def swap_unique_keys_values(d): A = False keys = [] values = [] uniqueness = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: uniqueness.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: uniqueness[i] = A uniqueness[p] = A p += 1 i += 1 j = 0 while j < len(uniqueness): if uniqueness[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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'}
true
41c113b8-6f57-4003-bed3-3587b2376170
2,016
7,670
def swap_keys_values(d): new_dict = {} for keys in list(d.keys()): temp = d[keys] new_dict[temp] = keys 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
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
2,016
2,258
def swap_keys_values(d): new_dict = {} for keys in list(d.keys()): temp = d[keys] new_dict[temp] = keys 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
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
2,016
11,224
def swap_unique_keys_values(d): new_dict = {} for keys in list(d.keys()): temp = d[keys] if temp in new_dict: del new_dict[temp] else: new_dict[temp] = keys 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
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
2,016
14,718
def swap_unique_keys_values(d): new_dict = {} for keys in list(d.keys()): temp = d[keys] if temp in new_dict: del new_dict[temp] else: new_dict[temp] = keys 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
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
2,016
41,218
def swap_unique_keys_values(d): new_dict = {} for keys in list(d.keys()): temp = d[keys] if temp in new_dict: del new_dict[temp] else: new_dict[temp] = keys 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
e36ebdf2-7cd7-440f-af8b-386d6e2d920f
2,016
25,020
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
712c50ed-0c17-44f1-a863-183f2d9a5e14
2,016
23,522
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
712c50ed-0c17-44f1-a863-183f2d9a5e14
2,016
14,619
def swap_keys_values(d): swapped_d = {} for key in d: swapped_d[d[key]] = key return swapped_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'}
true
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
24,850
def swap_keys_values(d): swapped_d = {} for key in d: swapped_d[d[key]] = key return swapped_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'}
true
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
5,787
def swap_keys_values(d): new_d = {v: k for k, v in list(d.items())} return new_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'}
true
dc42d7ae-53d0-4b49-988b-c619edf38a77
2,016
37,565
def swap_keys_values(d): new_d = {v: k for k, v in list(d.items())} return new_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'}
true
dc42d7ae-53d0-4b49-988b-c619edf38a77
2,016
33,876
def swap_unique_keys_values(d): new_d = {} for k in d: v = d.get(k) if v in new_dict: del new_dict[v] else: new_dict[v] = k 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'}
false
dc42d7ae-53d0-4b49-988b-c619edf38a77
2,016
10,585
def swap_unique_keys_values(d): new_d = {} for k in d: v = d.get(k) if v in new_d: del new_d[v] else: new_d[v] = k 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'}
true
dc42d7ae-53d0-4b49-988b-c619edf38a77
2,016
5,325
def swap_unique_keys_values(d): new_d = {} for k in d: v = d.get(k) if v in new_d: del new_d[v] else: new_d[v] = k 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'}
true
dc42d7ae-53d0-4b49-988b-c619edf38a77
2,016
34,108
def swap_unique_keys_values(d): new_d = {} for k in d: v = d.get(k) if v in new_d: del new_d[v] else: new_d[v] = k 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'}
true
dc42d7ae-53d0-4b49-988b-c619edf38a77
2,016
11,066
def swap_unique_keys_values(d): A = False keys = [] values = [] unique = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: unique.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: unique[i] = A unique[p] = A p += 1 i += 1 j = 0 while j < len(uniqueness): if uniqueness[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
5,461
def swap_unique_keys_values(d): A = False keys = [] values = [] unique = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: unique.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: unique[i] = A unique[p] = A p += 1 i += 1 j = 0 while j < len(uniqueness): if uniqueness[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
18,677
def swap_unique_keys_values(d): A = False keys = [] values = [] unique = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: unique.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: unique[i] = A unique[p] = A p += 1 i += 1 j = 0 while j < len(unique): if uniqueness[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
34,211
def swap_unique_keys_values(d): A = False keys = [] values = [] unique = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: unique.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: unique[i] = A unique[p] = A p += 1 i += 1 j = 0 while j < len(unique): if uniqueness[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
1,998
def swap_unique_keys_values(d): A = False keys = [] values = [] unique = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: unique.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: unique[i] = A unique[p] = A p += 1 i += 1 j = 0 while j < len(unique): if unique[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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'}
true
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
24,708
def swap_unique_keys_values(d): A = False keys = [] values = [] unique = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: unique.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: unique[i] = A unique[p] = A p += 1 i += 1 j = 0 while j < len(unique): if unique[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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'}
true
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
11,118
def swap_unique_keys_values(d): A = False keys = [] values = [] unique = [] swapped_unique_d = {} for key in d: keys.append(key) values.append(d[key]) for item in keys: unique.append(True) i = 0 while i < len(keys): p = i + 1 while p < len(values): if values[i] == values[p]: unique[i] = A unique[p] = A p += 1 i += 1 j = 0 while j < len(unique): if unique[j]: swapped_unique_d[values[j]] = keys[j] j += 1 return swapped_unique_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'}
true
07676427-a705-4cb7-a5ef-6a1c3c67c950
2,016
40,412
def swap_keys_values(d): for i in d: j[d[i]] = i return j
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
6668ebd6-a850-4666-b8cc-5c934a67601a
2,016