-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathasciiArt.js
More file actions
38 lines (31 loc) · 1.1 KB
/
asciiArt.js
File metadata and controls
38 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var L = parseInt(readline()); //length of each letter
var H = parseInt(readline()); //height of each row
var T = readline(); //the letter or set of letters to print
var letters = T.toUpperCase().split(''); //normalize to uppercase and convert to array of letters
var alphabetArray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'.split('');
var alphabetMap = {};
for (var j = alphabetArray.length - 1; j >= 0; j--) {
alphabetMap[alphabetArray[j]] = [];
}
var asciiArray = [];
for (var i = 0; i < H; i++) {
var ROW = readline();
var currentLetterIndex = 0;
for (var j = 0; j < alphabetArray.length; j++) {
var thisLetter = alphabetArray[j];
alphabetMap[thisLetter][i] = ROW.substr(currentLetterIndex, L);
currentLetterIndex += L;
}
}
var result = '';
for (var j = 0; j < H; j++) { //each line by height
for (var i = 0; i < letters.length; i++) { //each letter in output
var thisLetter = letters[i];
if ((thisLetter < 'A') || (thisLetter > 'Z')) {
thisLetter = '?';
}
result += alphabetMap[thisLetter][j];
}
result += '\n';
}
print(result);