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
40 votes
13 answers
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: ...
Zgarb's user avatar
  • 42.5k
36 votes
41 answers
5k 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 ...
Fatalize's user avatar
  • 38.5k
3 votes
2 answers
544 views

Evaluate the B-spline basis

B-splines are defined using a set of "knots", "control points", and degree. For the purposes of this challenge, the control points are not needed. The knots are simply a list of strictly increasing ...
helloworld922's user avatar
11 votes
14 answers
2k views

Help me I'm lost in the ocean!

Introduction Today I went fishing alone with my canoe, unfortunately I fell asleep and the stream brought me away, I lost my oars, now it's night and I am lost in the ocean! I can't see the coast so ...
Mario's user avatar
  • 3,091
12 votes
2 answers
500 views

Hexagonal coordinates: Polar to Cartesian

Wikipedia says about Polar Coordinates: In mathematics, the polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a reference ...
DJMcMayhem's user avatar
23 votes
7 answers
880 views

Distance Between Two Points Travelling on a Polar Graph Chart

Brief Problem Explanation Write a program to find the minimum distance between two points traveling only on rays emanating from the origin and circles centered on the origin. Explanation of Premise ...
Ando Bando's user avatar
34 votes
9 answers
3k 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 <...
Geobits's user avatar
  • 19.7k
9 votes
2 answers
527 views

Check if rectangles fill a rectangular space without gaps or overlaps

This challenge is based on another similar challenge. Because finding the most efficient packing of rectangles is NP-hard (that is, its solution is easy to check but hard to find), this challenge is a ...
hyper-neutrino's user avatar
  • 41.4k
31 votes
1 answer
665 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 ...
flawr's user avatar
  • 43.8k
3 votes
0 answers
113 views

Draw an oblique line [duplicate]

Given the width and height of a line in characters, draw it using ascii characters. Input Two integers separated by a space, the first one being the width, the second one being the height. Example: ...
SteeveDroz's user avatar
  • 2,463
10 votes
19 answers
1k views

Maximal number of regions obtained by joining n points around a circle by straight lines

Let's define f(n) as the maximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like ...
Oliver Ni's user avatar
  • 10.6k
15 votes
13 answers
2k views

Find the Centroid of a Polygon

From Wikipedia: The centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1) is the point (Cx, Cy), where and ...
mbomb007's user avatar
  • 23.3k
16 votes
2 answers
337 views

Real Chebyshev Rotation

This is a challenge inspired by Chebyshev Rotation. I suggest looking at answers there to get inspiration for this challenge. Given a point on the plane there is a unique square (a rectangle with ...
orlp's user avatar
  • 39.1k
37 votes
19 answers
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 ...
Martin Ender's user avatar
141 votes
27 answers
24k views

Appease Your Google Overlords: Draw the "G" Logo

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×...
Calvin's Hobbies's user avatar
20 votes
41 answers
9k views

Draw an ASCII Rectangle

Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height. Or, if your language supports it, the two integers can be given as separate inputs. ...
MCMastery's user avatar
  • 813
9 votes
1 answer
427 views

Flexagonal flexagation

Being programmers, watching us flex aren't very interesting. Today we change that! In this challenge you will lex and flex hexaflexagons. About For a video introduction, watch viharts video(s) on ...
BlackCap's user avatar
  • 3,898
24 votes
1 answer
3k views

Solve Grid-Tangram

The Tangram is a dissection puzzle made from seven shapes: Five differently sized triangles, a parallelogram and a square. Given a shape, the goal is recreating the shape using all the pieces and ...
flawr's user avatar
  • 43.8k
17 votes
6 answers
958 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 ...
acrolith's user avatar
  • 3,878
20 votes
14 answers
2k views

My triangle needs more nodes

Consider the standard equilateral triangle, with nodes labeled using barycentric coordinates: We can turn this 3 node triangle into a 6 node triangle by adding a new line of 3 vertices (one more than ...
helloworld922's user avatar
13 votes
4 answers
313 views

Staggered Starts

In races in which racers go around at least one turn of a curved track, the starting positions for each racer are staggered, so that each racer travels the same distance around the track (otherwise, ...
user avatar
24 votes
10 answers
4k 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 ...
Calvin's Hobbies's user avatar
24 votes
5 answers
2k views

Count the rectangles in a diagonal grid

As a follow-up to this challenge, we now want to count the number of rectangles in grid with r rows and c columns where there is a line crossing through every diagonal of a square in the grid. Now, we ...
miles's user avatar
  • 16.9k
112 votes
87 answers
27k 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. ...
insertusernamehere's user avatar
21 votes
2 answers
816 views

Borders of overlapping circles

Given the coordinates of several points on a plane, and the radius of a circle surrounding each point, draw polygons representing the circles and the edges where the circles meet. Straight edges will ...
Rip Leeb's user avatar
  • 1,240
7 votes
0 answers
250 views

Decompose the domain

In scientific computing, it is often desirable to decompose some large domain into smaller "subdomains", then parallelize the computation by performing the work on each subdomain in parallel and the ...
helloworld922's user avatar
17 votes
15 answers
1k views

g​o​l​f​ ​a​t​a​n​2

Sometimes it really is a struggle to convert Cartesian coordinates (x,y) to Polar coordinates (r,phi). While you can calculate <...
flawr's user avatar
  • 43.8k
26 votes
5 answers
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 ...
Bálint's user avatar
  • 1,865
3 votes
0 answers
286 views

Does the triangle contain the origin? [duplicate]

Challenge description On a Cartesian plane, a triangle can be described as a set of three points, each point being one of the triangle's vertices. For instance, coordinates ...
shooqie's user avatar
  • 5,592
34 votes
4 answers
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 ...
Luis Mendo's user avatar
  • 104k
10 votes
11 answers
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 ...
El'endia Starman's user avatar
13 votes
4 answers
4k views

Calculate the Fermat Point of a Triangle

This is somewhat similar to The centers of a triangle, but with a different point. The Fermat Point is the point P in triangle ABC such that the value of AP + BP + CP is minimized. There are two cases:...
soktinpk's user avatar
  • 4,462
34 votes
1 answer
1k 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 ...
trichoplax is on Codidact now's user avatar
-7 votes
18 answers
363 views

Find the remaining side of the tangential quadrilateral

(Taken from https://en.wikipedia.org/wiki/File:Tangential_quadrilateral.svg) A tangential quadrilateral (see example above) is a quadrilateral in which a circle can be inscribed. Your task is to find ...
Leaky Nun's user avatar
  • 49.7k
5 votes
1 answer
320 views

Tiling by substitution

EDIT: The incorrect A rhomb substitution has been fixed. Apologies to anoyone who had started working on a solution. Consider the following substitutions, where the substituted rhomb(us) is scaled up ...
jsh's user avatar
  • 919
3 votes
15 answers
388 views

Counting triangles with integer perimeter

Mary has given John two sticks of lengths a and b respectively, where a and ...
Leaky Nun's user avatar
  • 49.7k
12 votes
3 answers
2k views

Draw a simple cube

We don't have a single challenge about drawing a real 3 dimensional cube, so here it goes: Challenge Your task is to draw a rotated, cube with perspective. It can be in a separate window or as an ...
Bálint's user avatar
  • 1,865
16 votes
1 answer
330 views

Symme-Try This Triangle Trial

A string whose length is a positive triangular number (1, 3, 6, 10, 15...) can be arranged into an "equilateral text triangle" by adding some spaces and newlines (and keeping it in the same reading ...
Calvin's Hobbies's user avatar
8 votes
24 answers
1k views

Form tiles in a rectangular ring

Given the input tilesX and tilesY create a method that would make a rectangular ring from the tiles. The function must order ...
Creative Magic's user avatar
11 votes
3 answers
677 views

Find the area of a polygon

Given consecutive side lengths s1, s2, s3... s_n of an n-gon inscribed in a circle, find its area. You may assume that the polygon exists. In addition, the polygon ...
soktinpk's user avatar
  • 4,462
7 votes
3 answers
541 views

How can I shorten this python code analyzing a 3d grid?

My Python 3 function golf(...) should take a list of lists of lists of strings representing a solid cube and return whether there are any places in which two equal ...
Byte Commander's user avatar
44 votes
9 answers
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 ...
DJMcMayhem's user avatar
5 votes
1 answer
950 views

Need help golfing Python 3 code to calculate volume & surface of spheroids in <150 bytes

I want to write a function golf(C, A) that takes the height (C = 2*c) and the width (A = 2*a)...
Byte Commander's user avatar
21 votes
9 answers
2k views

Rectangle Detection

Write a program or function that takes in a multiline string of 0's and 1's. No other characters will be in the string and the ...
Calvin's Hobbies's user avatar
22 votes
3 answers
980 views

Draw a random hexa-glyph

The above image is called a hexa-glyph. Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class. Here's how you make one: Consider the following set of points, shaped ...
PhiNotPi's user avatar
  • 29k
13 votes
5 answers
275 views

Identify arborally satisfied point sets

An arborally satisfied point set is a 2D set of points such that, for any axis-aligned rectangle that can be formed using two points in the set as opposite corners, that rectangle contains or touches ...
PhiNotPi's user avatar
  • 29k
8 votes
2 answers
586 views

Count rectangle intersections

The Challenge Given an arbitrary amount of rectangles, output the total count of intersections of those when drawn in a 2D plane. An intersection here is defined as a point ...
Denker's user avatar
  • 6,821
16 votes
5 answers
437 views

How far from the exterior?

Take a 2D region of space divided into axis aligned unit square elements with their centers aligned at integer intervals. An edge is said to be internal if it is shared by two elements, otherwise it ...
helloworld922's user avatar
13 votes
4 answers
557 views

Trilaterate your position

Introduction Imagine you are on a two dimensional cartesian plane and want to determine your position on it. You know 3 points on that plane and your distance to each of them. While it is always ...
Denker's user avatar
  • 6,821
39 votes
4 answers
3k 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 context of encryption, I wanted ...
flawr's user avatar
  • 43.8k

1
4
5
6 7 8