# Questions tagged [grid]

For challenges involving a grid.

243 questions
Filter by
Sorted by
Tagged with
899 views

### Highlight the Bounding Box, Part II: Hexagonal Grid

You're given a hexagonal grid of the characters . and #, like this: ...
1k views

### Highlight the Bounding Box, Part I: Cartesian Grid

You're given a rectangular grid of the characters . and #, like this: ...
2k views

### Figure Out the Android Lock Pattern

Lets say you saw your friend enter his or her password into their Android phone. You don't remember how they made the pattern but you remember what the pattern looks like. Being the concerned friend ...
3k views

### Is this square symmetrical?

Write a program or function that takes in a 4×4 text grid consisting of exactly 4 A's, 4 B's, 4 ...
1k views

### Code golf ABC's: The ASCII Box Challenge

Given two positive integers, 'a' and 'b', output an ascii-art "box" that is a characters wide and b characters tall. For example, with '4' and '6': ...
521 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 ...
596 views

### I've been alphabet hunting for a while

Y'know, we've had a lot of "alphabet" challenges recently. (one two three four five.) While I love a good challenge, and those challenges were very fun, I think it's time for a change of pace. We need ...
783 views

### Gauss to Eisenstein

Given a Gaussian integer $a+bi$ where $a$,$b$ are integers and $i = \exp\left(\pi i/2\right)$ is the imaginary unit, return the closest (w.r.t to the Euclidean distance) Eisenstein integer \\$k+...
3k views

### A square of text

The Challenge Given a string, output the text in the shape of a square. You can assume that the text will always fit in a square, and that it will never be an empty string. You can also assume it ...
275 views

### Count blocks in a 2D grid

Challenge description Let's define an W x H grid as a two-dimensional array of length H ...
252 views

### Move platforms!

The Challenge Given either a string (may have newlines), or a two dimensional array, and a positive integer n, output the position of the platforms ...
1k views

### Integers, Assemble!

Your task is to assemble the integers from 1 to N (given as input) into a rectangle of width ...
640 views

Write a program or function that takes in a nonempty single-line string of printable ascii characters excluding space: ...
1k views

### Flood-fill a 2D grid

Challenge description Let's call a two-dimentional, rectangular array (meaning its every subarray has the same length), a grid. Every unit of a grid is either an empty space or a border. In a grid of ...
397 views

### A Hundred Squares!

Back to basics... As a teacher at the local primary (grade?) school, you need a way to teach your class their times tables. At your disposal, you have hundred squares and a load of red pens. You need ...
1k views

### Recognize a vine

Background I have a bunch of old and grainy black-and-white images. Some of them depict vines climbing on a wall, others don't – your task is to classify them for me. Input and output Your ...
482 views

### Generate ASCII TetraVex

TetraVex is a tile-based edge-matching game that was originally coded by Scott Ferguson for the Microsoft Entertainment Pack 3 back in 1990. The game consists of a grid upon which square tiles are ...
413 views

### How many squares are there?

This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this: ...
277 views

### Rotation-safe Latin squares

A Latin square is a square that has no repeated symbols in either the X or Y columns. For example: ABCD DABC CDAB BCDA is one such square. Notice how every ...
399 views

### One-to-one correspondence between pairs of integers and the positive integers

It is well-known that there are one-to-one correspondences between pairs of integers and the positive integers. Your task is to write code defining such a correspondence (by defining a pair of ...
5k views

For the non-zero digits on a standard numpad 789 456 123 consider placing a chess knight at any digit and moving it around with any number of normal L-shaped ...
708 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 ...
1k views

### Stable Game of Life

Challenge: Given a matrix (or 2d array) of 0s and 1s, output the number of steps it takes for Conway's game of life to reach a stable state, or -1 if it never reaches one. A stable state is a state ...
953 views

### KOTH: Everybody loves tokens

In this game two players compete to eat the most points worth of tokens, but there's a twist! Eating multiple tokens in a row of the same color gives an ever-growing bonus, but watch out, or your ...
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 ...
678 views

### Clean the muddy quartata-fish

This challenge is in honor of the Rookie of the Year category winners of Best of PPCG 2015: muddyfish (for I'm not the language you're looking for!) and quartata (for Implement a Truth-Machine). ...
246 views

### Highest score on the field

Introduction Let a field be a rectangle filled with only the characters - and [0-9]. An example of a field is: ...
412 views

### Go to opposite corner of rectangle in all directions - Harder

This is essentially the same thing as this question, except harder. You are again to write a program that gets from the lower-left corner of a rectangle to the upper-right corner. However, this time ...
726 views

### Optimal solution to go to opposite corner of a rectangle

Your job is to write a program that finds the optimal number of moves it takes to get from the lower-left corner of a rectangle to the upper-right corner directly opposite. Your program will accept ...
252 views

### Identify arborally satisfied point sets

An arborally satisfied point set is a 2D set of points such that, for any axis-aligned rectangle that can be formed using two points in the set as opposite corners, that rectangle contains or touches ...
519 views

### Tic-tac-toe with only crosses as quick as possible

As per Luke's request and Peter Taylor's addition to this challenge. Introduction Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only ...
270 views

### Count rectangle intersections

The Challenge Given an arbitrary amount of rectangles, output the total count of intersections of those when drawn in a 2D plane. An intersection here is defined as a point ...
378 views

### How far from the exterior?

Take a 2D region of space divided into axis aligned unit square elements with their centers aligned at integer intervals. An edge is said to be internal if it is shared by two elements, otherwise it ...
360 views

Introduction Imagine you are on a two dimensional cartesian plane and want to determine your position on it. You know 3 points on that plane and your distance to each of them. While it is always ...
2k views

### There's an ant on my Rubik's Cube

A standard, solved, 3×3×3 Rubik's Cube has 6 differently colored faces, where each face is a 3×3 grid of squares of one color. The white face is opposite the yellow, the red opposite ...
353 views

### Word Search Helper

I've been doing word searches recently, and I thought it would be so much easier if all of the words read left-to-right. But rewriting all the lines takes a lot of effort! So I'm enlisting code ...
615 views

### Cities: Sightlines

I'm at position (0, 0) of an infinite two-dimensional city, which is perfectly divided into blocks centered at each lattice point, some of which contain buildings. A building at a certain point (x, y) ...
1k views

### Stuffing primes in a box

Your task is write a program or function that can fill a given rectangle with prime numbers. The width and height of the ...
155 views

### Diagram of a leaper [duplicate]

Given an input of a pair of nonnegative integers describing a leaper in chess, output a diagram of the squares to which the leaper can move. From Wikipedia's description: An (m,n)-leaper is a ...
907 views

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 ...
318 views

### Find the Words on the Grid!

Write a program or function that extracts a word from a wordsearch using its start and end coordinates. The Input Your program or function should accept three parameters: the start coordinate, the ...
452 views

### Find the haystack in the needles

In a twist on finding a needle in a haystack, you need to find the largest contiguous haystack containing exactly one needle. Note that you cannot connect cells on diagonals, only left/right/up/down. ...
656 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 ...
245 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)-...
591 views

A friend of yours has given you directions to the best restaurant in town. It's a series of left and right turns. Unfortunately, they forgot to mention for how long you need to go straight ahead ...
6k views

### Print N Squared

Write a program or function that takes in a non-negative integer N from stdin or as a function argument. It must print or return a string of a hollow ASCII-art square whose sides are each made with N ...
1k 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, ...
936 views

### Grocery Store Micromanagement

You are an employee at the hip new grocery store Half Foods, and it's the day before Thanksgiving Christmas Easter. Since the store will be packed with customers rushing to get their foodstuffs, the ...