def restore_symmetry( dimensional_ordinals: Tuple[int, ...], point: Tuple[int, ...] ) -> FrozenSet[Tuple[int, ...]]: """ For each nth dimension indicated, generate a point that's negative in the dimension, with the appropriate combinations where there are multiple dimensions involved. restore_symmetry((2, 3), (1, 1, 1, 1)) == { (1, 1, -1, -1), (1, 1, 1, -1), (1, 1, -1, 1) } """ if all([point[n] == 0 for n in dimensional_ordinals]): return frozenset() new_points = set() base_mods = product([1, -1], repeat=len(dimensional_ordinals)) mods = lfilter(lambda m: not all([x >= 0 for x in m]), base_mods) for mod in mods: temp_point = [*point] for i, ordinal in enumerate(dimensional_ordinals): if point[ordinal] > 0: temp_point[ordinal] = mod[i] * temp_point[ordinal] new_points.add(tuple(temp_point)) return frozenset(new_points)
def validate_tickets(rules: dict, nearby: List[str]) -> Tuple: valid_tickets = [] invalid_numbers = [] for ticket in nearby: check = lambda n: not is_num_in_any_valid_range(rules, n) not_valid = lfilter(check, ticket) if not_valid: invalid_numbers.extend(not_valid) else: valid_tickets.append(ticket) return valid_tickets, [], [], invalid_numbers
def process_two(data: str) -> int: return len(lfilter(is_nice2, data))
def process_one(data: Any) -> Any: return len(lfilter(is_nice, data))
def process_two(data: List[dict]) -> int: return len(lfilter(is_valid_pw_two, data))
def process_one(data: List[dict]) -> int: return len(lfilter(is_valid_pw, data))
def group_to_unanimous(group: List[str]) -> int: check = lambda char: all([char in line for line in group]) return len(lfilter(check, set("".join(group))))
def validate_rules(rules: dict, values: List[int]) -> List[str]: valid = lambda x: all([valid_range(rules[x], v) for v in values]) return lfilter(valid, rules.keys())
def process_two(passports: List[dict]) -> int: return len(lfilter(validate_passport_advanced, passports))
def process_one(passports: List[dict]) -> int: return len(lfilter(validate_passport_basic, passports))
def process_two(data: list[int]) -> int: totals = map(sum, sliding_window(3, data)) return len(lfilter(comparer, sliding_window(2, totals)))
def process_one(data: list[int]) -> int: return len(lfilter(comparer, sliding_window(2, data)))