mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-09 11:30:38 +00:00
Auto urgent commit.
This commit is contained in:
22
graphes/leaudibidon/correction.py
Normal file
22
graphes/leaudibidon/correction.py
Normal file
@@ -0,0 +1,22 @@
|
||||
def produit_cartesien(*listes):
|
||||
if not listes:
|
||||
return []
|
||||
if len(listes) == 1:
|
||||
return listes[0]
|
||||
if len(listes) == 2:
|
||||
liste1, liste2 = listes
|
||||
resultat = list()
|
||||
for tuple_1 in liste1:
|
||||
for tuple_2 in liste2:
|
||||
resultat.append(tuple_1 + tuple_2)
|
||||
return resultat
|
||||
liste1, *reste = listes
|
||||
return produit_cartesien(liste1, produit_cartesien(*reste))
|
||||
|
||||
|
||||
|
||||
liste1 = [(_,) for _ in range(3)]
|
||||
liste2 = [(_,) for _ in range(5)]
|
||||
liste3 = [(_,)for _ in range(8)]
|
||||
print(produit_cartesien(liste1,liste2))
|
||||
|
||||
Reference in New Issue
Block a user