# Questions tagged [matrix]

This tag is for challenges involving matrices. A matrix, also known as a 2D array, is a list of numbers arranged in a rectangle with rows and columns.

297 questions
Filter by
Sorted by
Tagged with
603 views

### 9-16-25 2D Matrix

Given three grids and the sum of rows and columns of each grid, your task is: Grid 1: 3x3: Fill in the grid with integer from $1$ to $9$, ensure all elements of the grid are unique. Grid 2: 4x4: ...
2k views

### Borders of a Rectangular Matrix

Although it's done a few times as sub-challenge of a larger challenge, and we also have a challenge to remove the borders of a square matrix, I couldn't find a challenge to output the borders of a ...
3k views

### I'm Lazy*: Top-left align my text

* and don't have a word processor with top-left align support :D Take several lines of input, with at least four unique characters of your choice including newline and space. The input can also be ...
4k views

### Apply gravity to this matrix

This was inspired by this question. Given an $m\times n$ matrix of $0$'s and $1$'s, apply "gravity" to it. This means to drop down all the $1$'s as if they were affected by gravity. ...
6k views

### Construct the Identity Matrix

The challenge is very simple. Given an integer input n, output the n x n identity matrix. The identity matrix is one that has <...
2k views

### Checkered grid with X mark

Challenge Given two integer values $a \ge 2$ and $0 \le b < a$, generate a $(2a-1) \times (2a-1)$ matrix consisting of the integers 0, 1, and 2 as follows: Create a checkerboard of 0s and 1s ...
2k views

### Index of the row with most non-zero elements

This is a simple one: Take a matrix of integers as input, and output the index of the row with the most non-zero elements. You may assume that there will only be one row with the most non-zero ...
627 views

880 views

### Compute the logarithm of a matrix

There have already been challenges about computing the exponential of a matrix , as well as computing the natural logarithm of a number. This challenge is about finding the (natural) logarithm of ...
Given an $m \times n$ matrix of integers A, there exist a $m \times m$ matrix P, an $m \times n$ matrix D, and an $n \times n$ matrix Q such that: $A = P D Q$. P and Q are unimodular ...