Coding Challenge #126: Toothpicks

Subscribers:
1,750,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