Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ssic_idea
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
dario.genga
ssic_idea
Commits
46a1d7ae
Commit
46a1d7ae
authored
3 years ago
by
rayyan.belhi
Browse files
Options
Downloads
Patches
Plain Diff
Update main.py
parent
415651dc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+26
-5
26 additions, 5 deletions
main.py
with
26 additions
and
5 deletions
main.py
+
26
−
5
View file @
46a1d7ae
...
...
@@ -27,13 +27,34 @@ def mul_mod(a,b): # (a*b) mod 17 // p.3
return
res
def
xor
(
a
,
b
):
#
ne transforme pas les int en str,
# accepte
qu'en binaire str et de même taille
def
xor
(
a
,
b
):
#a XOR b = str(binaire)
#
CODE SPAGHETTI | À OPTIMISER SI POSSIBLE
# accepte
des nombres (décimaux & binaires) qui n'ont pas la même taille (100 et 7 par exemple)
res
=
''
size
=
len
(
a
)
if
(
type
(
a
)
!=
str
):
#transforme les int en str (5 = 101 ; pas 0b101)
a
=
format
(
a
,
"
b
"
)
if
(
type
(
b
)
!=
str
):
#transforme les int en str (7 = 111 ; pas 0b101)
b
=
format
(
b
,
"
b
"
)
if
(
len
(
a
)
>
len
(
b
)):
#si len(a) > len(b), met b --> a & a --> b pour étape suivante où len(a) pourra être comme len(b)
tmp
=
a
a
=
b
b
=
tmp
if
(
len
(
a
)
<
len
(
b
)):
#partie ou on met les 2 strings à la même taille.
l_a
=
len
(
a
)
#int
l_b
=
len
(
b
)
#int
list
=
[]
list
=
((
l_b
-
l_a
)
*
'
0
'
,
a
)
#à gauche, le nombre de '0' nécessaire pour avoir la même taille que 'b'
# & à droite 'a' qui est le plus petit str
a
=
''
.
join
(
list
)
#fusion des '0' et du str(a)
i
=
0
while
i
<
size
:
size
=
len
(
a
)
#choisis 'a', mais on aurait pu mettre 'b'; same
while
i
<
size
:
#fonction XOR
if
a
[
i
]
==
b
[
i
]:
res
+=
'
0
'
else
:
...
...
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