Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sudoku
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
epita
sudoku
Commits
2c8c9cbf
Commit
2c8c9cbf
authored
18 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
356458b5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/grid.cc
+15
-12
15 additions, 12 deletions
src/grid.cc
with
15 additions
and
12 deletions
src/grid.cc
+
15
−
12
View file @
2c8c9cbf
...
...
@@ -138,21 +138,23 @@ int Grid::solve_square()
int
posed
=
0
;
for
(
int
v
=
1
;
v
<=
GRID_SIDE
;
++
v
)
for
(
int
i
=
0
;
i
<
GRID_SIDE
;
i
+=
3
)
for
(
int
j
=
0
;
j
<
GRID_SIDE
;
j
+=
3
)
{
for
(
int
y
=
0
;
y
<
GRID_SIDE
;
y
+=
3
)
for
(
int
x
=
0
;
x
<
GRID_SIDE
;
x
+=
3
)
{
int
v_count
=
0
;
int
x
,
y
;
for
(
int
k
=
i
;
k
<
3
;
++
k
)
for
(
int
l
=
j
;
l
<
3
;
++
l
)
if
(
!
block_
[
k
][
l
].
is_forbidden
(
v
))
{
x
=
k
;
y
=
l
;
int
last_x
,
last_
y
;
for
(
int
y2
=
y
;
y2
<
y
+
3
;
++
y2
)
for
(
int
x2
=
x
;
x2
<
x
+
3
;
++
x2
)
if
(
!
block_
[
x2
][
y2
].
is_forbidden
(
v
))
{
last_
x
=
x2
;
last_
y
=
y2
;
++
v_count
;
}
std
::
cout
<<
"block: ("
<<
x
<<
","
<<
y
<<
"), val: "
<<
v
<<
", v_count: "
<<
v_count
<<
std
::
endl
;
if
(
v_count
==
1
)
{
std
::
cerr
<<
"found "
<<
v
<<
" with solve_square in ("
<<
x
+
1
<<
","
<<
y
+
1
<<
")
\n
"
;
pose
(
x
,
y
,
v
);
std
::
cerr
<<
"found "
<<
v
<<
" with solve_square in ("
<<
last_
x
+
1
<<
","
<<
last_
y
+
1
<<
")
\n
"
;
pose
(
last_x
,
last_
y
,
v
);
++
posed
;
}
}
...
...
@@ -187,6 +189,7 @@ int Grid::solve_line()
++
posed
;
}
if
(
vertical_count
==
1
)
{
//dont pose the same number two times
if
(
!
(
horizontal_x
==
vertical_x
&&
horizontal_y
==
vertical_y
))
{
std
::
cerr
<<
"found "
<<
v
<<
" with solve_line_v in ("
<<
vertical_x
+
1
...
...
@@ -215,7 +218,7 @@ void Grid::print() const
std
::
cout
<<
"|"
;
for
(
int
j
=
i
*
3
+
1
;
j
<=
i
*
3
+
3
;
++
j
)
if
(
block_
[
x
][
y
].
get
()
==
j
)
std
::
cout
<<
"
\033
[
0
;32m"
<<
j
<<
"
\033
[0m"
;
std
::
cout
<<
"
\033
[
1
;32m"
<<
j
<<
"
\033
[0m"
;
else
if
(
block_
[
x
][
y
].
is_forbidden
(
j
))
std
::
cout
<<
"
\033
[0;31m"
<<
j
<<
"
\033
[0m"
;
else
...
...
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