Construire une pyramide de balles (solution)

Q1 :

Il est plus facile de commencer par le haut et de fait grandir la pyramide jusqu’en bas. De cette façon, on peut créer des pyramides aussi grandes qu’on veut. Dans l’autre sens, la taille de la base détermine la taille finale de la pyramide avant qu’on l’ait terminée.

Q2 :

D’après la question précédente, il est préférable de commencer par le haut. La premier balle porte le numéro 1 et est celle du haut. Ensuite, un continue la numérotation en parcourant chaque ligne.

../_images/pyramide_num.png

De cette façon, on peut toujours agrandir la pyramide. Ce n’est pas le cas si on part vers le bas pour numéroter.

Q3 :

Le numéro de chaque balle n’indique pas sur quelle ligne elle se trouve. On va s’en changer cela.

../_images/pyramide_num2.png

Q4 :

Lorsqu’on regarde la seconde numérotation de chaque balle, on s’aperçoit que le premier numéro indique la ligne, le second la position de la balle sur cette ligne. Le problème est que ces deux nombres simples n’ont aucun rapport avec la position de la balle dans l’écran de Scratch. C’est pour cela qu’on fait la distinction entre la numérotation à deux chiffres de la balle et ses coordonnées sur l’écran de Scratch. Si on note

System Message: WARNING/2 (x_0)

latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6350 64-bit) entering extended mode (math.tex LaTeX2e <2017-04-15> Babel <3.10> and hyphenation patterns for 75 language(s) loaded. ("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls" Document Class: article 2014/09/29 v1.4h Standard LaTeX document class ("C:\Program Files\MiKTeX 2.9\tex\latex\base\size12.clo")) ("C:\Program Files\MiKTeX 2.9\tex\latex\base\inputenc.sty" (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\utf8x.def)) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\ucs.sty (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\uni-global.de f)) ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsmath.sty" For additional information on amsmath, use the `?' option. ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amstext.sty" ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty")) ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty")) ("C:\Program Files\MiKTeX 2.9\tex\latex\amscls\amsthm.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty" ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty")) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\anyfontsize\anyfo ntsize.sty) ("C:\Program Files\MiKTeX 2.9\tex\latex\tools\bm.sty") (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\eepic\epic.sty Enhancements to Picture Environment. Version 1.2 - Released June 1, 1986 ) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xy.sty" ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xy.tex" Bootstrap'ing: catcodes, docmode, ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyrecat.tex" ) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyidioms.tex") Xy-pic version 3.8.9 <2013/10/06> Copyright (c) 1991-2013 by Kristoffer H. Rose <krisrose@tug.org> and others Xy-pic is free software: see the User's Guide for details. Loading kernel: messages; fonts; allocations: state, direction, utility macros; pictures: \xy, positions, objects, decorations; kernel objects: directionals, circles, text; options; algorithms: directions, edges, connections; Xy-pic loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty") ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyall.tex" Xy-pic option: All features v.3.8 ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycurve.tex" Xy-pic option: Curve and Spline extension v.3.12 curve, circles, loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyframe.tex" Xy-pic option: Frame and Bracket extension v.3.14 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycmtip.tex" Xy-pic option: Computer Modern tip extension v.3.7 ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xytips.tex" Xy-pic option: More Tips extension v.3.11 loaded) loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyline.tex" Xy-pic option: Line styles extension v.3.10 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyrotate.tex" Xy-pic option: Rotate and Scale extension v.3.8 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycolor.tex" Xy-pic option: Colour extension v.3.11 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xymatrix.tex" Xy-pic option: Matrix feature v.3.14 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyarrow.tex" Xy-pic option: Arrow and Path feature v.3.9 path, \ar, loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xygraph.tex" Xy-pic option: Graph feature v.3.11 loaded) loaded)) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\movie15\movie15.s ty ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\base\ifthen.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\ifdraft.sty") (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ms\everyshi.sty)) (math.aux) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\ucsencs.def) ! Package movie15 Error: Package `hyperref' has not been loaded yet . See the movie15 package documentation for explanation. Type H <return> for immediate help. ... l.44 \begin{document} ! Undefined control sequence. \@begindocumenthook ...hyperref}}\ifHy@colorlinks \gdef \@MXV@pdfborder {/Bo... l.44 \begin{document} ! Extra \else. \@begindocumenthook ...der {/Border [0 0 0]}\else \gdef \@MXV@pdfborder {}\f... l.44 \begin{document} ! Extra \fi. \@begindocumenthook ...gdef \@MXV@pdfborder {}\fi \@EveryShipout@Init l.44 \begin{document} ABD: EveryShipout initializing macros ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd") Package movie15 Warning: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (movie15) @@ Package `movie15' is obsolete and @@ (movie15) @@ superseded by `media9'. @@ (movie15) @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. [1] (math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 252 bytes). Transcript written on math.log.
et

System Message: WARNING/2 (y_0)

latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6350 64-bit) entering extended mode (math.tex LaTeX2e <2017-04-15> Babel <3.10> and hyphenation patterns for 75 language(s) loaded. ("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls" Document Class: article 2014/09/29 v1.4h Standard LaTeX document class ("C:\Program Files\MiKTeX 2.9\tex\latex\base\size12.clo")) ("C:\Program Files\MiKTeX 2.9\tex\latex\base\inputenc.sty" (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\utf8x.def)) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\ucs.sty (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\uni-global.de f)) ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsmath.sty" For additional information on amsmath, use the `?' option. ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amstext.sty" ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty")) ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty")) ("C:\Program Files\MiKTeX 2.9\tex\latex\amscls\amsthm.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty" ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty")) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\anyfontsize\anyfo ntsize.sty) ("C:\Program Files\MiKTeX 2.9\tex\latex\tools\bm.sty") (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\eepic\epic.sty Enhancements to Picture Environment. Version 1.2 - Released June 1, 1986 ) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xy.sty" ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xy.tex" Bootstrap'ing: catcodes, docmode, ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyrecat.tex" ) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyidioms.tex") Xy-pic version 3.8.9 <2013/10/06> Copyright (c) 1991-2013 by Kristoffer H. Rose <krisrose@tug.org> and others Xy-pic is free software: see the User's Guide for details. Loading kernel: messages; fonts; allocations: state, direction, utility macros; pictures: \xy, positions, objects, decorations; kernel objects: directionals, circles, text; options; algorithms: directions, edges, connections; Xy-pic loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty") ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyall.tex" Xy-pic option: All features v.3.8 ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycurve.tex" Xy-pic option: Curve and Spline extension v.3.12 curve, circles, loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyframe.tex" Xy-pic option: Frame and Bracket extension v.3.14 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycmtip.tex" Xy-pic option: Computer Modern tip extension v.3.7 ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xytips.tex" Xy-pic option: More Tips extension v.3.11 loaded) loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyline.tex" Xy-pic option: Line styles extension v.3.10 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyrotate.tex" Xy-pic option: Rotate and Scale extension v.3.8 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycolor.tex" Xy-pic option: Colour extension v.3.11 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xymatrix.tex" Xy-pic option: Matrix feature v.3.14 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyarrow.tex" Xy-pic option: Arrow and Path feature v.3.9 path, \ar, loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xygraph.tex" Xy-pic option: Graph feature v.3.11 loaded) loaded)) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\movie15\movie15.s ty ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\base\ifthen.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\ifdraft.sty") (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ms\everyshi.sty)) (math.aux) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\ucsencs.def) ! Package movie15 Error: Package `hyperref' has not been loaded yet . See the movie15 package documentation for explanation. Type H <return> for immediate help. ... l.44 \begin{document} ! Undefined control sequence. \@begindocumenthook ...hyperref}}\ifHy@colorlinks \gdef \@MXV@pdfborder {/Bo... l.44 \begin{document} ! Extra \else. \@begindocumenthook ...der {/Border [0 0 0]}\else \gdef \@MXV@pdfborder {}\f... l.44 \begin{document} ! Extra \fi. \@begindocumenthook ...gdef \@MXV@pdfborder {}\fi \@EveryShipout@Init l.44 \begin{document} ABD: EveryShipout initializing macros ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd") Package movie15 Warning: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (movie15) @@ Package `movie15' is obsolete and @@ (movie15) @@ superseded by `media9'. @@ (movie15) @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. [1] (math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 252 bytes). Transcript written on math.log.
, on obtient comme relation entre les deux :

System Message: WARNING/2 (x = x_0 + j * sx + i * sx/2 y = y_0 - i * sy)

latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6350 64-bit) entering extended mode (math.tex LaTeX2e <2017-04-15> Babel <3.10> and hyphenation patterns for 75 language(s) loaded. ("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls" Document Class: article 2014/09/29 v1.4h Standard LaTeX document class ("C:\Program Files\MiKTeX 2.9\tex\latex\base\size12.clo")) ("C:\Program Files\MiKTeX 2.9\tex\latex\base\inputenc.sty" (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\utf8x.def)) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\ucs.sty (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\uni-global.de f)) ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsmath.sty" For additional information on amsmath, use the `?' option. ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amstext.sty" ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty")) ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty")) ("C:\Program Files\MiKTeX 2.9\tex\latex\amscls\amsthm.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty" ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty")) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\anyfontsize\anyfo ntsize.sty) ("C:\Program Files\MiKTeX 2.9\tex\latex\tools\bm.sty") (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\eepic\epic.sty Enhancements to Picture Environment. Version 1.2 - Released June 1, 1986 ) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xy.sty" ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xy.tex" Bootstrap'ing: catcodes, docmode, ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyrecat.tex" ) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyidioms.tex") Xy-pic version 3.8.9 <2013/10/06> Copyright (c) 1991-2013 by Kristoffer H. Rose <krisrose@tug.org> and others Xy-pic is free software: see the User's Guide for details. Loading kernel: messages; fonts; allocations: state, direction, utility macros; pictures: \xy, positions, objects, decorations; kernel objects: directionals, circles, text; options; algorithms: directions, edges, connections; Xy-pic loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty") ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyall.tex" Xy-pic option: All features v.3.8 ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycurve.tex" Xy-pic option: Curve and Spline extension v.3.12 curve, circles, loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyframe.tex" Xy-pic option: Frame and Bracket extension v.3.14 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycmtip.tex" Xy-pic option: Computer Modern tip extension v.3.7 ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xytips.tex" Xy-pic option: More Tips extension v.3.11 loaded) loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyline.tex" Xy-pic option: Line styles extension v.3.10 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyrotate.tex" Xy-pic option: Rotate and Scale extension v.3.8 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xycolor.tex" Xy-pic option: Colour extension v.3.11 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xymatrix.tex" Xy-pic option: Matrix feature v.3.14 loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xyarrow.tex" Xy-pic option: Arrow and Path feature v.3.9 path, \ar, loaded) ("C:\Program Files\MiKTeX 2.9\tex\generic\xypic\xygraph.tex" Xy-pic option: Graph feature v.3.11 loaded) loaded)) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\movie15\movie15.s ty ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\base\ifthen.sty") ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\ifdraft.sty") (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ms\everyshi.sty)) (math.aux) (C:\Users\Administrateur\AppData\Roaming\MiKTeX\2.9\tex\latex\ucs\ucsencs.def) ! Package movie15 Error: Package `hyperref' has not been loaded yet . See the movie15 package documentation for explanation. Type H <return> for immediate help. ... l.44 \begin{document} ! Undefined control sequence. \@begindocumenthook ...hyperref}}\ifHy@colorlinks \gdef \@MXV@pdfborder {/Bo... l.44 \begin{document} ! Extra \else. \@begindocumenthook ...der {/Border [0 0 0]}\else \gdef \@MXV@pdfborder {}\f... l.44 \begin{document} ! Extra \fi. \@begindocumenthook ...gdef \@MXV@pdfborder {}\fi \@EveryShipout@Init l.44 \begin{document} ABD: EveryShipout initializing macros ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd") ("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd") Package movie15 Warning: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (movie15) @@ Package `movie15' is obsolete and @@ (movie15) @@ superseded by `media9'. @@ (movie15) @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. [1] (math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 464 bytes). Transcript written on math.log.

Passer d’un système de numérotation (donc des coordonnées) au système de coordonnées de l’écran n’est pas toujours évident.

Exercice 1

L’astuce est de remarquer que, sur la ligne 1, il y a une balle, sur la ligne 2, il y a deux balles, et ainsi de suite : sur la ligne i, il y i balles.

La solution est illustrée par :

../_images/pyramide_solution.png

Et le programme à exécuter est le suivant : pyramide.sb2.

Exercice 2

L’article 2015-04-07 Motif, optimisation, biodiversité fait référence à cet exercice. Il utilise le programme Scratch suivant pour dessiner des balles de couleurs différentes selon un motif précis.

L’astuce consiste à changer de costume tous les trois arbres au fur et à mesure qu’on les pose : on commence par le costume a, puis b, puis c. Ensuite, on recommence à a, b et ainsi de suite.

C’est un petit tour de passe passe qu’on utilise souvent en mathématique : on considère les nombres 1, 2, 3, 4, 5, 6, … et on s’intéresse au reste de la division de chaque nombre par trois : reste de 1/3 = 1, reste de 2/3 = 2, reste de 3/3 = 0, reste de 4/3 = 1, reste de 5/3 = 2, reste de 6/3 = 0…

On appelle cette opération le modulo et cette opération existe en Scratch :

../_images/pyramide_couleur.png

Pour voir la correction en entier, il suffit de télécharger le fichier : pyramide_bio.sb2.