Problem six in ruby