Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rosettaStone(input) {
- let templateLen = Number(input[0]);
- let template = input.slice(1, templateLen + 1).map((x) => x.split(" ").map(Number));
- let message = input.slice(templateLen + 1).map((x) => x.split(" ").map(Number));
- let encoder = (n) => " ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(n % 27)];
- for (let row = 0; row < message.length; row++) {
- let tRow = template.shift();
- for (let col = 0; col < message[row].length; col += tRow.length) {
- for (let tCol = 0; tCol < tRow.length && col + tCol < message[row].length; tCol++) {
- message[row][col + tCol] += tRow[tCol];
- }
- }
- template.push(tRow);
- }
- let encodingMessage = message.flat().map(x => encoder(x)).join("").trimEnd();
- console.log(encodingMessage);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement