This challenge is intended to be solved by using, manipulating, or creating shapes or other geometric structures.

learn more… | top users | synonyms

31
votes
7answers
487 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 ...
7
votes
0answers
155 views

Can I make that shape with blocks, slabs, and stairs?

Consider a rectangular two-dimensional grid where each cell can either be empty (.) or full (0). e.g. ..00.... 0000.... .00000.. 000...00 ..000000 000.00.. The grid is considered infinite, all ...
6
votes
1answer
211 views

Computing the geometric median

Given a list of integer points in an n-dimensional space, output the geometric median. Note that the output is not necessarily integer. Your answer must be precise to at least two digits after the ...
27
votes
1answer
616 views

Find the area of the largest convex polygon

Given a list of integer coordinates, find the area of the biggest convex polygon you can construct from the list such that - every vertex is in the list no element of the list is contained within ...
13
votes
11answers
1k views

Empty a Swimming Pool . . . With Only a Red Solo Cup

You have a swimming pool that is filled to the brim with water. You need to empty it, but you can't think of an efficient method. So you decide to use your red solo cup. You will repeatedly fill the ...
15
votes
5answers
1k views

Find the nearest clock hands

Challenge Given a number of seconds past midnight, output the smallest angle between any two hands on a clock face, using as few bytes as possible. You may assume that the number of seconds is ...
15
votes
13answers
499 views

Find the reference angle

This is a fairly simple question. According to this random website I found, a reference angle is the acute angle formed by the terminal side of the given angle and the x-axis. You have to write a ...
6
votes
3answers
297 views

Integral triangles and integral medians

Consider a triangle ABC where each side has integer length (an integral triangle). Define a median of ABC to be a line segment from a vertex to the midpoint of the opposing side. In the figure below, ...
6
votes
1answer
340 views

Go south, east and north, come to the same place

There is that famous riddle: A bear walks 1 km south, 1 km east and 1 km north, and comes to the place it started from. What color is the bear? This one is very old, so I'll generalize it: A ...
7
votes
4answers
354 views

Calculate the Orthocenter of a Triangle

Try to write the shortest program or function you can that prints or returns the calculated orthocenter of a triangle. The orthocenter of a triangle is the intersection point of the three altitudes ...
4
votes
2answers
193 views

Cut a silicon wafer into dies

When manufacturing chips, circular silicon wafers are cut into dies of needed size: The goal of this challenge is maximizing the number of whole dies that can be cut from a wafer of a given ...
17
votes
3answers
510 views

Stacking Pythagorean Triangles

Background A Pythagorean triangle is a right triangle where each side length is an integer (that is, the side lengths form a Pythagorean triple): Using the sides of this triangle, we can attach ...
15
votes
2answers
419 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 ...
17
votes
1answer
308 views

Chute-A-Pearing

Here are five images of pears and a steel chute: A: B: C: D: E: These are only thumbnails, click them for full size! (I made these with Algodoo.) This class of images always has the ...
14
votes
5answers
493 views

Determine the Dimensions of a Rotated Rectangle

This Stack Snippet draws an aliased white rectangle on a black background given parameters for its dimensions, position, angle, and the grid dimensions: <style>html ...
35
votes
5answers
2k 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 ...
133
votes
9answers
19k views

Draw an Image as a Voronoi Map

Credits to Calvin's Hobbies for nudging my challenge idea in the right direction. Consider a set of points in the plane, which we will call sites, and associate a colour with each site. Now you can ...
21
votes
11answers
1k views

Tile the plane with this modified circle

Take a unit circle centered on the origin. In any two neighboring quadrants, mirror the curve of the circle across the lines connecting the circle's x and y intercepts. With the resulting shape, you ...
17
votes
2answers
356 views

Can you fold a hexomino into a cube?

One of my kid's favorite toys is a set like this. Actually its one of my favorite toys - I've been playing with it and its been giving me some PPCG challenge ideas. Here's one: Write a program or ...
18
votes
14answers
2k views

Random Golf of the Day #4: The Bertrand Paradox

About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
29
votes
7answers
2k views

Area of an ASCII polygon

You should write a program or function which receives a string representing an ascii-art polygon as input and outputs ot returns the area of the polygon. The input is a string consisting of the ...
18
votes
2answers
913 views

Determining the rotation of square given a list of points

In this challenge, you will be given a list of points. These points lie on the perimeter of an imaginary square. Your goal is to: If possible, print out the rotation of the square, which will be a ...
13
votes
6answers
524 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 ...
4
votes
0answers
153 views

Help My Brother Work on his Tan(gent)!

This challenge is entirely fictional. There is no time limit for this challenge. My little brother is terrible with computers! He saved up all of his money to buy a new one, and within half an hour ...
18
votes
11answers
2k views

Output a Face on a Numbered Cube

Assign the numbers 0 through 7 to the 8 vertices of a cube in any way you want. Exactly one number must be assigned to each vertex. For example, your vertices might be assigned like this: ...
15
votes
6answers
692 views

Overlapping circle

You should write a program or function that given an N by N equally spaced square grid and a solid inscribed circle outputs or returns the number of grid squares which are overlapped partially or ...
18
votes
3answers
530 views

Remove an unobstructed rectangle

This image was made by overlaying 7 differently colored rectangles on top of each other: The black and maroon rectangles are unobstructed, that is, no other rectangles are above them. Write a ...
12
votes
1answer
188 views

Finding Symmetries in Squares

Write a program or function that takes in a list of positive integers. Each of these integers represents the side length of a square on a 2D plane. Each square can be moved to any integer coordinates ...
27
votes
3answers
1k views

Area of a Self-Intersecting Polygon

Consider a potentially self-intersecting polygon, defined by a list of vertices in 2D space. E.g. {{0, 0}, {5, 0}, {5, 4}, {1, 4}, {1, 2}, {3, 2}, {3, 3}, {2, 3}, {2, 1}, {4, 1}, {4, 5}, {0, 5}} ...
11
votes
4answers
442 views

Identifying the triangles

Counting the amount of triangles in a picture is a task commonly used in brain tests. You are given a picture that contains shapes consisting of triangles. You then must find all possible triangles in ...
20
votes
7answers
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 ...
12
votes
1answer
585 views

Sharing pizza fairly

The difficulty with sharing pizza with friends is that it is hard to make sure that everyone gets the same amount of pepperoni on their slice. So, your task is to decide how to fairly slice a pizza so ...
17
votes
4answers
1k views

Draw A Snowflake

Joe lives at the Bahamas. It is winter. His children are disappointed that there is no snow. Joe needs to make snow for his children. Fortunately, he has a 3-d printer. He plans to make snowflakes ...
19
votes
3answers
550 views

Squarefinder – Locating regular tetragons

Imagine a bunch of rectangles drawn in the plane, each rectangle with its vertices at integer coordinates and its sides parallel to the axes: The rectangles partition the plane into a number of ...
7
votes
1answer
523 views

Digesting Polygons

Digesting a polygon is a process in which you take an input polygon, and create another polygon that can contain the entirety of the input polygon, while having one side less than it. The goal of ...
10
votes
4answers
772 views

Tiling, given vertex configuration

Task The task is to tile polygons, given a vertex configuration. Scoring Your score is equal to the "complexity level" your submission reaches. Complexity levels are cumulative, meaning that to ...
15
votes
5answers
737 views

Mondrian painting description language

This challenge consists in coding an interpreter for a Mondrian painting description language (MPDL). Language definition The language operates on a stack of rectangles. A rectangle is defined by ...
20
votes
1answer
644 views

Can you hear me now?

Background You are a rich executive of a software empire. Your time is worth a lot of money. As such, you must always travel in the most efficient route possible. However, as an executive, you spend ...
5
votes
1answer
273 views

Crafting Canonically Cöcher Crosswords

The Setup Most of us are familiar with crossword numbering, which follows three basic rules: in a character grid consisting of blacks and whites (see below), any maximal contiguous horizontal or ...
18
votes
4answers
577 views

Triangular battleships (A computational geometry problem)

You are the captain of a battleship. The engineering department's been cutting corners with designs this year, so the ship you're on takes the shape of a simple triangle. You walk out onto the deck ...
8
votes
1answer
694 views

Circle packing in a rectangle

Your task is to write a program that finds the largest radius that N circles can have and still fit inside of a rectangle that is X by Y pixels large. (similar to this wikipedia article) Your program ...
1
vote
1answer
279 views

Find a representative submatrix

You have a matrix of size m x n. Each cell in the matrix has a uniformly random integer value v, where 0 ≤ v < i, and i ≤ (m x n). (Meaning, the matrix contains a maximum of m x n distinct values, ...
41
votes
8answers
8k views

Draw the South Korean flag

When I stumbled upon this question I remembered that I had also once seen precise rules for the construction of the South Korean flag. And this is quite a different construction. Source: Wikipedia ...
15
votes
2answers
551 views

Construct n-gons with a ruler and compass

The task is to draw a regular polygon of n sides using only a compass and an unmarked ruler. Input (n) is one of the following 10 numbers: 3, 4, 5, 6, 8, 10, 12, 15, 16, 17. Method: Because you only ...
18
votes
3answers
801 views

2D Collision Detection

This challenge is based on actual collision detection I had to write for a simple game recently. Write a program or function which, given two objects, returns a truthy or falsy value depending on ...
3
votes
1answer
243 views

GPS: Golfed Positioning System

Your mission, should you choose to accept it, is to write code for a GPS receiver. Input The current time, as nanoseconds from the Unix epoch. [EDIT: This is optional, please state whether you ...
21
votes
4answers
2k views

Enclose 1009 pixels

Output is a shape that encloses 1009 pixels. The shape must take the form of a single, closed, non-intersecting loop. Input is a positive non-zero integer. Each input must yield output that is ...
7
votes
9answers
1k views

Create a grid as close to a square as possible

Create a function or program that makes a grid as close to an square as possible You will be given an integer N as input, whole numbers (1,2,3,25, etc) The output must be a perfect rectangular grid ...
46
votes
10answers
8k views

Little Chandler is sad. Draw him a cloud to cheer him up

Little Chandler is sad. Draw him a cloud to cheer him up. Note: Drawing a cloud won't actually cheer him up. A circle can be defined as a 3-tuple (x,y,r) where x is the x position of the circle on a ...
3
votes
0answers
752 views

The World in the Future [closed]

In the future, the world will change, there's no doubt about it. For that reason, you have to produce a realistic map of the world n years in the future. The number n should be the number of years in ...