Advertisement
ErolKZ

Untitled

Jan 5th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. function solve(inp) {
  2.  
  3.  
  4. function whileLoop(inp) {
  5.  
  6. let numArr = inp.shift().split(' ');
  7.  
  8. let curStr = undefined;
  9.  
  10. let arrOfStr = [];
  11.  
  12. while (inp[0] !== 'find') {
  13.  
  14. curStr = inp.shift().split('');
  15.  
  16. let strLength = curStr.length - 1;
  17.  
  18. let i = 0;
  19.  
  20. let j = 0;
  21.  
  22. while (true) {
  23.  
  24. let newChar = curStr[j].charCodeAt() - Number(numArr[i]);
  25.  
  26. curStr[j] = String.fromCharCode(newChar);
  27.  
  28. if (i < strLength && i === numArr.length - 1) {
  29.  
  30. i = 0;
  31.  
  32. j++;
  33.  
  34. if (j >= strLength) {
  35.  
  36. break;
  37.  
  38. }
  39.  
  40. continue;
  41.  
  42. } else if (j >= strLength) {
  43.  
  44. break;
  45.  
  46. }
  47.  
  48. i++;
  49.  
  50. j++;
  51.  
  52. }
  53.  
  54. arrOfStr.push(curStr.join(''));
  55.  
  56. }
  57.  
  58. return arrOfStr;
  59.  
  60. }
  61.  
  62.  
  63. function stringDivision() {
  64.  
  65. let arr = whileLoop(inp);
  66.  
  67. arr = arr.map(el => el.split(/\&|\<|\>/));
  68.  
  69. return arr;
  70.  
  71. }
  72.  
  73.  
  74. function printing() {
  75.  
  76. let arr = stringDivision();
  77.  
  78. for (let el of arr) {
  79.  
  80. let type = el[1];
  81.  
  82. let coordinates = el[3];
  83.  
  84. console.log(`Found ${type} at ${coordinates}`);
  85.  
  86. }
  87.  
  88. }
  89.  
  90.  
  91. printing();
  92.  
  93.  
  94. }
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement