from pathlib import Path


def test2solution(filename: str, source_path: str) -> Path:
    """
    Build a solution filename from a corresponding test filename.
    """

    tokens = filename.split("/")
    collection = tokens[-3]
    dataset = tokens[-2]
    filename = tokens[-1].replace("test-", "solutions-")

    # ref_file = f"/home/tiagot/repos/sigtyp2022/ST2022/{collection}/{dataset}/{filename}"
    ref_file = Path(source_path) / collection / dataset / filename

    return Path(ref_file)