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
22 votes
3 answers

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 ...
dan04's user avatar
  • 6,581
65 votes
16 answers

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: ...
A.L's user avatar
  • 1,288
14 votes
8 answers

Almost Equilaterial Heronian Triangles

An Almost Equilateral Heronian Triangle is a triangle with integer lengths of the form n-1, n, and ...
Kyle Kanos's user avatar
  • 4,342
25 votes
29 answers

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 ...
Taconut's user avatar
  • 903
23 votes
6 answers

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 ...
Niklas B.'s user avatar
  • 477
2 votes
5 answers

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 ...
Mohammad's user avatar
  • 2,018
29 votes
6 answers

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 ...
ST3's user avatar
  • 1,369
12 votes
1 answer

Find number of rectangles in a 2D byte array

microbian's user avatar
  • 2,287
4 votes
3 answers

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 ...
jzx's user avatar
  • 143
16 votes
8 answers

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 ...
Kendall Frey's user avatar
  • 2,473
8 votes
5 answers

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 ...
user avatar
11 votes
10 answers

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 ...
Doorknob's user avatar
  • 71.4k
13 votes
3 answers

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: ...
Volatility's user avatar
  • 3,364
12 votes
7 answers

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 ...
Kaya's user avatar
  • 720
23 votes
5 answers

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 ...
Dr. belisarius's user avatar
18 votes
3 answers

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 ...
beary605's user avatar
  • 4,310
14 votes
4 answers

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 ...
user avatar
12 votes
3 answers

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 ...
Wug's user avatar
  • 1,687
7 votes
3 answers

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 ...
beary605's user avatar
  • 4,310
12 votes
3 answers

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 ...
user avatar
21 votes
4 answers

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 ...
Keith Randall's user avatar
8 votes
8 answers

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. ...
fR0DDY's user avatar
  • 4,579
16 votes
25 answers

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). ...
Dr. belisarius's user avatar
5 votes
1 answer

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 ...
Ming-Tang's user avatar
  • 5,949
8 votes
2 answers

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 ...
kuszi's user avatar
  • 183
8 votes
2 answers

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). ...
Timwi's user avatar
  • 12.9k
39 votes
21 answers

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 ...
Dan McGrath's user avatar
  • 1,007

4 5 6 7