Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2019-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
adc2019
adc2019-system
Commits
51109486
Commit
51109486
authored
Aug 06, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add scripts for analyzing the groups of the blocks in a problem
parent
b6afe55f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
8 deletions
+127
-8
.gitignore
.gitignore
+1
-0
part_problems.html
templates/part_problems.html
+18
-6
data.py
utils/data.py
+108
-2
No files found.
.gitignore
View file @
51109486
...
...
@@ -2,6 +2,7 @@
# Project-specific files
/conf*.json
/test.py
/problems/*
!/problems/.gitkeep
/solutions/*
...
...
templates/part_problems.html
View file @
51109486
...
...
@@ -2,18 +2,30 @@
<thead>
<tr>
<th
class=
"large-cell"
>
File Name
</th>
<th
class=
"small-cell"
>
Size
</th>
<th
class=
"small-cell"
>
#Blocks
</th>
<th
class=
"large-cell"
>
Status
</th>
<th
class=
"small-cell"
>
Size
<br
/>
#B/#L/#G
</th>
<!-- <th class="small-cell">B/L/G</th> -->
<th
class=
"small-cell"
>
Status
</th>
</tr>
</thead>
<tbody>
{% for k, v in problems.items() %}
<tr
class=
"problem-row"
data-problem=
"{{v.name}}"
>
<td
class=
"large-cell"
>
{{v.name}}
</td>
<td
class=
"small-cell"
>
{{v.size_str}}
</td>
<td
class=
"small-cell"
>
{{v.block_num}}
</td>
<td
class=
"large-cell"
>
{{v.status}}
</td>
<td
class=
"small-cell"
>
{{v.size_str}}
<br
/>
{{v.block_num}} /
{{v.line_numbers | length - 1}} /
{{v.block_groups | length}}
</td>
<!-- <td class="small-cell">
{{v.block_num}}/
{{v.line_numbers | length}}/
{{v.block_groups | length}}
</td> -->
<td
class=
"small-cell"
>
{{v.status}}
</td>
</tr>
{% endfor %}
</tbody>
...
...
utils/data.py
View file @
51109486
import
datetime
import
json
import
os
import
queue
import
re
import
time
import
uuid
class
Problem
(
object
):
def
__init__
(
self
,
problem_path
,
solution_path
):
def
__init__
(
self
,
problem_path
,
solution_path
=
None
):
self
.
path
=
problem_path
self
.
name
=
''
...
...
@@ -19,6 +20,9 @@ class Problem(object):
self
.
solutions
=
dict
()
self
.
solution_path
=
solution_path
self
.
best_solution
=
None
self
.
line_numbers
=
list
()
self
.
connection
=
tuple
()
self
.
block_groups
=
list
()
self
.
_load_problem
(
problem_path
)
...
...
@@ -26,6 +30,35 @@ class Problem(object):
def
size_str
(
self
):
return
f
'{self.size[0]}X{self.size[1]}'
@
property
def
problem_text
(
self
):
def
intplus
(
v
):
if
v
.
isdecimal
():
return
int
(
v
)
else
:
return
v
_text
=
''
_text
+=
f
'SIZE {self.size_str}
\n
'
_text
+=
f
'BLOCK_NUM {self.block_num}
\n
'
_text
+=
'
\n
'
for
bi
,
block
in
self
.
blocks
.
items
():
_text
+=
f
'BLOCK#{bi} {block["w"]}X{block["h"]}
\n
'
for
cr
in
block
[
'cells'
]:
for
cci
,
cc
in
enumerate
(
cr
):
if
cci
>
0
:
_text
+=
','
if
isinstance
(
cc
,
int
)
and
cc
>
0
:
cc
=
self
.
line_numbers
.
index
(
cc
)
_text
+=
f
'{cc}'
_text
+=
'
\n
'
_text
+=
'
\n
'
return
_text
@
property
def
status
(
self
):
_status
=
'None'
...
...
@@ -64,6 +97,11 @@ class Problem(object):
else
:
return
v
line_number_list
=
[
0
]
block_to_line
=
dict
()
line_to_block
=
dict
()
li
=
0
while
li
<
len
(
q_lines
):
_l
=
q_lines
[
li
]
...
...
@@ -87,7 +125,25 @@ class Problem(object):
for
_h
in
range
(
bh
):
li
+=
1
_l
=
q_lines
[
li
]
.
strip
()
blocks
[
bi
][
'cells'
]
.
append
([
intplus
(
v
.
strip
())
for
v
in
_l
.
split
(
','
)])
_block_row
=
[]
for
v
in
_l
.
split
(
','
):
_line_num
=
intplus
(
v
.
strip
())
if
isinstance
(
_line_num
,
int
)
and
_line_num
>
0
:
# Line number conversion
if
not
_line_num
in
line_number_list
:
line_number_list
.
append
(
_line_num
)
# _line_num = line_number_list.index(_line_num)
# Make connection list
if
not
bi
in
block_to_line
:
block_to_line
[
bi
]
=
list
()
block_to_line
[
bi
]
.
append
(
_line_num
)
if
not
_line_num
in
line_to_block
:
line_to_block
[
_line_num
]
=
list
()
line_to_block
[
_line_num
]
.
append
(
bi
)
_block_row
.
append
(
_line_num
)
blocks
[
bi
][
'cells'
]
.
append
(
_block_row
)
# blocks[bi]['cells'].append([intplus(v.strip()) for v in _l.split(',')])
li
+=
1
...
...
@@ -98,8 +154,58 @@ class Problem(object):
self
.
blocks
=
blocks
self
.
name
=
name
self
.
problem
=
q_text
self
.
line_numbers
=
line_number_list
self
.
connection
=
(
line_to_block
,
block_to_line
)
# self.status = 'Ready'
self
.
_analyze_block_groups
()
def
_analyze_block_groups
(
self
):
traversed_block
=
list
()
line_to_block
=
self
.
connection
[
0
]
block_to_line
=
self
.
connection
[
1
]
block_groups
=
list
()
for
b
in
block_to_line
.
keys
():
if
b
in
traversed_block
:
continue
traverse_block_queue
=
queue
.
Queue
()
traverse_block_queue
.
put
(
b
)
target_group_blocks
=
list
()
while
not
traverse_block_queue
.
empty
():
target_block
=
traverse_block_queue
.
get
()
target_block_lines
=
block_to_line
[
target_block
]
if
target_block
in
traversed_block
:
continue
traversed_block
.
append
(
target_block
)
target_group_blocks
.
append
(
target_block
)
for
line
in
target_block_lines
:
corresponding_blocks
=
line_to_block
[
line
]
if
corresponding_blocks
[
0
]
==
target_block
:
next_block
=
corresponding_blocks
[
1
]
else
:
next_block
=
corresponding_blocks
[
0
]
if
next_block
in
traversed_block
:
continue
else
:
traverse_block_queue
.
put
(
next_block
)
block_groups
.
append
(
target_group_blocks
)
self
.
block_groups
=
block_groups
def
get_dict
(
self
):
return
{
'name'
:
self
.
name
,
...
...
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