Scrive il messaggio CIAO con poche operazioni…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
paintWhite # scrive C right forward(1) backward(1) left forward(2) right forward(1) stopPainting forward(1) right paintWhite # scrive I forward(2) left stopPainting forward(1) left paintWhite # scrive A forward(2) right forward(1) right forward(1) right forward(1) backward(1) left forward(1) left stopPainting forward(1) left paintWhite # scrive O forward(2) right forward(1) right forward(2) right forward(1) stopPainting backward(2) right |
Esercizi
- Alterna i colori
- Aumenta le dimensioni delle lettere.
La soluzione con direzioni assolute east(), south(), west(), north()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
paintWhite east(1) stopPainting west(1) paintWhite north(2) east(1) stopPainting east(1) paintWhite south(2) stopPainting east(1) paintWhite north(2) east(1) south(1) west(1) stopPainting east(1) paintWhite south(1) stopPainting east(1) paintWhite north(2) east(1) south(2) west(1) stopPainting east(2) |
Si semplifica il codice ma è difficilmente riciclabile.