Christmas tree 🌲

By Athira Radhakrishnan M

        
Comments
Anand Chitipothu
3 years ago
Post
Dismiss
Merry christmas! There is a lot of duplication in this program. See if you can make this shorter. You could have used `repeat` to create those three circles in one go. ``` c = circle(x=100, y=50, r=10, fill="gold") | repeat(3, translate(y=-50)) show(c) ``` You could even extend that to other three circles with one more repeat. ``` c = circle(x=100, y=50, r=10, fill="gold") | repeat(3, translate(y=-50)) | repeat(2, translate(x=-200)) show(c) ``` You could do the same for the green part. One suggestion though, don't use `circle` as a variable name. That would shadow the built-in function `circle` and you'll not be able to create a circle after that.
Merry christmas! There is a lot of duplication in this program. See if you can make this shorter. You could have used `repeat` to create those three circles in one go. ``` c = circle(x=100, y=50, r=10, fill="gold") | repeat(3, translate(y=-50)) show(c) ``` You could even extend that to other three circles with one more repeat. ``` c = circle(x=100, y=50, r=10, fill="gold") | repeat(3, translate(y=-50)) | repeat(2, translate(x=-200)) show(c) ``` You could do the same for the green part. One suggestion though, don't use `circle` as a variable name. That would shadow the built-in function `circle` and you'll not be able to create a circle after that.
Want to discuss?
Post it here, our mentors will help you out.