Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- for (let line of input) {
- if (line === "Last note") {
- break;
- }
- let pattern = /(?<peakName>^[A-Za-z0-9!@#$?]+)=(?<geohashcodeLength>\d+)<<(?<geohashcode>[\w\W]+?)$/gm;
- let result = pattern.exec(line);
- if (result) {
- let peakName = result.groups.peakName;
- peakName = peakName.match(/[A-Za-z0-9]/g).join('');
- let geohashcodeLength = Number(result.groups.geohashcodeLength);
- let geohashcode = result.groups.geohashcode;
- if (geohashcode.length === geohashcodeLength) {
- console.log(`Coordinates found! ${peakName} -> ${geohashcode}`);
- } else {
- console.log("Nothing found!");
- }
- }
- else {
- console.log("Nothing found!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement