I have cities: A, B, C, D, E
How can I generate an initial solution in Java that contains all of these elements once? For example: BCDAE
Currently I’m generating a solution in order ABCDE then mixing it up, is there an easier way to do this I’m just not thinking of?
I would use the Collections API to give me a one-liner:
Collections.shuffle()puts the elements in a random order.Here’s a little test. Every time you run this, you’ll get random order output: