This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_edge_order(sorted_edges, all_nodes): | |
set_trackers = {node: set(node) for node in all_nodes} | |
edge_order = [] | |
for edge, _ in sorted_edges: | |
node1, node2 = edge[0], edge[1] | |
# Case where the nodes already belong to the same set | |
if set_trackers[node1] == set_trackers[node2]: | |
continue | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Coding Test: Group all the anagrams into sets | |
""" | |
def get_unique_anagram_key(anagram): | |
anagram = anagram.replace(' ', '') # Get rid of any spaces | |
split_anagram = sorted(list(anagram)) | |
key = ''.join(split_anagram) | |
return key | |
def group_list_by_anagrams(input_list): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BloodPressureDataPoint(object): | |
def __init__(self, systole, diastole, hr): | |
self.systole = systole | |
self.diastole = diastole | |
self.hr = hr | |
print("finished initializing") |
OlderNewer