# Path: exams/E2014/pagrindinis/u1/u1.py
# def read_ints(lines: Iterator[str]) -> List[int]:
# def update_totals(totals: List[int], update: List[int]) -> List[int]:
# def add_director_points(total_points: List[int], director_points: List[int], max_point: int) -> List[int]:
# def get_unit_points(points_map: Tuple[int, ...], votes: List[int]) -> List[int]:
# def get_final_points(total_points: List[int], director_points: List[int]) -> List[int]:
# def get_winner_item(points: List[int]) -> int:
# def count_votes(
#     lines: Iterator[str],
#     points_map: Tuple[int, ...] = (4, 2, 0),
#     n_items: int = 3
# ) -> Tuple[List[int], List[int], int]:
# def format_results(votes: List[int], points: List[int], winner: int) -> Iterator[str]:
# def main(path: Path) -> None:
# 
# Path: exams/testing.py
# def read(path: Path) -> List[str]:
#     return path.read_text().splitlines()
# 
# Path: exams/testing.py
# def write(path: Path, lines: List[str]) -> None:
#     path.write_text('\n'.join(lines))


from exams.E2014.pagrindinis.u1 import u1
from exams.testing import read
from exams.testing import write


def test(path):
    write(path / 'U1.txt', [
        '6',
        '15 10 22',
        '15 40 13',
        '23 26 26',
        '110 30 58',
        '33 33 32',
        '0 56 0',
        '2 1 3',
    ])
    u1.main(path)
    assert read(path / 'U1rez.txt') == [
        '196 195 151',
        '6 12 6',
        '2',
    ]


def test_without_units():

# Path: exams/E2014/pagrindinis/u1/u1.py
# def read_ints(lines: Iterator[str]) -> List[int]:
# def update_totals(totals: List[int], update: List[int]) -> List[int]:
# def add_director_points(total_points: List[int], director_points: List[int], max_point: int) -> List[int]:
# def get_unit_points(points_map: Tuple[int, ...], votes: List[int]) -> List[int]:
# def get_final_points(total_points: List[int], director_points: List[int]) -> List[int]:
# def get_winner_item(points: List[int]) -> int:
# def count_votes(
#     lines: Iterator[str],
#     points_map: Tuple[int, ...] = (4, 2, 0),
#     n_items: int = 3
# ) -> Tuple[List[int], List[int], int]:
# def format_results(votes: List[int], points: List[int], winner: int) -> Iterator[str]:
# def main(path: Path) -> None:
# 
# Path: exams/testing.py
# def read(path: Path) -> List[str]:
#     return path.read_text().splitlines()
# 
# Path: exams/testing.py
# def write(path: Path, lines: List[str]) -> None:
#     path.write_text('\n'.join(lines))


# Path: exams/E2014/pagrindinis/u1/tests.py
from exams.E2014.pagrindinis.u1 import u1
from exams.testing import read
from exams.testing import write



def test(path):
    write(path / 'U1.txt', [
        '6',
        '15 10 22',
        '15 40 13',
        '23 26 26',
        '110 30 58',
        '33 33 32',
        '0 56 0',
        '2 1 3',
    ])
    u1.main(path)
    assert read(path / 'U1rez.txt') == [
        '196 195 151',
        '6 12 6',
        '2',
    ]


def test_without_units():

    results = u1.count_votes(iter(['0', '1 3 2']))