Draft

Smooth Lines

Description:

Task

Your friend Marc knows that you're a talented programmer, he encountered some issues in his rountine, he can't endure that his weird text files contains unordered lines. He asks you to write a script that can help him with this to make his lines smooths, he's not interested by the meaning of these lines, he just want them to be smoothly ordered.

Also he can't endure the fact that some duplicates remains, that means :

aa
aa
aaa
aa

Should result in:

aa
aaa
aa

or

aa
aaa
aa
aa

Should result in:

aa
aaa
aa

or

aa
aaa
aaa
aa

Should result in

aa
aaa
aa

So, none of side (over longest line, longest line itself, under longest line) contains duplicates.

Also, blank lines has to be removed.

       (contains spaces)
aaaa
aa
       (contains spaces)
aaa

Should result in:

aa
aaa
aaaa

Examples

Marc file content:

aaa
aa

Marc wants:

aa
aaa

Marc file content:

aaaaa
a
aaaa
aa
aaa
aaaaaaaaaaa
aaa
aaaaa
aa
a

Marc wants:

a
aa
aaa
aaaa
aaaaa
aaaaaaaaaaa
aaaaa
aaa
aa
a

Marc file content:

aaaaa
a
aaaa
aaa
aa
aaa <= This one should be deleted
aaaaaaaaaaa
aaa
aaaaa
aa
a

Marc wants:

a
aa
aaa
aaaa
aaaaa
aaaaaaaaaaa
aaaaa
aaa
aa
a

Marc file content:

zzzzz
z
zzzzzzzzzzz <= This one should be deleted
zzzz
zzz
zz
zzzzzzzzzzz
zzz
zzzzz
zz
z

Marc wants:

z
zz
zzz
zzzz
zzzzz
zzzzzzzzzzz
zzzzz
zzz
zz
z

Marc file content:

zzzzz
z
zzzzzzzzzzz <= Duplicate (It appears 2 times, but it's clear that is the longest line)
zzzz
zzz <= Duplicate (It appears 3 times, it could be a duplicate from top of longest or being a duplicate from under longest line)
zzz
zz
zzzzzzzzzzz
zzz
zzzzz <= Duplicate (It appears 3 times, it could be a duplicate from top of longest or being a duplicate from under longest line)
zzzzz
zz
z

Marc wants:

z
zz
zzz
zzzz
zzzzz
zzzzzzzzzzz
zzzzz
zzz
zz
z

You noticed that the content of these files may change.

Strings
Puzzles

Stats:

CreatedNov 27, 2024
Warriors Trained17
Total Skips0
Total Code Submissions393
Total Times Completed6
JavaScript Completions6
Total Stars2
% of votes with a positive feedback rating67% of 3
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments3
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • benjGam Avatar
Ad