Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- for (let line of input) {
- let pattern = /^([#*&%$])(?<racer>[A-Za-z]+)\1=(?<lengthGeohashCode>\d+)!!(?<geohashCode>.+)$/gm;
- let result = pattern.exec(line);
- if (result) {
- let racer = result.groups.racer;
- let lengthGeohashCode = Number(result.groups.lengthGeohashCode);
- let geohashCode = result.groups.geohashCode;
- let realLength = geohashCode.length;
- let decryptedCode = geohashCode.split('').map(e => String.fromCharCode(e.charCodeAt(0) + lengthGeohashCode)).join('');
- realLength === lengthGeohashCode
- ? console.log(`Coordinates found! ${racer} -> ${decryptedCode}`)
- : console.log(`Nothing found!`);
- }
- else {
- console.log(`Nothing found!`);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment