Advertisement
nikolayneykov

Untitled

Apr 14th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve (params) {
  2.   let regex = /^([#$%*&]+)([A-Za-z]+)\1=(\d+)!!(.+)$/
  3.  
  4.   for (let param of params) {
  5.     let match = param.match(regex)
  6.  
  7.     if (match) {
  8.       let length = +match[3]
  9.       if (length === match[4].length) {
  10.         let decrypted = match[4]
  11.           .split('')
  12.           .map(x => String.fromCharCode(x.charCodeAt(0) + length))
  13.           .join('')
  14.         console.log(`Coordinates found! ${match[2]} -> ${decrypted}`)
  15.         break
  16.       } else {
  17.         console.log(`Nothing found!`)
  18.       }
  19.     } else {
  20.       console.log(`Nothing found!`)
  21.     }
  22.   }
  23. }
  24. solve([
  25.   '%GiacomoAgostini%=7!!hbqw',
  26.   '&GeoffDuke*=6!!vjh]zi',
  27.   'JoeyDunlop=10!!lkd,rwazdr',
  28.   'Mike??Hailwood=5!![pliu',
  29.   '#SteveHislop#=16!!df%TU[Tj(h!!TT[S'
  30. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement