Quick backtracking search

Actually rather easier than I suspected.