Advertisement
ErolKZ

Untitled

Dec 24th, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. function solve(input) {
  2.  
  3.  
  4. // console.log(spacePutting());
  5.  
  6. let arr = spacePutting();
  7.  
  8. for (let el of arr) {
  9.  
  10. // console.log(typeof el);
  11.  
  12. console.log(el);
  13.  
  14. }
  15.  
  16.  
  17. function sorting(input) {
  18.  
  19. let sequences = input.map(el => JSON.parse(el).sort((a, b) => b - a));
  20.  
  21. sequences = sequences.map(el => JSON.stringify(el));
  22.  
  23. return sequences;
  24.  
  25. }
  26.  
  27.  
  28. function discardingDuplicates() {
  29.  
  30. let sequences = sorting(input);
  31.  
  32. sequences = [...new Set(sequences)];
  33.  
  34. return sequences;
  35.  
  36. }
  37.  
  38.  
  39. function sorting2() {
  40.  
  41. let sequences = discardingDuplicates();
  42.  
  43. sequences = sequences.map(el => JSON.parse(el));
  44.  
  45. sequences.sort((a, b) => a.length !== b.length ? a.length - b.length : false);
  46.  
  47. return sequences;
  48.  
  49. }
  50.  
  51.  
  52. function spacePutting() {
  53.  
  54. let sequences = sorting2();
  55.  
  56. // sequences = sequences.map(el => el.join(', '));
  57.  
  58. // sequences = sequences.map(el => [el]);
  59.  
  60.  
  61. sequences = sequences.map(el => JSON.stringify(el));
  62.  
  63. return sequences;
  64.  
  65. }
  66.  
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement