Algorithm Design and exploration in ruby