Skip to content

Instantly share code, notes, and snippets.

@marshallswain
Created August 18, 2022 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshallswain/80d104ee23809c5cc623d09bdaaf37fc to your computer and use it in GitHub Desktop.
Save marshallswain/80d104ee23809c5cc623d09bdaaf37fc to your computer and use it in GitHub Desktop.
-- See Nauany's full blog post at https://blog.bitovi.com
WITHRECURSIVEx(i)
AS (
VALUES(0)
UNIONALLSELECT i + 1FROM xWHERE i < 101
),
Z(Ix, Iy, Cx, Cy, X, Y, I)
AS (
SELECT Ix, Iy, X::float, Y::float, X::float, Y::float, 0
FROM(SELECT -2.2 + 0.031 * i, iFROM x)AS xgen(x,ix)
CROSSJOIN(SELECT -1.5 + 0.031 * i, iFROM x)AS ygen(y,iy)
UNIONALLSELECT Ix, Iy, Cx, Cy, X * X - Y * Y + CxAS X, Y * X * 2 + Cy, I + 1
FROM Z
WHERE X * X + Y * Y < 16.0
AND I < 27
),
Zt (Ix, Iy, I)AS (
SELECT Ix, Iy,MAX(I)AS I
FROM Z
GROUPBY Iy, Ix
ORDERBY Iy, Ix
)
SELECT array_to_string(
array_agg(
SUBSTRING(
' .,,,-----++++%%%%@@@@#### ',
GREATEST(I,1),
1
)
),''
)
FROM Zt
GROUPBY Iy
ORDERBY Iy;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment