solve 022 by Ruby