Hi,
I'm new to programming in python [total beginner in programming] and I would like to ask you for your help.
So here is my problem:
I'm trying to program a Sierpinski triangle for n-iterations. Here is what I got so far:
![[Image: YGm0dm.png]](https://i.stack.imgur.com/YGm0dm.png)
![[Image: R47xKm.png]](https://i.stack.imgur.com/R47xKm.png)
I even drew everything on the piece of paper, so I understand the algorithm, but don't know how to write it in syntax.
What about plotting all the points? Is there a 'grid' for these arrays? I read about numpy.zeros(), but it was explained this is a function for matrixes, so I'm not sure how to implement this into the program.
Can you help?
I'm new to programming in python [total beginner in programming] and I would like to ask you for your help.
So here is my problem:
I'm trying to program a Sierpinski triangle for n-iterations. Here is what I got so far:
import numpy as np from math import sqrt # a b c P = np.array([(0, 0), (1, 0), (1, (1/sqrt(2)))], dtype=float) # I could start with any point, but decided to start with a a = np.array((0, 0), dtype=float) new_point: #1.iteration # a + b p1 = P[0] + P[1] new_point #2.iteration t1 = P[0] + p1 t2 = P[1] + p1 t3 = P[2] + p1 # b + c p2 = P[1] + P[2] new_point #2.iteration t4 = P[0] + p2 t5 = P[1] + p2 t6 = P[2] + p2 # c + a p3 = P[2] + P[0] new_point #2.iteration t7 = P[0] + p3 t8 = P[1] + p3 t9 = P[2] + p3My problem is writing all this in recursion syntax in python (recursion is mandatory).
![[Image: YGm0dm.png]](https://i.stack.imgur.com/YGm0dm.png)
![[Image: R47xKm.png]](https://i.stack.imgur.com/R47xKm.png)
I even drew everything on the piece of paper, so I understand the algorithm, but don't know how to write it in syntax.
What about plotting all the points? Is there a 'grid' for these arrays? I read about numpy.zeros(), but it was explained this is a function for matrixes, so I'm not sure how to implement this into the program.
Can you help?