Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Grégoire PETIT
DataScience
Commits
7aaa0235
Commit
7aaa0235
authored
Nov 29, 2018
by
Grégoire PETIT
Browse files
height -> size (clearer)
parent
01a0fc5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Challenge3/code/challenge3.py
View file @
7aaa0235
...
@@ -85,8 +85,8 @@ def voisins(graphe,x,y):
...
@@ -85,8 +85,8 @@ def voisins(graphe,x,y):
flat
.
append
(
point
)
flat
.
append
(
point
)
return
(
flat
)
return
(
flat
)
def
neighbors
(
node
,
height
):
def
neighbors
(
node
,
size
):
#
height
represent the whole size of the image
#
size
represent the whole size of the image
my_neighbors
=
[]
my_neighbors
=
[]
x
,
y
=
node
[
0
],
node
[
1
]
x
,
y
=
node
[
0
],
node
[
1
]
...
@@ -96,15 +96,15 @@ def neighbors(node, height):
...
@@ -96,15 +96,15 @@ def neighbors(node, height):
my_neighbors
.
append
((
x
,
y
-
1
))
my_neighbors
.
append
((
x
,
y
-
1
))
if
x
-
1
>=
0
and
y
-
1
>=
0
:
if
x
-
1
>=
0
and
y
-
1
>=
0
:
my_neighbors
.
append
((
x
-
1
,
y
-
1
))
my_neighbors
.
append
((
x
-
1
,
y
-
1
))
if
x
+
1
<
height
[
0
]:
if
x
+
1
<
size
[
0
]:
my_neighbors
.
append
((
x
+
1
,
y
))
my_neighbors
.
append
((
x
+
1
,
y
))
if
y
+
1
<
height
[
1
]:
if
y
+
1
<
size
[
1
]:
my_neighbors
.
append
((
x
,
y
+
1
))
my_neighbors
.
append
((
x
,
y
+
1
))
if
x
+
1
<
height
[
0
]
and
y
+
1
<
height
[
1
]:
if
x
+
1
<
size
[
0
]
and
y
+
1
<
size
[
1
]:
my_neighbors
.
append
((
x
+
1
,
y
+
1
))
my_neighbors
.
append
((
x
+
1
,
y
+
1
))
if
x
+
1
<
height
[
0
]
and
y
-
1
>=
0
:
if
x
+
1
<
size
[
0
]
and
y
-
1
>=
0
:
my_neighbors
.
append
((
x
+
1
,
y
-
1
))
my_neighbors
.
append
((
x
+
1
,
y
-
1
))
if
y
+
1
<
height
[
1
]
and
x
-
1
>=
0
:
if
y
+
1
<
size
[
1
]
and
x
-
1
>=
0
:
my_neighbors
.
append
((
x
-
1
,
y
+
1
))
my_neighbors
.
append
((
x
-
1
,
y
+
1
))
return
my_neighbors
return
my_neighbors
...
...
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