Lists Hash function
        Posted  
        
            by John Retallack
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by John Retallack
        
        
        
        Published on 2010-05-21T23:42:51Z
        Indexed on 
            2010/05/21
            23:51 UTC
        
        
        Read the original article
        Hit count: 232
        
I'm trying to make a hash function so I can tell if too lists with same sizes contain the same elements.
For exemple this is what I want:
f((1 2 3))=f((1 3 2))=f((2 1 3))=f((2 3 1))=f((3 1 2))=f((3 2 1)).  
Any ideea how can I approch this problem ? I've tried doing the sum of squares of all elements but it turned out that there are collisions,for exemple f((2 2 5))=33=f((1 4 4)) which is wrong as the lists are not the same.
I'm looking for a simple approach it there are any.
© Stack Overflow or respective owner