Skip to main content
added 285 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 32 25 bytes

[:-:/[:(|/.~/:~"1)2-/\,&0

Try it online!

Based on Leo's excellent idea

  • 2-/\,&0 Adjacent elementwise row deltas, with an extra row of zeros appended first.
  • (|/.~/:~"1) Group by sorted rows and take absolute value. This puts all rows with a single 1 into one bucket, and all rows with a single -1 into another.
  • [:-:/ Are those buckets equal?

J, 32 25 bytes

[:-:/[:(|/.~/:~"1)2-/\,&0

Try it online!

Based on Leo's excellent idea

J, 32 25 bytes

[:-:/[:(|/.~/:~"1)2-/\,&0

Try it online!

Based on Leo's excellent idea

  • 2-/\,&0 Adjacent elementwise row deltas, with an extra row of zeros appended first.
  • (|/.~/:~"1) Group by sorted rows and take absolute value. This puts all rows with a single 1 into one bucket, and all rows with a single -1 into another.
  • [:-:/ Are those buckets equal?
deleted 2 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 3232 25 bytes

[:-:/[:(-@-:@#-`||/.\])@~/:~2~"1)2-/\,&0

Try it online!Try it online!

Based on Leo's excellent idea

J, 32 bytes

[:-:/[:(-@-:@#-`|.\])@/:~2-/\,&0

Try it online!

Based on Leo's excellent idea

J, 32 25 bytes

[:-:/[:(|/.~/:~"1)2-/\,&0

Try it online!

Based on Leo's excellent idea

Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 32 bytes

[:-:/[:(-@-:@#-`|.\])@/:~2-/\,&0

Try it online!

Based on Leo's excellent idea