Advertisement
tetris555

rage-quit

Dec 1st, 2022
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.     text = arr[0].replace(/[a-z]/ig, (m) => m.toUpperCase());
  3.  
  4.     const uniqueChars = new Set(text.match(/[^\d]/g));
  5.  
  6.     console.log(`Unique symbols used: ${uniqueChars.size}`);
  7.  
  8.     let result = [];
  9.    
  10.     for (const e of [...text.matchAll(/(?<chrs>[^\d]+)(?<n>\d+)/g)]) {
  11.         const {chrs, n} = e.groups;
  12.         result.push(chrs.repeat(Number(n)));
  13.     }
  14.     console.log(result.join(''));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement