Little algorithms, just for fun.