Last active
February 25, 2018 16:08
-
-
Save rkhapov/b8e077fe88ad3690d60cb60a13da4794 to your computer and use it in GitHub Desktop.
hash
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
mod = 100 | |
def my_hash(num): | |
return num % mod | |
keys = [ [] for i in range(mod) ] | |
values = [ [] for i in range(mod) ] | |
def set(key, value): | |
keys[my_hash(key)].append(key) | |
values[my_hash(key)].append(value) | |
def get(key): | |
return values[my_hash(key)][keys[my_hash(key)].index(key)] | |
push(6, 0) | |
push(16, 1) | |
push(26, 2) | |
print(get(6), get(16), get(26)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment