Stan08

8. Unique Sequences/2

Sep 26th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. function sum(input) {
  2.  
  3. let stored = new Set();
  4.  
  5. for (let user of input)
  6. {
  7.  
  8. let sor = JSON.parse(user).map(Number).sort((a,b)=>b-a);
  9.  
  10. stored.add(JSON.stringify(sor));
  11. }
  12. let res = [...stored].sort((a,b)=>a.length-b.length);
  13.  
  14. res.forEach(f=> console.log(`[${JSON.parse(f).join(', ')}]`));
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment