def reverse_dict(d):
    """
    Returns a dictionary with values as keys and vice versa.

    Will fail if the values aren't unique or aren't
    hashable.
    """
    vals = d.values()
    # confirm that all the values are unique
    assert len(vals) == len(set(vals))
    d2 = {}
    for k, v in d.items():
        d2[v] = k
    return d2