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
25 votes
2 answers
1k 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 ...
Wheat Wizard's user avatar
  • 97.6k
20 votes
2 answers
790 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 ...
DELETE_ME's user avatar
  • 17.3k
29 votes
38 answers
4k 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 ...
FlipTack's user avatar
  • 14.6k
15 votes
14 answers
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 ...
Esolanging Fruit's user avatar
27 votes
14 answers
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 ...
AdmBorkBork's user avatar
  • 43.3k
14 votes
8 answers
640 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 ...
Ian H.'s user avatar
  • 2,926
50 votes
81 answers
10k 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 positive ...
mdahmoune's user avatar
  • 2,862
6 votes
2 answers
289 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 ...
orlp's user avatar
  • 39.1k
2 votes
2 answers
470 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 ...
Calvin's Hobbies's user avatar
14 votes
2 answers
276 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-...
Digital Trauma's user avatar
11 votes
5 answers
457 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 ...
Ethan Ward's user avatar
28 votes
7 answers
1k 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 ...
orlp's user avatar
  • 39.1k
7 votes
2 answers
381 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 ...
Fixed Point's user avatar
15 votes
17 answers
5k views

Sort the points by linear distance in a 3D space

Specs You have a cubic 3D space x,y,z of size S integer units, such as 0 <= x,y,z <= S...
Mario's user avatar
  • 3,091
22 votes
30 answers
2k views

Calculate the area of a regular polygon

Task Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, ...
Zach Gates's user avatar
  • 6,660
43 votes
44 answers
5k 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 ...
DJMcMayhem's user avatar
21 votes
4 answers
492 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 ...
Nathan Merrill's user avatar
31 votes
26 answers
3k 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 ...
xnor's user avatar
  • 144k
30 votes
4 answers
796 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 ...
Wheat Wizard's user avatar
  • 97.6k
19 votes
9 answers
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 ...
Leaky Nun's user avatar
  • 49.7k
21 votes
4 answers
2k views

Classify Quadrilaterals | Help me with my math exam!

Help! My math exam is coming up soon and I didn't study! 1 Part of the exam is to classify a quadrilateral given its vertex coordinates, which I, unfortunately, do not know how to do. 2 So, your ...
hyper-neutrino's user avatar
  • 41.4k
6 votes
3 answers
424 views

Help me sort out my desktop windows!

It's really frustrating when I'm working and I have a ton of windows open that are completely or partially hidden behind other windows. To make things worse, I'm still using two 1024x768 monitors. ...
Govind Parmar's user avatar
14 votes
3 answers
1k views

Draw an ASCII cuboid

Given three integers >= 2, create an ASCII cube in an orthogonal (cabinet) projection. The three integers represent height, width and depth (measured in visible characters) including the corners. The ...
NiklasJ's user avatar
  • 241
21 votes
19 answers
4k 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 ...
JAD's user avatar
  • 2,984
0 votes
1 answer
1k views

Menger Sponge Generator [duplicate]

Challenge My challenge, is for you to generate a Menger Sponge based on the level/iteration given. You need to draw it in ...
Noah Cristino's user avatar
28 votes
20 answers
5k 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 ...
darrylyeo's user avatar
  • 7,887
1 vote
0 answers
140 views

Puzzle & Golf : Reproduce this gif [closed]

The objective of this programming puzzle is to reproduce the following gif. Simplification: If you notice the geometric figures don't exactly touch each other. I think it's simpler if you make each ...
An old man in the sea.'s user avatar
2 votes
0 answers
109 views

Can those squares form an imperfect square [duplicate]

Given a non-empty array of positive integers, determine if it is possible to take squares with side lengths specified by each integer, and arrange them in space such that they form a square. The ...
Roman Gräf's user avatar
  • 3,059
3 votes
1 answer
217 views

ASCII Arc Length: How long is a piece of string?

Given an ASCII representation of a piece of string, determine its length. Input An multi-line ASCII rendering of a piece of string, which runs from top to bottom, with one 'node' (corner) on each ...
VisualMelon's user avatar
  • 3,878
25 votes
1 answer
2k views

Flatten the CUBE

Do you ever look at 3D shapes and think that we have 2 many dimensions. So let's make 3D into 1D! (See what I did there?) Task Given a 2D representation of a cube (layout below), flatten it into a ...
caird coinheringaahin g's user avatar
18 votes
16 answers
965 views

What are my dimensions?

Task: Given the area of a triangle, find a Heronian triangle with that area. Any Heronian triangle with the specified area is allowed. A Heronian triangle is a triangle with integer sides and integer ...
Neil A.'s user avatar
  • 2,106
28 votes
15 answers
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: ...
sporkl's user avatar
  • 6,824
21 votes
7 answers
2k views

Hexagonal Triangles!

Your task: make a hexagonal triangle with side length n, where n is a positive whole number or 0. First, let me define a ...
sporkl's user avatar
  • 6,824
-3 votes
13 answers
230 views

Finding the center point between two points on a plane

Challenge: To take two points on the plane and figure out the position of the point that's a) on the line that connects them, and b) equally distant from each of the original points. Example: ...
Caleb Kleveter's user avatar
3 votes
9 answers
515 views

Embedded Triangles!

Your task: given an integer n, output an embedded triangle to the nth depth. Standard methods of input and output, input in any ...
sporkl's user avatar
  • 6,824
19 votes
2 answers
316 views

Fold Some Towels!

I heard somewhere that one thing that technology cannot do yet is fold towels1. So it is now your job to prove that statement false! Given a string as input, made up of rectangles (towels), like the ...
sporkl's user avatar
  • 6,824
27 votes
11 answers
2k 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 ...
Martin Ender's user avatar
-2 votes
5 answers
222 views

No Singles Allowed [closed]

This is a fairly simple challenge. Write a program that computes the distance between two points on a 2D plane. However, you can't use any functions or operators (referred to here as symbols) that ...
Feathercrown's user avatar
19 votes
2 answers
2k views

Schläfli Convex Regular Polytope Interpreter

Background The Schläfli Symbol is a notation of the form {p,q,r,...} that defines regular polytopes and tessellations. The Schläfli symbol is a recursive description, starting with a p-sided regular ...
Tony Ruth's user avatar
  • 761
8 votes
1 answer
403 views

Tiling the unit square

Background By expanding and cancelling terms, it is easy to show the following identity: However, it is an open problem whether all 1/n-by-1/(n+1) rectangles can tile the unit square. The Task Your ...
user1502040's user avatar
  • 3,744
19 votes
8 answers
4k views

How Many Holes?

Challenge Given a graphical input of a shape, determine how many holes there are in it. Not Duplicate This question was marked as a possible duplicate of Count Islands. I believe this challenge is ...
hyper-neutrino's user avatar
  • 41.4k
13 votes
3 answers
654 views

Grids can be curvy. How long is yours?

Consider depicting a simple, open, two-dimensional curve on a W wide by H high grid of text where X represents part of the curve and ...
Calvin's Hobbies's user avatar
23 votes
10 answers
2k views

Two-Coloring Overlapping Circles

Write a program or function that takes in the following input in a reasonable format of your choice: Two positive integers W and H that define the width and height of the image you'll be generating. ...
Calvin's Hobbies's user avatar
14 votes
1 answer
743 views

Average distance of two points in unit n-dimensional hypercube

An easy way to understand the unit n-dimensional hypercube is to consider the region of space in n dimensions that you can get if every coordinate component lies in [0, 1]. So for one dimension it's ...
orlp's user avatar
  • 39.1k
23 votes
11 answers
1k views

Counting unit squares circle passes through

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a ...
orlp's user avatar
  • 39.1k
5 votes
3 answers
268 views

Contiguous Block Count

Count the number of contiguous blocks within a given 3D input. Input The input will consist of one or more rectangles of characters separated by blank lines. Each rectangle represents a cross ...
Gareth's user avatar
  • 11.3k
28 votes
25 answers
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: ...
anna328p's user avatar
  • 6,348
19 votes
6 answers
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 ...
Keyu Gan's user avatar
  • 2,153
43 votes
6 answers
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 ...
flawr's user avatar
  • 43.8k
18 votes
4 answers
531 views

Let's Tessellate!

Introduction From Wikipedia: A tessellation of a flat surface is the tiling of a plane using one or more geometric shapes, called tiles, with no overlaps and no gaps. A fairly well known ...
Andrew Li's user avatar
  • 1,071

1 2 3
4
5
8