Questions tagged [geometry]

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

264 questions
30k 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 ...
19k views

Write a program or function that takes in a positive integer N, and outputs an N×N pixel image of Google's "G" logo according to this* construction: For example, if N is 400, a 400×...
14k 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 ...
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 ...
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. ...
3k views

Sprocket Science: Animating a Chain Drive System

The goal of this challenge is to produce an animation of a chain drive system, comprised of a set of sprocket gears connected together by a chain. General Requirements Your program will be given a ...
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 ...
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 ...
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 <...
9k views

Is my triangle right?

Given a, b, c the length of the three sides of a triangle, say if the triangle is right-angled (i.e. has one angle equal to 90 degrees) or not. Input Three ...
5k views

Build a triangle without any triangles

As a little kid, I liked to play with these toys a lot: They probably intended for these to be used for art, but I always used them for math! Fractals, patterns, etc. One time, I was given this ...
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]...
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 ...
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 ...
3k views

Volumes of ASCII boxes

Introduction In this challenge, you are given as input the ASCII representation of the net (unfolded surface) of a rectangular cuboid (3D box). The format is this: ...
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 ...
2k views

Can I Slide Apart The Puzzle?

Write a program or function that takes in a rectangular grid of text where every cell is either an A or a B. All the ...
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 ...
4k views

The Crow vs The Taxicab

Imagine travelling to a point lying A miles away horizontally and B miles away vertically from your current position. Or in other words, travelling from (0, 0) to ...
5k views

Toilet Paper Mysteries

Today you need to solve a very practical problem: How many loops do you need to have a certain number of sheets on your toilet paper roll? Let's look at some facts: The diameter of a bare toilet ...
3k views

​P​i​ =​= ​3​.​2​

Inspired by this video of Infinite Series. Introduction Pi is defined as the ratio of the circumference to the diameter of a circle. But how is a circle defined? Usually a circle is defined as the ...
4k views

Visually Explain the Pythagorean Theorem

A common visual explanation of the Pythagorean theorem is as such: The squares are meant to represent the side length's squared, and the areas of a + b = c, just ...
7k views

Angle between the hands on a clock

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

Gasket Weaving - draw a Sierpiński knot

Given an integer N >= 2, produce an image showing a Sierpiński knot of degree N. For example, here are knots of degree 2, 3, 4 and 5: Click on the images to view full size (the higher the degree the ...
3k views

Evaluate the aspect ratio of a triangle

Given three sidelengths of a triangle, evaluate its aspect ratio AR given the following formula: where The closer to equilaterality a triangle is, the closer to 1 ...
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, ...
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. ...
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 ...
2k views

Draw HyperNeutrino's benzene hegaxon icon in ASCII

In celebration of HyperNeutrino getting back his account and rep, following Mr. Xcoder. Apologies for rotating the picture for drawability. Print or output this ASCII art exactly. You may have ...
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 ...
722 views

A Dog on a Chain

I'm looking out of my attic window into my neighbor's yard. They have a dog chained to a post in the center of the yard. The dog runs around the yard but is always on the end of its chain, so it ...
551 views

Fishing for Cube Nets

Cubes can be made of six squares as sides. But you could also fold three 2x1 rectangles in half and glue them together to form a cube. Now in this challenge you get a set of pieces which are each made ...
3k views

Beatles Songs and Hexagons

Write two triangle (i.e. pyramid) shaped programs. The first one should be an upwards pointing text triangle with a minimum base width of three characters. So it would have a structure like ...
827 views

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 ...
3k views

Normalize a Vector

To normalize a vector is to scale it to a length of 1 (a unit vector), whilst keeping the direction consistent. For example, if we wanted to normalize a vector with 3 components, u, we would first ...
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 ...
755 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 ...
915 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 ...
4k views

Diamond creator +

Challenge : Given an integer n as input. Create a diamond that is 2x the given number n. Input : Input is integer ...
4k views

Draw A Reuleaux Triangle!

The Reuleaux triangle is the shape formed by the intersection of three circles, with each circle passing through the others' centers. Regardless of rotation, a Reuleaux triangle's width will always ...
4k views

The shortest distance between two points is a line

Code a program or function to construct an interactive canvas on the screen of at least 400 pixels x 400 pixels in size. The canvas can be any color you wish, bordered or borderless, with or without a ...
2k views

Rotate a hypercube

Introduction A hypercube/tesseract is the 4 dimensional equivalent of a normal cube. It's made by taking a cube net, extending it to the 3rd dimension, then – using the 4th dimension – folding it ...
721 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 ...
2k views

Print a cube net of the specified size

Challenge Given a size s, print a cube net of that size made of hash symbols (#) and spaces (). Examples: ...
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 ...
2k views

Largest rectangle in 2d array

Input The board: A 2D container (matrix, list of lists, etc.) of letters like: ...