Coding Challenge #126: Toothpicks
In this coding challenge, I implement Omar Polβs fractal toothpick sequence. Code: https://thecodingtrain.com/challenges/126-toothpicks
πΉοΈ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/SJMl3u5xN
π₯ Previous video: https://youtu.be/Mm2eYfj0SgA?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Next video: https://youtu.be/XUA8UREROYE?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References:
π The On-Line Encyclopedia of Integer Sequences: https://oeis.org/A139250
π Explorations Omar Polβs toothpick sequence: https://oeis.org/A139250/a139250.anim.html
Videos:
π₯ Terrific Toothpick Patterns: https://youtu.be/_UtCli1SgjI
π΄ Coding Train Live 163: https://youtu.be/pKyU92cza0Y?t=6250s
Related Coding Challenges:
π #2 Menger Sponge Fractal: https://youtu.be/LG8ZK-rRkXo
π #14 Recursive Fractal Trees: https://youtu.be/0jjeOYMjmDU
π #123 Chaos Game: https://youtu.be/7gNzMtYo9n4
π #129 Koch Fractal Snowflake: https://youtu.be/X8bXDKqMsXE
π #174 AppleSoft Basic Fractal Tree: https://youtu.be/UNkHditYGls
Timestamps:
0:00 Introducing today's topic
1:00 The On-Line Encyclopedia of Integer Sequences
2:41 Toothpick number sequence
3:36 Start Coding!
4:00 Create a toothpick class
4:38 Each toothpick will have a length, center point, and direction
7:20 Write a show() function
8:11 Create an array list of toothpicks
9:03 Add a toothpick at the center of the canvas
10:50 Create an array list to hold the next generation of toothpicks
14:00 Each toothpick checks whether its end points are free
19:01 Add a new toothpick at a free point
19:55 Use mousePressed() to add toothpicks
21:32 Optimize by only checking the new toothpicks
23:38 Dynamically adjust the scale of the toothpicks
27:39 Adjust strokeWeight as scale changes
29:15 Print the sequence to the console
30:09 Other toothpick variations
30:45 Conclusion and creative possibilities
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
π Website: http://thecodingtrain.com/
πΎ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide
π© Suggest Topics: https://github.com/CodingTrain/Suggestion-Box
π‘ GitHub: https://github.com/CodingTrain
π¬ Discord: https://discord.gg/hPuGy2g
π Membership: http://youtube.com/thecodingtrain/join
π Store: https://standard.tv/codingtrain
ποΈ Twitter: https://twitter.com/thecodingtrain
πΈ Instagram: https://www.instagram.com/the.coding.train/
π₯ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: https://p5js.org
π p5.js Web Editor: https://editor.p5js.org/
π Processing: https://processing.org
π Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new
#toothpickpattern #fractal #omarpol #processing