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.

247 questions
Filter by
Sorted by
Tagged with
651 views

Simulate weathering of a rock

Inspired by my geography class, Sandboxed Simulate weathering / erosion. Input Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces ...
667 views

Is it an elementary matrix?

Consider a linear system of equations, in $n$ unknowns, expressed as $$A \textbf x = \textbf b$$ where $A \in M_{n,n}(\mathbb Z)$ is an $n \times n$ matrix of integers, $\textbf x$ is a column ...
2k views

Compute matrix blockiness

Consider a non-empty binary matrix M and a natural number n. For the purposes of this challenge, M is said to have blockiness n if it can be built using adjacent square blocks of size n, where each ...
762 views

Remove submatrices

Given two integer matrices a and b, your challenge is to replace any occurences of b in <...
495 views

Fast Matrix Multiplicator Evaluator

A triplet of real tensors $(A,B,C)$ of size $\gamma \times \gamma \times \sigma$ represents a matrix multiplication algorithm with $\sigma$ elementary multiplications iff the following function ...
2k views

Bird's Algorithm for Computing Determinants

There is a division-free algorithm for computing determinants published by R.S.Bird in 2011 that uses only matrix multiplications. Given a $n×n$ matrix $X$, the matrix $Y=μ(X)$ is another $n×n$...
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

Double trace of a square matrix

Inspired by a question (now closed) at Stack Overflow. Given a square matrix, let its double trace be defined as the sum of the entries from its main diagonal and its anti-diagonal. These are marked ...
1k views

Information Given a non-negative odd integer (let's call it $n$), find the number of all possible paths which covers all squares and get from the start to end on a grid. The grid is of size $n$×$... 15answers 1k views Drop down the numbers This was inspired by Apply gravity to this matrix Your challenge is to input a matrix with non-negative one-digit integers and drop down the 1's down 1 column, the 2's down 2 columns, the 3's down 3 ... 24answers 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. ... 4answers 559 views Calculate the integer square root of a matrix Let$A$be a square matrix that is at least$2 \times 2$where each element is an integer.$A^2 = A \times A$will then have the same dimensions as$A$, and will have integer elements. For ... 7answers 2k views Is this a Jordan matrix? Background A Jordan matrix is a block-diagonal matrix where each block on the diagonal has the structure of  \begin{bmatrix} \lambda & 1 & 0 & \cdots & 0 \\ 0 &... 26answers 2k views Recursive Z-matrix Originally from a CMC I proposed for the last BMG event Challenge Given a non-negative integer$n$, create a 2D array of size$2^n × 2^n$which is generated in the following manner: Divide the ... 9answers 535 views To raise$ e $to the power of a matrix Inspired by this 3Blue1Brown video Given a square matrix$ M $, compute its matrix exponential$ \exp(M) $, which is defined, using an extension of the Maclaurin series for$ e^x $, as  \exp(M)... 11answers 2k views Count my Pluses Your task is, to count how many pluses I have. What Pluses? The no plus: 0 Points - The naïve Plus: 1 Point + The double ... 7answers 1k views Drop some boxes Say I have a pile of boxes: AAA BBB I can create it in two steps: BBB ↓ (empty) --- AAA ↓ BBB But with this: ... 17answers 780 views Square chunk my matrix Your challenge is to write a function/program that takes a matrix of integers m and a number n as input and: Splits m into n by n chunks Replaces each chunk with the most common value in that chunk (... 9answers 2k views Is it a valid Parker Square 5 Years ago, this happened, and then it became sort of a meme. Challenge The Challenge today is, to check if a "magic square" is a valid parker square. What is a Real Magic square? All the ... 43answers 2k views Generate this number table Given an integer$1 < n < 10 $generate a table like below. For$n = 5$, 1 2 3 4 5 2 2 3 4 5 3 3 3 4 5 4 4 4 4 5 5 5 5 5 5 For$n = 8, ... 15answers 748 views Construct a Modulo Multiplication Table Consider a n x n multiplication table and replace each item with its remainder of division by n. For example, here is a ... 21answers 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 ... 2answers 953 views Minecraft piston pushing In Minecraft, pistons are blocks that can move other blocks. However, they can only move at most twelve blocks, and won't work at all if any obsidian is in the way. Also, slime blocks are sticky and ... 44answers 2k views Output a Latin Square Ann\times n$Latin Square is a grid containing exactly$n$distinct values where the values in each row and column are distinct. For example, \begin{matrix} A & B & C \\ C & A &... 4answers 488 views The Game of Cat And Mice | With Matrices Challenge This coding challenge is to figure out how many rounds the cat can live. In a$4\times4$matrix, there are a number of mice and exactly 1 cat. Example:  \begin{array} {|r|r|}\hline 🐭 &... 5answers 731 views Dominate a zero-sum game Consider a zero-sum game with 2 contestants. Each round, each contestant chooses, independently of each other, one of$n \ge 2$different choices. Depending on the two chosen choices, one player is ... 21answers 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 ... 3answers 692 views Validating a Battleship board Do you know the game Battleship? Well, I want to play with my little brother, but before we can begin we need to set up our ships on the board. This is your input. Now, we need to check that the ships ... 10answers 2k views Help Stack Exchange transpose tables Stack Exchange doesn't know how to transpose tables. Let's help. Given a markdown table, transpose it. Input assumptions: There will be at least two rows (including header) and two columns Either all ... 20answers 3k views Calculate the inverse of a matrix Somehow, we don't yet have a challenge for finding the inverse of an arbitrarily-sized square matrix, despite having ones for 3x3 and 4x4, as well as a more complex version. Your task is, given a ... 1answer 235 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 ... 24answers 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 ... 1answer 354 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 ... 14answers 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 ... 1answer 491 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 ... 10answers 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 ... 0answers 194 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 ... 5answers 967 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, ... 21answers 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 ... 3answers 282 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. ... 2answers 189 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 ... 6answers 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 ... 7answers 706 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 ... 1answer 319 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): ... 3answers 697 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 ... 17answers 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) ... 16answers 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 ... 10answers 594 views Decomposition of a matrix in$ SL_2(\mathbb{Z}) $Background The special linear group$ SL_2(\mathbb{Z}) $is a multiplicative group of$ 2 \times 2 $matrices whose elements are integers and determinant is 1. It is known that every member of$...
The permanent of an $n$-by-$n$ matrix $A = (a_{i,j})$ is defined as: $$\operatorname{perm}(A)=\sum_{\sigma\in S_n}\prod_{i=1}^n a_{i,\sigma(i)}$$ For a fixed $n$, consider the $n$-by-$n$ ...
The title pretty much describes it all. Given as input a $n \times m$ matrix and an integer $i$ create a complete function/program that returns the matrix $i$ times clockwise rotated by \\$90^\...