Solve a Holy Knight's tour: Difference between revisions
m
→JS ES6: (made one function less partial - for case where problem lacks a starting '1')
(→JS ES6: Replaced startPosn function with a more generic (and slight better typed) charColRow function) |
m (→JS ES6: (made one function less partial - for case where problem lacks a starting '1')) |
||
Line 1,961:
// hash :: (Int, Int) -> String
const hash = ([col, row]) => col.toString() + '.' + row.toString();
// Start node, and degree-sorted cache of moves from each node
Line 1,974 ⟶ 1,972:
courseMoves = (xs, [x, y]) => intersectBy(
([a, b], [c, d]) => a === c && b === d, kmoves([x, y]), xs
)
maybeStart = charColRow('1', boardLines);
return {
start:
.just),▼
boardWidth: boardLines.length > 0 ? boardLines[0].length : 0,
stepCount: steps.length,
Line 2,048 ⟶ 2,046:
dctModel = problemModel(trackLines),
strStart = dctModel.start;
return strStart !== '' ? firstSolution(
dctModel.cache, dctModel.stepCount, strStart, strStart, []
)
};
};
|