Skip to main content
Removed 2 bytes thanks to xnor
Source Link
colossus16
  • 2.3k
  • 8
  • 12

Haskell, 4949 47 bytes

l#1=pure<$>l
l#n=[c:a:r|(ar|a:r)<r<-l#(n-1),c<-l,a/=c]

Try it online!Try it online!

Edit: Thanks to @xnor for taking off two bytes! I didn't know you could remove the parentheses in that context

Haskell, 49 bytes

l#1=pure<$>l
l#n=[c:a:r|(a:r)<-l#(n-1),c<-l,a/=c]

Try it online!

Haskell, 49 47 bytes

l#1=pure<$>l
l#n=[c:a:r|a:r<-l#(n-1),c<-l,a/=c]

Try it online!

Edit: Thanks to @xnor for taking off two bytes! I didn't know you could remove the parentheses in that context

Source Link
colossus16
  • 2.3k
  • 8
  • 12

Haskell, 49 bytes

l#1=pure<$>l
l#n=[c:a:r|(a:r)<-l#(n-1),c<-l,a/=c]

Try it online!