Umm. Random guessing isn't a good way to find all the possibilities. The number of rearrangements of n values is n!, because first you pick one of the values (n possibilities), then you pick one of the remaining n-1 values, then one of the remaining... etc. So in your five-values example, there are only 5! = 120 arrangements, and in 1000 guesses you're likely to find a lot of them even though some will be duplicates. But 10! = 3628800, so it'd take millions of guesses.
The official textbook way to find all the permutations (that's the technical term for "rearrangements") of a set of values is to divide that set of permutations, in your head before writing any code, into those that start with the first value and those that don't start with the first value. Then figure out how to list all the permutations of each kind, using recursion to solve a smaller problem.
In other words, write this helper function: