Skip to main content
added 41 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 9 bytes

Z^t!dXAY)

Try it online!

Explanation

Z^    % Implicit inputs. Cartesian product. EachGives Cartesiana tuplecharacter matrix where 
      % each row is a rowCartesian tuple (*)
t!    % Duplicate, transpose
d     % Consecutive differences, computed along vertical dimension
XA    % Vertical-all: gives true for columns that only contain nonzeros
Y)    % Use as logical index into the rows of (*). ImpliciyImplicit display

MATL, 9 bytes

Z^t!dXAY)

Try it online!

Explanation

Z^    % Implicit inputs. Cartesian product. Each Cartesian tuple is a row (*)
t!    % Duplicate, transpose
d     % Consecutive differences, computed along vertical dimension
XA    % Vertical-all: gives true for columns that only contain nonzeros
Y)    % Use as logical index into the rows of (*). Impliciy display

MATL, 9 bytes

Z^t!dXAY)

Try it online!

Explanation

Z^    % Implicit inputs. Cartesian product. Gives a character matrix where 
      % each row is a Cartesian tuple (*)
t!    % Duplicate, transpose
d     % Consecutive differences, computed along vertical dimension
XA    % Vertical-all: gives true for columns that only contain nonzeros
Y)    % Use as logical index into the rows of (*). Implicit display
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 9 bytes

Z^t!dXAY)

Try it online!

Explanation

Z^    % Implicit inputs. Cartesian product. Each Cartesian tuple is a row (*)
t!    % Duplicate, transpose
d     % Consecutive differences, computed along vertical dimension
XA    % Vertical-all: gives true for columns that only contain nonzeros
Y)    % Use as logical index into the rows of (*). Impliciy display