def count_blocks(line: tuple[bool, ...]) -> int: blocks = 0 in_block = False for cell in line: if cell: if not in_block: blocks += 1 in_block = True else: in_block = False return blocks