Counting Pebbles#
The labyrinth below contains randomly placed pebbles. The mission is to
exit the labyrinth while counting the pebbles.
- Initially, ignore the variable - nbcaillouxand write a program that allows the ant to exit the labyrinth.- Hint - If there is a pebble in front, take it, move forward, and drop it behind. Otherwise, simply move forward. Repeat until the exit is reached. 
- The variable - nbcaillouxwill now serve as a counter. Adapt your program so that each time the ant sees a pebble, the variable- nbcaillouxis incremented by- 1.- Hint - Use - nbcailloux = nbcailloux + 1
from laby.global_fr import *
Laby(lignes = 1, colonnes = 10, option = "rocks")
debut()
nbcailloux = 0
### BEGIN SOLUTION
droite()
while (regarde() != Sortie):
    if regarde() == Caillou:
        nbcailloux = nbcailloux + 1
        prend()
        avance()
        droite()
        droite()
        pose()
        droite()
        droite()
    else:
        avance()
### END SOLUTION
ouvre()
The cell below should now display the number of pebbles:
nbcailloux
5
assert est_gagnant()
♣ For a spicier challenge, the mission below is to reach the exit, counting
the webs and pebbles. Proceed in two steps as above.
Indication
You can destroy a web by placing a pebble on it.
from laby.global_fr import *
Laby(lignes = 1, colonnes = 10, option = "rocksAndWebs")
debut()
### BEGIN SOLUTION
nbcailloux = 0
nbtoiles = 0
droite()
while (regarde() != Sortie):
    if regarde() == Toile:
        nbtoiles = nbtoiles + 1
        pose()
    if regarde() == Caillou:
        nbcailloux = nbcailloux + 1
        droite()
        droite()
        pose()
        droite()
        droite()
        prend()
        avance()
    else:
        avance()
droite()
droite()
pose()
droite()
droite()
### END SOLUTION
ouvre()
The following cells should display the number of pebbles and webs respectively
### BEGIN SOLUTION
nbcailloux
### END SOLUTION
11
### BEGIN SOLUTION
nbtoiles
### END SOLUTION
6
assert est_gagnant()
