Skip to main content
added 7 characters in body
Source Link
Cristian Lupascu
  • 8.7k
  • 2
  • 25
  • 52

Haskell, 67 59 58 bytes

(q:r)!x|x<last q=q:r!x|1<2=(q++[x]):r
_!x=[[x]]
foldl(!)[]

Explanation: Given a list of lists (that are already sorted) and a value x, the ! operator will place x insideat the end of the first list whose last element is less than or equal to x. If no such list exists, the list [x] is placed at the end.

Try it online.

Haskell, 67 59 58 bytes

(q:r)!x|x<last q=q:r!x|1<2=(q++[x]):r
_!x=[[x]]
foldl(!)[]

Explanation: Given a list of lists (that are already sorted) and a value x, the ! operator will place x inside the first list whose last element is less than or equal to x. If no such list exists, the list [x] is placed at the end.

Try it online.

Haskell, 67 59 58 bytes

(q:r)!x|x<last q=q:r!x|1<2=(q++[x]):r
_!x=[[x]]
foldl(!)[]

Explanation: Given a list of lists (that are already sorted) and a value x, the ! operator will place x at the end of the first list whose last element is less than or equal to x. If no such list exists, the list [x] is placed at the end.

Try it online.

edited body
Source Link
Cristian Lupascu
  • 8.7k
  • 2
  • 25
  • 52

Haskell, 67 59 5958 bytes

(q:r)!x|x<last q=q:r!x|1<2=(q++[x]):r
_!x=[[x]]
foldl(!)[]
(q:r)!x|last q<=x=(q++[x]):r|1<2=q:r!x
_!x=[[x]]
foldl(!)[]

Explanation: Given a list of lists (that are already sorted) and a value x, the ! operator will place x inside the first list whose last element is less than or equal to x. If no such list exists, the list [x] is placed at the end.

Try it online.Try it online.

Haskell, 67 59 bytes

(q:r)!x|last q<=x=(q++[x]):r|1<2=q:r!x
_!x=[[x]]
foldl(!)[]

Try it online.

Haskell, 67 59 58 bytes

(q:r)!x|x<last q=q:r!x|1<2=(q++[x]):r
_!x=[[x]]
foldl(!)[]

Explanation: Given a list of lists (that are already sorted) and a value x, the ! operator will place x inside the first list whose last element is less than or equal to x. If no such list exists, the list [x] is placed at the end.

Try it online.

deleted 7 characters in body
Source Link
Cristian Lupascu
  • 8.7k
  • 2
  • 25
  • 52

Haskell, 6767 59 bytes

(q:r)!x|null q||lastx|last q<=x=(q++[x]):r|1<2=q:r!x
_!x=[[x]]
foldl(!)[]

Try it online.Try it online.

Haskell, 67 bytes

(q:r)!x|null q||last q<=x=(q++[x]):r|1<2=q:r!x
_!x=[[x]]
foldl(!)[]

Try it online.

Haskell, 67 59 bytes

(q:r)!x|last q<=x=(q++[x]):r|1<2=q:r!x
_!x=[[x]]
foldl(!)[]

Try it online.

Source Link
Cristian Lupascu
  • 8.7k
  • 2
  • 25
  • 52
Loading