Solutions algorithms in ruby