Questions tagged [grid]

For challenges involving a grid.

Filter by
Sorted by
Tagged with
10
votes
1answer
264 views

The autopilot mode

A helicopter starting at the top left corner is descending (in a 2D space, for the purpose of this question) towards the ground. It has an autopilot mode and a manual mode. The autopilot mode behaves ...
32
votes
6answers
2k views

Tic-tac-toe with only crosses

Introduction Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only going to use crosses. The first person who places three crosses in a row ...
7
votes
6answers
2k views

A 4x4 Challenge

There exists a brain game called Enumerate (which I made, based on Takuzu). Your challenge is to play this game. Task Solve a game of 4x4 Enumerate/Takuzu. Receive a starting grid via STDIN or ...
16
votes
1answer
341 views

Can I live here?

In the game Terraria, one of the game mechanics involves building houses so that an NPC can move in. There is a strict set of rules for what counts as a valid house or not. Here is the list of rules: ...
23
votes
25answers
2k 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: ...
32
votes
5answers
2k views

Chain reaction of bombs

Introduction: Before the task, here is what every element does on the map: Plain land (X): This does nothing. Destroyed land (...
27
votes
4answers
713 views

Find my word(s)!

The idea of this challenge is to find all the words from a dictionary on a grid of letters. Your input should come from stdin or function arg and will come in the following format: ...
26
votes
8answers
2k views

Fill the rows, columns, and diagonals of an NxN grid with 1 through N

Task Given input N, generate and output an NxN grid where each row, column and the two diagonals contain the numbers 1 to N (or 0 to ...
17
votes
4answers
381 views

Flip the switches

After you wake in a dark room, you see a rectangular grid of lights with corresponding switches. You decide to use a coordinate system with the bottom left light representing (1,1) and the coordinates ...
4
votes
0answers
213 views

Finding the smallest grid of squares [closed]

Inspiration from Puzzling.SE. Suppose we have an m × n grid such that each element is a base 10 digit. We can read the numbers from such a grid so that we fix a starting element, go to one of the ...
24
votes
8answers
747 views

The alphanumeric spiral

The task is very simple, when given an input, output one of the following spirals: Input = 1 gives a spiral with the letter A ...
10
votes
2answers
341 views

Crack the safe!

Inspired by https://puzzling.stackexchange.com/questions/24334/to-catch-a-thief You are given an n by n (...
25
votes
5answers
875 views

Parse a two-dimensional syntax

Background Alice and Bob are creating a golfing language to win every single PPCG challenge. Alice wants to make a two-dimensional language, like ><>, but Bob prefers a prefix-infix syntax like in ...
21
votes
3answers
621 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 ...
13
votes
2answers
496 views

Does the fishy road have an end?

I love ><>, ><> is life! 2D langages are amazing! In this challenge, you will have to say if a "fishy" road has an end, while code-golfing. Definition A fishy road is constructed with tiles, ...
13
votes
0answers
543 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 ...
14
votes
25answers
2k views

Number of pieces on a checkers board

Introduction A normal checkers board contains 8 x 8 = 64 squares: You can see that in total, there are 12 white pieces. Black and white always have the same amount of pieces. If there are any more ...
29
votes
24answers
1k views

Very Simple Grid Marks

Write a program or function that takes in three positive integers, W, H, and N. Print or return a W×H grid of .'s where every Nth ...
24
votes
1answer
378 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<> (...
34
votes
5answers
2k 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 ...
7
votes
1answer
275 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
188 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
816 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
653 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
603 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
731 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
417 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
169 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 ...
32
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
512 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
534 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 ...
49
votes
3answers
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
419 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 ...
18
votes
12answers
715 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
974 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
784 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 ...
43
votes
1answer
7k 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
417 views

Permutations of the Fifteen Puzzle

The Challenge Consider the following diagram of the Fifteen Puzzle in its solved state: ...
42
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
220 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-...