9
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 centre triangle. The right Sierpinski triangle has corners at (0,0)
, (0,1)
and (1,0)
, and looks like this:
Some equivalent definitions of this set are as follows:
Points in the
n
th iteration of the process described above, for alln
.Points
(x,y)
with0 <= x <= 1
and0 <= y <= 1
such that for all positive integersn
, then
th bit in the binary expansion of x and y are not both1
.Let
T = {(0,0),(1,0),(0,1)}
Let
f
be a function on sets of 2D points defined by the following:f(X) = {(0,0)} ∪ {(x+t)/2 | x∈X, t∈T}
Then the right Sierpinski triangle is the topological closure of the least fixed point (by set containment) of
f
.Let
S
be the square{(x,y) | 0<=x<=1 and 0<=y<=1}
Let
g(X) = S ∩ {(x+t)/2 | x∈(X), t∈T}
(whereT
is as defined above)Then the right Sierpinski triangle is the greatest fixed point of
g
.
Challenge
Write a program or function which accepts 4 integers, a,b,c,d
and gives a truthy value if (a/b,c/d)
belongs to the right Sierpinski triangle, and otherwise gives a falsey value.
Scoring
This is a code golf. Shortest code in bytes wins.
Test cases
The following are in the right Sierpinski triangle:
0 1 0 1
0 1 12345 123456
27 100 73 100
1 7 2 7
8 9 2 21
8 15 20 63
-1 -7 2 7
The following are not in the right Sierpinski triangle:
1 1 1 1
-1 100 1 3
1 3 1 3
1 23 1 7
4 63 3 66
58 217 4351 7577
-1 -7 3 7
Is
-1 -3 1 1
a valid input? – xnor – 2015-05-17T00:02:51.347Yes, that is a valid input. I've added test cases to make this clear. – cardboard_box – 2015-05-17T01:53:37.863