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