converted all 3 algorithms to functions

All 3 functions are descending reasonably and now need to write a script to compare them