# [Vyxal](https://github.com/Vyxal/Vyxal) `S`, 124 [bits<sup>v1](https://github.com/Vyxal/Vyncode/blob/main/README.md)</sup>, 15.5 bytes ``` s:¯0J⁽ṅḋ•ꜝƛ₍htU\-j ``` [Try it Online!](https://vyxal.pythonanywhere.com/?v=1#WyJTfj0iLCIiLCJzOsKvMErigb3huYXhuIvigKLqnJ3Gm+KCjWh0VVxcLWoiLCIiLCIhKC4qKSAtPiBcIiguKilcIlxuWzYsIDEsIDIsIDQsIDMsIDUsIDgsIDcsIDEwXSAtPiBcIjEtOCAxMFwiXG5bMTEsIDEwLCA2LCA5LCAxMywgOCwgMywgNCwgMTVdIC0+IFwiMy00IDYgOC0xMSAxMyAxNVwiXG5bOSwgMTMsIDMsIDExLCA4LCA0LCAxMCwgMTUsIDZdIC0+IFwiMy00IDYgOC0xMSAxMyAxNVwiXG5bNSwgOCwgMywgMiwgNiwgNCwgNywgMV0gLT4gXCIxLThcIlxuWzUsIDMsIDcsIDEsIDldIC0+IFwiMSAzIDUgNyA5XCIiXQ==) ## Explained ``` s:¯0J⁽ṅḋ•ꜝƛ₍htU\-j s: # Push two copies of the input list but sorted ¯0J # Forward differences of items with 0 appended ⁽ṅḋ # Grouped by whether they are <= 1 • # Reshape the sorted input to that shape ꜝ # and remove the 0 # the top of the stack will be a list of lists of numbers that are ranges ƛ # to each range ₍htU # either get the first and last item or just the first \-j # join on "-" # S flag joins the result on spaces ```