import typing


def compute_prefixes(strings: typing.Iterable[str]):
    """Given an iterable of strings, returns a dict of unique shorter prefixes.

    Note in case of collision, the string is not included in the results, eg.:

    $> compute_prefixes(["foo", "foobar"])
    {"foobar": "foob"}
    """
    prefixes = {}
    for s in strings:
        for hashlen in range(1, len(s) + 1):
            prefix = s[:hashlen]
            if prefix not in prefixes:
                prefixes[prefix] = s
                break
            if not prefixes[prefix]:
                # this prefix is already shorter than another unique prefix
                continue
            # {prefix: string} -> {prefix: None, longer_prefix: string}
            # for parallelization, these write operations must be atomic as a whole
            prefixes[prefixes[prefix][: hashlen + 1]] = prefixes[prefix]
            prefixes[prefix] = None
    return {v: k for k, v in prefixes.items() if v}