Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16566 > unrolled thread
| Started by | Dave Angel <d@davea.name> |
|---|---|
| First post | 2011-12-02 13:39 -0500 |
| Last post | 2011-12-02 13:39 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: order independent hash? Dave Angel <d@davea.name> - 2011-12-02 13:39 -0500
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2011-12-02 13:39 -0500 |
| Subject | Re: order independent hash? |
| Message-ID | <mailman.3235.1322851211.27778.python-list@python.org> |
On 12/01/2011 08:55 AM, Neal Becker wrote: > Gelonida N wrote: > >> On 11/30/2011 01:32 PM, Neal Becker wrote: >>> I like to hash a list of words (actually, the command line args of my >>> program) in such a way that different words will create different hash, but >>> not sensitive >>> to the order of the words. Any ideas? >>> >> Do youmean hash like digest like md5sum / sha1 ? >> >> >> You should sort the words alphabetically, concatenate them with a space >> or any character, that will NEVER be part of a word and calulate the hash. >> >> If words can exist multiple times, then youhad tu uniqufy them (u using >> a python dict / set) first. > Yes that sounds just like what I wanted - thanks! > "different words will create different hash, but not sensitive to the order of the words" Just note that you can only say that "probably create" a different hash. If the hash number is constrained in size (eg. 32 bits), then a collision is possible. (Unless of course you also constrain the alphabet and/or length of the words involved) -- DaveA
Back to top | Article view | comp.lang.python
csiph-web