"""
Exercise 1: comprehension warm-up

Implement three functions, each MUST use a comprehension (not a
regular for-loop with .append()):

  squares_of_evens(nums) -> list of squares of only the even numbers in nums
  invert_dict(d)          -> dict with keys and values swapped
                              (assume all values in d are unique and hashable)
  flatten(matrix)          -> single flat list from a list of lists,
                               using a comprehension with two `for` clauses
"""

def squares_of_evens(nums):
    # TODO: list comprehension with a filter.
    pass


def invert_dict(d):
    # TODO: dict comprehension.
    pass


def flatten(matrix):
    # TODO: list comprehension with two `for` clauses.
    pass


# --- self-check: do not modify below this line ---
checks = [
    (squares_of_evens([1, 2, 3, 4, 5, 6]), [4, 16, 36]),
    (invert_dict({"a": 1, "b": 2, "c": 3}), {1: "a", 2: "b", 3: "c"}),
    (flatten([[1, 2], [3, 4], [5]]), [1, 2, 3, 4, 5]),
]

all_passed = all(actual == expected for actual, expected in checks)
for actual, expected in checks:
    print(f"got {actual!r}, expected {expected!r} -> {'PASS' if actual == expected else 'FAIL'}")

print("ALL PASS" if all_passed else "SOME FAILED")
