开发者

smallest checksum on a string

scratching my head over this.

i have 350 strings average 90 chars long, all strings 开发者_StackOverflow社区are unique. Now, i wanna generate a unique id for each string.

i tried the sum of chars in the string wich gave two doubles, the returned sum is not unique enough. Anybody any idea how to approach this? I thought of hash(), is that the best solution?

abcdef will return the same as abcdfe


If you have a fixed set of strings and you will only need to look those up then find a minimal perfect hash function. http://en.wikipedia.org/wiki/Perfect_hash_function


Checksums and hashes will never be unique. Call the first string "1" and go from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜