Let say that we have four straight string with colors RED, GREEN, BLUE and YELLOW. These strings are tied up randomly. We know the current state of string (like starting point, where we should we start untying from) and the final state (where current string must look like after untying them).

Here is a very simple example of the problem:

a sample of the puzzle

At every move, we are allowed to replace only two nearby strings. For example, to solve the shown problem, we should do the following replacements:

1) Replace GREEN and YELLOW

2) Replace BLUE and GREEN

But in a programming environment, how can I calculate the movements to untie the strings? What will be the algorithm specifically to solve such type of problems? Here is another variation of the question. Its not possible to solve this problem according to the answer.


Sequential programming would not be suitable for this kind of problem, but an algorithm could be implemented in a declarative programming language. I would suggest using Answer Set Programming, a language that is designed for logic axioms.

| improve this answer | |
  • 1
    $\begingroup$ I took the liberty of adding links. Please don't hesitate to correct if I've gotten anything wrong. (Thanks for this answer--"short and sweet" but but useful!) $\endgroup$ – DukeZhou May 18 '18 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.