solved 45 in ruby