1234567891011121314151617181920212223 |
- 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]
- >>> import math
- >>> def h(k):
- ... return math.floor(7 * (k * math.sqrt(2) - math.floor(k * math.sqrt(2))))
- ...
- >>> def hash(k, i):
- ... return (h(k) + 1/2 * i + 1/2 * i * i) % 7
- ...
- >>> [(n, int(hash(n, 0))) for n in numbers]
- [(17, 0), (16, 4), (11, 3), (9, 5), (20, 1), (0, 0), (3, 1)]
- >>> [(n, int(hash(n, 1))) for n in numbers]
- [(17, 1), (16, 5), (11, 4), (9, 6), (20, 2), (0, 1), (3, 2)]
- >>> [(n, int(hash(n, 2))) for n in numbers]
- [(17, 3), (16, 0), (11, 6), (9, 1), (20, 4), (0, 3), (3, 4)]
- >>> [(n, int(hash(n, 3))) for n in numbers]
- [(17, 6), (16, 3), (11, 2), (9, 4), (20, 0), (0, 6), (3, 0)]
|