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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silas Dohm
sudoku solver
Commits
e4cf0a7b
Commit
e4cf0a7b
authored
2 years ago
by
Silas Dohm
Browse files
Options
Downloads
Patches
Plain Diff
1d array
parent
2c0ceaab
No related branches found
No related tags found
1 merge request
!1
Master
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
cell.cpp
+3
-0
3 additions, 0 deletions
cell.cpp
cell.h
+1
-0
1 addition, 0 deletions
cell.h
window.cpp
+14
-14
14 additions, 14 deletions
window.cpp
window.h
+2
-1
2 additions, 1 deletion
window.h
with
20 additions
and
15 deletions
cell.cpp
+
3
−
0
View file @
e4cf0a7b
...
...
@@ -31,6 +31,9 @@ Cell::Cell(QWidget *parent) : QWidget(parent)
connect
(
m_number
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
un
()));
}
Cell
::
Cell
(
const
Cell
&
old_obj
){
qInfo
(
"aaa"
);
}
void
Cell
::
collapse
(
int
x
)
{
collapsed
=
true
;
...
...
This diff is collapsed.
Click to expand it.
cell.h
+
1
−
0
View file @
e4cf0a7b
...
...
@@ -9,6 +9,7 @@ class Cell : public QWidget
Q_OBJECT
public:
explicit
Cell
(
QWidget
*
parent
=
0
);
Cell
(
const
Cell
&
old_obj
);
int
possibleStates
=
9
;
bool
collapsed
=
false
;
std
::
vector
<
int
>
index
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
};
...
...
This diff is collapsed.
Click to expand it.
window.cpp
+
14
−
14
View file @
e4cf0a7b
...
...
@@ -36,8 +36,8 @@ Window::Window(QWidget *parent)
dy
=
4
;
if
(
y
>=
6
)
dy
=
8
;
m_cell
[
x
][
y
]
=
new
Cell
(
this
);
m_cell
[
x
][
y
]
->
setGeometry
(
x
*
100
+
dx
,
y
*
100
+
dy
,
100
,
100
);
m_cell
[
x
+
y
*
9
]
=
new
Cell
(
this
);
m_cell
[
x
+
y
*
9
]
->
setGeometry
(
x
*
100
+
dx
,
y
*
100
+
dy
,
100
,
100
);
/* code */
}
}
...
...
@@ -48,11 +48,11 @@ Window::Window(QWidget *parent)
{
for
(
int
d
=
0
;
d
<
9
;
d
++
)
//rows and columns
{
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
update
(
int
)),
m_cell
[
x
][
d
],
SLOT
(
removeOption
(
int
)));
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
update
(
int
)),
m_cell
[
d
][
y
],
SLOT
(
removeOption
(
int
)));
connect
(
m_cell
[
x
+
y
*
9
],
SIGNAL
(
update
(
int
)),
m_cell
[
x
+
d
*
9
],
SLOT
(
removeOption
(
int
)));
connect
(
m_cell
[
x
+
y
*
9
],
SIGNAL
(
update
(
int
)),
m_cell
[
d
+
y
*
9
],
SLOT
(
removeOption
(
int
)));
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
undo
(
int
)),
m_cell
[
x
][
d
],
SLOT
(
addOption
(
int
)));
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
undo
(
int
)),
m_cell
[
d
][
y
],
SLOT
(
addOption
(
int
)));
connect
(
m_cell
[
x
+
y
*
9
],
SIGNAL
(
undo
(
int
)),
m_cell
[
x
+
d
*
9
],
SLOT
(
addOption
(
int
)));
connect
(
m_cell
[
x
+
y
*
9
],
SIGNAL
(
undo
(
int
)),
m_cell
[
d
+
y
*
9
],
SLOT
(
addOption
(
int
)));
}
int
a
=
x
/
3
*
3
;
int
b
=
y
/
3
*
3
;
...
...
@@ -60,9 +60,9 @@ Window::Window(QWidget *parent)
{
for
(
int
y1
=
b
;
y1
<
b
+
3
;
y1
++
)
{
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
update
(
int
)),
m_cell
[
x1
][
y1
],
SLOT
(
removeOption
(
int
)));
connect
(
m_cell
[
x
+
y
*
9
],
SIGNAL
(
update
(
int
)),
m_cell
[
x1
+
y1
*
9
],
SLOT
(
removeOption
(
int
)));
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
undo
(
int
)),
m_cell
[
x1
][
y1
],
SLOT
(
addOption
(
int
)));
connect
(
m_cell
[
x
+
y
*
9
],
SIGNAL
(
undo
(
int
)),
m_cell
[
x1
+
y1
*
9
],
SLOT
(
addOption
(
int
)));
}
}
}
...
...
@@ -80,17 +80,17 @@ void Window::solveButtonClicked()
{
for
(
int
y
=
0
;
y
<
9
;
y
++
)
{
if
(
m_cell
[
x
][
y
]
->
collapsed
)
if
(
m_cell
[
x
+
y
*
9
]
->
collapsed
)
continue
;
else
if
(
m_cell
[
x
][
y
]
->
possibleStates
<
minEtropy
)
else
if
(
m_cell
[
x
+
y
*
9
]
->
possibleStates
<
minEtropy
)
{
minEtropy
=
m_cell
[
x
][
y
]
->
possibleStates
;
minEtropy
=
m_cell
[
x
+
y
*
9
]
->
possibleStates
;
b
.
clear
();
b
.
push_back
(
m_cell
[
x
][
y
]);
b
.
push_back
(
m_cell
[
x
+
y
*
9
]);
}
else
if
(
m_cell
[
x
][
y
]
->
possibleStates
==
minEtropy
)
else
if
(
m_cell
[
x
+
y
*
9
]
->
possibleStates
==
minEtropy
)
{
b
.
push_back
(
m_cell
[
x
][
y
]);
b
.
push_back
(
m_cell
[
x
+
y
*
9
]);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
window.h
+
2
−
1
View file @
e4cf0a7b
...
...
@@ -17,7 +17,8 @@ private:
QPushButton
*
grid
[
9
][
9
];
QProgressBar
*
m_progressBar
;
QSlider
*
m_slider
;
Cell
*
m_cell
[
9
][
9
];
//Cell *m_cell[9][9];
std
::
array
<
Cell
*
,
81
>
m_cell
;
int
m_delay
=
300
;
signals:
void
counterReached
();
...
...
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