from typing import Callable


def make_f(flavor: int) -> Callable[[int], int]:
  """Return a 1-bit constant or balanced function f. 4 flavors."""

  # The 4 versions are:
  #    f(0) -> 0, f(1) -> 0  constant
  #    f(0) -> 0, f(1) -> 1  balanced
  #    f(0) -> 1, f(1) -> 0  balanced
  #    f(0) -> 1, f(1) -> 1  constant
  flavors = [[0, 0], [0, 1], [1, 0], [1, 1]]

  def f(bit: int) -> int:
    """Return f(bit) for one of the 4 possible function types."""
    return flavors[flavor][bit]

  return f