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
2fb0703d
Commit
2fb0703d
authored
Aug 14, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for splitting a pattern-repeating problem
parent
a4c73f4e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
5 deletions
+50
-5
data.py
utils/data.py
+50
-5
No files found.
utils/data.py
View file @
2fb0703d
import
datetime
import
json
import
math
import
os
import
queue
import
re
...
...
@@ -70,6 +71,45 @@ class Problem(object):
return
_text
@
property
def
group_problem_text
(
self
):
group_problems
=
list
()
for
g
in
self
.
block_groups
:
problem_text
=
''
num_tiles
=
0
line_remap_list
=
list
()
block_text
=
''
for
bi
,
bn
in
enumerate
(
g
):
b
=
self
.
blocks
[
bn
]
num_tiles
+=
b
[
'num_tiles'
]
block_text
+=
f
'BLOCK#{bi+1} {b["w"]}X{b["h"]}
\n
'
for
br
in
b
[
'cells'
]:
br_cells
=
list
()
for
bc
in
br
:
if
isinstance
(
bc
,
int
)
and
bc
>
0
:
if
not
bc
in
line_remap_list
:
line_remap_list
.
append
(
bc
)
remapped_index
=
line_remap_list
.
index
(
bc
)
+
1
br_cells
.
append
(
str
(
remapped_index
))
else
:
br_cells
.
append
(
str
(
bc
))
block_text
+=
','
.
join
(
br_cells
)
+
'
\n
'
block_text
+=
'
\n
'
board_xy
=
math
.
ceil
(
2
*
math
.
sqrt
(
num_tiles
))
problem_text
+=
f
'SIZE {board_xy}X{board_xy}
\n
'
problem_text
+=
f
'BLOCK_NUM {len(g)}
\n
'
problem_text
+=
'
\n
'
problem_text
+=
block_text
group_problems
.
append
(
problem_text
)
return
group_problems
@
property
def
status
(
self
):
_status
=
'None'
...
...
@@ -133,8 +173,10 @@ class Problem(object):
'index'
:
bi
,
'w'
:
bw
,
'h'
:
bh
,
'cells'
:
list
()
'cells'
:
list
(),
'num_tiles'
:
0
}
num_block_tile
=
0
for
_h
in
range
(
bh
):
li
+=
1
_l
=
q_lines
[
li
]
.
strip
()
...
...
@@ -146,7 +188,7 @@ class Problem(object):
if
not
_line_num
in
line_number_list
:
line_number_list
.
append
(
_line_num
)
# _line_num = line_number_list.index(_line_num)
tile_num
+=
1
num_block_tile
+=
1
# Make connection list
if
not
bi
in
block_to_line
:
...
...
@@ -155,9 +197,12 @@ class Problem(object):
if
not
_line_num
in
line_to_block
:
line_to_block
[
_line_num
]
=
list
()
line_to_block
[
_line_num
]
.
append
(
bi
)
elif
_line_num
==
'+'
:
num_block_tile
+=
1
_block_row
.
append
(
_line_num
)
blocks
[
bi
][
'cells'
]
.
append
(
_block_row
)
# blocks[bi]['cells'].append([intplus(v.strip()) for v in _l.split(',')])
blocks
[
bi
][
'num_tiles'
]
=
num_block_tile
tile_num
+=
num_block_tile
li
+=
1
...
...
@@ -171,7 +216,6 @@ class Problem(object):
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
()
...
...
@@ -228,7 +272,8 @@ class Problem(object):
'size_str'
:
self
.
size_str
,
'block_num'
:
self
.
block_num
,
'problem'
:
self
.
problem
,
# 'status': self.status
'group_problems'
:
self
.
group_problem_text
,
'status'
:
self
.
status
}
def
get_d3json
(
self
):
...
...
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