MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / hash

Function hash

Hash.py:6–11  ·  view source on GitHub ↗
(astring, tablesize)

Source from the content-addressed store, hash-verified

4
5# 按照正常的字母在ASCII中的顺序mod tablesize构造hash
6def hash(astring, tablesize):
7 sum = 0
8 for pos in astring:
9 sum = sum + ord(pos)
10
11 return sum%tablesize
12
13print(hash('cat', 11)) # cat在hash中的位置,hash table长度11
14

Callers 1

Hash.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected