# Questions tagged [geometry]

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

377 questions
Filter by
Sorted by
Tagged with
1k views

### The Star-Spangled Code Challenge

The flag of the United States of America contains, in its canton, 50 stars, representing the 50 states. In the past, when there were fewer states, there were of course fewer stars, and they were ...
• 6,581
11k views

### Draw the € sign

The goal is to output or display an image with an € (euro) sign according to the following specs (ignoring the border of the sign). Source: http://en.wikipedia.org/wiki/File:Euro_Construction.svg ...
• 1,288
978 views

### Almost Equilaterial Heronian Triangles

An Almost Equilateral Heronian Triangle is a triangle with integer lengths of the form n-1, n, and ...
• 4,342
10k views

### Draw a regular polygon

The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex). The number of sides and the radius can be ...
• 903
2k views

### Circles dividing the plane

Task You will be given a set of circles in the plane with their centers on the line y=0. It is guaranteed that no pair of circles has more than one common point. Your task is to determine into how ...
• 477
351 views

### Let's learn geometry

Today our lesson is about rectangles and triangles. you will be given as an input an n x n grid that is based on two characters ...
• 2,018
9k 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 ...
• 1,369
1k views

...
• 2,287
1k views

### Thinking inside the circle

In as few characters of code as you can, create an algorithm which will pack the least number of rectangles necessary to completely fill a rasterized circle with integer radius r and return the ...
• 143
1k views

### Thinking outside the box

You are trying to fit a sphere into a 5-sided box, but sometimes it does not fit completely. Write a function to calculate how much of the sphere is outside (above the rim of) the box. There are 3 ...
• 2,473
407 views

### Golfing: How many unit-length squares in a list of 2d coordinates?

Given a list of 2d (x, y) coordinates, determine how many unit squares (edge length 1 unit) can be formed using the coordinates. Input will be an array of 0 or more pairs of coordinates: e.g. in ...
2k views

### Generate a right triangle

In this challenge, you must take two numbers (separated by a space) as input and output an ASCII right triangle, made up of xs. The first number will be the width ...
• 71.4k
1k views

### The centers of a triangle

Circles and squares have a single, definite center point. However, the notion of the center of a triangle has long been discussed. Four different centers were known to the Ancient Greeks: Incenter: ...
• 3,364
1k views

### Number of holes in a polygon

The Problem: Count the number of holes in a connected polygon. Connectivity of the polygon is guaranteed by the condition that every triangle in the input triangulation shares at least 1 side with ...
• 720
5k views

### Find the Convex Hull of a set of 2D points

When you hammer a set of nails into a wooden board and wrap a rubber band around them, you get a Convex Hull. Your mission, should you decide to accept it, is to find the Convex Hull of a given set ...
• 5,515
60k views

### Polygon prefixes

Polygons are named after the number of sides that they have. A pentagon has 5 sides, an octagon has 8 sides. But how are they named? What's the name for a 248-sided polygon? All polygons are suffixed ...
• 4,310
6k views

### Drawing 3d nets - Platonic solids

This is a basic version of the rather more difficult Drawing 3d nets - Archimedean solids . I have a weakness for 3d nets which when cut out and folded allow you to make 3d shapes out of paper or ...
438 views

### Regions of regular polygons

Given a regular N-gon with all diagonals drawn, how many regions do the diagonals form? For example, a regular triangle has exactly 1, a square has exactly 4, pentagon has exactly 11, and a hexagon ...
• 1,687
319 views

### Line through Polygon

Input: A line of the standard slope-and-intercept form: mx+b, as well as a set of Cartesian points determining the vertices of a polygon. Assume that the x and y ...
• 4,310
2k views

### Solving triangles with trigonometry

Time to dig up your old trigonometry notes from high school! The challenge is to solve the unknown sides and angles of different triangles. And as is customary in code golf, the smallest working code ...
2k views

### Determine if a polygon is convex

Write a program to determine if the input polygon is convex. The polygon is specified with one line containing N, the number of vertices, then N lines containing the x and y coordinates of each ...
• 20.8k
645 views

### Intersection of Two Lines

Given equation of two lines in the format Ax+By=C, determine their intersection point. If they are parallel print 'parallel' without quotes. For input/output format refer sample input/output. ...
• 4,579
2k 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). ...
• 5,515
147 views

### Squares in Movement Range

There are two inputs, the first input is a map in 2D array, where 2 represents an obstacle and 0 represents a regular ground, and 1 represents the player's location (implies that the player is ...
• 5,949
682 views

### Simple Geometric problem

This problem (see below) has been given as a High School Programming League code golf challenge. The shortest codes submitted during the contest were: 177 bytes in Ruby, 212 bytes in Python 2.5, 265 ...
• 183
800 views

### Turn 2D boolean array into (rectilinear) polygons

Challenge Write a program which, given a 2-dimensional boolean array (equivalently, a monochromatic bitmap), outputs a series of polygons that describe the outline of the region that is “true” (1). ...
• 12.9k
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 ...
• 1,007