Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [grid]

For challenges involving a grid.

24
votes
1answer
332 views

Loop Detection - not that kind!

The goal of this challenge is to find the direction and area enclosed by a loop. Input: A rectangular grid consisting entirely of these characters: ^v<> (...
33
votes
5answers
1k views

Gravity simulator

Statement You are given a still of a series of balls falling in a 2D grid. This grid is surrounded by immutable and unbreakable walls so all the action in contained within them. Your task is to ...
6
votes
1answer
270 views

Fill in the path

Write a program that fills in the paths of a grid of characters (ASCII 20-7E) according to the following rules. The path is governed by eight directional characters: ...
1
vote
3answers
187 views

Layout my tiles for me

I'm retiling my kitchen with different coloured tiles. In fact, it's going to have at least 2 colours - and 26 colours as a maximum. But, I'm fussy. I want this wall to look random, but sometimes ...
19
votes
1answer
775 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 ...
16
votes
7answers
1k views

Print a Pentomino Rectangle

Write a program or function that takes no input but prints or returns a constant textual depiction of a rectangle made of the 12 distinct pentominoes: The rectangle may have any dimensions and be in ...
25
votes
3answers
630 views

Find the largest N digit number in a W by H grid of digits

Write a program or function that takes in a positive integer N and a grid of decimal digits (0 to 9) with width W and height H (which are also positive integers). You can assume that N will be less ...
23
votes
2answers
573 views

Plumbing Random Paths

Write a program or function that takes in three integers, a width w, a height h, and a step count ...
26
votes
5answers
708 views

The Traveling O

The world is a five by five array of cells. It wraps on all sides. It can be visualized like... XXXXX XXXXX XXOXX XXXXX XXXXX You are an O. You love to travel the world, and you do so according to ...
21
votes
2answers
396 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 ...
2
votes
0answers
149 views

Coloring the switchboard red [closed]

Question If you are currently on a cell with a value x, you can move to any cell in the same row or column, provided it has a value y such that x > y. This move is called a switch. The input ...
24
votes
9answers
2k views

Print all 3 by 3 sturdy squares

A sturdy square (akin to a magic square) is an arrangement of the integers 1 to N2 on an N by N grid such that every 2 by 2 subgrid has the same sum. For example, for N = 3 one sturdy square is <...
28
votes
15answers
2k views

Illustrate the square of a binomial

Given (by any means) two different natural numbers (of any reasonable size), output (by any means) the square of their sum as in the examples below: Given 4 and 3, output: ...
38
votes
8answers
2k views

Can I Slide Apart The Puzzle?

Write a program or function that takes in a rectangular grid of text where every cell is either an A or a B. All the ...
36
votes
1answer
1k views

“Fill the Grid” Problem

A challenge with simple rules but non-trivial algorithms. :-) Task Take input in the form of space-separated integers: N A B S Where N is the side length of a ...
31
votes
4answers
3k views

Invert a Minesweeper Board

Minesweeper is a popular computer game that you have probably wasted time playing where you try to reveal the cells that are mines in a rectangular grid based on hints of how many neighboring mines ...
27
votes
3answers
479 views

Filling Arbitrary Ice Cube Trays

Suppose this grid of spaces and X's represents the cross section of some strangely shaped empty ice cube trays: ...
16
votes
1answer
481 views

Cut a pizza into identical slices

This is what I thought this question was going to be, before I fully read it. A group of code golfers walk into The Nineteenth Bite Pizzeria and order a pizza. It comes in an irregular shape, made of ...
42
votes
8answers
2k views

Dennis, Doorknob, Martin Büttner, Chris Jester-Young - Pizzeria!

Programming Puzzles & Code Golf is about to get a new moderator, Dennis! This challenge is a tribute to him and our other active (or recently active) moderators: Doorknob, Martin Büttner, and ...
45
votes
2answers
3k views

Shortest universal maze exit string

A maze on an N by N grid of square cells is defined by specifying whether each edge is a wall or not a wall. All outer edges are walls. One cell is defined as the start, and one cell is defined as the ...
40
votes
8answers
6k views

40 Numbers in 9 Bytes

There are 40 ways a directed Hamiltonian path can be arranged on a 3×3 grid: This graphic (thanks Sp3000!) shows only the 20 undirected paths. Traverse each colored line in both directions for ...
30
votes
9answers
2k views

Uniquely separated pixels

For an N by N image, find a set of pixels such that no separation distance is present more than once. That is, if two pixels are separated by a distance d, then they are the only two pixels that are ...
14
votes
3answers
388 views

Highest perimeter polyomino

This is code golf. The winner is the valid code with the smallest number of bytes. Challenge Given inputs M and N, the width and height of a rectangular grid of squares, output a polygon that ...
17
votes
11answers
669 views

Grid crossing sequence

If you take a sheet of graph paper and draw a sloped line that goes m units right and n units up, you cross ...
19
votes
34answers
3k views

Generate boxes!

Your task is to generate boxes using any one ASCII character with respect to the inputs given. Test Cases ...
20
votes
2answers
949 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 ...
21
votes
34answers
2k views

Print all colorings of a 3x3 grid

You have a 3x3 grid. Each cell can be colored black or white. Display all 512 of these colorings. Fewest bytes wins. You can display the grids in any formation as long as they are visually separated ...
10
votes
5answers
758 views

Count the crossing words

Consider the following standard 15×15 crossword puzzle grid. We can represent this in ASCII art by using # for blocks and ...
42
votes
1answer
6k views

Rearranging Words

You should write a program which receives two strings as input and outputs a sequence of movements which rearrange the first string into the second. You should use as few moves as you can. Both ...
13
votes
5answers
405 views

Permutations of the Fifteen Puzzle

The Challenge Consider the following diagram of the Fifteen Puzzle in its solved state: ...
41
votes
5answers
3k views

Block Building Bot Flocks!

The contest is over! Intro This is an interactive king-of-the-hill contest where the controller is fully contained in a Stack Snippet at the bottom of the question. The controller automatically ...
11
votes
1answer
218 views

Find the Fenceposts

Background An atomic bomb has exploded near the fencepost factory! Since fenceposts are essential for the survival of our civilization, we must rescue as many as possible. We are sending radiation-...
21
votes
3answers
626 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, ...
11
votes
2answers
415 views

Finding Poly Nemo!

Oh no! Nemo, our small clown fish is lost in this ASCII ocean and his dad Marlin is trying to find him. Your task is to get Marlin to Nemo safely. But beware, we have a feeding frenzy Bruce on the ...
10
votes
1answer
228 views

Simplest Tiling of the Floor

You should write a program or function which receives a string describing the floor as input and outputs or returns the area of the simplest meta-tiling which could create the given pattern of the ...
6
votes
1answer
224 views

Finding Pairs for Letters

You should write a program or function which given a string as input outputs or returns a string or list of the lowercase letters in the order they find their uppercase pair. The input is a string ...
18
votes
3answers
990 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 ...
14
votes
7answers
1k views

Tiling a 2^N by 2^N Grid with L-Shaped Trominoes

When students are first taught about the proof technique of mathematical induction, a common example is the problem of tiling a 2N×2N grid with L-shaped trominoes, leaving one predetermined grid ...
10
votes
1answer
373 views

Slime Molds Can Count!

Background Slime molds are awesome. If you place them on a surface with food sources, they will spread their tendrils to find the food, after which they form a network of connections between the ...
15
votes
2answers
632 views

Programs to build a rat maze

You have been hired as a research assistant, and asked to create a small program that will build rat mazes. The rat box is always 62x22 and has an entrance (a) and exit (A) for the rat, like this (...
129
votes
22answers
10k views

Red vs. Blue - Pixel Team Battlebots

This contest is officially over. The Blue Team won! I autoran two sets of 50 battles and amazingly, Blue won all 100 of them. Looking at the stats, it is clear that the cooperative entries of ...
13
votes
2answers
388 views

Find a mirror configuration to match laser destinations

UPDATED SCORING: As this challenge is more difficult than I anticipated, I have adjusted the scoring. A program that can solve a single mirror input is a valid answer. More sophisticated programs get ...
14
votes
4answers
1k views

Draw a Random Walk with Slashes

Write a program or function that takes in a positive integer N (via stdin/command line/function arg) and prints or returns a string representation of a two dimensional random walk that is N steps long,...
35
votes
4answers
3k views

Infinite Labyrinths

Background You are the apprentice of a powerful wizard, and your master is currently developing a spell for creating an inter-dimensional labyrinth to trap his enemies in. He wants you to program his ...
6
votes
1answer
409 views

Evening Commute Solver

I recently moved to an apartment overlooking the inner ring-road of town, and every day, a beautiful scene unfolds. The traffic lights are apparently so confusing (mostly because the Dutch are used to ...
15
votes
2answers
857 views

How do I get more Klotski in my life?

I really love sliding tile puzzles, but recently, I haven't had time for them. Hence, I need a program to give me my fix of sliding-tile puzzles, specifically Klotski puzzles. Your input will be in ...
17
votes
2answers
850 views

Help our robots reach the teleporter

UPDATE: Added a Python framework to get started. The space-station has been overtaken by crusher-bots. You must direct as many of our expensive and fragile tech-bots called "rabbits" to an exit ...
15
votes
8answers
1k views

Discrete Baker's Map

Introduction The Baker's map is an important dynamical system that exhibits chaotic behavior. It is a function from the unit square to itself defined intuitively as follows. Cut the square ...
33
votes
6answers
1k views

Grid Based Digital Logic (Duodyadic Tiles)

Duodyadic tiles are kinds of square function blocks that take two inputs, one from their top side and one from their left side, and have two outputs, one on their right side and one on their bottom ...
11
votes
1answer
627 views

Constructing an Orthogonal-Diagonal Greco-Latin Square

Consider a grid of NxN unique elements. Each element has a letter (from A to the Nth letter,...