SlideShare une entreprise Scribd logo
1  sur  1
Télécharger pour lire hors ligne
Mais comment passer des s´equences aux pavages?
C’est grˆace `a cet algorithme en language Python qu’on parvient
`a transformer une s´equence de pile ou face sur excel en un
pavage de Truchet.
1 import pygame , Buttons
2 from pygame . l o c a l s import ∗
3 from PIL import Image
4 import random
5 import x l r d
6 import os
7
8 #o u v e r t u r e du f i c h i e r e x c e l
9 workbook = x l r d . open workbook ( ’ C l a s s e u r 1 . x l s ’ )
10 s h e e t = workbook . s h e e t b y i n d e x ( 0 )
11
12 d e f av ( x , y , dh ) :
13 i f ( x==0 and y>0) :
14 r e t u r n ( dh∗x+y−1)
15 e l i f ( x>0) :
16 r e t u r n ( ( x−1)∗dh+y )
17 random . seed ( )
18 #Ouverture des images n c e s s a i r e s
19 pr = Image . open ( ” pr . png” )
20 pv = Image . open ( ”pv . png” )
21 f r = Image . open ( ” f r . png” )
22 f v = Image . open ( ” f v . png” )
23
24 ( width , h e i g h t )= pr . s i z e
25 #l e c t u r e des i n f o r m a t i o n s du t a b l e u r
26 n=s h e e t . nrows
27 c=s h e e t . n c o l s
28
29 #C r e a t i o n d ’ une l i s t e
30 pouf = [ [ ] f o r i i n xrange ( n ) ]
31 f o r i i n xrange ( 0 , n ) :
32 f o r h i n xrange ( 0 , c ) :
33 #Ajout des i n f o r m a t i o n s du t a b l e a u dans l a l i s t e pouf
34 i f s h e e t . c e l l v a l u e ( h , i )==”F” :
35 pouf [ i ] . append ( ”F” )
36 e l i f s h e e t . c e l l v a l u e ( h , i )==”P” :
37 pouf [ i ] . append ( ”P” )
38
39 #C r e a t i o n d ’ une image qui s ’ adapte l a t a i l l e du t a b l e u r
40 image=Image . new ( ”RGB” , ( n∗width , c∗ h e i g h t ) , ( 2 5 5 , 2 5 5 , 2 5 5 ) )
41 ( iwidth , i h e i g h t ) = image . s i z e
42 dh = i h e i g h t / h e i g h t
43 dw = i w i d t h / width
44 l o g = [ ]
45
46 #Ajout des images s u i v a n t l a sequence d ’ e x c e l
47 f o r x i n xrange ( 0 , dh ) :
48 f o r y i n xrange ( 0 ,dw) :
49 avant = av ( x , y , dh )
50 i f ( pouf [ x ] [ y]==”F” ) :
51 i f ( x==0 and y==0) :
52 g . p a s t e ( fv , ( x∗width , y∗ h e i g h t ) )
53 l o g . append ( ” f v ” )
54 e l s e :
55 i f ( l o g [ avant]==” f v ” or l o g [ avant]==” pr ” ) :
56 g . p a s t e ( f r , ( x∗width , y∗ h e i g h t ) )
57 l o g . append ( ” f r ” )
58 e l i f ( l o g [ avant]==” f r ” or l o g [ avant]==”pv” ) :
59 g . p a s t e ( fv , ( x∗width , y∗ h e i g h t ) )
60 l o g . append ( ” f v ” )
61 e l i f ( pouf [ x ] [ y ] . upper ( )==”P” ) :
62 i f ( x==0 and y==0) :
63 g . p a s t e ( pv , ( x∗width , y∗ h e i g h t ) )
64 l o g . append ( ”pv” )
65 e l s e :
66 i f ( l o g [ avant]==”pv” or l o g [ avant]==” f r ” ) :
67 g . p a s t e ( pr , ( x∗width , y∗ h e i g h t ) )
68 l o g . append ( ” pr ” )
69 e l i f ( l o g [ avant]==” pr ” or l o g [ avant]==” f v ” ) :
70 g . p a s t e ( pv , ( x∗width , y∗ h e i g h t ) )
71 l o g . append ( ”pv” )
72 #Ouvrir l ’ image
73 image . show ( )
Cet algorithme permet de cr´eer des chefs-d’œuvre comme
les pavages suivants:
Pour cela, il suffit de changer les images de base et inventer
un dessin unique.
Enrique Lacal et Lu˜a Streit

Contenu connexe

Tendances

Un algorithme de chiffrement a flot base sur le probleme des 3 corps.
Un algorithme de chiffrement a flot base sur le probleme des 3 corps.Un algorithme de chiffrement a flot base sur le probleme des 3 corps.
Un algorithme de chiffrement a flot base sur le probleme des 3 corps.Samir Crypticus
 
Rappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.comRappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.comcours fsjes
 
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTITD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTIsoufiane merabti
 
TD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTI
TD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTITD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTI
TD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTIsoufiane merabti
 
Résumé Algorithme et Programmation
Résumé Algorithme et ProgrammationRésumé Algorithme et Programmation
Résumé Algorithme et Programmationborhen boukthir
 

Tendances (11)

Un algorithme de chiffrement a flot base sur le probleme des 3 corps.
Un algorithme de chiffrement a flot base sur le probleme des 3 corps.Un algorithme de chiffrement a flot base sur le probleme des 3 corps.
Un algorithme de chiffrement a flot base sur le probleme des 3 corps.
 
Ch07 15
Ch07 15Ch07 15
Ch07 15
 
3-Cm9 2013-2014
3-Cm9 2013-20143-Cm9 2013-2014
3-Cm9 2013-2014
 
Rappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.comRappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.com
 
Ch17 13
Ch17 13Ch17 13
Ch17 13
 
3-Cm7 2013-2014
3-Cm7 2013-20143-Cm7 2013-2014
3-Cm7 2013-2014
 
Correction td2
Correction td2Correction td2
Correction td2
 
algebra de boole
algebra de boolealgebra de boole
algebra de boole
 
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTITD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
 
TD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTI
TD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTITD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTI
TD - travaux dirigé la fonction exponentielle ( exercice ) - soufiane MERABTI
 
Résumé Algorithme et Programmation
Résumé Algorithme et ProgrammationRésumé Algorithme et Programmation
Résumé Algorithme et Programmation
 

Similaire à 3 affiche enrique_lua_truchet2

Affiches eleve
Affiches eleveAffiches eleve
Affiches eleveOTANGAD
 
cours-5.1.pdf
cours-5.1.pdfcours-5.1.pdf
cours-5.1.pdfGonnaBe1
 
Projet Méthodes Numériques
Projet  Méthodes Numériques Projet  Méthodes Numériques
Projet Méthodes Numériques Ramin Samadi
 
Coffee script
Coffee scriptCoffee script
Coffee scriptantho1404
 
Lect14 dev2
Lect14 dev2Lect14 dev2
Lect14 dev2moisko
 
Corrigé langage c
Corrigé langage cCorrigé langage c
Corrigé langage ccoursuniv
 
ALF 11 - Diagrame de flux de controlle
ALF 11 - Diagrame de flux de controlleALF 11 - Diagrame de flux de controlle
ALF 11 - Diagrame de flux de controlleAlexandru Radovici
 
Corrigés exercices langage C
Corrigés exercices langage CCorrigés exercices langage C
Corrigés exercices langage Ccoursuniv
 
Techniques et-methodes-calcul-integral-mr-anis-ben-ali
Techniques et-methodes-calcul-integral-mr-anis-ben-aliTechniques et-methodes-calcul-integral-mr-anis-ben-ali
Techniques et-methodes-calcul-integral-mr-anis-ben-alim.a bensaaoud
 
resume algo 2023.pdf
resume algo 2023.pdfresume algo 2023.pdf
resume algo 2023.pdfsalah fenni
 
Corrigé SERIE 2 cinématique du point.pptx
Corrigé SERIE 2 cinématique du point.pptxCorrigé SERIE 2 cinématique du point.pptx
Corrigé SERIE 2 cinématique du point.pptxMidoxotk
 
ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)
ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)
ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)Dimitris Psounis
 
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]Yessin Abdelhedi
 

Similaire à 3 affiche enrique_lua_truchet2 (16)

Affiches eleve
Affiches eleveAffiches eleve
Affiches eleve
 
cours-5.1.pdf
cours-5.1.pdfcours-5.1.pdf
cours-5.1.pdf
 
Projet Méthodes Numériques
Projet  Méthodes Numériques Projet  Méthodes Numériques
Projet Méthodes Numériques
 
Coffee script
Coffee scriptCoffee script
Coffee script
 
Lect14 dev2
Lect14 dev2Lect14 dev2
Lect14 dev2
 
ALF 11 - WebAssembly
ALF 11 - WebAssemblyALF 11 - WebAssembly
ALF 11 - WebAssembly
 
Corrigé langage c
Corrigé langage cCorrigé langage c
Corrigé langage c
 
246242769 sequence-1-pdf
246242769 sequence-1-pdf246242769 sequence-1-pdf
246242769 sequence-1-pdf
 
ALF 11 - Diagrame de flux de controlle
ALF 11 - Diagrame de flux de controlleALF 11 - Diagrame de flux de controlle
ALF 11 - Diagrame de flux de controlle
 
Corrigés exercices langage C
Corrigés exercices langage CCorrigés exercices langage C
Corrigés exercices langage C
 
Techniques et-methodes-calcul-integral-mr-anis-ben-ali
Techniques et-methodes-calcul-integral-mr-anis-ben-aliTechniques et-methodes-calcul-integral-mr-anis-ben-ali
Techniques et-methodes-calcul-integral-mr-anis-ben-ali
 
Exercice intégrales
Exercice intégralesExercice intégrales
Exercice intégrales
 
resume algo 2023.pdf
resume algo 2023.pdfresume algo 2023.pdf
resume algo 2023.pdf
 
Corrigé SERIE 2 cinématique du point.pptx
Corrigé SERIE 2 cinématique du point.pptxCorrigé SERIE 2 cinématique du point.pptx
Corrigé SERIE 2 cinématique du point.pptx
 
ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)
ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)
ΠΛΗ30 ΚΑΡΤΑ 1.4 (4sl)
 
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
 

Plus de OTANGAD

AU FABLAB
AU FABLABAU FABLAB
AU FABLABOTANGAD
 
Travail geotortue
Travail geotortueTravail geotortue
Travail geotortueOTANGAD
 
7 affiche maira
7 affiche maira7 affiche maira
7 affiche mairaOTANGAD
 
6 affiche camila_gabriel_anita
6 affiche camila_gabriel_anita6 affiche camila_gabriel_anita
6 affiche camila_gabriel_anitaOTANGAD
 
5 affiche louise_arts
5 affiche louise_arts5 affiche louise_arts
5 affiche louise_artsOTANGAD
 
4 affiche louise_truchet
4 affiche louise_truchet4 affiche louise_truchet
4 affiche louise_truchetOTANGAD
 
2 affiche enrique_lua_truchet1
2 affiche enrique_lua_truchet12 affiche enrique_lua_truchet1
2 affiche enrique_lua_truchet1OTANGAD
 
1 affiche arthur_ernesto_luisfelipe_pileouface
1 affiche arthur_ernesto_luisfelipe_pileouface1 affiche arthur_ernesto_luisfelipe_pileouface
1 affiche arthur_ernesto_luisfelipe_pileoufaceOTANGAD
 
Des réponses possibles au problème du tirage des 100 lancers de pile ou face.
Des réponses possibles au problème du tirage des 100 lancers de pile ou face.Des réponses possibles au problème du tirage des 100 lancers de pile ou face.
Des réponses possibles au problème du tirage des 100 lancers de pile ou face.OTANGAD
 
Sur le cycle3_mathematiques
Sur le cycle3_mathematiquesSur le cycle3_mathematiques
Sur le cycle3_mathematiquesOTANGAD
 
1 s tm1_suites_vecteurs
1 s tm1_suites_vecteurs1 s tm1_suites_vecteurs
1 s tm1_suites_vecteursOTANGAD
 
3e tm5 calc litt_trigo_espace
3e tm5 calc litt_trigo_espace3e tm5 calc litt_trigo_espace
3e tm5 calc litt_trigo_espaceOTANGAD
 
3e tm4 fcts lin_calc litt_arithm
3e tm4 fcts lin_calc litt_arithm3e tm4 fcts lin_calc litt_arithm
3e tm4 fcts lin_calc litt_arithmOTANGAD
 
3e tm3 calc litt_fct_thales
3e tm3 calc litt_fct_thales3e tm3 calc litt_fct_thales
3e tm3 calc litt_fct_thalesOTANGAD
 
3e tm2 4em_fct_thales
3e tm2 4em_fct_thales3e tm2 4em_fct_thales
3e tm2 4em_fct_thalesOTANGAD
 
3e tm1 notions 4e_image fct
3e tm1 notions 4e_image fct3e tm1 notions 4e_image fct
3e tm1 notions 4e_image fctOTANGAD
 

Plus de OTANGAD (16)

AU FABLAB
AU FABLABAU FABLAB
AU FABLAB
 
Travail geotortue
Travail geotortueTravail geotortue
Travail geotortue
 
7 affiche maira
7 affiche maira7 affiche maira
7 affiche maira
 
6 affiche camila_gabriel_anita
6 affiche camila_gabriel_anita6 affiche camila_gabriel_anita
6 affiche camila_gabriel_anita
 
5 affiche louise_arts
5 affiche louise_arts5 affiche louise_arts
5 affiche louise_arts
 
4 affiche louise_truchet
4 affiche louise_truchet4 affiche louise_truchet
4 affiche louise_truchet
 
2 affiche enrique_lua_truchet1
2 affiche enrique_lua_truchet12 affiche enrique_lua_truchet1
2 affiche enrique_lua_truchet1
 
1 affiche arthur_ernesto_luisfelipe_pileouface
1 affiche arthur_ernesto_luisfelipe_pileouface1 affiche arthur_ernesto_luisfelipe_pileouface
1 affiche arthur_ernesto_luisfelipe_pileouface
 
Des réponses possibles au problème du tirage des 100 lancers de pile ou face.
Des réponses possibles au problème du tirage des 100 lancers de pile ou face.Des réponses possibles au problème du tirage des 100 lancers de pile ou face.
Des réponses possibles au problème du tirage des 100 lancers de pile ou face.
 
Sur le cycle3_mathematiques
Sur le cycle3_mathematiquesSur le cycle3_mathematiques
Sur le cycle3_mathematiques
 
1 s tm1_suites_vecteurs
1 s tm1_suites_vecteurs1 s tm1_suites_vecteurs
1 s tm1_suites_vecteurs
 
3e tm5 calc litt_trigo_espace
3e tm5 calc litt_trigo_espace3e tm5 calc litt_trigo_espace
3e tm5 calc litt_trigo_espace
 
3e tm4 fcts lin_calc litt_arithm
3e tm4 fcts lin_calc litt_arithm3e tm4 fcts lin_calc litt_arithm
3e tm4 fcts lin_calc litt_arithm
 
3e tm3 calc litt_fct_thales
3e tm3 calc litt_fct_thales3e tm3 calc litt_fct_thales
3e tm3 calc litt_fct_thales
 
3e tm2 4em_fct_thales
3e tm2 4em_fct_thales3e tm2 4em_fct_thales
3e tm2 4em_fct_thales
 
3e tm1 notions 4e_image fct
3e tm1 notions 4e_image fct3e tm1 notions 4e_image fct
3e tm1 notions 4e_image fct
 

3 affiche enrique_lua_truchet2

  • 1. Mais comment passer des s´equences aux pavages? C’est grˆace `a cet algorithme en language Python qu’on parvient `a transformer une s´equence de pile ou face sur excel en un pavage de Truchet. 1 import pygame , Buttons 2 from pygame . l o c a l s import ∗ 3 from PIL import Image 4 import random 5 import x l r d 6 import os 7 8 #o u v e r t u r e du f i c h i e r e x c e l 9 workbook = x l r d . open workbook ( ’ C l a s s e u r 1 . x l s ’ ) 10 s h e e t = workbook . s h e e t b y i n d e x ( 0 ) 11 12 d e f av ( x , y , dh ) : 13 i f ( x==0 and y>0) : 14 r e t u r n ( dh∗x+y−1) 15 e l i f ( x>0) : 16 r e t u r n ( ( x−1)∗dh+y ) 17 random . seed ( ) 18 #Ouverture des images n c e s s a i r e s 19 pr = Image . open ( ” pr . png” ) 20 pv = Image . open ( ”pv . png” ) 21 f r = Image . open ( ” f r . png” ) 22 f v = Image . open ( ” f v . png” ) 23 24 ( width , h e i g h t )= pr . s i z e 25 #l e c t u r e des i n f o r m a t i o n s du t a b l e u r 26 n=s h e e t . nrows 27 c=s h e e t . n c o l s 28 29 #C r e a t i o n d ’ une l i s t e 30 pouf = [ [ ] f o r i i n xrange ( n ) ] 31 f o r i i n xrange ( 0 , n ) : 32 f o r h i n xrange ( 0 , c ) : 33 #Ajout des i n f o r m a t i o n s du t a b l e a u dans l a l i s t e pouf 34 i f s h e e t . c e l l v a l u e ( h , i )==”F” : 35 pouf [ i ] . append ( ”F” ) 36 e l i f s h e e t . c e l l v a l u e ( h , i )==”P” : 37 pouf [ i ] . append ( ”P” ) 38 39 #C r e a t i o n d ’ une image qui s ’ adapte l a t a i l l e du t a b l e u r 40 image=Image . new ( ”RGB” , ( n∗width , c∗ h e i g h t ) , ( 2 5 5 , 2 5 5 , 2 5 5 ) ) 41 ( iwidth , i h e i g h t ) = image . s i z e 42 dh = i h e i g h t / h e i g h t 43 dw = i w i d t h / width 44 l o g = [ ] 45 46 #Ajout des images s u i v a n t l a sequence d ’ e x c e l 47 f o r x i n xrange ( 0 , dh ) : 48 f o r y i n xrange ( 0 ,dw) : 49 avant = av ( x , y , dh ) 50 i f ( pouf [ x ] [ y]==”F” ) : 51 i f ( x==0 and y==0) : 52 g . p a s t e ( fv , ( x∗width , y∗ h e i g h t ) ) 53 l o g . append ( ” f v ” ) 54 e l s e : 55 i f ( l o g [ avant]==” f v ” or l o g [ avant]==” pr ” ) : 56 g . p a s t e ( f r , ( x∗width , y∗ h e i g h t ) ) 57 l o g . append ( ” f r ” ) 58 e l i f ( l o g [ avant]==” f r ” or l o g [ avant]==”pv” ) : 59 g . p a s t e ( fv , ( x∗width , y∗ h e i g h t ) ) 60 l o g . append ( ” f v ” ) 61 e l i f ( pouf [ x ] [ y ] . upper ( )==”P” ) : 62 i f ( x==0 and y==0) : 63 g . p a s t e ( pv , ( x∗width , y∗ h e i g h t ) ) 64 l o g . append ( ”pv” ) 65 e l s e : 66 i f ( l o g [ avant]==”pv” or l o g [ avant]==” f r ” ) : 67 g . p a s t e ( pr , ( x∗width , y∗ h e i g h t ) ) 68 l o g . append ( ” pr ” ) 69 e l i f ( l o g [ avant]==” pr ” or l o g [ avant]==” f v ” ) : 70 g . p a s t e ( pv , ( x∗width , y∗ h e i g h t ) ) 71 l o g . append ( ”pv” ) 72 #Ouvrir l ’ image 73 image . show ( ) Cet algorithme permet de cr´eer des chefs-d’œuvre comme les pavages suivants: Pour cela, il suffit de changer les images de base et inventer un dessin unique. Enrique Lacal et Lu˜a Streit