mirror of
https://github.com/iritmaximus/tira.git
synced 2026-10-12 19:13:47 +03:00
39 lines
667 B
Python
39 lines
667 B
Python
A = 19
|
|
N = 10**6
|
|
|
|
|
|
def main():
|
|
hash_function("aybabtu")
|
|
hash_function("maanantai")
|
|
hash_function("tiistai")
|
|
hash_function("keskiviikko")
|
|
hash_function("torstai")
|
|
hash_function("perjantai")
|
|
hash_function("lauantai")
|
|
hash_function("sunnuntai")
|
|
|
|
|
|
def hash_function(s):
|
|
print(s)
|
|
|
|
list = []
|
|
for x in s:
|
|
list.append(ord(x))
|
|
|
|
print(list)
|
|
|
|
result = 0
|
|
for i, y in enumerate(list):
|
|
# print(list, y)
|
|
print(f"{A} ** {len(list)}-1-{i}={(len(list) - 1 - i)} * {y}")
|
|
result += A ** (len(list) - 1 - i) * y
|
|
|
|
result %= N
|
|
|
|
print(result)
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|