Is it possible to shuffle just the rows in an array?
Say you have:
1, 2, 3, 4
2, 3, 4, 5
3, 4, 5, 6
to turn into:
2, 3, 4, 5
1, 2, 3, 4
3, 4, 5, 6
or any other random order. Thank you
Is it possible to shuffle just the rows in an array?
Say you have:
1, 2, 3, 4
2, 3, 4, 5
3, 4, 5, 6
to turn into:
2, 3, 4, 5
1, 2, 3, 4
3, 4, 5, 6
or any other random order. Thank you
No, it is not possible. Unfortunately, even with our technology that can calculate Pi to over trillion digits in less than four days, we haven't yet mastered the art of shuffling items in an array.
Kidding aside, of course it is possible. There are probably several dozen different ways to do it, too, and all of them depend on what kind of data structures you're using.
It is possible to do that. You could use a repetition statement to choose the current row to shuffle, and you could use a helper two-dimensional array to put the shuffled elements; then, you could either print the new array or copy its contents to the old array, and print it.