Questions tagged [binary-matrix]

Indicates that the challenge involves the manipulation of binary matrices, matrices whose elements are all one of two possible values, typically 1 and 0, or True and False.

Filter by
Sorted by
Tagged with
18 votes
6 answers
2k views

Matrix Meets ASCII Art

A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is 0. For example, the array ...
user avatar
15 votes
7 answers
1k views

Euler characteristic of a binary matrix

A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is <...
user avatar
  • 32.7k
19 votes
7 answers
1k views

Expand a matrix goo-ily

Input An \$m\$ by \$n\$ binary matrix, with \$m\$ and \$n\$ both at least 2. Think of the ones as gobs of melted cheese, which stretch as we expand the matrix horizontally and vertically. More ...
user avatar
  • 26.5k
6 votes
2 answers
355 views

Reveal all clues of Black Box

Black Box is a board game, Your task is to reveal all clues. What is black box Black box is a board game with hidden atoms, Your task is given input, All atoms, reveal all clues. I/O Input The atoms ...
user avatar
  • 2,493
22 votes
6 answers
754 views

Check if a matrix is Zarankiewicz-maximal

My final-year project at the National University of Singapore is on Zarankiewicz's problem: What is the maximum number of 1s in an \$m×n\$ binary matrix (\$m\$ rows and \$n\$ columns) with no \$a×b\$ ...
user avatar
18 votes
17 answers
1k views

Generate a regular graph

Inspired by this Mathematica.SE post Given two positive integers \$n, k\$ with \$n > k \ge 1\$, output a binary \$n\times n\$ matrix such that every row and column contains exactly \$k\$ 1s, and ...
user avatar
12 votes
9 answers
1k views

AoCG2021 Day 13: Defrag in action!

Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 14. To recap: The disk is a rectangular grid with \$r\$ rows and \$c\$ columns. Each ...
user avatar
  • 62.1k
19 votes
13 answers
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 ...
user avatar
  • 99.3k
9 votes
9 answers
845 views

Neural Processing Lattice Checker

Consider the following 9 "row patterns", using 0s to represent empty cells and 1s to represent a full cell. Each pattern is associated with an integer \$n\$, such that \$0 \le n \le 8\$ (...
user avatar
  • 12.7k
9 votes
3 answers
309 views

How many dominoes can you fit here?

Much harder than Can this pattern be made with dominoes? Challenge A grid of width \$w\$ and height \$h\$ is given, filled with 1s and 0s. You can place a domino somewhere on the grid only if both ...
user avatar
  • 62.1k
7 votes
6 answers
514 views

Group binary shapes together

Consider the following binary matrix: $$\begin{matrix} 1 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 1 \end{matrix}$$ The (1-indexed) co-ordinates of the \$1\$s here are \$(1,1), (1,3), (2,...
user avatar
12 votes
11 answers
1k views

Peter is Puzzled!

As some of you may remember, Peter, who was a picky eater is now puzzled Peter. This time Peter got some puzzles as a present from his Aunt. He has tried a lot, but has failed to solve the puzzles. ...
user avatar
18 votes
11 answers
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 ...
user avatar
  • 3,595
9 votes
4 answers
295 views

Venn of \$n\$ statements

Given a positive integer \$n\$, output \$n\$ 2D bool images with the same width and height such that: Each image should be 4-connected, i.e. for each two pixels that are true, you can start from one ...
user avatar
  • 12.7k
33 votes
25 answers
4k views

Is there a single straight line in the matrix?

Inspired by Wzl Determine if a given square binary matrix has exactly one row or column consisting of entirely 1s, and the rest of the matrix is ...
user avatar
19 votes
16 answers
2k views

Is there a left-right connection?

Task Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, ...
user avatar
  • 541
11 votes
1 answer
283 views

Count all my sheep

Sandbox Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep. A sheep is a single independent unbroken line of sheep length \...
user avatar
  • 25.1k
17 votes
7 answers
2k views

But, Is It Art?

But Is It Art? is an esolang created by ais523, where one step is break the program into orthogonally connected "tiles": A BBBB A B B AA CC A CC Each ...
user avatar
25 votes
19 answers
1k views

Just Enough Ones

Challenge Given a positive integer \$n\$, count the number of \$n\times n\$ binary matrices (i.e. whose entries are \$0\$ or \$1\$) with exactly two \$1\$'s in each rows and two \$1\$'s in each column....
user avatar
  • 6,216
25 votes
14 answers
4k views

Is this an L-shape?

Background An L-shape is defined as a polyomino which can be made by extending two rectangular legs in orthogonal directions from a full square (called a pivot). The size of the square should be at ...
user avatar
  • 62.1k
16 votes
18 answers
3k views

Calculate COVID spread

Because the coronavirus is still at large, I thought it would be fitting to have a epidemic-themed challenge. Challenge You are given a 2D array of people, where 1 ...
user avatar
18 votes
6 answers
428 views

Secret ">" Stacking Challenge: grading

Background Tetris Grand Master 3 has a hidden grading system based on the shape of the stack at the end of the game, which is called Secret ">" Stacking Challenge. It consists of entirely ...
user avatar
  • 62.1k
24 votes
9 answers
875 views

Maintain diagonal symmetry when placing N items on a square grid

Write a program that takes in two non-negative integers S and N in that order. S represents the side length of a square grid of . characters. N represents the ...
user avatar
25 votes
14 answers
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 ...
user avatar
  • 9,426
32 votes
6 answers
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 ...
user avatar
  • 14.5k
9 votes
3 answers
368 views

Identical grids

You’re given two \$r×c\$ grids. Each cell contains either 0 or 1. What are the minimum number of swaps (between horizontally and vertically adjacent cell elements, no wrapping i.e no swapping between ...
user avatar
  • 221
32 votes
18 answers
7k views

To find islands of 1 and 0 in matrix

Given a two dimensional matrix of 0 and 1s. Find the number of island for 1s and 0s where neighbours are only in the horizontal and vertical. ...
user avatar
  • 329
40 votes
4 answers
2k views

Dungeon Crawler

Input A binary matrix \$M\$ representing the walls of a dungeon. The position \$(x,y)\$ of the player within the dungeon. The direction \$d\$ that the player is currently facing (0 = North, 1 = East, ...
user avatar
  • 166k
13 votes
16 answers
2k views

Trim that distracting background off!

Isn't it annoying when you're taking a picture, but the background detracts from the actual substance of the image? I'd say it is. I need to know how much I should crop so that I get rid of this ...
user avatar
  • 41.4k
8 votes
15 answers
1k views

Scoring 6,5,4 (AKA Ship, Captain, and Crew)

Inspired and looted from this dice challenge by Arnauld Input You are given a 5x1 or 1x5 (your choice) dice matrix which consist of binary 3x3 sub-matrices. Goal Given a valid dice matrix, you are ...
user avatar
  • 4,002
21 votes
8 answers
2k views

Belarus rushnyk

We've got quite a few national flag challenges already: AU CH FI FR GB GB IS KR NP US... Here's another, somewhat more advanced one: Return or print the decorative pattern from Belarus's national ...
user avatar
  • 14.5k
22 votes
10 answers
2k views

How much is my dice matrix worth?

Input A non-empty binary matrix consisting of 3x3 sub-matrices put side by side. Task Your task is to identify valid dice patterns (as described below) among the 3x3 sub-matrices. Each valid ...
user avatar
  • 166k
36 votes
7 answers
3k views

Where is that snake going?

Write a function (using as few bytes as possible) that takes a bi-dimensional array of any number of columns and rows in which: 0 represents empty block, ...
user avatar
  • 403
26 votes
8 answers
2k views

Mutually Attacking Queens

Let an 8x8 chessboard be represented by any two distinct values, with one value being an empty square and the other being a queen. In the following examples, I use 0s as the empty squares and 1s as ...
user avatar
  • 879
10 votes
2 answers
415 views

The Lonely Islands

Input: A 2D array containing two distinct (optional) values. I'll use 0 and 1 when explaining the rules. The input format is of course flexible. Challenge: Zeros are water, and ones are islands. In ...
user avatar
13 votes
7 answers
456 views

Cutpoints in a maze

A maze is given as a matrix of 0s (walls) and 1s (walkable space) in any convenient format. Each cell is considered connected to its 4 (or fewer) orthogonal neighbours. A connected component is a set ...
user avatar
  • 14.5k
19 votes
1 answer
689 views

Advent Challenge 1: Help Santa unlock his present vault!

Next >> Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find Challenge Santa has had a history of elves stealing presents from his vault in the past, so this ...
user avatar
  • 40.1k
23 votes
3 answers
2k views

Decode Faux Braille

...
user avatar
  • 14.5k
13 votes
5 answers
1k views

Is it bipartite?

A bipartite graph is a graph whose vertices can be divided into two disjoint set, such that no edge connects two vertices in the same set. A graph is bipartite if and only if it is 2-colorable. ...
user avatar
  • 2,361
18 votes
5 answers
909 views

Change the rules of Life

Life-like cellular automaton are cellular automaton that are similar to Conway's Game of Life, in that they operate on a (theoretically) infinitely large square grid, where each cell has exactly 8 ...
user avatar
21 votes
13 answers
1k views

The Binary Square Diagonal Sequence

The binary-square-diagonal-sequence is constructed as follows: Take the sequence of positive natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ... Convert each number to ...
user avatar
  • 25k
11 votes
2 answers
479 views

Make a Bit Continent

Let's imagine we have a matrix of bits (which contains at least one 1): ...
user avatar
34 votes
6 answers
3k views

Finding Snakes in a Matrix

Challenge Given a binary matrix and a binary string, determine if that binary string can be found starting at any point in the matrix and moving in any direction at any subsequent point to form the ...
user avatar
  • 40.1k
48 votes
12 answers
3k views

Braille graphics

Cut a boolean matrix in 4x2 blocks and render them as Braille characters U+2800...U+28FF. ...
user avatar
  • 14.5k
13 votes
8 answers
667 views

Minimal taxicab distance map

Challenge description In taxicab metric, a distance between two points is defined as: Consider a matrix with only zeros and ones: ...
user avatar
  • 5,432
54 votes
9 answers
5k views

Which tetromino is this?

Given an unsigned 16-bit integer N, your task is to determine whether its binary representation mapped inside a 4x4 matrix is matching a tetromino shape, and if so, which shape it is. Matrix Each ...
user avatar
  • 166k
22 votes
16 answers
1k views

Weakened Binary Walls

Inspired by Create a binary wall Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example: ...
user avatar
  • 40.1k
10 votes
3 answers
1k views

Binary Puzzle Solver

Introduction Rules of the puzzle: The puzzle Binary (also known as Takuzu or Subiku) is very simple to understand, and has only a few rules: Since the name of the game is binary it's pretty obvious, ...
user avatar
8 votes
4 answers
667 views

Find the rows which make each column have one True (was: Knuth's Algorithm X)

Task Given a Boolean matrix, find one (or optionally more) subset(s) of rows which have exactly one True in each column. You may use any algorithm, but must support very large matrices, like the last ...
user avatar
  • 27.1k
11 votes
3 answers
537 views

Print a specific value in the Wythoff matrix modulo 2

The Wythoff matrix is an infinite matrix consisting of the Grundy numbers of each square on a chessboard in Wythoff's game. Each entry in this matrix is equal to the smallest nonnegative number that ...
user avatar
  • 33.7k