Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-Dahmane-lynda
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lynda Dahmane
AP-Dahmane-lynda
Commits
ed3ad4d9
Commit
ed3ad4d9
authored
1 year ago
by
Dahmane Lynda
Browse files
Options
Downloads
Patches
Plain Diff
suite anagrammes
parent
50fa6fa9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tp1/anagrammes.py
+32
-12
32 additions, 12 deletions
Tp1/anagrammes.py
with
32 additions
and
12 deletions
Tp1/anagrammes.py
+
32
−
12
View file @
ed3ad4d9
...
...
@@ -36,11 +36,11 @@
#>>>"!".join(s)
#"la méthode split est parfois bien utile"
#>>>"".join()
#
"la méthode split est parfois bien utile"
#
(" ")
#>>>"".join([])
#[]
#>>>"".join([1,2])
#"
la méthode split est parfois bien utile
"
#"
12
"
#Question 2:
# La methode join est utiliseé pour joindre les éléments d'une liste en une suele chaine de caractères
...
...
@@ -57,7 +57,7 @@
# """renvoie une nouvelle chaine de caractéres en concaténant les élement de
# l en les intercalant avec s.
#
# Précondition :
crypto
# Précondition :
# Exemple(s) :
# $$$ join('.', ['raymond', 'calbuth', 'ronchin', 'fr'])
# 'raymond.calbuth.ronchin.fr'
...
...
@@ -128,20 +128,40 @@ def sont_anagrammes(s1: str, s2: str) -> bool:
True
$$$ sont_anagrammes(
'
orange
'
,
'
Organe
'
)
False
"""
res
=
dict
()
d
=
dict
()
for
elt
in
s1
:
if
elt
in
res
:
dict1
=
dict
()
dict2
=
dict
()
for
elt
in
s1
:
if
elt
in
dict1
:
dect1
[
elt
]
=
dict1
[
elt
]
+
1
else
:
dict1
[
elt
]
=
1
for
elt
in
s2
:
if
elt
in
dict2
:
dect2
[
elt
]
=
dict2
[
elt
]
+
1
else
:
dict2
[
elt
]
=
1
d1
,
d2
=
list
(
dict1
),
list
(
dict2
)
d1
.
sort
(),
d2
.
sort
()
return
d1
==
d2
#question 3:
def
sont_anagrammes
(
s1
:
str
,
s2
:
str
)
->
bool
:
"""
Renvoie True si s1 et s2 sont anagrammatiques, False sinon
Précondition : aucune
Exemple(s) :
$$$ sont_anagrammes(
'
orange
'
,
'
organe
'
)
True
$$$ sont_anagrammes(
'
orange
'
,
'
Organe
'
)
False
$$$ sont_anagrammes(
'
orange
'
,
'
OrganE
'
)
False
"""
res
=
False
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment