Skip to content

String hashing

storing

Level 1 of 3

Also called Horner's rule and Polynomial string hash.

Turns a word into a slot of a table of 13, letter by letter. Multiply the value so far by 31, add the next letter's number, and keep only the remainder after dividing by 13. Each letter is weighed by its place, so the same letters in another order can land elsewhere, as listen and silent do.

the word, a column for each letter: its number, the value times 31 plus it, and the remainder after dividing by 13

letters read
0

step 1 of 1

Examples

One word of 1 to 6 letters, a to z only, for example listen.