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

learn more… | top users | synonyms

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
483 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
290 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
335 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
347 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
190 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
479 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
415 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
291 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
483 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
18k 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
351 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
908 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
514 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 ...
3
votes
0answers
149 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
685 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
526 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
184 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
441 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
1k 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
582 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
548 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
515 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
768 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
731 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
637 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
269 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
573 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
675 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
278 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
545 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
790 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
238 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
725 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 ...
20
votes
3answers
1k views

Drawing Epicyclogons

An epicycloid is the curve a point on a circle makes as it rolls around another circle. A cyclogon is the shape a point on a regular polygon makes as it rolls across a plane. An epicyclogon is the ...
5
votes
3answers
742 views

The distance between circles

Imagine you are given two lists of numbers which are to be interpreted as points on a circle of circumference 1000. Let us say circleA = [10, 24, 44, 175, 321, 579, 618, 841, 871, 979] circleB = ...
67
votes
15answers
7k views

Implement the Game of Life on Anything but a Regular Grid

Conway's Game of Life is (almost) always played on a regular square grid, but it doesn't need to be. Write a program that implements the standard cell neighboring rules from Conway's Game of Life on ...
19
votes
2answers
2k views

Fill the Screen with Wang Tiles

It has been proven that the following 13 square Wang tiles always tile the plane aperiodically. This means that when the squares are arranged in a grid with all neighboring sides the same color, a ...
16
votes
4answers
682 views

Three-pointer! But what kind?

From http://en.wikipedia.org/wiki/Triangle: Write a program that takes three 2d coordinate tuples (Cartesian), and classifies what shape these three points describe. In almost all cases these ...