A class was asked to write code to build an image of the Puerto Rican flag. Two students started by defining the following values:

(define background (rectangle 300  200  "outline"  "black"))
(define rrectangle (rectangle 300 200/5  "solid" "red"))
(define btriangle (rotate 30 (triangle 200 "solid" "blue")))
(define wstar (star 40 "solid" "white"))

They then two very different strategies to define puerto-rico to compose an image of the flag. And both work!

Mia’s Method:

(define puerto-rico
  (translate wstar 65 100
    (translate btriangle 85 100
      (translate rrectangle 150 20
        (translate rrectangle 150 100
          (translate rrectangle 150 180                                                          background))))))

Savannah’s Method:

(define step1 (translate rrectangle
  150 20
  background))

(define step2 (translate rrectangle
  150 100
  step1))

(define step3 (translate rrectangle
  150 180
  step2))

(define step4 (translate btriangle
  85 100
  step3))

(define step5 (translate wstar
  65 100
  step4))

(define puerto-rico-2 step5)

1 How is their code similar?

2 How is their code different?

3 What else do you Notice?

4 What do you Wonder?

Open the Composing 1 Step at a Time Starter File and click "Run".

5 Type step1 and hit Enter. Do the same thing with step2, step3, step4…​ What happens?

6 Which strategy do you prefer? Why?

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.