summaryrefslogtreecommitdiff
path: root/knights-tour.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'knights-tour.cpp')
-rw-r--r--knights-tour.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/knights-tour.cpp b/knights-tour.cpp
index 3f1e674..d0f9a3a 100644
--- a/knights-tour.cpp
+++ b/knights-tour.cpp
@@ -14,20 +14,15 @@ neighbors(int row, int col)
{
std::vector<point_t> v;
std::vector<point_t> possible = {
- { row - 2, col - 1 },
- { row - 1, col - 2 },
- { row + 1, col - 2 },
- { row + 2, col - 1 },
- { row - 2, col + 1 },
- { row - 1, col + 2 },
- { row + 1, col + 2 },
- { row + 2, col + 1 },
+ { row - 2, col - 1 }, { row - 1, col - 2 },
+ { row + 1, col - 2 }, { row + 2, col - 1 },
+ { row - 2, col + 1 }, { row - 1, col + 2 },
+ { row + 1, col + 2 }, { row + 2, col + 1 },
};
for (point_t p : possible)
{
- if (p.row >= 0 && p.row < n &&
- p.col >= 0 && p.col < n)
+ if (p.row >= 0 && p.row < n && p.col >= 0 && p.col < n)
{
v.push_back(p);
}
@@ -37,7 +32,7 @@ neighbors(int row, int col)
}
bool
-tour(int row, int col, int step, field_t field, field_t &result)
+tour(int row, int col, int step, field_t &field, field_t &result)
{
for (point_t p : neighbors(row, col))
{