def _get_suitable_palettes(self, tile_pal: OrderedSet) -> List[int]: """ Check which palettes contain all colors of tile_pal. If tile_pal is instead a superset of any of the palettes, those palettes are updated with the colors from tile_pal. """ possible = [] for p_idx, p in enumerate(self.palettes): if tile_pal.issubset(p): possible.append(p_idx) elif tile_pal.issuperset(p): self.palettes[p_idx] = p.union(tile_pal) possible.append(p_idx) return possible