random algorithms, implemented for fun