23 lines
474 B
Python
Executable file
23 lines
474 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
"""Vérifie si deux chaînes S1 et S2 sont anagrammes"""
|
|
|
|
|
|
def main() -> None:
|
|
print(SontAnagrammes("chien", "niche"))
|
|
|
|
|
|
def SontAnagrammes(S1 : str, S2 : str) -> bool:
|
|
if len(S1) == 0 and len(S2) == 0:
|
|
return True
|
|
elif len(S1) != len(S2):
|
|
return False
|
|
else:
|
|
lettre = S1[0]
|
|
S1 = S1[1:]
|
|
S2 = S2.replace(lettre, "", 1)
|
|
return SontAnagrammes(S1, S2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|