Lab 3 implemented in ruby