From the course: Coding Exercises: Scala
Unlock the full course today
Join today to access over 24,100 courses taught by industry experts.
Sierpinski Triangle - Scala Tutorial
From the course: Coding Exercises: Scala
Sierpinski Triangle
(playful game music) (system chimes) (quirky tone plays) - [Instructor] The Sierpinski triangle is an interesting fractal. It starts by putting a triangle above two triangles that are beside each other. Successive iterations repeat the pattern with the fragment from the previous iteration. Your challenge is to implement the Sierpinski triangle. We've given you a bit of code to start with in the file 01_14b.scala. Now pause the video, come back when you've completed the challenge, and see how I did it. (upbeat retro video game music) (quirky tone plays) So here's the starting point that we've given you. We've defined a triangle here that you can build the Sierpinski triangle from. What we need to implement is the iterative fractal-building process. So, what I need to do is, on the first iteration when the depth is 1, I need to return just the triangle, and on the other iterations, I need to build from the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Palindrome detector2m 15s
-
(Locked)
Password checker4m 20s
-
(Locked)
Colored boxes2m 15s
-
(Locked)
System properties1m 17s
-
(Locked)
Resistor tolerance2m 36s
-
(Locked)
Snakes and camels1m 58s
-
(Locked)
Stuff the stats sheet5m 50s
-
(Locked)
A slice of Pi5m 13s
-
(Locked)
Cron and regular expressions4m 35s
-
(Locked)
Reservoir sampling4m 55s
-
(Locked)
Evaluate a decision tree3m 3s
-
(Locked)
Calculator2m 41s
-
(Locked)
Error handling2m 58s
-
(Locked)
Sierpinski Triangle2m 2s
-
(Locked)
Rocketship7m 16s
-