Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isleOfMan(input) {
- for (line of input) {
- let [nameAndSymbols, geohashcode] = line.split('=');
- if (nameAndSymbols != undefined && geohashcode !== undefined) {
- let name = nameAndSymbols.substring(1, nameAndSymbols.length - 1);
- let startingSymbol = nameAndSymbols[0];
- let lastSymbol = nameAndSymbols[nameAndSymbols.length - 1];
- let lengthOfGeo = geohashcode.slice(0, geohashcode.indexOf('!!'));
- let index = geohashcode.indexOf(lengthOfGeo);
- let encryptedCode = geohashcode.slice(index + lengthOfGeo.length + 2);
- if (startingSymbol === lastSymbol) {
- if (Number(lengthOfGeo) === encryptedCode.length) {
- let decryptedCode = encryptedCode.split('');
- let resultCoords = ""
- for (let j = 0; j < decryptedCode.length; j++) {
- let currentSymbol = decryptedCode[j];
- let ascii = Number(currentSymbol.charCodeAt(0));
- let newAscii = ascii + Number(lengthOfGeo);
- let newSymbol = String.fromCharCode(newAscii);
- resultCoords += newSymbol;
- }
- console.log(`Coordinates found! ${name} -> ${resultCoords}`);
- break;
- } else {
- console.log(`Nothing found!`);
- }
- } else {
- console.log(`Nothing found!`);
- }
- } else {
- console.log(`Nothing found!`);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement