Implementation of some algorithm in python.