Questions tagged [geometry]

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

Filter by
Sorted by
Tagged with
58
votes
10answers
12k 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 ...
106
votes
79answers
22k views

Draw the national flag of Iceland

This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag. ...
41
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 ...
28
votes
6answers
7k views

Let's draw the flag of Nepal

Nepal’s flag (Wikipedia, Numberphile) looks very different from any other. It also has specific drawing instructions (included in the Wikipedia article). I want you guys to make a program which will ...
106
votes
84answers
19k views

Draw the national flag of France

There have been many other flag challenges posted but not one for the national flag of France. This week seems like an appropriate time. Produce this flag in the fewest bytes possible: The image ...
61
votes
15answers
10k views

Draw the € sign

The goal is to output or display an image with an € (euro) sign according to the following specs (ignoring the border of the sign). Source: http://en.wikipedia.org/wiki/File:Euro_Construction.svg ...
39
votes
22answers
8k views

Check if point lies inside triangle

Your goal is to determine whether a given 2D point X lies within the area of the triangle with given vertices A,B,C. Write a function that takes in the coordinates of the test point X and the three ...
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 ...
32
votes
3answers
3k views

Area of a Self-Intersecting Polygon

Consider a potentially self-intersecting polygon, defined by a list of vertices in 2D space. E.g. ...
20
votes
41answers
5k views

Draw an ASCII Rectangle

Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height. Or, if your language supports it, the two integers can be given as separate inputs. ...
21
votes
3answers
1k 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 ...
12
votes
3answers
1k views

The centers of a triangle

Circles and squares have a single, definite center point. However, the notion of the center of a triangle has long been discussed. Four different centers were known to the Ancient Greeks: Incenter: ...
8
votes
2answers
630 views

Simple Geometric problem

This problem (see below) has been given as a High School Programming League code golf challenge. The shortest codes submitted during the contest were: 177 bytes in Ruby, 212 bytes in Python 2.5, 265 ...
20
votes
4answers
4k views

Find the Convex Hull of a set of 2D points

When you hammer a set of nails into a wooden board and wrap a rubber band around them, you get a Convex Hull. Your mission, should you decide to accept it, is to find the Convex Hull of a given set ...
17
votes
6answers
845 views

A cube of text ݀

Last time you made a square of text, but now, can you make a cube of text? The Challenge Given a string, output the string in the form of a cube. You can assume the string will always have 2 chars ...
37
votes
19answers
3k views

Chebyshev Rotation

Consider a regular grid, where each cell has integer coordinates. We can group the cells into (square-shaped) "rings" where the cells in each ring have the same Chebyshev distance (or chessboard ...
33
votes
9answers
2k views

I really wanted a rhombus, but all I got was this stupid rectangle

Given only a straightedge and compass, inscribe a rhombus inside the given rectangle, sharing two opposite points. Input Input is the dimensions of the rectangle. In the example shown, that would be ...
22
votes
4answers
1k 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 points ...
32
votes
4answers
4k views

The happy Ender problem

The happy ending problem (actually a theorem) states that Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. The ...
19
votes
12answers
3k views

What is the area of this polygon?

Calculate the area of a polygon. Inspired by this shoelace algorithm video. Task Your job is to create a program or function that calculates the area of a polygon. Program or function is defined ...
10
votes
10answers
2k views

Generate a right triangle

In this challenge, you must take two numbers (separated by a space) as input and output an ASCII right triangle, made up of xs. The first number will be the width ...
19
votes
15answers
2k views

Hypercube elements

Write a function or program that outputs the number of each type of element (vertex, edge, face, etc.) of an N-dimensional hypercube. As an example, the 3 dimensional cube has 1 cell (i.e. 1 3-...
18
votes
3answers
642 views

Text on a circle

Write a program or function that prints an input string around the discrete circle that has the minimum possible radius. For example, for input This is an example, ...
16
votes
3answers
511 views

Regular Polygrams

Given the number of vertices n ≥ 3 and the "step size" 1 ≤ m < n/2 (indicating the distance between two connected vertices), ...
7
votes
5answers
787 views

Hypercube sides

Your goal is to output all the "sides" (corners, edges, faces, etc.) of an N-dimensional unit hypercube, where N is non-negative. A "side" is defined as any (N-M)-dimension surface embedded in N-...
7
votes
3answers
462 views

How can I shorten this python code analyzing a 3d grid?

My Python 3 function golf(...) should take a list of lists of lists of strings representing a solid cube and return whether there are any places in which two equal ...
7
votes
7answers
536 views

Intersection of Two Lines

Given equation of two lines in the format Ax+By=C, determine their intersection point. If they are parallel print 'parallel' without quotes. For input/output format refer sample input/output. ...
169
votes
8answers
31k 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 ...
57
votes
10answers
10k 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 <...
28
votes
4answers
776 views

Smallest region of the plane that contains all free n-ominoes

On Math Stack Exchange, I asked a question about the smallest region that can contain all free n-ominos. I'd like to add this sequence to the On-Line Encyclopedia of Integer Sequences once I have ...
24
votes
3answers
3k 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 ...
35
votes
21answers
7k views

Angle between the hands on a clock [duplicate]

Given the time in 24 hour format (2359 = 11:59pm) return the angle between the minute and hour hands on a standard clock (on the ...
29
votes
2answers
858 views

Addition on Elliptic Curves

Addition on Elliptic Curves Disclaimer: This does not do any justice on the rich topic of elliptic curves. It is simplified a lot. As elliptic curves recently got a lot of media attention in the ...
25
votes
12answers
1k views

Embedded Diamonds!

No, not this. And not this either. This question is nothing like those Write the shortest code to print/return the following output: ...
22
votes
38answers
4k views

Distance between two points in n-dimensional space

Here is another simple one: The Challenge Given two points in an n-dimensional space, output the distance between them, also called the Euclidean distance. The coordinates will be rational numbers; ...
16
votes
2answers
1k 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
4answers
692 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 ...
17
votes
3answers
45k views

Polygon prefixes

Polygons are named after the number of sides that they have. A pentagon has 5 sides, an octagon has 8 sides. But how are they named? What's the name for a 248-sided polygon? All polygons are suffixed ...
33
votes
12answers
2k views

Triangular Lattice Points close to the Origin

Background A triangular grid is a grid formed by tiling the plane regularly with equilateral triangles of side length 1. The picture below is an example of a triangular grid. A triangular lattice ...
32
votes
20answers
3k views

How much present did you get for Christmas?

Yes, how much, not how many... As we all know, a large present is far better than a small one. Therefore, the value of the presents should always be measured in total volume, not number of presents, ...
26
votes
6answers
2k views

Two dozen kissing number approximations

Given a number from 1 to 24, output the kissing number to the best of current knowledge (some numbers will have more than one acceptable output). Knowledge of geometry is not essential as the outputs ...
25
votes
2answers
842 views

Is it a Rubik's Cube?

A venerated pass time of pedants is to point out that pictures of "Rubik's Cubes" (on t-shirts, posters etc.) are not actually solvable. The first thing that should be checked is that the cube is ...
23
votes
6answers
700 views

Distances to coordinates

There are n people on a 2D plane. Using distances between them we're going to find their positions. To get a unique answer you must make four assumptions: There are at least 3 people. The first ...
20
votes
2answers
950 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
2answers
921 views

Random Golf of the Day #6: Roll a d20

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 ...
16
votes
3answers
636 views

Rolling the Dice

Rolling the Dice So, I was rolling dice a while ago and thought of a challenge. Given the cube with a net taken from input and a list of moves, find the square on the bottom at the end. I will use ...
14
votes
11answers
2k 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 ...
14
votes
4answers
4k views

Drawing 3d nets - Platonic solids

This is a basic version of the rather more difficult Drawing 3d nets - Archimedean solids . I have a weakness for 3d nets which when cut out and folded allow you to make 3d shapes out of paper or ...
43
votes
23answers
5k views

Covering a Skyline with brush strokes

Given a non-negative integer skyline height list, answer how many uninterrupted 1-unit-high horizontal brush strokes are needed to cover it. [1,3,2,1,2,1,5,3,3,4,2]...
24
votes
3answers
837 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 ...