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

298 questions
Filter by
Sorted by
Tagged with
18k 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: ...
• 194k
7k views

### The Hungry Mouse

Sixteen piles of cheese are put on a 4x4 square. They're labeled from $1$ to $16$. The smallest pile is $1$ and the biggest one is $16$. The Hungry Mouse is so hungry that it always goes ...
• 194k
4k views

### Friar simulator

The brethren from the order of St Golfus the Concise have a tradition of reciting a short prayer whenever they see someone make the sign of the cross. Due to the high level of sin measured among ...
• 15.3k
6k views

### Dig a border trench

Background: Too many illegal immigrants from Blandia are crossing the border to Astan. The emperor of Astan has tasked you with digging a trench to keep them out, and Blandia must pay for the expenses....
• 30.6k
7k views

### Seats in a Finnish cinema

You're given the map of a cinema theatre as a boolean matrix: 0 represents a free seat, 1 - occupied. Each Finn who walks in chooses the seat farthest away (Euclidean distance) from the nearest ...
• 15.3k
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 <...
• 1,395
6k 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 ...
• 197k
5k views

### In Flanders Fields

Today is November 11th, which for many regions is Remembrance Day. If you don't know anything about the history or context of Remembrance Day, you can read about it in the wiki page, but it's not ...
• 42.5k
2k views

### Summon the sevens

You are given a $3\times3$ square matrix where each cell is any digit between $0$ and $9$ except $7$. Your task is to figure out the minimum number of digits that must be replaced with $7$'s ...
• 194k
7k views

### Cops: Make a regex - Make a snake

This is the cop's thread. The robber's thread is here. Write a code that takes an input n and creates a n-by-n "snake matrix". A snake matrix is a matrix that ...
• 46.4k
4k views

• 50.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,434
3k views

### Is it a stochastic matrix?

A stochastic matrix is a matrix of probabilities used in the context of Markov chains. A right stochastic matrix is a matrix where each row sums to 1. A left ...
• 38.9k
6k views

### Is it a good 2048 board?

This is my first question here, so any suggestions in the comments would be appreciated! Thanks ;) Introduction One very common strategy for the 2048 game is never ever swiping down. This positions ...
• 393
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 ...
• 38.9k
3k views

### Create Bernard from Desmos

Background In the online graphing calculator Desmos, there is a certain shape that appears in the lower left portion of the graph in many high detail graphs, which the Desmos community has dubbed &...
• 13.7k
4k views

### Generate a Walsh Matrix

A Walsh matrix is a special kind of square matrix with applications in quantum computing (and probably elsewhere, but I only care about quantum computing). Properties of Walsh matrices The ...
5k views

### Implement the 2D Hadamard Transform

The Hadamard transform works similarly to the Fourier transform: it takes a vector and maps it to its frequency components, which are the Walsh functions. Instead of sine waves in the Fourier ...
• 663
4k views

### Symbolic matrix multiplication

There are lots of different ways to explain matrix multiplication. I'll stick with a single figure since I believe most people here are familiar with it (and the figure is very descriptive). If you ...
• 46.4k
590 views

### Interlaced Rotations

Challenge Given a square matrix of characters (single-byte printable ASCII characters), rotate each "ring" of the matrix in opposite directions. Let's take an example: ...
• 42.5k
1k views

### Golf A Free Lunch

Find a maximally profitable sequence of exchanges given an exchange rate table. As an example consider the currencies Ariary (your home currency), Baht, Cedi, and Denar where the rate from one to ...
• 108k