Last active
February 21, 2020 10:59
-
-
Save joonas-yoon/e95a413d51a2cadcff9716dbb0734bdd to your computer and use it in GitHub Desktop.
hashing string to unique integer - base 26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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