Skip to main content
5 of 5
Commonmark migration

SWI-Prolog, 165 162 159 bytes

b(Z,C,[D|E]):-Z=[A|B],(A=:=D+1,(B=[],put(45),print(A);b(B,C,[A,D|E]));(E=[],tab(1),print(A);writef('-%t %t',[D,A])),b(B,A,[A]));!.
a(A):-sort(A,B),b(B,_,[-1]).

Pretty bad but then again Prolog is a terrible golfing language

Example: a([9,13,3,11,8,4,10,15,6]). outputs 3-4 6 8-11 13 15

Fatalize
  • 39.3k
  • 5
  • 70
  • 162