Skip to content

Instantly share code, notes, and snippets.

View jvvk's full-sized avatar

Vamshi jvvk

View GitHub Profile
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
@jvvk
jvvk / fogcreek_hash.hs
Created August 19, 2014 12:50
Fogcreek hash problem
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"