# 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.

93 questions
Filter by
Sorted by
Tagged with
3k views

### Diamondize a Matrix

Given a matrix, output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom. For example, consider ...
• 36.8k
5k views

### Zigzagify a Matrix

As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take a matrix (not necessarily square) and return ...
• 194k
4k views

### Determinant of an Integer Matrix

Given a square integer matrix as input, output the determinant of the matrix. Rules You may assume that all elements in the matrix, the determinant of the matrix, and the total number of elements in ... 1k views

### Simplify matrix input!

I have written a few challenges related to matrices, and common for all are that I use a format like the one below when representing the matrices, both in examples and in test cases: ...
• 45.1k
4k views

### Fryer simulator

Your task is to model the effects of batter on pieces of food. Please add three layers of crust. ...
• 14.9k
2k views

### Check if all non-zero elements in a matrix are connected

Input: A matrix containing integers in the range [0 - 9]. Challenge: Determine if all non-zero elements are connected to each other vertically and/or horizontally. Output: A truthy value if all ...
• 45.1k
875 views

### Reconstruct a zigzagified matrix

As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take the unrolled vector along with the matrix ...
• 194k
732 views

### Draw diagonal positions of me squared

Based on the interpretation user @ThePirateBay made from the first version of my own challenge Output diagonal positions of me squared now I challenge you to make ASCII art that draws diagonal lines ...
• 3,338
5k 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 <...
• 1,317
5k views

### Make it explode!

Take a matrix of positive integers as input, and make it explode! The way you explode a matrix is by simply adding zeros around every element, including the outside borders. Input/output formats are ...
• 45.1k
3k views

### Orthodiagonal steps

It's a common problem to navigate in a 2D matrix. We've seen it many times and will see again. So let's help future us and develop the shortest solutions to generate all eight possible steps in a 2D ...
• 3,336
1k views

### Solve a 2x2 Eigensystem

For those with a little linear algebra background, the challenge is as simple as this: determine the eigenvalues and eigenvectors of a given complex 2x2 matrix. You may skip ahead to The Challenge for ...
• 194k
2k views

### Generalized matrix trace

Inspiration. Given (by any means): A two-argument (or single argument consisting of a two-element list) black box function, f: ℤ+ × ℤ+ → ℤ+ (input and output are 1,...
• 28.4k
2k views

### Do Matrix Multiplication!

In mathematics, matrix multiplication or the matrix product is a binary operation that produces a matrix from two matrices. The definition is motivated by linear equations and linear transformations ...
• 10.4k
3k views

• 37.6k
5k views

### Calculate the permanent as quickly as possible

The challenge is to write the fastest code possible for computing the permanent of a matrix. The permanent of an n-by-n matrix ... 3k 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. ...
• 799
530 views

### Ascending matrix

The "ascending matrix" is an infinite matrix of whole numbers (0 included) in which any element is the smallest available element which has not been previously used on the respective row and column: <...
• 707
2k views

### Calculate the Kronecker Product

Related, but very different. In the examples below, $A$ and $B$ will be $2\times2$ matrices, and the matrices are one-indexed. A Kronecker product has the following properties: ...
• 45.1k
2k views

### Verify Eigenpairs

In this challenge, you will be given a square matrix A, a vector v, and a scalar λ. You will ...
• 40.3k
2k views

### Sum the diagonals

Take a matrix of positive integers as input, and output the individual sums of the elements on the diagonal lines through the matrix. You shall only count the lines that goes diagonally down and to ...
• 45.1k
1k views

### (RGS 4/5) Inverting matrices modulo m

Task Given an integer matrix M and a modulus m, find an inverse of M modulo ...
• 13.8k
1k views

### Output diagonal positions of me squared

Given a number n, Output an ordered list of 1-based indices falling on either of the diagonals of an n*n square matrix. ...
• 3,338
2k views

### There, I fixed it (with rope)

Related: Rather similar (but much easier) challenge horizontally: There I fixed it (with tape) Challenge: Given a string only containing upper- and/or lowercase letters (whichever you prefer) and new-...
• 109k
2k views

### 2D Array Middle Point

Given dimensions of a 2D array, except 1xn, that results in an odd number of elements, find the midpoint index. Example: Input is 3x5, representing the 2D array [0,0] [0,1] [0,2] [0,3] [0,4] [1,0] [1,...
• 479
216 views

### Advent Challenge 7: Balance the storage carts!

<< Prev Next >> After some careful analysis, Santa was able to determine the dock size ranges and get the presents into the correct transportation dock. Now, he needs you to help him balance ...
• 40.3k
17k views

### Where's the 0xBEEF?

This challenge was inspired by this Wendy's commercial from 1984. Illustration by T S Rogers Your task is to find a hexadecimal 0xBEEF on a binary bun. The 'beef' consists of the following pattern: ...
• 171k
4k views

• 22.8k