Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created November 12, 2010 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qpfiffer/674796 to your computer and use it in GitHub Desktop.
Save qpfiffer/674796 to your computer and use it in GitHub Desktop.
hashing function
// I think this works correctly...
int stringSize = strlen(s);
int i(0), j(0);
int runTotal(0);
for(;i<stringSize;i++) {
int temp = (int)s[i];
for(j=0;j<(stringSize-(i+1));j++) {
temp *= 31;
}
runTotal += temp;
}
return runTotal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment