Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 105 - 2620_Birla Open Mind C-8
P. 105

    Look at this example:
                    Robby has to paint these blank boxes to make a letter ‘U’
                                                                              Start

                    The program will be

                              Fill Colour                                      Fill Colour
                              Move 1 down                                      Repeat 3 times
                              Move 1 step and fill colour                      (Move 1 step and fill colour)
                              Move 1 step and fill colour
                              Turn left                                        Turn left
                              Move 1 step and fill colour                      Repeat 2 times
                              Move 1 step and fill colour                      (Move 1 step and fill colour)
                              Turn left
                              Move 1 step and fill colour                      Turn left
                              Move 1 step and fill colour                      Repeat 3 times
                              Move 1 step and fill colour                      (Move 1 step and fill colour)

                                    Program without a loop                             Program with a loop

                    Look at another examples:
                    1.                                             Start
                         Repeat 2 times
                         {
                         Move 1 step down
                         }
                         Repeat 6 times
                         (
                         Fill colour
                         Move 1 step left
                         )

                                                                  Start
                    2.

                         Repeat until reached last column
                         (
                         Fill colour
                         Move 1 step left
                         )

                                                                                                 #Algorithmic Intelligence 103

| 100 101 102 103 104 105 106 107 108 109 110 |