+ 7
Challenge : compressing lists with successive numbers
You want to compress a list by replacing successions of numbers with the corresponding range. Ex : [-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20]) ==> "-6,-3-1,3-5,7-11,14,15,17-20" Write the program doing this compression. Oneliners welcomed !
9 odpowiedzi
+ 3
It seems impossible to write in one line... Separate input numbers with spaces.
https://code.sololearn.com/cqNjsJ4xe2SV/?ref=app
+ 3
https://code.sololearn.com/cdsmnQQS0Tcr/#py
EDIT: @VcC oops! my bad! fixed it :)
it's not even close to be as short as you've shown to be possible, but it does the job :p
+ 2
Oneliners friends where are you ?
https://code.sololearn.com/c82XfKVLiK5G/?ref=app
+ 1
@VcC I have fixed the code, thanks for your comments!
+ 1
heres mine....##)
https://code.sololearn.com/cDMvDFzgA0LA/?ref=app
0
Not impossible ! Can provide test input or use the proposed format to facilitate testing ?
0
@VcC for example,
3 7 8 9 10 14 21 22 23
0
Good work but not 100% ok. check the proposed example