def partition(elts, predicate):
    """Splits elts depending on their result.

    Partitions set of elts. Result of the predicate must be hashable.

        >>> partition("qweryuop ", lambda x: "How are you ?".count(x))
        {0: ['q', 'p'], 1: ['w', 'e', 'r', 'y', 'u'], 2: ['o'], 3: [' ']}

    """
    heaps = {}
    for elt in elts:
        key = predicate(elt)
        heaps[key] = heaps.get(key, []) + [elt]
    return heaps