This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import Popen | |
from datetime import date, datetime | |
import os | |
import math | |
import codecs | |
from itertools import islice | |
from sqlalchemy import create_engine, Column, Index | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.dialects.sqlite import FLOAT, INTEGER, TEXT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hash s h0 str = last $ scanl1 (\x y -> x*37 + y) (h0:[fromJust $ elemIndex c str | c <- s]) | |
unhash h h0 str = reverse $ unfoldr (\x -> if x == h0 then Nothing else Just (str !! (x `mod` 37), x `quot` 37)) h | |
hash "leepadg" 7 "acdegilmnoprstuw" | |
unhash 680131659347 7 "acdegilmnoprstuw" |