This example attempts to create a perfect hash for the character dictionary containing all lower case letters, numbers, underscore, dash, and hash. The final result should allow us to do something like `arr[map(n)]
` to execute the relevant character parsing routine / step.
When the target number of buckets is met (16 in this case), the UI turns green. Example result would be: `31&(((15^x)%13|0)^x|0);
`, which you can verify in this tool (mapping the input array index to the output).
It uses the the Gasher and attempts to show you a formula (JS code) which should do the mapping.
Inputs for dictionary hashing:
// a-z 0-9 $ _ - # TARGET_VALUES = [ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 36, 95, 45, 35, ];
Inputs for bit scan hasher:
for (let i = 0; i < 31; ++i) { TARGET_VALUES[i] = (1 << i >>> 0); }
(This example has static inputs)
The goal is for each input to have a unique bucket index. The more unique buckets the better the result. A smile means an improvement was found this batch, a frown means it was not.
bucket-count 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
(Click start to begin!)