Hacker News new | past | comments | ask | show | jobs | submit login

Avoiding 1,1,1, in a code like this

   for x1 in range(1, 10):
        for x2 in range(1, 10):
            if x2 in [x1]:
                continue
            for x3 in range(1, 10):
                if x3 in [x1, x2]:
                    continue
looks like backtracking to me. Specifically, the "continue" statement is that "jump back" that prunes invalid search sub-tree. Though, the constrains are expressed as predicates here.

But even in a code where constrains are built into the loop, it also can be called backtracking, since we have our target predicate "is_valid(square)". The search tree is trivial in this case, though. It's just a root and leaves.

In other words, I didn't quite understand the distinction that you were talking about.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: