Questions tagged [grid]

For challenges involving a grid.

Filter by
Sorted by
Tagged with
23 votes
30 answers
3k views

Produce an XOR table

Introduction XOR is a digital logic gate that implements an exclusive or. Most of the times, this is shown as ^. The four possible outcomes in binary: ...
Adnan's user avatar
  • 44.4k
23 votes
6 answers
3k views

Play the Fruit Box Game

Play the Fruit Box Game Intro Fruit Box is a game consisting of a 10x17 grid of numbers, each between 1 and 9, where the goal is to clear as many numbers as possible in a two-minute time window. In ...
Theo's user avatar
  • 509
23 votes
11 answers
1k views

Counting unit squares circle passes through

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a ...
orlp's user avatar
  • 39.1k
23 votes
2 answers
607 views

Roguelike pathfinding

Roguelike pathfinding Your task will be, given a two-dimensional array of the elements described below, which represents a dungeon, to output or return a single number representing the amount of gold ...
Michail's user avatar
  • 331
23 votes
2 answers
700 views

Plumbing Random Paths

Write a program or function that takes in three integers, a width w, a height h, and a step count ...
Calvin's Hobbies's user avatar
23 votes
2 answers
578 views

Water held in a hexagonal rod scuplture

I have bunch of hexagonal rods glued together into an odd sculpture. The rods are 1 to 99 centimetres (cm) long and 1 square cm in cross-section area. All rods are glued on a hexagonal face to at ...
Logic Knight's user avatar
  • 6,772
22 votes
26 answers
2k views

Delannoy numbers

Consider a grid from \$(0,0)\$ in the bottom-left corner to \$(m,n)\$ in the top-right corner. You begin at \$(0,0)\$, and can only move in one of these three ways: Directly north \$(+0, +1)\$, ...
caird coinheringaahin g's user avatar
22 votes
10 answers
1k views

Traverse a rectangle's antidiagonals

There exists a bijection between the natural and rational numbers that works (approximately) like this: You create a 1-indexed 2-dimensional grid. In every field of this grid with position ...
leo848's user avatar
  • 637
22 votes
10 answers
1k views

Grid-Routing Battle

NOTE: This challenge is currently dead, as I'm unable to install the languages needed to run a match. If someone else has the time and interest to do it, I'm not opposed. See the bottom of the post ...
Zgarb's user avatar
  • 42.6k
22 votes
6 answers
1k views

><> Out of Water

The beloved fish who swims through the code of ><> (an esoteric programming language) has been taken out of its natural environment. This change has rendered it incapable of moving around in the ...
cole's user avatar
  • 3,996
22 votes
9 answers
4k views

Determine if a move exists in a Bejeweled/match 3 game

Background In Bejeweled and similar games, the player must swap any two adjacent gems (no diagonals) in an 8x8 grid of gems in order to match three of the same color in a row. The gems can be matched ...
bdr9's user avatar
  • 323
22 votes
8 answers
1k views

Alice's First Code Review

Alice is an intern in a company that uses Brainfuck as a primary language for both client-side and server-side development. Alice just has written her first code and she's a bit nervous as she's ...
Daniil Tutubalin's user avatar
22 votes
10 answers
2k views

Finding Lonely Primes

Lonely primes (as I call them) are primes, where given a number grid with width w ≥ 3, are primes which do not have any other primes adjacent to them orthogonally ...
Okx's user avatar
  • 16.4k
22 votes
2 answers
589 views

Partition a square grid into parts of equal area

This challenge is based on the following puzzle: You are given an n by n grid with n cells ...
Peter Kagey's user avatar
  • 8,679
22 votes
6 answers
744 views

Find the longest snake on a grid

Background A snake is a path over the cells of a square grid, such that it doesn't touch itself on a side of a unit square. Touching at a corner is allowed. An example snake: ...
Bubbler's user avatar
  • 76k
22 votes
3 answers
1k views

Solve an Ice Maze

Ice mazes have been one of my favorite staples of Pokémon games since their debut in Pokémon Gold and Silver. Your task will be to make a program that solves these types of problems. Ice mazes ...
Wheat Wizard's user avatar
  • 98.5k
22 votes
3 answers
975 views

Follow the dots

The Challenge Given a rectangular grid of characters A B C D E F G H I J K L M N O P Q R S T and a grid with the same dimensions of dots and spaces . . . . . . . . . . . Output ...
Denker's user avatar
  • 6,841
21 votes
10 answers
2k views

Elevator sequence

Totally not inspired by Lyxal repeatedly mentioning elevators in chat :P Challenge In short: simulate some people filling up an elevator and then leaving it. The elevator is simplified as a grid, ...
Bubbler's user avatar
  • 76k
21 votes
7 answers
2k views

Cover a Region with Rectangles

Input Your input in this challenge is a list of integer pairs. They represent the southwest corners of unit squares on the plane, and the list represents their union as a subset of the plane. For ...
Zgarb's user avatar
  • 42.6k
21 votes
13 answers
1k views

Walk home one step at a time

You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of: Walk one step in the current facing ...
xnor's user avatar
  • 145k
21 votes
9 answers
2k views

Rectangle Detection

Write a program or function that takes in a multiline string of 0's and 1's. No other characters will be in the string and the ...
Calvin's Hobbies's user avatar
21 votes
10 answers
832 views

Decrypt the extended Wechsler format

This challenge is based on a sandbox post by user48538. Since he is no longer active on this site, I took over this challenge. apgsearch, the distributed soup search program for Conway's Game of Life ...
alephalpha's user avatar
21 votes
3 answers
663 views

How varied is my obstacle course?

Background I have constructed a simple obstacle course by placing boxes in a rectangular room. Now I want to count the number of essentially different ways in which it can be solved. I need you to ...
Zgarb's user avatar
  • 42.6k
21 votes
1 answer
936 views

How should I tile my kitchen?

I recently ordered some new and colorful tiles to replace my boring old white tiling for my kitchen. However, when the tiles arrived, they were all in a weird shape! Therefore, I need a program to ...
Nathan Merrill's user avatar
21 votes
4 answers
2k views

Count Mills in Nine Men's Morris

Introduction Nine Mens's Morris (also called Mills) is a board game for two players which is played on the following board (image taken from the linked Wikipedia-page): Each player has 9 men, colored ...
Denker's user avatar
  • 6,841
21 votes
3 answers
675 views

Selectively murder positive integers

Introduction Arithmetic Gaol is a special facility that incarcerates positive integers. However, recently, the positive integers have been trying to escape. Therefore the wardens have decided to, um, ...
absinthe's user avatar
  • 8,639
21 votes
4 answers
495 views

Rectangular difference

In this challenge, you are given two overlapping rectangles, and you need to calculate the rectangles created by removing one from the other. For example, if you remove the red rectangle from the ...
Nathan Merrill's user avatar
20 votes
9 answers
2k views

Partitioning the grid into triangles

Goal The goal of this challenge is to produce a function of n which computes the number of ways to partition the n X 1 grid into ...
Peter Kagey's user avatar
  • 8,679
20 votes
7 answers
3k views

The smallest area of a convex grid polygon

I got an email from Hugo Pfoertner, an Editor-in-Chief at the On-Line Encyclopedia of Integer Sequences, with a terrific idea for a fastest-code challenge, which will also help verify or expand the ...
Peter Kagey's user avatar
  • 8,679
20 votes
8 answers
955 views

Cycles on the torus

Challenge This challenge will have you write a program that takes in two integers n and m and outputs the number non-...
Peter Kagey's user avatar
  • 8,679
20 votes
2 answers
1k views

Wait, which tetromino was that?

Background Tetris is a single-player game played on a rectangular grid with tetromino pieces. When you fill one or more lines with tetrominoes, the filled lines are removed, and all blocks above them ...
Bubbler's user avatar
  • 76k
20 votes
6 answers
844 views

The Caged Circles

This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$. Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\...
Peter Kagey's user avatar
  • 8,679
20 votes
4 answers
710 views

Plant trees in a park - As fast as you can!

This challenge is inspired by this app. The test cases are borrowed from that app. This is a fastest-code challenge, where the objective is to solve the largest test cases in the least amount of time....
Stewie Griffin's user avatar
20 votes
2 answers
382 views

Exactly N in a line

Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal. This ...
xnor's user avatar
  • 145k
20 votes
1 answer
933 views

Determine winner of Connect 4

You are given a partially filled Connect 4 grid (7x6). O X O X X O X O O X O X O X X O X X X O O X O O O X X O X (Input can be given ...
ghosts_in_the_code's user avatar
20 votes
1 answer
424 views

Complete the grid-filling meander

A grid-filling meander is a closed path that visits every cell of a square \$N \times N\$ grid at least once, never crossing any edge between adjacent cells more than once and never crossing itself. ...
Jordan's user avatar
  • 10.1k
20 votes
2 answers
386 views

Transpose a word cloud

Background I wanted to make a pretty word cloud, like this: these are words floating I computed the (x,y)-...
Zgarb's user avatar
  • 42.6k
20 votes
2 answers
1k views

Worst Case Manhattan Exclusion

Imagine a W by H grid of squares that wraps toroidally. Items are placed onto the grid as follows. The first item can be placed on any square, but subsequent items must not be within a Manhattan ...
trichoplax is on Codidact now's user avatar
20 votes
2 answers
452 views

Where'd that germ go?

Introduction You are a biologist studying the movement patterns of bacteria. Your research team has a bunch of them in a petri dish, and you are recording their activity. Unfortunately, you are ...
Zgarb's user avatar
  • 42.6k
20 votes
1 answer
529 views

Can I wall glitch to there?

Background In a 2d game that I play, each screen is a 2d grid of tiles with walls and walkable tiles, with the player only able to travel on walkable tiles, and being stopped by walls. When the player ...
Aiden Chow's user avatar
  • 13.3k
19 votes
34 answers
3k views

Generate boxes!

Your task is to generate boxes using any one ASCII character with respect to the inputs given. Test Cases ...
Spikatrix's user avatar
  • 1,875
19 votes
23 answers
3k views

Grid ASCII art code golf

Challenge Create the shortest program that meets the requirements Requirements The code must generate a 5x5 grid of 0s, like so: 00000 00000 00000 00000 00000 ...
Dave Jones's user avatar
19 votes
14 answers
2k views

The Area of Rectangles

Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally ...
Wheat Wizard's user avatar
  • 98.5k
19 votes
8 answers
4k views

How Many Holes?

Challenge Given a graphical input of a shape, determine how many holes there are in it. Not Duplicate This question was marked as a possible duplicate of Count Islands. I believe this challenge is ...
hyper-neutrino's user avatar
  • 42.4k
19 votes
3 answers
1k views

Stringing a Pearl Necklace

Overview Pearls (or Masyu) is a logic game played on a grid. There are black and white pearls placed on the grid. The object is to form a single, closed loop that travels through each pearl using only ...
Geobits's user avatar
  • 19.7k
19 votes
4 answers
585 views

Minimal Word Search

Last week, we worked to create the shortest 1-D string using the top 10,000 words in the English language. Now, lets try the same challenge in 2D! What you need to do is to take all of the above ...
Nathan Merrill's user avatar
19 votes
3 answers
2k views

Crossing a river with weird animals

Background One kind of river-crossing problems involves two kinds of animals. One such problem reads like this: (all wordings, including animal species, are arbitrary) A farmer has to cross a river ...
Bubbler's user avatar
  • 76k
19 votes
1 answer
752 views

Seeking Leapers

I recently got a really weird irregular chess board. It's squares are all over the place and not even all connected. At least they're still laid out on a regular grid. I want to adapt the chess rules ...
Martin Ender's user avatar
19 votes
2 answers
337 views

Island Golf #2: The Eccentric Hermits

This is the second in a series of Island Golf challenges. Previous challenge Two hermits have arrived on a desert island. Since they came seeking solitude, they wish to live as far away from each ...
DLosc's user avatar
  • 39.4k
19 votes
2 answers
693 views

Chain words crossword-style

The challenge Given a list of words ["Programming", "Puzzles", "Code", "Golf"] output the words crossword-style: P r o g r a m m i n g u z ...
Denker's user avatar
  • 6,841

1 2
3
4 5
8