$KCODE='u' $<.map{|i|s=c=0;n=1;h={'千',1000,'百',?d,'十',10};i.chop.chars{|c|s+=n*h[c].to_i n=%W[d 一 二 三 四 五 六 七 八 九].index(c)||1};s+=n if !h[c];p s}