Skip to content

Instantly share code, notes, and snippets.

@KasaiMagi
Last active September 14, 2015 21:02
Show Gist options
  • Save KasaiMagi/9fcc9ec98adf70918123 to your computer and use it in GitHub Desktop.
Save KasaiMagi/9fcc9ec98adf70918123 to your computer and use it in GitHub Desktop.
backtracking pseudocode
bool Solve(configuration conf) {
if (no more choices) { // BASE CASE
return (conf is goal state)
}
for (all available choices) {
try one choice C:
// solve from here, if works out, you're done
if (Solve(conf with choice c made)) return true;
unmake choice c;
}
return false; // tried all choices, no soln found
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment