Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let arr = spaceHandling();
- for (let el of arr) {
- // console.log(typeof el);
- console.log(`[${el}]`);
- }
- function sorting(input) {
- let sequences = input;
- sequences = sequences.map(el => JSON.parse(el));
- sequences = sequences.map(el => el.sort((a, b) => b - a));
- sequences.sort((a, b) => a.length !== b.length ? a.length - b.length : false);
- return sequences;
- }
- function discardingDuplicates() {
- let sequences = sorting(input);
- sequences = sequences.map(el => JSON.stringify(el));
- sequences = [...new Set(sequences)];
- return sequences;
- }
- function spaceHandling() {
- let sequences = discardingDuplicates();
- sequences = sequences.map(el => JSON.parse(el));
- sequences = sequences.map(el => el.join(', '));
- let arr = [];
- return sequences;
- // return arr;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement