def print_same_line(s: str, fill_num_chars: int, done: bool = False) -> int:
    """A helper to repeatedly print to the same line.

    Args:
        s: The text to be printed.
        fill_num_chars: This should be `0` on the first call to
          print_same_line() for a series of prints to the same output line. Then
          it should be the return value of the previous call to
          print_same_line() repeatedly until `done` is True, at which time the
          cursor will be moved to the next output line.
        done: On the final call to print_same_line() for a given line of output,
          pass `True` to have the cursor move to the next line.

    Returns:
        The number of characters that were written, which should be passed as
        `fill_num_chars` on the next call. At the end of printing over the same
        line, finish by calling with `done` set to true, which will move to the
        next line."""
    s += " " * (fill_num_chars - len(s))
    if not done:
        print("\r" + s, end="")
    else:
        print("\r" + s)
    return len(s)