writing algorithms for fun and learning