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