Skip to main content

Questions tagged [fractal]

Fractals are shapes that are self-similar and are usually quite detailed. Well-known fractal sets include the Mandelbrot set, Julia sets, and Phoenix sets. Tree-like fractal drawings are also common.

Filter by
Sorted by
Tagged with
19 votes
5 answers
3k views

Draw a Fibonacci Swoosh

Title courtesy of Greg Martin For this challenge, I'll define an arc of size \$k\$ as a single piece of a sine wave with a length of \$k\$ units and an height of \$\frac{k}{4}\$ units: And I'll ...
emanresu A's user avatar
  • 44.2k
17 votes
22 answers
2k views

Compute this fractal matrix

The unique-disjointness matrix ( UDISJ(n) ) is a matrix on all pairs of subsets of {1...,n} with entries $$ U_{(A,B)}=\begin{cases} 0, ~ if ~ |A\cap B|=1\\ 1, ~ ...
bsoelch's user avatar
  • 6,035
16 votes
4 answers
1k views

Create a triangle whose colors are determined by the bitsums of coordinates

Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows. We may give the triangle barycentric coordinates so ...
Akiva Weinberger's user avatar
17 votes
11 answers
3k views

Fibonacci word fractal

The Fibonacci word is a sequence of binary strings defined as: \$F_0 = \$ 0 \$F_1 = \$ 01 \$F_n = F_{n-1} F_{n-2}\$ The first ...
alephalpha's user avatar
19 votes
6 answers
1k views

Draw this fractal generated by applying Newton's method to cosh(x) - 1

I came across this picture the other day: (Credit to Josep M Batlle I Ferrer) Your job is to generate this picture. This graph is generated by repeatedly applying newton's method to the graph of: $$f(...
mousetail 'he-him''s user avatar
23 votes
12 answers
2k views

Quicksand (piles)

In this fastest-code challenge, you take a positive integer as input, which represents the height of a sand pile, located at (0,0) on an infinite square grid. For example, if our input is ...
AnttiP's user avatar
  • 7,918
15 votes
7 answers
602 views

Double the diagonal squares

Given a positive integer N, output this doubling pattern of slash squares/rectangles. For N=1, the base is: ...
emanresu A's user avatar
  • 44.2k
22 votes
9 answers
1k views

Unicode T-square

Challenge Create a function or program that, when given an integer size, behaves the following way: If size is equal to 1, ...
zdimension's user avatar
23 votes
2 answers
2k views

Eye test - How many squares are in this picture?

The picture: Sick of the same old grid where the answer is simply a square pyramidal number? Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are ...
Domenico's user avatar
  • 2,333
23 votes
15 answers
3k views

The Cantor Function

The Cantor function is continuous everywhere and constant almost everywhere, but has an average slope of 1: The function can be found recursively: \$f_0(x)=x\$ \$f_{n+1}(x)=\left\{\begin{matrix}\frac{...
golf69's user avatar
  • 2,059
7 votes
1 answer
649 views

Hilbertize an image

For a computer vision app I want to do a mapping of an image, in such a way that every pixel fit hilbert curve, instead of conventional layout. So task could be as follows: Task description Given ...
xakepp35's user avatar
  • 313
10 votes
4 answers
1k views

ASCII art H trees

An H tree is a fractal tree structure that starts with a line. In each iteration, T branches are added to all endpoints. In this challenge, you have to create an ASCII representation of every second H ...
nwellnhof's user avatar
  • 10.6k
16 votes
9 answers
3k views

Drawing the Peano curve

Introduction In geometry, the Peano curve is the first example of a space-filling curve to be discovered, by Giuseppe Peano in 1890. Peano's curve is a surjective, continuous function from the unit ...
Peiffap's user avatar
  • 287
17 votes
12 answers
631 views

Generalized Cantor set segment lengths

Problem Let's define a generalized Cantor set by iteratively deleting some rational length segments from the middle of all intervals that haven't yet been deleted, starting from a single continuous ...
Angs's user avatar
  • 4,987
81 votes
30 answers
13k views

Create an "H" from smaller "H"s

Challenge Create a function or program that, when given an integer size, does the following: If size is equal to 1, output ...
Bazinga_9000's user avatar
2 votes
1 answer
1k views

Make a 2d menger sponge [duplicate]

A menger sponge is a fractal made out of cubes within cubes within cubes... If you start with a cube, on each face there are 9 squares. The middle square becomes empty (or 0). The other 8 squares ...
johnpyp's user avatar
  • 131
30 votes
14 answers
3k views

Generate TeX to typeset Sierpinski Triangle Fractal

Challenge Write code that outputs TeX (LaTeX) math-equation code (given below) that will typeset Sierpinski Triangle Fractal of 5 levels. Shortest code wins. Details TeX (and friends like LaTeX, ...
Vitaliy Kaurov's user avatar
22 votes
24 answers
4k views

Fractal Cathedral

Given a positive integer n >= 1, output the first n rows of the following structure: ...
hyperneutrino's user avatar
  • 42.6k
21 votes
7 answers
1k views

The strange attraction of the logistic map

The purpose of the challenge is to approximately plot the attractor of the logistic map as a function of its parameter r (also called bifurcation diagram), or a subregion of it. The appearance of the ...
Luis Mendo's user avatar
  • 105k
28 votes
5 answers
1k views

The Image of the Dragon

I saw a cool gif of the twin dragon curve made from a square, and wondered what would happen if we started from another base image. So I wrote a program to do this.                                    ...
Wheat Wizard's user avatar
  • 100k
18 votes
1 answer
477 views

Make Some Snow!

Your task: generate a Koch snowflake to the nth depth. You do not need to make a complete Koch snowflake, just one side of the starting triangle. Wikipedia on Koch flakes: https://en.wikipedia.org/...
sporkl's user avatar
  • 6,924
26 votes
7 answers
832 views

ASCII Cayley Graph

While doing some research for a different challenge I'm formulating, I came across a Cayley graph, specifically this one. Since I'm one of the top ascii-art challenge writers, of course I had to make ...
AdmBorkBork's user avatar
  • 43.5k
20 votes
9 answers
2k views

Is it within the Cantor set?

The Challenge For this challenge, you are supposed to determine if a given number is in the Cantor set. So first, let's define the Cantor set. First, start with the numbers between 0 and 1. Any ...
TheNumberOne's user avatar
  • 11.6k
26 votes
11 answers
725 views

Binary tree fractal

Today's challenge is to draw a binary tree as beautiful ascii-art like this example: ...
DJMcMayhem's user avatar
  • 59.6k
34 votes
6 answers
1k views

Generate a Padovan Spiral

Introduction Similar to the Fibonacci Sequence, the Padovan Sequence (OEIS A000931) is a sequence of numbers that is produced by adding previous terms in the sequence. The initial values are defined ...
Andrew Li's user avatar
  • 1,071
24 votes
1 answer
397 views

It's factors all the way down!

This challenge is inspired by this fantastic animated diagram (thanks to flawr for posting it in chat). Given an input n, draw all of its prime factors as nested ...
Sherlock9's user avatar
  • 12.3k
26 votes
2 answers
1k views

ASCII Hilbert Curve

Given an integer n output the nth iteration of the Hilbert Curve in ASCII using the characters ...
Bobas_Pett's user avatar
  • 1,035
29 votes
2 answers
965 views

Hilbertify an image

I like the Hilbert Curve. Your task for this challenge is to take an image (strictly a square image where all the sides are a power of two pixels wide) and unravel it line by line in a zig-zagging ...
Wheat Wizard's user avatar
  • 100k
21 votes
13 answers
8k views

Draw a Dragon Curve

You task for today: draw a dragon curve! In case you don't know what a Dragon Curve is, here is an introductory ViHart video (Really cool, please watch!) Your task: draw a dragon curve, iterated at ...
Alecto's user avatar
  • 1,582
1 vote
0 answers
102 views

Draw the Serpinski Triangle [duplicate]

For today's fractal challenge, draw at least 5 iterations of Sierpinski's triangle! (Shown below is Sierpinski's trinagle) The resolution of the image must be sufficent that the smallest triangles ...
Alecto's user avatar
  • 1,582
15 votes
10 answers
5k views

Draw the Hilbert Curve

A Hilbert Curve is a type of space-filling curve, and it basically maps a line to a plane. Each point in the line corresponds to just one point in the plane, and each point in the plane corresponds to ...
Alecto's user avatar
  • 1,582
33 votes
24 answers
3k views

The IHIH Pyramid

I find it fascinating how the letters "H" and "I" are very similar. "H" is a horizontal stroke surrounded by two vertical strokes; "I" is a vertical stroke surrounded by two horizontal strokes (...
DJMcMayhem's user avatar
  • 59.6k
45 votes
4 answers
2k views

Computer Generated Cracked Soil

Write a program that takes in an integer from 0 to 65535 (216-1) and generates a unique 500×500 pixel image that looks as similar as possible to these 6 real life images of cracked soil: These ...
Calvin's Hobbies's user avatar
13 votes
2 answers
1k views

Recursive Steiner Chains

Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images: In ...
Dendrobium's user avatar
  • 2,502
35 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
15 votes
7 answers
900 views

Draw an indexed fractal

Introduction In this challenge, a 2×2 matrix is indexed like this: 0 1 2 3 We define a family of fractal-like patterns ...
Zgarb's user avatar
  • 42.8k
27 votes
4 answers
1k views

Map string to Hilbert curve

Let's map some strings to 2d space, fractal style. Your task is to compute a Hilbert curve and lay a string along it. Task The task is to take the single-line input string, and lay it out along a ...
wizzwizz4's user avatar
  • 2,397
50 votes
3 answers
4k views

Help, I'm trapped in a Sierpinski triangle!

Drawing the Sierpinski triangle has been done to death. There's other interesting things we can do with it though. If we squint hard enough at the triangle, we can view upside-down triangles as nodes ...
Martin Ender's user avatar
16 votes
6 answers
884 views

Converging Sums of a Fractal Sequence

Background A fractal sequence is an integer sequences where you can remove the first occurrence of every integer and end up with the same sequence as before. A very simple such sequence is called ...
Martin Ender's user avatar
10 votes
3 answers
922 views

Generate Toothpick Sequence

What is Toothpick Sequence? According to Wikipedia In geometry, the toothpick sequence is a sequence of 2-dimensional patterns which can be formed by repeatedly adding line segments ("toothpicks&...
Xwtek's user avatar
  • 2,039
12 votes
2 answers
430 views

Beta's Snowflake

Challenge Winter is fast approaching with many places receiving the first layers of snow for the 15/16 season, so why don't we break out the snow machines and code ourselves some snow? Given a ...
Beta Decay's user avatar
  • 23.4k
36 votes
10 answers
3k views

Generate fractals from bit patterns in ASCII

Overview Write a program that prints out simple fractal patterns given a bit pattern encoding the fractal, plus the per-generation scale factor of the fractal and number of generations. Explanation ...
samgak's user avatar
  • 1,677
26 votes
5 answers
2k views

ASCII Dragon's Curve

Introduction The Dragon's Curve is a fractal curve that notably appears on section title pages of the Jurassic Park novel. It can very simply be described as a process of folding a paper strip, as ...
Fatalize's user avatar
  • 39.3k
32 votes
9 answers
4k views

ASCII Art of the Day #2 - Flow Snakes

A Flow Snake, also known as a Gosper curve, is a fractal curve, growing exponentially in size with each order/iteration of a simple process. Below are the details about the construction and a few ...
Optimizer's user avatar
  • 26.6k
9 votes
2 answers
772 views

ASCII art square affine fractals

Write the smallest program you can to create affine fractals. You may use any method you feel like that generates the same results as the rules below. You don't have to use any ideas from the ...
CJ Dennis's user avatar
  • 4,266
9 votes
1 answer
344 views

Determine whether rational coordinates are in the right Sierpinski triangle

The Sierpinski triangle is a set of points on the plane which is constructed by starting with a single triangle and repeatedly splitting all triangles into four congruent triangles and removing the ...
cardboard_box's user avatar
4 votes
1 answer
1k views

Word fractal plotter

Iterated Function Systems An Iterated Function System (IFS) is a method of constructing self-similar fractals. Each fractal is defined recursively as the union of several copies of itself, with each ...
Uri Granta's user avatar
  • 2,949
16 votes
3 answers
906 views

ASCII L-system renderer

Background An L-system (or Lindenmayer system) is a parallel rewriting system that, among other things, can be easily used to model fractals. This question concerns deterministic, context-free L-...
Uri Granta's user avatar
  • 2,949
14 votes
4 answers
1k views

Draw a Random Walk with Slashes

Write a program or function that takes in a positive integer N (via stdin/command line/function arg) and prints or returns a string representation of a two dimensional random walk that is N steps long,...
Calvin's Hobbies's user avatar
48 votes
16 answers
5k views

Sierpinskified Code

Write a rectangular block of text that when arranged into a Sierpinski carpet, using same-sized blocks of spaces for the empty portions, creates a program that outputs the iteration number of the ...
Calvin's Hobbies's user avatar