Advertisement
Guest User

alexTagarev

a guest
Feb 16th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const getGets = arr => {
  2.   let index = 0;
  3.  
  4.   return () => {
  5.     const toReturn = arr[index];
  6.     index += 1;
  7.     return toReturn;
  8.   };
  9. };
  10. // this is the test
  11. //const test = ["thank you", "muchas gracias"];
  12. const test = ['talk','hablar'];
  13.  
  14. const gets = this.gets || getGets(test);
  15. const print = this.print || console.log;
  16.  
  17. //////////////////////////////////////////////////////////////////////
  18.  
  19. let inputA = gets().split("");
  20. let inputB = gets().split("");
  21.  
  22. print(inputA);
  23. print(inputB);
  24.  
  25. let indexA = [];
  26. let indexB = [];
  27.  
  28. //let english = "abcdefghijklmnopqrstuvwxyz";
  29. let english = "abcdefghijklmnopqrstuvwxyz -";
  30.  
  31. let forResult = "";
  32. if (inputA.length > inputB.length) {
  33.   forResult = inputA.splice(inputB.length, inputA.length);
  34.   forResult = forResult.join("");
  35. } else if (inputA.length < inputB.length) {
  36.   forResult = inputB.splice(inputA.length, inputB.length);
  37.   forResult = forResult.join("");
  38. } else if (inputA.length === inputB.length) {
  39.   forResult = "";
  40. }
  41.  
  42. print(forResult);
  43. print(inputA);
  44. print(inputB);
  45.  
  46. /////////////////////////////////////////////////////////
  47.  
  48. for (let i = 0; i < inputA.length; i++) {
  49. //   if (
  50. //     inputA[i] !== " " ||
  51. //     (inputA[i] !== "-" && inputB[i] !== " ") ||
  52. //     inputB[i] !== "-"
  53. //   ) {
  54.     // indexA.push(String(english.indexOf(inputA[i]) + 1));
  55.     // indexB.push(String(english.indexOf(inputB[i]) + 1));
  56.     indexA.push(String(english.indexOf(inputA[i])));
  57.     indexB.push(String(english.indexOf(inputB[i])));
  58. //   }
  59. }
  60.  
  61.  
  62. // what's if char is ' ' or '-' ???
  63. ////////////////////
  64.  
  65. print(indexA);
  66. print(indexB);
  67.  
  68.  
  69. ////////////////////////////////////
  70.  
  71. let indexC = [];
  72. let words = "";
  73. for (let i = 0; i < indexA.length; i++) {
  74. //   if (indexA[i] === "0" || indexB[i] === "0") {
  75. //     indexC[i] = 0;
  76. //     continue;
  77. //   }
  78.  
  79. if (indexA[i] === '26' || indexA[i] === '27') {
  80.     indexC[i] = +indexA[i];
  81.     continue;
  82.   }
  83.   else if(indexB[i] === '26' || indexB[i] === '27'){
  84.     indexC[i] = +indexB[i];
  85.     continue;
  86.   }else{
  87.   indexC[i] = indexA[i] - indexB[i];
  88.   }
  89.   if (indexC[i] < 0) {
  90.     indexC[i] = -indexC[i];
  91.   }
  92. }
  93.  
  94. print(indexC);
  95.  
  96. ////////////////////////////////////////
  97.  
  98. for (const i of indexC) {
  99. //   if (i === 0) {
  100. //     words += " ";
  101. //     continue;
  102. //   }
  103.  
  104.   words += english[i];
  105. }
  106.  
  107.  
  108. print(words + forResult);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement