Login
You're viewing the ruby.social public feed.
  • Nov 20, 2026, 9:56 PM

    @futurebird You're a true inspiration!

    I'm not much of a programmer but got saddled with the course at my school. Here's the latest lesson I walked through with my kids.

    We started with a basic equilateral triangle and then used old-fashioned trig to figure out the exact vertices. Then we coded an algorithm to create a Sierpinski triangle fractal. I didn't show the kids what we were making until we finished the code so they could see the design being made as a surprise at the end. It's a fun little lesson for coding and chaos theory all at once.

    Feel free to use it and modify as you see fit if you want. I love to remind the kids that since the program is picking 7000 (or however many loops you want) random points, none of the kids' programs will ever do the exact same thing, but we all end up with the same structure.

    "OMG! Mr. Corby! It's like...the Triforce!" they tell me.

    A python turtle code and monitor screen of a Sierpinski triangle. The monitor screen is colored cyan blue as a background while the triangle structure is orange. The structure is an equilateral triangle with an inverted triangle gap cut out of the center creating three new triangles. Each of those triangles has another inverted triangle gap cut out creating more triangles and so on until the size of the pixels limits the repetition. The code (on the left side of the screen) creates a triangle first, then a list of vertices for the large triangle. Then it codes for the turtle to pick a vertex at random, move halfway to said vertex and plant a single dot before choosing the next vertex and going halfway to that vertex and so on 7000 times. The entire code takes about 22 lines without gaps.
    💬 0🔄 0⭐ 2