Coding Challenge #126: Toothpicks

Subscribers:
1,740,000
Published on ● Video Link: https://www.youtube.com/watch?v=-OL_sw2MiYw



Duration: 31:13
79,505 views
1,797


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







Tags:
computer science
programming
daniel shiffman
tutorial
coding
the coding train
coding challenge
coding train
creative coding
code challenge
creative coding tutorials
coding train coding challenge
programming challenge
processing challenge
the coding train processing challenge
the coding train processing
toothpicks
toothpicks pattern
toothpick fractal
toothpick numberphile
numberphile