interesting algo in python