solve 021 by Ruby