Skip to content

Instantly share code, notes, and snippets.

@joonas-yoon
Last active February 21, 2020 10:59
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 joonas-yoon/e95a413d51a2cadcff9716dbb0734bdd to your computer and use it in GitHub Desktop.
Save joonas-yoon/e95a413d51a2cadcff9716dbb0734bdd to your computer and use it in GitHub Desktop.
hashing string to unique integer - base 26
#define MAX_LENGTH 13
unsigned long long str2llu(const char s[MAX_LENGTH + 1]) {
unsigned long long r = 0;
for (int i = 0; s[i]; ++i) r = r * 26 + s[i] - 'a';
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment