Problem: given a string needle, and a string haystack determine if there is there an anagram of needle present as a substring of haystack? (Assume case doesn't matter).
One solution is to map the characters a-z to the first $26$ primes $2$-$101$ (we exclude $1$). This way it doesn't matter what order your characters are in, $a\cdot b\cdot c = b\cdot a\cdot c = ...$
The problem is that if your needle is $zzzzzzzzzz = z^{10} = 101^{10}$, that number is already larger than $2^{64}$, the max value of an unsigned long.
To get around this limit you can mod by some large prime and expect a fairly good spread. But I was wondering if there's a way to achieve similar results with addition instead of multiplication.
Obviously you can't do a sequential mapping of primes like you could for multiplication (counter example: $2 + 3 = 5$, all three are prime) but I was wondering if there's a combination of primes (or just numbers in general) that you could pick that would allow you to do addition.
The additive equivalent would be to increment the n-th base b digit when you see the n-th character, with b chosen larger than the largest exponent you expect. So add $b^{25}$ when you see
z, with $b\ge11$ if you expect some letter might appear 10 times. But $11^{25}>101^{10}$ so this might not be good for your use case!