1c 643 B

123456789101112131415161718192021222324252627
  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. >>> def h_1(k):
  7. ... return k % 7
  8. ...
  9. >>> def h_2(k):
  10. ... return (k % 5) + 1
  11. ...
  12. >>> def hash(k, i):
  13. ... return (h_1(k) + (i * h_2(k))) % 7
  14. ...
  15. >>> [hash(n, 0) for n in numbers]
  16. [3, 2, 4, 2, 6, 0, 3]
  17. >>> [hash(n, 1) for n in numbers]
  18. [6, 4, 6, 0, 0, 1, 0]
  19. >>> [hash(n, 2) for n in numbers]
  20. [2, 6, 1, 5, 1, 2, 4]
  21. >>> [hash(n, 3) for n in numbers]
  22. [5, 1, 3, 3, 2, 3, 1]
  23. >>> [hash(n, 4) for n in numbers]
  24. [1, 3, 5, 1, 3, 4, 5]
  25. >>>