maymunskoa

Sequence

Mar 5th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input){
  2.    
  3.     let collection = input.map(arr=>{
  4.        
  5.         let singleArr = JSON.parse(arr);
  6.         singleArr.map(Number);
  7.         singleArr.sort((a,b)=>{
  8.             return b-a;
  9.         });
  10.          return JSON.stringify(singleArr);
  11.     });
  12.  
  13. let uniqueSet = new Set(collection);
  14.  
  15. let output = Array.from(uniqueSet);
  16.  
  17.  
  18. output
  19.     .map(JSON.parse)
  20.     .sort((a,b)=>{
  21.     return a.length - b.length;
  22. })
  23.     .forEach(el=>console.log(`[${el.join(', ')}]`));
  24.  
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment