.. _td1apyramidebigarreerst: =================================== 1A.1 - Tracer une pyramide bigarrée =================================== .. only:: html **Links:** :download:`notebook `, :downloadlink:`html `, :download:`python `, :downloadlink:`slides `, :githublink:`GitHub|_doc/notebooks/td1a/td1a_pyramide_bigarree.ipynb|*` Cet exercice est inspirée de l’article `2015-04-07 Motif, optimisation, biodiversité `__. Il s’agit de dessiner un motif. .. code:: ipython3 %matplotlib inline .. code:: ipython3 from jyquickhelper import add_notebook_menu add_notebook_menu() .. contents:: :local: Problème -------- Il faut dessiner la pyramide suivante à l’aide de `matplotlib `__. .. code:: ipython3 from IPython.display import Image Image("http://www.xavierdupre.fr/app/code_beatrix/helpsphinx/_images/biodiversite_tri2.png") .. image:: td1a_pyramide_bigarree_4_0.png Idée de la solution ------------------- On sépare le problème en deux plus petits : - Trouver la position des boules dans un repère cartésien. - Choisir la bonne couleur. Le repère est hexagonal. L’image suivante est tirée de la page wikipédia `empilement compact `__. .. code:: ipython3 from pyquickhelper.helpgen import NbImage NbImage("data/hexa.png") .. image:: td1a_pyramide_bigarree_6_0.png A vous.