Skip to main content
added 440 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 32 bytes

function(x)split(x,(x-seq(x))^2)

Try it online!

(51 bytes if we want to include the empty lists for displacements that don't occur:
function(x)Map(function(n)x[abs(x-s)==n],s<-seq(x)), painfully long because of the double "function" keyword, although this could be replaced by "\" in R≥4.1 for 37 bytes)

R, 32 bytes

function(x)split(x,(x-seq(x))^2)

Try it online!

R, 32 bytes

function(x)split(x,(x-seq(x))^2)

Try it online!

(51 bytes if we want to include the empty lists for displacements that don't occur:
function(x)Map(function(n)x[abs(x-s)==n],s<-seq(x)), painfully long because of the double "function" keyword, although this could be replaced by "\" in R≥4.1 for 37 bytes)

Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 32 bytes

function(x)split(x,(x-seq(x))^2)

Try it online!