Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

MATL, 17 bytes

4:"Gas2YLG@X!X=va

Try it online! Or verify all test cases.

Outputs 1 for Pascal matrices, 0 otherwise.

###Explanation

Explanation

4: % Push [1 2 3 4]
" % For each
 G % Push input: ×ばつN
 a % ×ばつN vector containing 1 for matrix columns that have at least a nonzero
 % entry, and 0 otherwise. So it gives a vector containing 1 in all entries
 s % Sum. Gives N
 2YL % Pascal matrix of that size
 G % Push input
 @ % Push current iteration index
 X! % Rotate the matrix that many times in steps of 90 degress
 X= % Are they equal?
 v % Concatenate with previous accumulated result
 a % Gives 1 if at least one entry of the vector is nonzero
 % End (implicit). Display (implicit)

MATL, 17 bytes

4:"Gas2YLG@X!X=va

Try it online! Or verify all test cases.

Outputs 1 for Pascal matrices, 0 otherwise.

###Explanation

4: % Push [1 2 3 4]
" % For each
 G % Push input: ×ばつN
 a % ×ばつN vector containing 1 for matrix columns that have at least a nonzero
 % entry, and 0 otherwise. So it gives a vector containing 1 in all entries
 s % Sum. Gives N
 2YL % Pascal matrix of that size
 G % Push input
 @ % Push current iteration index
 X! % Rotate the matrix that many times in steps of 90 degress
 X= % Are they equal?
 v % Concatenate with previous accumulated result
 a % Gives 1 if at least one entry of the vector is nonzero
 % End (implicit). Display (implicit)

MATL, 17 bytes

4:"Gas2YLG@X!X=va

Try it online! Or verify all test cases.

Outputs 1 for Pascal matrices, 0 otherwise.

Explanation

4: % Push [1 2 3 4]
" % For each
 G % Push input: ×ばつN
 a % ×ばつN vector containing 1 for matrix columns that have at least a nonzero
 % entry, and 0 otherwise. So it gives a vector containing 1 in all entries
 s % Sum. Gives N
 2YL % Pascal matrix of that size
 G % Push input
 @ % Push current iteration index
 X! % Rotate the matrix that many times in steps of 90 degress
 X= % Are they equal?
 v % Concatenate with previous accumulated result
 a % Gives 1 if at least one entry of the vector is nonzero
 % End (implicit). Display (implicit)
added 723 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 17 bytes

4:"Gas2YLG@X!X=va

Try it online! Or verify all test cases.

Outputs 1 for Pascal matrices, 0 otherwise.

###Explanation

4: % Push [1 2 3 4]
" % For each
 G % Push input: ×ばつN
 a % ×ばつN vector containing 1 for matrix columns that have at least a nonzero
 % entry, and 0 otherwise. So it gives a vector containing 1 in all entries
 s % Sum. Gives N
 2YL % Pascal matrix of that size
 G % Push input
 @ % Push current iteration index
 X! % Rotate the matrix that many times in steps of 90 degress
 X= % Are they equal?
 v % Concatenate with previous accumulated result
 a % Gives 1 if at least one entry of the vector is nonzero
 % End (implicit). Display (implicit)

MATL, 17 bytes

4:"Gas2YLG@X!X=va

Try it online! Or verify all test cases.

Outputs 1 for Pascal matrices, 0 otherwise.

MATL, 17 bytes

4:"Gas2YLG@X!X=va

Try it online! Or verify all test cases.

Outputs 1 for Pascal matrices, 0 otherwise.

###Explanation

4: % Push [1 2 3 4]
" % For each
 G % Push input: ×ばつN
 a % ×ばつN vector containing 1 for matrix columns that have at least a nonzero
 % entry, and 0 otherwise. So it gives a vector containing 1 in all entries
 s % Sum. Gives N
 2YL % Pascal matrix of that size
 G % Push input
 @ % Push current iteration index
 X! % Rotate the matrix that many times in steps of 90 degress
 X= % Are they equal?
 v % Concatenate with previous accumulated result
 a % Gives 1 if at least one entry of the vector is nonzero
 % End (implicit). Display (implicit)
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 17 bytes

4:"Gas2YLG@X!X=va

Try it online! Or verify all test cases.

Outputs 1 for Pascal matrices, 0 otherwise.

AltStyle によって変換されたページ (->オリジナル) /