1b 814 B

1234567891011121314151617181920212223
  1. strlst@ayaya ue4 python3
  2. Python 3.8.2 (default, Mar 24 2020, 03:08:36)
  3. [GCC 9.3.0] on linux
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> numbers = [17, 16, 11, 9, 20, 0, 3]
  6. >>> import math
  7. >>> def h(k):
  8. ... return math.floor(7 * (k * math.sqrt(2) - math.floor(k * math.sqrt(2))))
  9. ...
  10. >>> def hash(k, i):
  11. ... return (h(k) + 1/2 * i + 1/2 * i * i) % 7
  12. ...
  13. >>> [(n, int(hash(n, 0))) for n in numbers]
  14. [(17, 0), (16, 4), (11, 3), (9, 5), (20, 1), (0, 0), (3, 1)]
  15. >>> [(n, int(hash(n, 1))) for n in numbers]
  16. [(17, 1), (16, 5), (11, 4), (9, 6), (20, 2), (0, 1), (3, 2)]
  17. >>> [(n, int(hash(n, 2))) for n in numbers]
  18. [(17, 3), (16, 0), (11, 6), (9, 1), (20, 4), (0, 3), (3, 4)]
  19. >>> [(n, int(hash(n, 3))) for n in numbers]
  20. [(17, 6), (16, 3), (11, 2), (9, 4), (20, 0), (0, 6), (3, 0)]