Created
September 19, 2016 00:00
-
-
Save andyfangdz/4597c00a4e43438dbd7c37aa01ecc3e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def DFS(depth=0, state=None): | |
if check_state_is_valid(depth, state): | |
report_found(state) | |
if depth >= target_depth: | |
return | |
for next_step in possible_steps(depth, state): | |
current_state = state | |
apply_step_on_state(next_step, state) | |
if is_valid_state(state): | |
DFS(depth + 1, state) | |
state = current_state | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment