Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [geometry]

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

8
votes
2answers
306 views

Can this container hold this much liquid?

Can this container hold this much liquid? Challenge Synopsis As you most likely know, liquids have an indefinite shape and a definite volume. As such, they always take the shape of their container. ...
25
votes
4answers
568 views

How lit is this room? 🔥 pt. 1

Related to this question. A room is defined to be a (not necessarily convex) non-intersecting polygon, expressed as an ordered list of 2-dimensional coordinates. A sufficiently bright lightbulb is ...
43
votes
23answers
4k 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]...
8
votes
1answer
279 views

Count the Closed Polygons

Input: An NxM grid or multi-line string (or other reasonable input-format), containing only printable ASCII (unicode range ...
7
votes
1answer
354 views

Hilbertize an image

For a computer vision app I want to do a mapping of an image, in such a way that every pixel fit hilbert curve, instead of conventional layout. So task could be as follows: Task description Given ...
18
votes
9answers
2k views

Partitioning the grid into triangles

Goal The goal of this challenge is to produce a function of n which computes the number of ways to partition the n X 1 grid ...
13
votes
9answers
1k views

Drawing the Peano curve

Introduction In geometry, the Peano curve is the first example of a space-filling curve to be discovered, by Giuseppe Peano in 1890. Peano's curve is a surjective, continuous function from the unit ...
18
votes
8answers
761 views

Is this quadrilateral cyclic?

In mathematics, a cyclic quadrilateral is one whose vertices all lie on the same circle. In other words, every vertex is on the circumcircle of the other three. For more information, see the MathWorld ...
23
votes
11answers
2k views

Smallest Integer Disk

This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must ...
3
votes
0answers
119 views

Number of circles packed into a rectangle [closed]

Calculate the maximum number of circles of radius r that can fit in a rectangle with width x and height ...
8
votes
0answers
124 views

Find a way to determine to which fibonacci squares a given coordinate belongs [closed]

Given a random coordinate (x,y), determine in which square (squares are referenced by their sidelength) it is (or the borders of which squares). The squares are drawn in a counter clockwise direction,...
7
votes
2answers
205 views

Drawing convex polyiamonds

Description OEIS sequence A096004 gives the Number of convex triangular polyominoes [polyiamonds] containing n cells. It begins: ...
7
votes
2answers
231 views

Intersection Point of Two Line Segments

Given two line segments, determine if the line segments intersect and if so, where. In the case that the two given line segments are co-linear and overlap, determine the midpoint of the overlapping ...
6
votes
11answers
631 views

Draw a times table (also called modular multiplication circle) of a number \$n\$ with \$k\$ vertices

Not to be confused with this question. You need to draw a times table (also known as Cremona's method for cardioid generation) as shown in this video. The number \$n\$ and \$k\$ will be the inputs. ...
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 ...
1
vote
3answers
332 views

Rounded Rectangles

Challenge Given an integer greater or equal to 4, n, print a rounded rectangle of as close as possible (with a gap of 1) sides and a perimeter of n characters. Rules n is always 4 or greater, ...
27
votes
4answers
735 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 ...
-1
votes
1answer
193 views

Find the longest uninterrupted arc in N dimensions

See similar question for 2D case: Find the longest uninterrupted arc The challenge here is to find the longest uninterruped great circle arc around a unit hypersphere in N dimensions, with a random ...
5
votes
3answers
335 views

Find the longest uninterrupted arc

The challenge here is to find the longest uninterruped arc around a unit circle with a random amount of points distributed in random positions around it. Here is a diagram to assist my explanation: ...
31
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 ...
14
votes
10answers
910 views

Area enclosed by perimeter loop

Find the area of a region of unit cells given its perimeter loop as a sequence of 90-degree turns. For example, take the three-cell region XX X whose perimeter ...
14
votes
6answers
939 views

Will you be my Weaver?

I've been recently playing through 'The Weaver' and I think it presents an interesting challenge for code-golf. Premise: The Weaver is a game wherein you are given a number of ribbons coming from 2 ...
27
votes
43answers
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 ...
14
votes
12answers
990 views

Circle intersection area

Description : Given x and y positions of two circles along with their radii, output the ...
11
votes
20answers
2k views

Distance between two points on the Moon

Given latitude/longitude of two points on the Moon (lat1, lon1) and (lat2, lon2), compute the distance between the two points in ...
26
votes
9answers
2k views

Largest rectangle in 2d array

Input The board: A 2D container (matrix, list of lists, etc.) of letters like: ...
15
votes
9answers
995 views

Join up the rooms

So, here's a map of, let's say, a dungeon... ########## # ##### # ##### ########## ########## ########## ########## #### ## #### ## ########## Let's ...
16
votes
14answers
752 views

Euler-Poincaré-Characteristic of Polyhedra

Given a triangulation of the surface of a polyhedron p, calculate its Euler-Poincaré-Characteristic χ(p) = V-E+F, where ...
12
votes
5answers
619 views

Sparse Protractor

Given some positive integer n, design a protractor with the fewest number of marks that lets you measure all angles that are an integral multiple of ...
6
votes
1answer
221 views

Stereographic projection of polyhedra

You will create a program that generates the stereographic projection of polyhedra. In particular, to keep things simple, we'll only focus on n-chamfered dodecahedron. Given a natural number ...
13
votes
3answers
483 views

Code Golf Simulated Golf

Given a list of hole yardages, green sizes, a slice angle and a max distance, compute a golf score. Assumptions Earth is flat All greens are circular Slice angle will be between -45 and 45 degrees ...
8
votes
2answers
976 views

Solve a Rubik's Cube

Your challenge is to write a program to solve a 3x3x3 Rubik's Cube. This challenge is based on this one from 2013, rewritten to adhere to current community standards, and reposted with the original ...
14
votes
5answers
317 views

Integer triangles with perimeter less than n

Definition An "integer triangle" is one with integer coordinates. For example the following triangle is an integer triangle: ...
22
votes
3answers
793 views

​L​o​o​p​ ​I​t​

Note: The title of this question should be "Loop It", but because title needs to be at least 15 characters, there are some invisible spaces. This note is such that the challenge can be searched for. ...
4
votes
1answer
280 views

Maximum Area of a Polygon with Vertices of a Polygon [closed]

Rules Given a list of integer coordinates, l, with a length of at least 4, and an integer n such that n is smaller than the length of l (but at least 3), return the largest area of an n-sided polygon ...
6
votes
0answers
181 views

Find the smallest triangle encompassing the specified polygon

Input: An integer N which represents the polygon's vertices and a list of their x and y coordinates. Expected output: The smallest difference possible between the area of the(not necessarily convex) ...
16
votes
2answers
224 views

Program an Uncircularness Score

Your task is to program a mathematical function s, that takes a nonempty finite set A of points in the 2D plane, and outputs an ...
24
votes
2answers
799 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 ...
17
votes
2answers
645 views

Intersection of two triangles

Given 4 points on the 2D planes A, B, C, D, calculate the area of the intersection region of the triangles OAB and ...
28
votes
35answers
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 ...
15
votes
14answers
1k views

Quadrants passed through by a line

Task Given a representation of a line, output the number of quadrants that that line passes through. Valid Representations of a Line You can represent a line as Three signed integers ...
27
votes
14answers
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 ...
14
votes
8answers
587 views

Sum the Vertex Connections

Let's say you have a positive integer N. First, build a regular polygon, that has N vertices, with the distance between neighbouring vertices being 1. Then connect lines from every vertex, to every ...
46
votes
76answers
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 ...
6
votes
2answers
256 views

Fuzzy distances to coordinates

This challenge is similar to my previous one, but has a twist that makes it significantly more difficult. There are n people on a 2D plane. Using distances between them we're going to find their ...
3
votes
2answers
428 views

A Slashy Dashy Spiral [duplicate]

Given a positive integer N, output the innermost N×N square of an ASCII art spiral made of -|/\ that spirals clockwise inward. The ...
14
votes
2answers
237 views

Like a path-segment; touched for the very first time

Given an ordered list of 2 or more 2D cartesian points, output a truthy value if either the path touches itself or self-intersects; otherwise output a falsy value if it does not touch itself or self-...
9
votes
5answers
369 views

Elliptic system

Introduction Given five points in the plane, your task is to compute the area of the ellipse passing through these points. You can assume that exactly one non-degenerate ellipse can be constructed ...
23
votes
6answers
698 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 ...
7
votes
2answers
293 views

Find the Intersections

Let us consider a regular n-sided polygon where all of the sides are equal in length with n being a natural number larger than or equal to three. All of the vertices lie on the unit circle (circle of ...