Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
TABBONE Lucas
cs54 challenge BRULLARD_TABBONE_DUHOUX_HENEAUX
Commits
47682ca2
Commit
47682ca2
authored
3 years ago
by
Baptiste Brullard
Browse files
Options
Download
Email Patches
Plain Diff
Answer first question
parent
d6de375a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
cs54_ex01.py
cs54_ex01.py
+102
-0
No files found.
cs54_ex01.py
0 → 100644
View file @
47682ca2
# Conversion en binaire et ajout des 0 manquants
def
convertToBinary
(
number
,
padding
):
binary
=
bin
(
number
)[
2
:]
res
=
str
(
binary
)
while
(
len
(
res
)
<
padding
):
res
=
"0"
+
str
(
res
)
return
res
# Conversion des 0/1 en figures
def
convertBinaryToFigure
(
str
):
res
=
""
for
i
in
range
(
len
(
str
)
):
if
(
str
[
i
]
==
'1'
):
res
+=
' '
else
:
res
+=
'██'
return
res
# Parcours de la liste et assamblage du QRCode
def
traverse
(
liste
):
res
=
""
for
i
in
range
(
0
,
len
(
liste
)):
if
(
i
>
0
):
res
+=
"
\n
"
for
j
in
range
(
0
,
len
(
liste
[
i
])):
v
=
liste
[
i
][
j
][
0
]
p
=
liste
[
i
][
j
][
1
]
binary
=
convertToBinary
(
v
,
p
)
res
+=
convertBinaryToFigure
(
binary
)
print
(
res
)
list
=
[
[
[
1
,
1
],[
3
,
2
],[
7
,
3
],[
85
,
7
],[
15
,
5
],[
7
,
3
]
],
[
[
8
,
4
],[
0
,
1
],[
17
,
6
],[
2
,
3
],[
2
,
2
],[
0
,
4
],[
1
,
1
]
],
[
[
11
,
4
],[
1
,
1
],[
2
,
3
],[
77
,
7
],[
3
,
3
],[
5
,
3
]
],
[
[
1
,
1
],[
1
,
2
],[
1
,
1
],[
1
,
1
],[
0
,
1
],[
19
,
5
],[
9
,
4
],[
29
,
6
]
],
[
[
1
,
1
],[
29
,
6
],[
0
,
2
],[
58
,
7
],[
3
,
2
],[
5
,
3
]
],
[
[
2
,
2
],[
0
,
1
],[
0
,
3
],[
5
,
3
],[
0
,
2
],[
0
,
3
],[
65
,
7
]
],
[
[
127
,
7
],[
0
,
1
],[
1
,
1
],[
21
,
6
],[
31
,
5
],[
1
,
1
]
],
[
[
0
,
2
],[
0
,
3
],[
0
,
3
],[
10
,
6
],[
0
,
7
]
],
[
[
5
,
3
],[
12
,
7
],[
98
,
7
],[
2
,
3
],[
1
,
1
]
],
[
[
7
,
3
],[
14
,
4
],[
13
,
4
],[
4
,
4
],[
26
,
5
],[
1
,
1
]
],
[
[
0
,
1
],[
26
,
5
],[
58
,
6
],[
9
,
4
],[
21
,
5
]
],
[
[
22
,
5
],[
85
,
7
],[
1
,
2
],[
57
,
7
]
],
[
[
1
,
1
],[
95
,
7
],[
10
,
4
],[
4
,
3
],[
3
,
6
]
],
[
[
0
,
7
],[
3
,
3
],[
30
,
5
],[
25
,
6
]
],
[
[
3
,
2
],[
15
,
4
],[
41
,
6
],[
31
,
5
],[
13
,
4
]
],
[
[
1
,
1
],[
1
,
6
],[
0
,
2
],[
3
,
3
],[
1
,
2
],[
0
,
1
],[
1
,
1
],[
0
,
2
],[
1
,
3
]
],
[
[
93
,
7
],[
0
,
1
],[
40
,
7
],[
1
,
1
],[
1
,
2
],[
0
,
1
],[
0
,
2
]
],
[
[
46
,
6
],[
2
,
2
],[
3
,
5
],[
0
,
1
],[
0
,
1
],[
60
,
6
]
],
[
[
46
,
6
],[
11
,
4
],[
5
,
5
],[
3
,
3
],[
1
,
2
],[
1
,
1
]
],
[
[
1
,
1
],[
0
,
3
],[
1
,
3
],[
2
,
4
],[
24
,
6
],[
4
,
3
],[
0
,
1
]
],
[
[
1
,
1
],[
1
,
1
],[
125
,
7
],[
1
,
1
],[
5
,
3
],[
0
,
1
],[
4
,
6
],[
1
,
1
]
]
]
#Lancement du programme
traverse
(
list
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment