C
C
crayon232021-07-28 21:55:12
C++ / C#
crayon23, 2021-07-28 21:55:12

How to make a universal algorithm for checking a combination of tags for solvability?

There is a two-dimensional array, all cells of which are filled with random non-repeating numbers, except for one. The position of an empty cell in an array is always different. How to make sure that the generated combination is solvable? I found several examples of describing such an algorithm on the Internet, but they did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LoliDeveloper, 2021-07-28
@crayon23

Count the number of inversions. If odd, there is no solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question