Skip to main content
deleted 59 characters in body
Source Link
Kirill L.
  • 14.1k
  • 2
  • 16
  • 50

R, 73 6664 bytes

function(m,n,d=diff(rbind(m,0)),`-`=rowSums)any(d[-d>0,]+d[-d<0,])

Try it online!Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

R, 73 66 bytes

function(m,n,d=diff(rbind(m,0)),`-`=rowSums)any(d[-d>0,]+d[-d<0,])

Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

R, 73 64 bytes

function(m,d=diff(rbind(m,0)),`-`=rowSums)any(d[-d>0,]+d[-d<0,])

Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row. Outputs a swapped T/F value (in the footer, the results are swapped back).

added 3 characters in body
Source Link
Kirill L.
  • 14.1k
  • 2
  • 16
  • 50

R, 73 6766 bytes

function(m,n,d=td=diff(diffrbind(m,0)),w=which`-`=rowSums)any(head(w(d[-d>0)%%n,-1)]+d[-w(d<0)%%n,])

Try it online!Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

R, 73 67 bytes

function(m,n,d=t(diff(m)),w=which)any(head(w(d>0)%%n,-1)-w(d<0)%%n)

Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

R, 73 66 bytes

function(m,n,d=diff(rbind(m,0)),`-`=rowSums)any(d[-d>0,]+d[-d<0,])

Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

deleted 6 characters in body
Source Link
Kirill L.
  • 14.1k
  • 2
  • 16
  • 50

R, 7373 67 bytes

function(m,n,d=t(diff(m)),w=which,x=w)any(head(w(d>0)%%n,-1)any(x[seq(y<-w(d<0)%%n)]-y)

Try it online!Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

R, 73 bytes

function(m,n,d=t(diff(m)),w=which,x=w(d>0)%%n)any(x[seq(y<-w(d<0)%%n)]-y)

Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

R, 73 67 bytes

function(m,n,d=t(diff(m)),w=which)any(head(w(d>0)%%n,-1)-w(d<0)%%n)

Try it online!

Based on the idea in Leo's Husk answer.

Takes input as a matrix m of 1s and 0s with each pattern corresponding to a row, and the size of the pattern n. Outputs a swapped T/F value (in the footer, the results are swapped back).

added 67 characters in body
Source Link
Kirill L.
  • 14.1k
  • 2
  • 16
  • 50
Loading
Source Link
Kirill L.
  • 14.1k
  • 2
  • 16
  • 50
Loading