a simple coding exercise in ruby