Webs and pebbles#
Let’s start with a little warm-up before tackling the challenge below.
Hint: when there is a web, you can destroy it with a pebble.
Attention
This exercise is marked with a ♣ and is therefore of a more advanced level; do not hesitate to skip it if it seems difficult to you in order to not waste too much time, and to come back to it later.
from laby.global_fr import *
carte = """
o o o o o o
o → . r w x
o o o o o o
"""
Laby(carte=carte)
debut()
### BEGIN SOLUTION
avance()
prend()
avance()
pose()
prend()
droite()
droite()
pose()
droite()
droite()
avance()
### END SOLUTION
ouvre()
assert est_gagnant()
How to solve the following maze?
Note that the number of pebbles / webs varies!
Todo
Rédiger une solution et remettre la cellule de test.
from laby.global_fr import *
Laby(lignes=1, colonnes=10, option="rocksAndWebs")
debut()
### BEGIN SOLUTION
def pose_derriere():
droite()
droite()
pose()
droite()
droite()
def neutralise():
pose()
prend()
avance()
def retourner_chercher_caillou():
droite()
droite()
while (regarde() != Caillou):
avance()
prend()
droite()
droite()
while (regarde() == Vide):
avance()
droite()
while (regarde() != Sortie):
if regarde() == Caillou:
prend()
avance()
pose_derriere()
elif regarde() == Toile:
retourner_chercher_caillou()
neutralise()
pose_derriere()
else:
avance()
ouvre()
### END SOLUTION