cnt = [3,2,2,2,3,2,3,2,4,3] p gets.chomp.chars.inject(1){|s,r|s+cnt[r.to_i]}