I need some help with a permutation problem. Say I have a string, 6 characters long - "123456" - how can I generate a list of all permutations of that string, limited to 4 characters long? So basically, each permutation generated can only be 4 characters long. As an example, my output should look something like:
There are plenty of code examples on the web that show you how to generate permutations of a string, but I haven't been able to find any limit the permutation length.
Can someone here show me how to do it? Or does anyone know where I could find a solution to this on the web? This isn't part of a homework assignment, or anything like that, but rather, I'm developing a game in Java, and this specific problem is to do with the computers AI in solving its part of the board.
Thanks in advance for any help you can provide,