No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

get_palindromic_hash.b93 863B

1234567891011121314151617181920212223242526
  1. v
  2. v !:\<
  3. > 0"YOUTH" 0\:!vv-1\5< v*\<+
  4. v <>: >| >\:|$
  5. v_"A"-0\: ^$>| >^
  6. >$@ >:#<^>1\^
  7. [Stack] -> [Stack]
  8. Input := zero-terminated string
  9. Output := 64bit number
  10. Calculate a hash value for the palindromic identity of a string.
  11. We use a base-5 number where every digit denotes the count of a specific lette rin the input
  12. (eg digit-1 = `count of letter A`, digit_2 = `coutn of letter B` ...)
  13. Base-5 means we only support numbers that have maximally five times the same letter.
  14. Five is the biggest base we can use with 64bit signed numbers (otherwise the number can get too big and overflow):
  15. ~~~
  16. x^(26-1) = 2^(64-1) <=>
  17. x = 2^(63/25) <=>
  18. x = 5.735
  19. ~~~
  20. With 32bit numbers the maximum would be `2`.