"""PA2 Magazine Collage.

A greeting card is pasted together from letters cut out of a magazine page.
Each letter on the page can be cut out only once, and an uppercase letter is a
different letter from its lowercase twin. Spaces and punctuation are drawn
in by hand, so they never need to be cut out.

Name: YOUR NAME
Date: THE DATE
"""


def letter_counts(page: str) -> dict[str, int]:
    """Count the letters on a magazine page that could be cut out.

    Args:
        page: The text of the page.

    Returns:
        A new dictionary that maps each letter on the page to the number of
        times it appears. Anything that is not a letter, such as a space, a
        digit, or punctuation, is not counted, and "A" and "a" are counted
        separately. Ex: letter_counts("Go, go!") returns {"G": 1, "o": 2,
        "g": 1}, and letter_counts("7 - 2") returns {}.
    """
    pass


def cut_out(note: str, page: str) -> tuple[str, int]:
    """Paste a note together from the letters on a page.

    Args:
        note: The message to make.
        page: The text of the page to cut letters from.

    Returns:
        A tuple of two things: the note as it can be pasted together, and the
        number of letters that could not be found. Going from left to right,
        a letter of the note is cut out only if letter_counts(page) still has
        one of it to spare, and each one cut out uses one up. A letter that
        cannot be found is replaced by "_". Anything that is not a letter is
        kept as it is. Ex: cut_out("meet at noon", "the moon is out tonight")
        returns ("me_t _t noon", 2), since the page has only one e and no a.
    """
    pass


if __name__ == "__main__":
    # Do not edit the main block. It pastes up three notes once cut_out() works.
    page = "Win BIG at the county fair! Pie contest Sat, 7 pm. Free entry."
    notes = ["Meet me at noon.", "See you at the fair!", "Thanks a ton, Sam!"]
    print(f"Page: {page}")
    for note in notes:
        pasted, missing = cut_out(note, page)
        print(f"{pasted}  ({missing} missing)")
