Questions tagged [grid]

For challenges involving a grid.

Filter by
Sorted by
Tagged with
24
votes
20answers
2k views

How many balloons do I need in each corner?

You have a square board with a bunch of items laid out on it in one of a \$3 \times 3\$ grid of cells and you want to lift it up using balloons, but you can only attach balloons to the corners of the ...
19
votes
13answers
963 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 ...
8
votes
0answers
283 views

Morpion solitaire

Morpion solitaire This is a game that I remember having learnt from my grandparents in my childhood. Initially I didn't know the name. G B has found it to be Join Five (or less ambiguously - Morpion ...
14
votes
3answers
264 views

Is this board Latin-style?

Inspired by Flow Fit: Sudoku, a brand-new mobile puzzle game (as of Nov 2019). Background A Latin square is a square grid of side length \$ n \$ filled with \$ n \$ different symbols, where each row ...
3
votes
1answer
365 views

Draw a fuzzy grid

Print the ASCII version of a random grid. ...
16
votes
1answer
373 views

Counting symmetric grid chains

Notation and definitions Let \$[n] = \{1, 2, ..., n\}\$ denote the set of the first \$n\$ positive integers. A polygonal chain is a collection of connected line segments. The corner set of a ...
24
votes
4answers
805 views

Can Jimmy escape the ghosts?

It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy ...
16
votes
5answers
401 views

Is it a Hamiltonian cycle on a grid?

A Hamiltonian path in a graph is a path that visits each vertex exactly once; a Hamiltonian cycle is a Hamiltonian path that is a cycle – the path forms a simple closed loop. In this challenge the ...
17
votes
2answers
622 views

Number of distinct tilings of an n X n square with free n-polyominoes

The newest "nice" OEIS sequence, A328020, was just published a few minutes ago. Number of distinct tilings of an n X n square with free n-polyominoes. This sequence counts tilings up to symmetries ...
5
votes
2answers
273 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 ...
19
votes
1answer
319 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. ...
21
votes
8answers
958 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 ...
6
votes
2answers
420 views

Can the cursor reach the bottom?

In a matrix of characters, a cursor is a movable position between two adjacent characters, before the first character or after the last character in a line, like that "I"-shaped indicator which moves ...
9
votes
2answers
199 views

Reroute the Path

Given a grid of directions and a start and end position, determine the minimum number of substitutions in the direction grid that needs to be made to complete the path between the two points. The grid ...
9
votes
1answer
278 views

Partition and Restructure

Given two contiguous shapes of the same area, determine the optimal way to divide the first shape into a minimum number of contiguous segments such that they can be rearranged to form the second shape....
10
votes
10answers
689 views

Determine if a grid contains another grid

Challenge Create a function takes in two 2-dimensional arrays of Characters (or Strings if the programming language does not have characters as a datatype) as inputs: a and b. If your language does ...
5
votes
1answer
160 views

Words Everywhere

Given a list of words, output a square grid of characters, so that all the words can be read from the grid, by moving horizontally, vertically, or diagonally between characters, without reusing ...
12
votes
5answers
349 views

Terrain Reachability

Turn-based tactics games like Advance Wars, Wargroove, and Fire Emblem are made up of a square grid of varying terrain with units of differing movement classes requiring different costs for each ...
20
votes
8answers
849 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-...
17
votes
10answers
572 views

2-Dimensional Bubble Sort

Sorting makes no sense for a 2-dimensional array... or does it? Your task is to take an input grid and apply a bubble-sort-like algorithm to it until all values in the grid are non-decreasing from ...
48
votes
8answers
3k views

N-movers: How much of the infinite board can I reach?

Single moves The board is an infinite 2 dimensional square grid, like a limitless chess board. A piece with value N (an N-mover) can move to any square that is a distance of exactly the square root ...
30
votes
3answers
1k views

A Turtle Finds a Portal

The turtle wants to move along the grid to get to his food. He wants to know how many moves it will take for him to get there. As well since he is slow he has teleporters set up around his domain ...
11
votes
3answers
270 views

Ambiguous Locations on a Grid

You have a little robot with four distance sensors. It knows the layout of a room, but it has no sense of orientation other than being able to lock onto the grid orientation. You want to be able to ...
17
votes
1answer
317 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 ...
8
votes
1answer
288 views

Count the Closed Polygons

Input: An NxM grid or multi-line string (or other reasonable input-format), containing only printable ASCII (unicode range ...
8
votes
7answers
828 views

Length of the Longest Descent

Your task is to determine the length of the longest descent down a "mountain" represented as a grid of integer heights. A "descent" is any path from a starting cell to orthogonally adjacent cells with ...
3
votes
17answers
375 views

Print coordinates of an NxN grid [duplicate]

Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted Input: N (integer) Output: for N=3, a 3x3 grid: ...
18
votes
9answers
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 ...
10
votes
1answer
292 views

Tatamibari solver

Background Tatamibari is a logic puzzle designed by Nikoli. A Tatamibari puzzle is played on a rectangular grid with three different kinds of symbols in it: +, <...
4
votes
2answers
245 views

Nightmare Puzzlang translator

Background Puzzlang is a derivative of Brainfuck, where the symbol X executes a BF command based on three characters on top of it, and anything else does nothing. ...
25
votes
25answers
5k views

Output a Sudoku board

Today's challenge is simple: Without taking any input, output any valid sudoku board. In case you are unfamiliar with sudoku, Wikipedia describes what a valid board should look like: The objective ...
12
votes
6answers
703 views

Get me out of here

Challenge Given a grid size, obstacles' positions, player position and target position your task is to find a path for the player to get to the target and avoid the obstacles at the same time (if ...
4
votes
0answers
370 views

Textbattles KoTH [closed]

Textbattles Textbattles is is strategy game about, well, text. It consists of a 10x10 grid, where each player has a position on the grid. When it is a player's turn, they can decide whether to move a ...
17
votes
3answers
481 views

Dead Frog Walking

Introduction Jonny wants to play Frogger. However, he's not very good. In fact, he will only try to move forward, and only after the platforms have moved. Find out if Jonny's frog manages to reach ...
35
votes
6answers
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, ...
16
votes
10answers
2k views

Assign Airliner Seats

Inspired by last week's APL lesson. Given an uppercase 2D seat map and a 1D list of customers, return the seat map and the customer list but modified as follows (to indicate occupied seats and seated ...
11
votes
3answers
503 views

Word Search on a Torus [duplicate]

The Challenge Given a list of words and a grid of letters, your job is to determine which of the given words can be found on the grid in all 8 directions (forward, backward, up, down, and the 4 ...
14
votes
10answers
934 views

Area enclosed by perimeter loop

Find the area of a region of unit cells given its perimeter loop as a sequence of 90-degree turns. For example, take the three-cell region XX X whose perimeter ...
9
votes
5answers
372 views

Four Spiraling Axes

Take the numbers 0, 1, 2, 3, 4, ... and arrange them in a clockwise spiral, starting downward, writing each digit in its own separate square. Then, given one of ...
21
votes
1answer
462 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 ...
24
votes
3answers
735 views

Ice Golf Challenge

The goal of this challenge is to write a program or function that returns the least amount of strikes needed to complete a given course. Input The layout of the course can be passed in any suitable ...
10
votes
3answers
762 views

RoboZZle interpreter

Your task is to write a RoboZZle interpreter. If you're not familiar with the game, please watch the video at robozzle.com or read my description below. A robot lives on a rectangular grid of squares ...
21
votes
10answers
1k 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 ...
10
votes
2answers
569 views

Biggest square in a grid [closed]

Challenge Given a grid like this, ...
26
votes
1answer
458 views

Jolly gerrymandering

Background The United States has a unique love of gerrymandering––the deliberate manipulation of an electoral district to predict certain voting results. Just recently there was a gerrymandering case ...
14
votes
7answers
633 views

Is my kids' alphabet mat properly grouped by colors?

My kids have an alphabet mat to play with, something like this: After months with the tiles of the mat randomly placed, I got tired and placed all the tiles of the mat grouped by sections according ...
24
votes
3answers
375 views

Implement simplified kerning

Introduction Kerning means adjusting the spacing between the letters of a text. As an example, consider the word Top written with the following three glyphs: <...
27
votes
9answers
2k views

ASCII rhombic grid

Write the shortest code measured by byte count to generate an ASCII grid composed of rhombi, given the following parameters: m - number of complete rhombi in one row n - number of rows s - side of ...
6
votes
2answers
219 views

Balanced and Centre-Free Sets of Points

Taking in Input Define a function f as follows: IF x < 0: f(x) = -√|x| ELSE: f(x) = √x In your programs/functions,...
2
votes
0answers
123 views

Bucket Brigade! [closed]

Inspired by this, this and this. So, now that the evil farmer has set your field on fire, you naturally want to put it out. You have a bunch of friends who all have buckets, and you want a program ...

1
2 3 4 5