I want to convert a string to hash and divid into n bucket

295 Views Asked by At

Problem: I want to divide the M strings into N bucket as uniformly as possible.

One solution I was thinking is,

  1. Create a hash of string
  2. Convert the hash to integer by mapping ascii value of each character in hash
  3. Sum up those ascii values
  4. Divide the sum by N

Uniform distribution I believe will be solved by hashing but not sure converting to ascii will change anything.

Please suggest better solution if you have one.

Thank you in advance

0

There are 0 best solutions below