"""One solution. Try the exercise first."""


def send_times(n_chunks: int, chunk_ms: int = 80) -> list[float]:
    return [k * chunk_ms / 1000 for k in range(n_chunks)]


def rewrites(screens: list[list[str]]) -> tuple[int, int]:
    changed = shown = 0
    prev: list[str] = []
    for words in screens:
        for i, old in enumerate(prev):
            if i >= len(words) or words[i] != old:
                changed += 1
        for i, new in enumerate(words):
            if i >= len(prev) or prev[i] != new:
                shown += 1
        prev = words
    return changed, shown


def local_agreement(screens: list[list[str]]) -> list[list[str]]:
    committed: list[str] = []
    prev: list[str] = []
    out = []
    for words in screens:
        agreed = []
        for a, b in zip(prev, words):
            if a != b:
                break
            agreed.append(a)
        if len(agreed) > len(committed) and agreed[:len(committed)] == committed:
            committed = agreed
        prev = words
        out.append(list(committed))
    return out


def cut_offs(pauses_s: list[float], timer_ms: int) -> list[bool]:
    return [p * 1000 > timer_ms for p in pauses_s]
