Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = arr => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- //const test = ["thank you", "muchas gracias"];
- const test = ['talk','hablar'];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- //////////////////////////////////////////////////////////////////////
- let inputA = gets().split("");
- let inputB = gets().split("");
- print(inputA);
- print(inputB);
- let indexA = [];
- let indexB = [];
- //let english = "abcdefghijklmnopqrstuvwxyz";
- let english = "abcdefghijklmnopqrstuvwxyz -";
- let forResult = "";
- if (inputA.length > inputB.length) {
- forResult = inputA.splice(inputB.length, inputA.length);
- forResult = forResult.join("");
- } else if (inputA.length < inputB.length) {
- forResult = inputB.splice(inputA.length, inputB.length);
- forResult = forResult.join("");
- } else if (inputA.length === inputB.length) {
- forResult = "";
- }
- print(forResult);
- print(inputA);
- print(inputB);
- /////////////////////////////////////////////////////////
- for (let i = 0; i < inputA.length; i++) {
- // if (
- // inputA[i] !== " " ||
- // (inputA[i] !== "-" && inputB[i] !== " ") ||
- // inputB[i] !== "-"
- // ) {
- // indexA.push(String(english.indexOf(inputA[i]) + 1));
- // indexB.push(String(english.indexOf(inputB[i]) + 1));
- indexA.push(String(english.indexOf(inputA[i])));
- indexB.push(String(english.indexOf(inputB[i])));
- // }
- }
- // what's if char is ' ' or '-' ???
- ////////////////////
- print(indexA);
- print(indexB);
- ////////////////////////////////////
- let indexC = [];
- let words = "";
- for (let i = 0; i < indexA.length; i++) {
- // if (indexA[i] === "0" || indexB[i] === "0") {
- // indexC[i] = 0;
- // continue;
- // }
- if (indexA[i] === '26' || indexA[i] === '27') {
- indexC[i] = +indexA[i];
- continue;
- }
- else if(indexB[i] === '26' || indexB[i] === '27'){
- indexC[i] = +indexB[i];
- continue;
- }else{
- indexC[i] = indexA[i] - indexB[i];
- }
- if (indexC[i] < 0) {
- indexC[i] = -indexC[i];
- }
- }
- print(indexC);
- ////////////////////////////////////////
- for (const i of indexC) {
- // if (i === 0) {
- // words += " ";
- // continue;
- // }
- words += english[i];
- }
- print(words + forResult);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement