Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. def fileToHash(self, name):
  2. self.hash = 0
  3. self.name = name.upper()
  4. for j in range(len(self.name)):
  5. self.hash = (self.hash * 61 + ord(self.name[j])) - 32
  6. print self.hash
  7. return self.hash
  8.  
  9. //output for "loc.dat":
  10. 44
  11. 2731
  12. 166626
  13. 10164200
  14. 620016236
  15. 37820990429
  16. 2307080416221
  17.  
  18. ---
  19.  
  20. int fileToHash(String name) {
  21. int hash = 0;
  22. name = name.toUpperCase();
  23. for (int j = 0; j < name.length(); j++) {
  24. hash = (hash * 61 + name.charAt(j)) - 32;
  25. System.out.println(hash);
  26. }
  27. return hash;
  28. }
  29.  
  30. //output for "loc.dat":
  31. 44
  32. 2731
  33. 166626
  34. 10164200
  35. 620016236
  36. -833715235
  37. 682978269
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement