123456789101112131415161718192021222324252627 |
- strlst@ayaya ue4 python3
- Python 3.8.2 (default, Mar 24 2020, 03:08:36)
- [GCC 9.3.0] on linux
- Type "help", "copyright", "credits" or "license" for more information.
- >>> numbers = [17, 16, 11, 9, 20, 0, 3]
- >>> def h_1(k):
- ... return k % 7
- ...
- >>> def h_2(k):
- ... return (k % 5) + 1
- ...
- >>> def hash(k, i):
- ... return (h_1(k) + (i * h_2(k))) % 7
- ...
- >>> [hash(n, 0) for n in numbers]
- [3, 2, 4, 2, 6, 0, 3]
- >>> [hash(n, 1) for n in numbers]
- [6, 4, 6, 0, 0, 1, 0]
- >>> [hash(n, 2) for n in numbers]
- [2, 6, 1, 5, 1, 2, 4]
- >>> [hash(n, 3) for n in numbers]
- [5, 1, 3, 3, 2, 3, 1]
- >>> [hash(n, 4) for n in numbers]
- [1, 3, 5, 1, 3, 4, 5]
- >>>
|