Skip to content

Instantly share code, notes, and snippets.

@QuincyLarson
Last active August 29, 2015 14:25
Show Gist options
  • Save QuincyLarson/ff1dbc5a478b6fe463d9 to your computer and use it in GitHub Desktop.
Save QuincyLarson/ff1dbc5a478b6fe463d9 to your computer and use it in GitHub Desktop.
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
var L = parseInt(readline());
var H = parseInt(readline());
var T = readline().toUpperCase();
var ascii = [[]];
for (var i = 0; i < H; i++) {
var ROW = readline();
ascii[i] = [];
for (var j = 0; j < 27; j += 1 ) {
ascii[i][j] = ROW.substr(L * j, L);
}
}
var ascii_A = 'A'.charCodeAt(0);
var ascii_Z = 'Z'.charCodeAt(0);
var N = T.length;
var res = '';
for (var i = 0; i < H; i++) {
for(var j = 0; j < N; j++) {
var ch = T.charCodeAt(j);
if(ch >= ascii_A && ch <= ascii_Z) {
ch -= ascii_A;
res += ascii[i][ch];
} else {
res += ascii[i][26];
}
}
res = res + '\n';
}
print(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment