Some algorithms in Python