Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
18 votes
6 answers
2k views

Matrix Meets ASCII Art

A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is 0. For example, the array ...
user avatar
  • 529
15 votes
7 answers
1k views

Euler characteristic of a binary matrix

A binary matrix represents a shape in the plane. 1 means a unit square at that position. 0 means nothing. The background is <...
user avatar
  • 32.9k
7 votes
5 answers
415 views

Calculate the overlapping line

(l, r) defines a line whose left end is at l and the right end is at r, on a 1-dimensional ...
user avatar
  • 2,121
17 votes
12 answers
2k views

Random Point from a 2D Donut Distribution

A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius <...
user avatar
  • 6,240
10 votes
3 answers
296 views

Coordinates for a Heronian tetrahedron

Did you know that Heronian Tetrahedra Are Lattice Tetrahedra? A Heronian tetrahedron is a tetrahedron where the length of each edge is an integer, the area of each face is an integer, and the volume ...
user avatar
  • 8,097
15 votes
5 answers
420 views

Score a curling end

Curling is a sport where two teams aim to place stones as close to the centre of a target as possible. The winner of a curling end is the team whose stone is closest to the centre – they score as many ...
user avatar
21 votes
4 answers
823 views

Is this hexagon symmetric?

TLDR: This is the hexagonal version of Is this square symmetrical? Given a hexagonal grid, decide if it is symmetric. The shape of the grid is a regular hexagon. Each cell in the grid has two possible ...
user avatar
  • 32.9k
13 votes
6 answers
428 views

AoCG2021 Day 22: Hyperbolic rescue

Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 11. Crossing the bridge, you've barely reached the other side of the stream when you ...
user avatar
  • 85k
14 votes
9 answers
2k views

All distances different on a chessboard

Inspired by this Puzzling SE question: All distances different on a chess board. Introduction Lets define a sequence \$a(n), n\geqslant 1\$ as how many pawns can you put on a \$n \times n\$ chessboard ...
user avatar
  • 10.9k
19 votes
13 answers
2k views

The Area of Rectangles

Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally ...
user avatar
  • 85k
18 votes
4 answers
905 views

Find the sliced sheet of paper

Context : Suppose you have a sheet of paper measuring 8 x 10. You want to cut it exactly in half while maintaining its rectangular shape. You can do this in two ...
user avatar
14 votes
2 answers
489 views

Draw me a shape

The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape. Specs Shapes Each shape has a unique ...
user avatar
  • 27.5k
27 votes
10 answers
5k views

Distances between keys on a QWERTY keyboard

Inspired by this video by Matt Parker The distances between the letter keys of a QWERTY keyboard are somewhat standardised. The keys are square and both the horizontal and vertical spacing are 19.05mm ...
user avatar
  • 18.7k
16 votes
1 answer
331 views

Build the widest unsupported bridge with nothing but frictionless blocks

In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is ...
user avatar
  • 38.7k
10 votes
3 answers
262 views

Minkowski sum of two convex polygons

Background Minkowski addition is a binary operation on two sets of points (usually geometric objects) in the Euclidean space. The Minkowski sum of two sets \$A\$ and \$B\$ is formally defined as ...
user avatar
  • 62.1k
3 votes
8 answers
885 views

Are vertices in a clockwise order?

Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input ...
user avatar
21 votes
18 answers
4k views

Convince me Gabriel's Horn is possible

From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took ...
user avatar
19 votes
2 answers
519 views

Determine Circles

Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given? Task Your ...
user avatar
  • 1,367
15 votes
2 answers
384 views

Connecting the Dots: Counting n²-gons in the n×n Grid

The recent volume of MAA's Mathematics Magazine had an article "Connecting the Dots: Maximal Polygons on a Square Grid" by Sam Chow, Ayla Gafni, and Paul Gafni about making (very convex) \$n^...
user avatar
  • 8,097
33 votes
3 answers
1k views

Placing circles along a square spiral

In this code golf challenge, you'll be computing the placement of circles of areas \$\pi, 2\pi, 3\pi, \dots\$ when greedily placed along integer points in a square spiral in such a way that no two ...
user avatar
  • 8,097
13 votes
8 answers
1k views

Count the number of possible squares [duplicate]

In a 9 by 9 grid some points have been marked. The task is it to make a program that counts all distinct squares that can be made using four marked points. Note that squares can also be placed ...
user avatar
  • 1,119
8 votes
8 answers
561 views

Coordinate Connecting

Input: Ten unique integer coordinates, between (0,0) and (100,100). Output: The coordinates arranged in the order/an order such ...
user avatar
  • 1,184
14 votes
8 answers
2k views

Is my triangle on the lattice?

Write a program or function which takes three positive integers \$a, b, c\$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose ...
user avatar
  • 407
20 votes
5 answers
788 views

The Caged Circles

This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$. Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\...
user avatar
  • 8,097
12 votes
5 answers
644 views

Ellipsoid surface area

Related: Ellipse circumference Introduction An ellipsoid (Wikipedia / MathWorld) is a 3D object analogous to an ellipse on 2D. Its shape is defined by three principal semi-axes \$a,b,c\$: $$ \frac{x^2}...
user avatar
  • 62.1k
29 votes
2 answers
1k views

Golf the smallest sphere!

Inspired by this challenge, as well as a problem I've been working on Problem: Given a non-empty set of points in 3D space, find the diameter of the smallest sphere ...
user avatar
  • 361
1 vote
2 answers
162 views

Triangulating Angles [closed]

Prompt: You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being ...
user avatar
17 votes
20 answers
2k views

Find distance between the closest 3D points

Your task is to take \$n \ge 2\$ points in 3D space, represented as 3 floating point values, and output the Euclidean distance between the two closest points. For example $$A = (0, 0, 0) \\ B = (1, 1, ...
user avatar
  • 387
16 votes
14 answers
1k views

Centerless Polygons

A centered polygonal number is a positive integer given by the number of vertices when a point is surrounded by (increasingly larger) polygons with the same number of sides, as shown below. For ...
user avatar
  • 8,097
16 votes
1 answer
363 views

Gluing tetrahedra together

(This challenge exists to extend sequence A276272 in the On-Line Encyclopedia of Integer Sequences, and perhaps create a new OEIS sequence1.) This is a code-challenge, which will have you write code ...
user avatar
  • 8,097
15 votes
1 answer
278 views

Polygons in a cube

Inspired in part by this Mathologer video on gorgeous visual "shrink" proofs, and my general interest in the topic, this challenge will have you count regular polygons with integer ...
user avatar
  • 8,097
16 votes
12 answers
1k views

Rectangles in rectangles

This code-golf challenge will give you two positive integers n and k as inputs and have you count the number of rectangles with ...
user avatar
  • 8,097
18 votes
5 answers
525 views

Triangles with rational side lengths

This challenge will have give you a positive integer \$n\$ and ask you to output \$t(n)\$, the number of triangles (up to congruence) satisfying the three conditions: The triangles have perimeter of ...
user avatar
  • 8,097
30 votes
24 answers
3k views

Circumference of an ellipse

Challenge Unlike the circumference of a circle (which is as simple as \$2\pi r\$), the circumference of an ellipse is hard. Given the semi-major axis \$a\$ and semi-minor axis \$b\$ of an ellipse (see ...
user avatar
  • 62.1k
22 votes
2 answers
883 views

Cut a triangle into equal-sized parts!

Similar in spirit to Number of distinct tilings of an n X n square with free n-polyominoes and Partition a square grid into parts of equal area, this challenge will have you count ways of partitioning ...
user avatar
  • 8,097
17 votes
13 answers
2k views

Is it in the polygon?

The challenge Given point and a path of points, say whether or not the point is in the polygon that is created by the path. Also return true if the point is on an ...
user avatar
  • 1,388
12 votes
4 answers
240 views

Is it a uniform polyhedron?

Objective Given a vertex figure consisting of regular convex polygons, determine whether it represents a convex uniform polyhedron. What is a uniform polyhedron? A uniform polyhedron is a polyhedron ...
user avatar
  • 4,163
16 votes
7 answers
1k views

Counting painted sides of cubic shapes

Sandbox Many of us have seen math problems where a shape made of unit cubes is dipped in paint, and the answer is the number of painted sides. We'll generalize that problem in this challenge. Input A ...
user avatar
16 votes
19 answers
2k views

Are they collinear?

Task Write a program/function that when given three 2d points in cartesian coordinates as input outputs a truthy value if they are collinear otherwise a falsey value Three points are said to be ...
user avatar
  • 6,449
5 votes
5 answers
330 views

Divide into 2 isosceles triangles

Given the measures of two of the interior angles of a triangle (x and y; the other angle can be easily calculated with ...
user avatar
2 votes
2 answers
194 views

Create a text image by manual automation

Challenge Premise It's 2006, and Alice is trying to send Bob their her completed notes on their newly ended expeditions into the labyrinthine school library, which the two of them found suffers from a ...
user avatar
12 votes
3 answers
284 views

Friendly Incenters

The incenter of a triangle is the intersection of the triangle's angle bisectors. This is somewhat complicated, but the coordinate formula for incenter is pretty simple (reference). The specifics of ...
user avatar
  • 15.9k
15 votes
7 answers
987 views

Draw the "{🏅} CODE GOLF & coding challenges" logo!

Wow, time really flies! It's already been one year since the debut of the Code Golf Stack Exchange site design. Let's celebrate this milestone with a code golf challenge... to imitate the site logo! ...
user avatar
  • 7,781
12 votes
14 answers
1k views

Calculate the vector component

Challenge Assume two vectors \$\mathbf{a} = (a_1,a_2,\cdots,a_n)\$ and \$\mathbf{b} = (b_1,b_2,\cdots,b_n)\$ are given in an \$n\$-dimensional space, where at least one of \$b_1,\cdots,b_n\$ is ...
user avatar
  • 62.1k
13 votes
7 answers
2k views

Who Took My Toilet Paper?

You step into the restroom, and notice that the toilet paper has missing! It occurs to you that someone had stolen it. Strangely enough, the first thing you would like to know is the amount of toilet ...
user avatar
12 votes
1 answer
341 views

Leon's shooting range problem

Leon's story Leon is a professional sling shooter and he comes to a shooting range everyday to practice. A casual target is not a challenge for him anymore so before shooting he first covers the ...
user avatar
  • 740
10 votes
5 answers
486 views

Is this a cube?

This challenge is a riff on Dion's challenge "Is this a rectangle?". The goal of this challenge is to write a program to decide whether or not some collection of tuples of integers represents a ...
user avatar
  • 8,097
18 votes
1 answer
412 views

Rubik's Snakes! (Part 1)

The Rubik's Snake (or Rubik's Twist) is a toy consisting of several triangular prisms strung together in a line in such a way that the pieces can be rotated about one another in 90 degree turns. Any ...
user avatar
11 votes
3 answers
512 views

Triangles in a tetrahedron

The goal of this challenge is to extend the OEIS sequence A334581. Number of ways to choose \$3\$ points that form an equilateral triangle from the \$\binom{n+2}{3}\$ points in a regular tetrahedral ...
user avatar
  • 8,097
11 votes
1 answer
219 views

Counting hypercube Tetris pieces

Consider the Tetris pieces, but made out of some number of (hyper)cubes instead of four squares, where two blocks are considered the same if one is a rotation, reflection, or translation of another. ...
user avatar
  • 8,097

1
2 3 4 5
7