Advertisement
Guest User

Untitled

a guest
Jul 29th, 2019
252
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3. let a=5;
  4.  
  5. let line = input.shift();
  6.  
  7. while (line !== 'Last note') {
  8. let pattern = /^([A-Za-z0-1!@#$?]+)=(\d+)<<(.+)$/gm;
  9.  
  10. let result = pattern.exec(line);
  11.  
  12.  
  13. if (result === null) {
  14. console.log('Nothing found!')
  15. } else {
  16. let len = Number(result[2]);
  17. let lenCode = Number(result[3].length);
  18. if (len === lenCode) {
  19. let patternName = /[A-Za-z]+/gm;
  20.  
  21. let validNames = [];
  22. let validName = null;
  23. while ((validName = patternName.exec(result[1])) !== null) {
  24. validNames.push(validName[0]);
  25. }
  26.  
  27. console.log(`Coordinates found! ${validNames.join('')} -> ${result[3]}`)
  28.  
  29. } else {
  30. console.log('Nothing found!')
  31. }
  32. }
  33.  
  34.  
  35. line = input.shift();
  36. }
  37. }
  38.  
  39. solve(['!@Ma?na?sl!u@=7<<tv58ycb4845',
  40. 'E!ve?rest=.6<<tuvz26',
  41. '!K@2.,##$=4<<tvnd',
  42. '!Shiha@pan@gma##9<<tgfgegu67',
  43. '!###Anna@pur@na##=16<<tv5dekdz8x11ddkc',
  44. 'Last note']);
  45. //
  46. // solve(['Ka?!#nch@@en@ju##nga@=3<<thfbghvn',
  47. // '=9Cho?@#Oyu<<thvb7ydht',
  48. // 'Nan??ga#Par!ba!t?=16<<twm03q2rx5hpmyr6',
  49. // 'Dhau??la#gi@ri?!#=3<<bvnfhrtiuy',
  50. // 'Last note']);
Advertisement
RAW Paste Data Copied
Advertisement