diff --git a/day07.py b/day07.py index 009f342..3de8b51 100644 --- a/day07.py +++ b/day07.py @@ -32,16 +32,15 @@ def getBagContent(bag_line): def getPossibleBagsForMyColor(color_dict, my_color): if my_color not in color_dict: - return [] + return set() - color_list = color_dict[my_color] + color_set = set(color_dict[my_color]) for color in color_dict[my_color]: - extend_list = getPossibleBagsForMyColor(color_dict, color) - for extra_color in extend_list: - if extra_color not in color_list: - color_list.append(extra_color) + extend_set = getPossibleBagsForMyColor(color_dict, color) + for extra_color in extend_set: + color_set.add(extra_color) - return color_list + return color_set def getBagContentCount(color_dict, my_color):