Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sudoku solver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silas Dohm
sudoku solver
Commits
1d08e830
Commit
1d08e830
authored
2 years ago
by
Silas Dohm
Browse files
Options
Downloads
Patches
Plain Diff
var names
parent
e9e29398
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
window.cpp
+14
-14
14 additions, 14 deletions
window.cpp
with
14 additions
and
14 deletions
window.cpp
+
14
−
14
View file @
1d08e830
...
@@ -88,21 +88,21 @@ void Window::solveButtonClicked()
...
@@ -88,21 +88,21 @@ void Window::solveButtonClicked()
if
(
backtracking
)
if
(
backtracking
)
{
{
hist
.
back
().
cell
->
collapsedCellClicked
();
hist
.
back
().
cell
->
collapsedCellClicked
();
std
::
vector
<
int
>
b
;
std
::
vector
<
int
>
validNrs
;
for
(
int
i
=
0
;
i
<
9
;
i
++
)
for
(
int
i
=
0
;
i
<
9
;
i
++
)
if
(
hist
.
back
().
blocked
[
i
]
==
0
)
if
(
hist
.
back
().
blocked
[
i
]
==
0
)
b
.
push_back
(
i
);
validNrs
.
push_back
(
i
);
if
(
b
.
size
()
==
0
)
if
(
validNrs
.
size
()
==
0
)
{
{
hist
.
pop_back
();
hist
.
pop_back
();
continue
;
continue
;
}
}
backtracking
=
false
;
backtracking
=
false
;
int
choice
Nr
=
rand
()
%
b
.
size
();
// choose a random number;
int
rnd
Nr
=
rand
()
%
validNrs
.
size
();
// choose a random number;
repaint
();
// draw cells again
repaint
();
// draw cells again
delay
(
delayTime
);
delay
(
delayTime
);
hist
.
back
().
cell
->
collapse
(
b
[
choice
Nr
]);
// collapse cell with chosen number;
hist
.
back
().
cell
->
collapse
(
validNrs
[
rnd
Nr
]);
// collapse cell with chosen number;
hist
.
back
().
blocked
[
b
[
choice
Nr
]]
++
;
hist
.
back
().
blocked
[
validNrs
[
rnd
Nr
]]
++
;
}
}
else
else
{
{
...
@@ -138,16 +138,16 @@ void Window::solveButtonClicked()
...
@@ -138,16 +138,16 @@ void Window::solveButtonClicked()
continue
;
continue
;
}
}
int
choice
Cell
=
rand
()
%
b
.
size
();
// choose a random cell
int
rnd
Cell
=
rand
()
%
b
.
size
();
// choose a random cell
std
::
vector
<
int
>
c
;
std
::
vector
<
int
>
validNrs
;
for
(
int
i
=
0
;
i
<
9
;
i
++
)
for
(
int
i
=
0
;
i
<
9
;
i
++
)
{
{
if
(
b
[
choice
Cell
]
->
blocked
[
i
]
==
0
)
if
(
b
[
rnd
Cell
]
->
blocked
[
i
]
==
0
)
c
.
push_back
(
i
);
validNrs
.
push_back
(
i
);
}
}
int
choice
Nr
=
rand
()
%
c
.
size
();
// choose a random number;
int
rnd
Nr
=
rand
()
%
validNrs
.
size
();
// choose a random number;
hist
.
push_back
(
History
(
b
[
choice
Cell
],
b
[
choice
Cell
]
->
blocked
,
c
[
choiceNr
]));
// fix this!!!
hist
.
push_back
(
History
(
b
[
rnd
Cell
],
b
[
rnd
Cell
]
->
blocked
,
validNrs
[
rndNr
]));
b
[
choice
Cell
]
->
collapse
(
c
[
choiceNr
]);
// collapse that random cell with chosen number;
b
[
rnd
Cell
]
->
collapse
(
validNrs
[
rndNr
]);
// collapse that random cell with chosen number;
}
}
}
}
}
}
...
...
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