Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2020
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let uniqueSymbols = [...new Set(input[0].match(/[^0-9]/g).map((x) => x.toUpperCase()))];
  3.     let series = input[0].split(/[0-9]+/).filter((x) => x != "");
  4.     let repeaters = input[0].split(/[^0-9]+/).filter((x) => x != "");
  5.  
  6.     console.log(`Unique symbols used: ${uniqueSymbols.length}`);
  7.  
  8.     let result = "";
  9.  
  10.     for (let i = 0; i < series.length; i++) {
  11.         result += series[i].toUpperCase().repeat(repeaters[i]);  
  12.     }
  13.  
  14.     console.log(result);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement