solve 024 by Ruby