Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let regex = /(=|\/)(?<country>[A-Z][A-Za-z]{2,})\1/g;
- let matches = input.match(regex);
- let countries = [];
- let travelPoints = 0;
- if(matches) {
- for(let line of matches) {
- regex = /(=|\/)(?<country>[A-Z][A-Za-z]{2,})\1/g;
- let exec = regex.exec(line);
- countries.push(exec.groups.country);
- travelPoints += exec.groups.country.length;
- }
- }
- console.log(`Destinations: ${countries.join(', ')}`);
- console.log(`Travel Points: ${travelPoints}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement