# -*- coding: utf-8 -*-
"""
Created on Sat Oct 31 14:01:10 2026

@author: anplo
"""

#%% Ouvrir le ficher

#Q1 Lecture de L

text = open("liste_mots.txt", "r" , encoding='utf-8')

L = text.readlines()
text.close()


#Q2 suppression des '\n'

for i in range(len(L)) :
    
    if L[i][-1] == '\n':
        L[i] = L[i][:-1]

import unicodedata

L = [unicodedata.normalize("NFC", mot) for mot in L]

#%%
#Q3 nettoyage mots composés

L1 = []
for m in L :
    
    if "-" not in m :
        L1.append(m)
        
L = L1
        
        
#%%
        
#Q4 : Mots les plus long 

L1 = ["a"]

for m in L :
    
    if len(m) > len(L1[0]):
        L1 = [m]
        
    elif len(m) == len(L1[0]):
        L1.append(m)
        
print(len(L1[0]),L1)

#%% 
#Q5 : Mots avec "à"

L1 = []

for m in L :
    if "à" in  m:
        L1.append(m)
        
print(L1)

#%% Q6
# le mot qui contient le plus la lettre "t"    
  

def compte_T(m):
    
    compteur =0
    
    for c in m :
        if c == 't':
            compteur += 1
                
    return compteur
        
     
L1 = []
maxi = 0
for m in L :
    c = compte_T(m)
    if c > maxi:
        L1 = [m]
        maxi = c
        
    elif c == maxi:
        L1.append(m)
        
print(maxi,L1)     

#%% Q7
# Mot contenant toutes les voyelles 
        
liste_voy = ["aà","eéëèê", "oô", "iïî","uù","y"]

def contient_voyelles(m):
    
    for s in liste_voy :
        pas_dedans = True
        for i in s :
            if i in m:
                pas_dedans = False 
        if pas_dedans :
            return False
        
    return True
        
L1 = []
for m in L :
    if contient_voyelles(m):
        L1.append(m)
        
print(len(L1),L1)  

#%% Q8
# le plus long mot composé uniquement de voyelles


Voyelles = "AEIOUaeiouyàéëêèùïôö"

def contient_consomne(m):
    
    for c in m :
        if c not in Voyelles :
            return True
                
    return False
        
L1 = []
maxi = 0
for m in L :
    if not(contient_consomne(m)):
        c = len(m)
        if c > maxi:
            L1 = [m]
            maxi = c
        
        elif c == maxi:
            L1.append(m)
        
print(maxi,L1) 

#%% Q9
# Compte de voyelles identiques     

liste_voy = ["aà","eéëèê", "oô", "iïî","uù","y"]

def compte_voyelles_sim(m):
    
    compteur = [0,0,0,0,0,0]
    
    for c in m :
        for i in range(len(liste_voy)):
            
            if c in liste_voy[i]:
                compteur[i] += 1
                
    return max(compteur)

print(compte_voyelles_sim("indivisibilité"))
        
     
L1 = []
maxi = 0
for m in L :
    c = compte_voyelles_sim(m)
    if c > maxi:
        L1 = [m]
        maxi = c
        
    elif c == maxi:
        L1.append(m)
        
print(maxi,L1)          

    
#%%
#Q10 : Mot avec le plus de consomnes consécutifs

Voyelles = "AEIOUaâeiîouyàéëêèùïôö"

def compte_consomne_consec(m):
    
    compteur = 0; maxi = 0
    for i in m:
        
        if i in Voyelles :
            if compteur > maxi :
                maxi = compteur
            compteur = 0
        else :
            compteur += 1
    
    if compteur > maxi :
        maxi = compteur
    compteur = 0
            
    return maxi


print(compte_consomne_consec("abracadabra"))      
print(compte_consomne_consec("obstination"))       
        

L1 = []
maxi = 0
for m in L :
    c = compte_consomne_consec(m)
    if c > maxi:
        L1 = [m]
        maxi = c
        
    elif c == maxi:
        L1.append(m)
        
print(maxi,L1)



 

   
        
#%% 
# Mot contenant le plus de voyelles

Voyelles = "AEIOUaeiouyàéëêèùïôö"

def compte_voyelles(m):
    
    compteur = 0
    for i in m:
        if i in Voyelles :
            compteur += 1
        
    return compteur      
        
        
L1 = []
maxi = 0
for m in L :
    c = compte_voyelles(m)
    if c > maxi:
        L1 = [m]
        maxi = c
        
    elif c == maxi:
        L1.append(m)
        
print(maxi,L1)      
        






#%%
def compte_voyelles_consec(m):
    
    compteur = 0; maxi = 0
    for i in m:
        
        if i not in Voyelles :
            if compteur > maxi :
                maxi = compteur
            compteur = 0
        else :
            compteur += 1
    
    if compteur > maxi :
        maxi = compteur
    compteur = 0
            
    return maxi


print(compte_voyelles_consec("abracadabra"))      
print(compte_voyelles_consec("obstination"))       
        

L1 = []
maxi = 0
for m in L :
    c = compte_voyelles_consec(m)
    if c > maxi:
        L1 = [m]
        maxi = c
        
    elif c == maxi:
        L1.append(m)
        
print(maxi,L1)
