# frozen_string_literal: true # 入力された値を受け取る A = gets.chomp S = gets.chomp S.length.times do |i| hoge = S[i] S[i] = A[hoge.to_i] unless hoge.match(/\d/).nil? end puts S