Skip to content

Instantly share code, notes, and snippets.

@rkhapov
Last active February 25, 2018 16:08
Show Gist options
  • Save rkhapov/b8e077fe88ad3690d60cb60a13da4794 to your computer and use it in GitHub Desktop.
Save rkhapov/b8e077fe88ad3690d60cb60a13da4794 to your computer and use it in GitHub Desktop.
hash
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