Skip to content

Instantly share code, notes, and snippets.

@benhutton
Created March 22, 2011 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhutton/882170 to your computer and use it in GitHub Desktop.
Save benhutton/882170 to your computer and use it in GitHub Desktop.
def backtrack(grid, row)
if matches?(grid, row)
if row == (grid.length - 1) # If we've matched everything!
return true
end
else
return false
end
for i = 0; i < grid.length, i++
rotate(grid, row + 1)
if backtrack(grid, row + 1)
return true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment