I wrote this algorithm for the purpose of practicing!