Advertisement
Todorov_Stanimir

01. The Isle of Man TT Race Final Exam-14 April 2019 Group 2

Jul 18th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function theIsleOfManTTRace(input) {
  2.     const pattern = /([#$%\*&])(?<name>[a-z]+)\1=(?<len>\d+)!!(?<geohash>.+)/gi;
  3.     for (checkedRacer of input) {
  4.         if (checkedRacer.match(pattern)) {
  5.             let racer = pattern.exec(checkedRacer);
  6.             let lengthGeohash = Number(racer.groups.len);
  7.             if (lengthGeohash === racer.groups.geohash.length) {
  8.                 let geohashcode = racer.groups.geohash
  9.                     .split('')
  10.                     .map(char => String.fromCharCode(char.charCodeAt() + lengthGeohash))
  11.                     .join('')
  12.                 console.log(`Coordinates found! ${racer.groups.name} -> ${geohashcode}`);
  13.                 break;
  14.             }
  15.         }
  16.         console.log('Nothing found!');
  17.     }
  18. }
  19. theIsleOfManTTRace(['%GiacomoAgostini%=7!!hbqw',
  20.     '&GeoffDuke*=6!!vjh]zi',
  21.     'JoeyDunlop=10!!lkd,rwazdr',
  22.     'Mike??Hailwood=5!![pliu',
  23.     '#SteveHislop#=16!!df%TU[Tj(h!!TT[S'])
  24. theIsleOfManTTRace(['Ian6Hutchinson=7!!\\(58ycb4',
  25.     '#MikeHailwood#!!\'gfzxgu6768=11',
  26.     'slop%16!!plkdek/.8x11ddkc',
  27.     '$Steve$=9Hhffjh',
  28.     '*DavMolyneux*=15!!efgk#\'_$&UYV%h%',
  29.     'RichardQ^uayle=16!!fr5de5kd'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement