from functools import reduce


def to_dense_hash(hash):
    """Returns the dense hash from a sparse hash by XOR-ing 16 elements
    from consecutive blocks"""
    dense_hash = []
    for i in range(0, len(hash), 16):
        block = reduce(lambda x, y: x ^ y, hash[i:i+16])
        dense_hash.append(block)
    return dense_hash