solve 023 by Ruby