I have been exploring OEIS sequence A229037 aka "fractal smoke" and am trying to write some efficient code to produce it. I also want to look at variations of the sequence (e.g. what does the lexographically 2nd sequence that doesn't include arithmetic progressions look like? Does adding some erroneous points at the start change the long term fractal pattern that emerges?), which is why I can't just copy the coordinates given on the OEIS website.
The current code I'm using is in python (as its the only language I know):
# fractal smoke sequence
l = [(1, 1)] # sequence
f = [] # forbidden points
for i in range(1000): # first e.g. 100 terms
fy = []
for n in range(len(l) - 1):
xa = 2 * l[len(l) - 1][0] - l[n][0] # calculate x value of forbidden point
ya = 2 * l[len(l) - 1][1] - l[n][1] # calculate y value of forbidden point
a = (xa, ya)
f.append(a) # append forbidden coordinate to f, then repeat for all other new arithmetic progressions
for i in f:
if i[0] == len(l) + 1:
fy.append(i[1]) # append the y value of all forbidden points which have the x value of the current new sequence value
l.append((len(l) + 1, min(set(range(1, len(l) + 1)) - set(fy)))) # append the point with the current x value and the minimum number which is not contained in fy
# plotting
x = []
y = []
for i in l:
x.append(i[0])
y.append(i[1])
plt.scatter(x, y, s=1)
which produces the correct values, but is very slow. This code can be generalised to e.g. this sequence by adding the gradient and y-intercept of each line that passes through every 2 points, rather than a single point like my above code does.
This code golf includes a python 2 program, but I'm struggling to understand their logic and how the zip() function is being used.
A reddit user here has calculated millions of points. Obviously this took a long time, but can anyone produce code that is efficient enough to do something similar e.g. approx 1 million points in a runtime that is approx 1 day? In python or another coding language?