Solve a Holy Knight's tour: Difference between revisions

Content added Content deleted
(→‎{{header|JavaScript}}: added JS (ES6) version (composing generic functions))
Line 1,979: Line 1,979:
};
};


// firstSolution :: {nodeKey: [nodeKey]} -> Int -> nodeKey, nodeKey, [nodeKey] ->
// firstSolution :: {nodeKey: [nodeKey]} -> Int ->
// -> {path::[nodeKey], pathLen::Int, found::Bool}
// nodeKey -> nodeKey -> [nodeKey] ->
// -> {path::[nodeKey], pathLen::Int, found::Bool}
const firstSolution = (dctMoves, intTarget, strStart, strNodeKey, path) => {
const firstSolution = (dctMoves, intTarget, strStart, strNodeKey, path) => {
const
const
Line 2,096: Line 2,097:
just: startXY
just: startXY
}), lstGroups)),
}), lstGroups)),
strSoln = 'First solution found in c.' +
strSoln = 'First solution found in c. ' +
intMSeconds + ' milliseconds:\n\n' +
intMSeconds + ' milliseconds:\n\n' +
unlines(map(groupLine(cellWidth, ' ', {
unlines(map(groupLine(cellWidth, ' ', {
Line 2,123: Line 2,124:
0 0 0
0 0 0


First solution found in c.24 milliseconds:
First solution found in c. 21 milliseconds:


25 14 23
25 14 23
Line 2,151: Line 2,152:
0 0
0 0


First solution found in c.7223 milliseconds:
First solution found in c. 7084 milliseconds:


1 3
1 3
Line 2,168: Line 2,169:




[Finished in 7.331s]</pre>
[Finished in 7.2s]</pre>


=={{header|Lua}}==
=={{header|Lua}}==