Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Python prototype
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
Cinematinator
Python prototype
Commits
4aea0ff1
Commit
4aea0ff1
authored
4 years ago
by
Rick van Hoef
Browse files
Options
Downloads
Patches
Plain Diff
start isomorphic compare
parent
c6580148
Branches
isomorphic-cinema-compare
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cinematinator/types.py
+46
-0
46 additions, 0 deletions
cinematinator/types.py
with
46 additions
and
0 deletions
cinematinator/types.py
+
46
−
0
View file @
4aea0ff1
...
...
@@ -100,3 +100,49 @@ class Cinema:
amount
+=
1
return
amount
def
isomorphic_compare
(
self
,
other
:
Cinema
)
->
bool
:
# size of the grid
size
=
height
*
width
# the four possible directions in the other cinema
# we will also find isomorphisms that are shifted versions of this cinema
# in all directions
start
,
north
,
south
,
west
,
east
=
0
,
0
,
0
,
0
,
0
# skipping empty seats in every direction, including the current cinema
while
self
.
seats
[
start
]
!=
SeatStatus
.
Available
:
start
=
start
+
1
while
other
.
seats
[
north
]
!=
SeatStatus
.
Available
:
north
=
north
+
1
while
other
.
seats
[
size
-
south
-
1
]
!=
SeatStatus
.
Available
:
south
=
south
+
1
# I hate this indexing, but it will do for now
while
(
other
.
seats
[
width
*
(
east
//
width
)
+
width
-
east
%
width
-
1
]
!=
SeatStatus
.
Available
):
east
=
east
+
1
while
(
other
.
seats
[
size
-
width
*
(
west
//
width
)
-
width
+
(
west
%
width
)]
!=
SeatStatus
.
Available
):
west
=
west
+
1
# actual compare (just once cause I'm done for today)
for
i
in
range
(
size
-
start
):
if
self
.
seats
[
start
]
==
SeatStatus
.
Available
:
if
other
.
seats
[
i
+
north
]
!=
SeatStatus
.
Available
:
break
else
:
if
other
.
seats
[
i
+
north
]
==
SeatStatus
.
Available
:
break
if
i
==
size
-
start
:
# actually still have to check if the rest is empty, but I'm done for today
return
True
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