What's the deal with Deno? We talk with a major contributor to find out. Listen now.

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

214 questions
Filter by
Sorted by
Tagged with
216 views

### Thin Paper Folding

Thin Paper Folding This is a "lighter" version of the challenge Paper Folding for the win. This challenge is being posted as a different challenge with many modifications in order to try ...
2k views

### Antisymmetry of a Matrix

A matrix is antisymmetric, or skew-symmetric, if its transpose equals its negative. The transpose of a matrix can be obtained by reflecting its elements across the main diagonal. Examples of ...
332 views

### Paper Folding for the win

Paper Folding for the win "How many times can you fold a paper?" - This well known question led to many arguments, competition, myths and theories. Well, the answer to that question depends ...
1k views

### Help me accelerate linear recurrence relation!

Background A linear recurrence relation is a description of a sequence, defined as one or more initial terms and a linear formula on last $k$ terms to calculate the next term. (For the sake of ...
198 views

### Checkerboard the Matrix

Task Given a matrix, your program/function should output a row-equivalent matrix in checkerboard form ( $A_{ij}=0$ if and only if $i+j$ is odd). Two matrices are defined to be row-equivalent if ...
2k views

### Complete the Magic Square

Background A magic square is an n×n matrix consisting of one of each of the integers from $1$ to $n^2$ where every row, column, and diagonal sum to the same ...
129 views

### Cover positions with snakes of same 'colour'

Imagine a grid where the origin square $(0,0)$ is at the top left of the screen, and positive $x$ is rightwards whereas positive $y$ is downwards. Coloured squares are at various positions on ...
947 views

### What is the Subspace Dimension?

Challenge Given the Cartesian coordinates of two or more distinct points in Euclidean n-space ($\mathbb{R}^n$), output the minimum dimension of a flat (affine) subspace that contains those points, ...
2k 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 ...
263 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. ...
171 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 ...
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 ...
660 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 ...
301 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): ...
672 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) ...
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 ...
440 views

6k 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

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

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

### Reorder a matrix, twice

You are given a square $n \times n$ matrix $A$, and a list (or vector) $u$ of length $n$ containing the numbers $1$ through $n$ (or $0$ through $n-1$). Your task is to reorder the ...
314 views

### Decompose Commutators

A theorem in this paper1 states that every integral n-by-n matrix M over the integers with trace M = 0 is a commutator, that means there are two integral matrices A,B of the same size as M such that M ...
1k views

### An array battle with odd secret powers

Here is a relatively simple two dimensional array challenge. Imagine a battlefield of 625 foot soldiers. You command the odd troops, but unfortunately the strength of the even troops overwhelms you. ...
1k views

### Subtract the Folded Matrix

Challenge: Given an NxN matrix where $N\geq2$ and one of eight distinct 'folding options', output a 2D array/list with the subtracted values. The eight folding options are: left-to-right; right-to-...
2k views

### Overlapping String-Blocks

Challenge: Given a list of multi-line strings, overlap them (in the top-left) and output the result. Example: Input: ["aaaa\naaaa\naaaa\naaaa","bb\nbb\nbb","c"] ...
2k views

### Make all the squares explode

You are given a square matrix of width $\ge2$, containing square numbers $\ge1$. Your task is to make all square numbers 'explode' until all of them have disappeared. You must print or return the ...
4k views

### Binary Numbers Magic Trick

The challenge is simply; output the following six 2D integer arrays: ...
1k views

### Slither Like a Snake

The Idea We've done matrix spirals before, and full rotations, and even diagonal rotations, but not, as far as I can find, snake rotations! What is a snake rotation? Imagine the rows of a matrix ...
2k views

### Is this Pascal's Matrix?

In Pascal's triangle each number is the sum of the two numbers directly above it, treating empty spots as zero: By rotating the triangle, we can cut out square matrices of varying sizes and rotations ...
574 views

### Black Hole challenge from codewars

I came across this challenge from codewars. I wish to know how to solve this problem. The problem description is given below. Its elements are in range[1..n^2]. The matrix is filled by rings, from the ...
362 views

### Can this container hold this much liquid?

Can this container hold this much liquid? Challenge Synopsis As you most likely know, liquids have an indefinite shape and a definite volume. As such, they always take the shape of their container. ...
2k views

### Exploding Numbers

sandbox (deleted) Lets define a matrix of 9s as: $$N = \begin{bmatrix} 9&9&9\\9&9&9\\9&9&9 \end{bmatrix}$$ Lets define an exploding number as a number at position $(x,y)$...
442 views

### Cell phone Charge

Challenge Taken with permission from my University Code Challenge Contest The dependence we have on mobile phones makes us charge them every night up to the maximum level of the battery, so we do not ...
2k views

### Borderless table

In this challenge you are going to place letters from the alphabet in a Cartesian plane and output the result as a text. Your input will consist in a list of list with 3 parameters: X coordinate Y ...
1k views

### Spot all (anti)diagonals with duplicated values

Challenge: Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers. So if we have a matrix like this: ...
786 views

### Binary self-rotation

Given a binary 3D array, for each layer, cyclically rotate up each of its columns as many steps as indicated by the binary encoding of the columns of the layer above it, and then cyclically rotate ...
441 views

### Matrix rotation sort

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Lets define 4 matrix moves as: ↑* (up): Moves a ...
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....
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 ...