Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(inp) {
- function whileLoop(inp) {
- let numArr = inp.shift().split(' ');
- let curStr = undefined;
- let arrOfStr = [];
- while (inp[0] !== 'find') {
- curStr = inp.shift().split('');
- let strLength = curStr.length - 1;
- let i = 0;
- let j = 0;
- while (true) {
- let newChar = curStr[j].charCodeAt() - Number(numArr[i]);
- curStr[j] = String.fromCharCode(newChar);
- if (i < strLength && i === numArr.length - 1) {
- i = 0;
- j++;
- if (j >= strLength) {
- break;
- }
- continue;
- } else if (j >= strLength) {
- break;
- }
- i++;
- j++;
- }
- arrOfStr.push(curStr.join(''));
- }
- return arrOfStr;
- }
- function stringDivision() {
- let arr = whileLoop(inp);
- arr = arr.map(el => el.split(/\&|\<|\>/));
- return arr;
- }
- function printing() {
- let arr = stringDivision();
- for (let el of arr) {
- let type = el[1];
- let coordinates = el[3];
- console.log(`Found ${type} at ${coordinates}`);
- }
- }
- printing();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement