# Questions tagged [matrix]

A matrix is a list of numbers arranged in a rectangle with rows and columns. In programming, it is also known as a 2D array. Use this tag if your challenge is about manipulating matrices.

206 questions
Filter by
Sorted by
Tagged with
50 views

### Logo Pack LAPACK

This is the logo for LAPACK, a widely used software library for numerical linear algebra. Your task is to print the logo (color and matrix brackets not required) as this exact string. Trailing ...
209 views

### Identify the smallest possible tile in the matrix

Challenge Given a matrix of digits (0-9), find the smallest (in terms of area) rectangular matrix of digits where one or more copies of itself, possibly rotated, can tile the original matrix. ...
151 views

### Create a text image by manual automation

Challenge Premise It's 2006, and Alice is trying to send Bob their her completed notes on their newly ended expeditions into the labyrinthine school library, which the two of them found suffers from a ...
15k 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: ...
2k views

### The matrix has U

Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as ...
644 views

### Toroidally magnify-blur a matrix

Task Given a matrix of numbers $M$ with $r$ rows and $c$ columns, and the magnification factor $n$, build the matrix with $rn$ rows and $cn$ columns where the original elements are spaced ...
3k 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 ...
6k views

### I transpose the source code, you transpose the input!

Rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its input/argument¹. The tricky part is that ...
2k views

### Codegolf the Hafnian

The challenge is to write codegolf for the Hafnian of a matrix. The Hafnian of an 2n-by-2n symmetric matrix ...
1k views

### Minimally sort a list into a matrix

Given an unsorted list of unique strictly positive integers, minimally sort it into a 2D matrix. The input list is guaranteed to be of composite length, which means the output matrix is not ...
297 views

### Positioning a fake mirror for best effect

Challenge Premise Consider a mosaic of $m\times n$ tiles, in $k$ unique colours designated by integers. Example ($3\times6$, four colours): ...
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 ...
2k 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 ...
664 views

### Make a rectangle from a collection of (sliced) squares

Inspired by Make a Rectangle from a Triangle. Task There is a famous formula on the sum of first $n$ squares: $$1^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}$$ It is known that this number ...
3k views

### Make a Rectangle from a Triangle

You can depict a triangular number, T(N), by writing one 1 on a line, then two 2's on the line below, then three 3's on the line below that, and so on until N N's. You end up with a triangle of T(N) ...
3k views

### Matrix Jigsaw Puzzles

Input: An integer n Two equal-sized square matrices (with their width/height being a multiple of n) Output: One of two ...
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

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

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

### Rotation summation

Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix. Rotated sum: Take the sum of the original matrix and the same matrix rotated 90, 180 and ...
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 ...
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,...
4k views

6k 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 ...
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 ...
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 ...
427 views

5k views

### Euclidean Distance Between Two Matrices

Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following: Given two matrices it must return the euclidean distance matrix. The euclidean distance ...
3k views

### Implement the Max-Pooling operation from Convolutional Neural Networks

In convolutional neural networks, one of the main types of layers usually implemented is called the Pooling Layer. Sometimes, the input image is big (and therefore time consuming especially if you ...
3k views

### ASCII texturing

Write a function or a full program that applies an ASCII texture to a 2d shape. Inputs: shape, texture, dimensions(optionally). Both Shape and Texture can be given by any convenient method (2d ...
845 views

### Cofactor Matrices

The cofactor matrix is the transpose of the Adjugate Matrix. The elements of this matrix are the cofactors of the original matrix. The cofactor (i.e. the element of the cofactor matrix at row i and ...
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 ...
6k views

### Dijkstra's Challenge

Presented in honor of APL as an interactive tool turning 50 this year Background Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on ...
667 views

### Matrices Generated Using Rectangles

Input is an r by c matrix of non-negative integers (you may input r and c as other parameters if this helps with golf). This may be inputted as a 2D array or, if you prefer, a 1D array (though taking ...
1k views

### Expand a recursive pattern

Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps. More specifically: Let the following be an example: ...
3k views

### Matrix in “slash” order

Given two positive numbers N >= 2 and N <= 100 create a matrix which follows the following rules: First Number starts at ...
2k views

### Slash the matrix

You are given a matrix of forward and back slashes, for instance: //\\ \//\ //\/ A slash cuts along the diagonal of its cell corner-to-corner, splitting it in ...
864 views

### Most contributing rows

Given a non-empty matrix of non-negative integers, answer which unique rows contribute most to the sum total of elements in the matrix. Answer by any reasonable indication, for example a mask of the ...
85 views

### Generate square sub-matrices of 1's [duplicate]

Back again, stealing another question from stackoverflow. You are given a list of integers >= 0. Generate in order square 1-matrices where the side length is given by the list entry of the current ...
575 views

### Lists and arrays, part by part

In this challenge, you'll get four different but somewhat related tasks that must be solved in a specific manner. First, I'll explain the tasks, then follows an explanation of how you must solve it. ...
3k 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 ...
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 ...
3k views

### Beware of the matrix tornado!

The matrix tornado is just like any other tornado: it consists of things rotating around a center. In this case, elements of the matrix instead of air. Here is an example of a matrix tornado: First ...