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
10
votes
0answers
213 views
+50

Counting symmetric grid chains

Notation and definitions Let \$[n] = \{1, 2, ..., n\}\$ denote the set of the first \$n\$ positive integers. A polygonal chain is a collection of connected line segments. The corner set of a ...
4
votes
2answers
32 views

Area of diagonal-folded regular polygon

I have a piece of paper whose shape is a regular n-gon with side length 1. Then I fold it through some of its diagonals. What is ...
19
votes
9answers
2k views

Does this line pass through that square?

Divide the first quadrant (including the positive x-axis, the positive y-axis, and the origin) into 1x1 grids, with each grid labelled by the coordinates of its bottom-left corner, as demonstrated ...
13
votes
12answers
1k views

Is it rectilinear?

Today's challenge: Given an ordered list of at least 3 unique integer 2D points forming a polygon, determine if the resulting polygon is Rectilinear. A polygon is rectilinear if every interior ...
24
votes
8answers
4k views

Billiard balls collision

Given the 2-dimensional positions and velocities of a pair of billiard balls right before impact, calculate their velocities after a perfectly elastic collision. The balls are assumed to be ideal ...
12
votes
2answers
547 views

Counting generalized polyominoes

This challenge will have you count pseudo-polyforms on the snub square tiling. I think that this sequence does not yet exist on the OEIS, so this challenge exists to compute as many terms as possible ...
18
votes
8answers
810 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 ...
26
votes
11answers
1k views

Triangular Manhattan Distance

The Manhattan distance on a regular grid is the number of orthogonal steps one needs to take to reach one cell from another. Orthogonal steps are those that go through the edges of the grid cells (as ...
1
vote
0answers
131 views

Rotated analog clock [closed]

Given: a 12 hour time t in hours and minutes, a rotation r in degrees, return the time shown when an analog clock that is ...
17
votes
10answers
1k views

Write a function that returns an iterable object of all valid points 4-directionally adjacent to (x, y)

A very common need in algorithms classes and computer science in general is to iterate 4-directionally over a grid or matrix (such as in BFS or DFS). This seems to often result in a lot of clunky and ...
31
votes
21answers
6k views

Random point on a sphere

The Challenge Write a program or function that takes no input and outputs a vector of length \$1\$ in a theoretically uniform random direction. This is equivalent to a random point on the sphere ...
107
votes
79answers
23k 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. ...
22
votes
24answers
4k views

Count the number of triangles

Given a list of positive integers, find the number of triangles we can form such that their side lengths are represented by three distinct entries of the input list. (Inspiration comes from CR.) ...
11
votes
11answers
2k views

Do these squares overlap?

Given the coordinates of the upper left corners of two squares and their side lengths, determine whether the squares overlap. A square includes the top and left lines, but not the bottom and right ...
36
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 ...
9
votes
2answers
375 views

​Plane​ ​Blow​up​

The Blow-up is a powerful tool in algebraic geometry. It allows the removal of singularities from algebraic sets while preserving the rest of their structure. If you're not familiar with any of that ...
34
votes
15answers
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 ...
5
votes
6answers
565 views

The Knight's estate

And then the King said: You fought bravely, Knight, and your deed will not be forgotten for centuries. For your valor I grant you this castle and the lands around it. Things rush me, and I can not ...
14
votes
12answers
1k views

Circle intersection area

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

Construct a pentagon avoiding compass use

Rules You will start with only two elements: Points \$A\$ and \$B\$ such that \$A \neq B\$. These points occupy a plane that is infinite in all directions. At any step in the process you may do any ...
18
votes
7answers
1k views

Count the squares

Challenge Origami (folding paper) is a creative form of art. As far as I know, master of Origami prefers square paper. Let's start from beginning - convert a rectangular paper to a square one. So ...
24
votes
7answers
821 views

Expand a hexagon

Given an ASCII art hexagon as input, output one whose sides are all one unit longer. ...
29
votes
7answers
7k views

Golf the smallest circle!

The problem: Given a non-empty set of points in the Cartesian plane, find the smallest circle that encloses them all (Wikipedia link). This problem is trivial if the number of points is three or ...
35
votes
41answers
4k 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 ...
11
votes
6answers
1k views

Area of a 2D convex hull

You are given an array/list/vector of pairs of integers representing cartesian coordinates \$(x, y)\$ of points on a 2D Euclidean plane; all coordinates are between \$−10^4\$ and \$10^4\$, duplicates ...
8
votes
1answer
272 views

Partition and Restructure

Given two contiguous shapes of the same area, determine the optimal way to divide the first shape into a minimum number of contiguous segments such that they can be rearranged to form the second shape....
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 ...
14
votes
16answers
632 views

Dihedral group D4 composition with custom labels

The dihedral group \$D_4\$ is the symmetry group of the square, that is the moves that transform a square to itself via rotations and reflections. It consists of 8 elements: rotations by 0, 90, 180, ...
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 ...
170
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 <...
20
votes
4answers
368 views

Rectangular difference

In this challenge, you are given two overlapping rectangles, and you need to calculate the rectangles created by removing one from the other. For example, if you remove the red rectangle from the ...
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 ...
6
votes
1answer
272 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 ...
25
votes
4answers
604 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 ...
8
votes
2answers
343 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. ...
40
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 ...
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]...
15
votes
17answers
1k views

Code-Golf: Lattice Points inside a Circle

The following picture shows the problem: Write a function that, given an integer as the circle radius, calculates the number of lattice points inside the centered circle (including the boundary). ...
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 ...
47
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 ...
17
votes
6answers
850 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 ...
10
votes
15answers
2k 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 ...
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 ...
8
votes
1answer
285 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
405 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 ...
36
votes
18answers
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 ...
3
votes
0answers
1k 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 ...
22
votes
10answers
3k views

Is this square symmetrical?

Write a program or function that takes in a 4×4 text grid consisting of exactly 4 A's, 4 B's, 4 ...
17
votes
14answers
936 views

Find the reference angle

This is a fairly simple question. According to this random website I found — Web Archive, a reference angle is ...