Shuffling a 2D Array

For this challenge we will investigate how to create a 2D array to store the value from 1 to 100 in a 10×10 array. We will then write an algorithm to shuffle the content of this array.
See the code below to see how the array can be initialised to contain all numbers from 1 to 100 and how it is then displayed on screen.

Your Challenge

The aim of this challenge will is add a function to the code above to shuffle all 100 values inside the array:


Check the following flowchart for a solution that:

  • Accesses each value of the array one by one (using two nested loops),
  • Swaps each value: it swaps the value with another value of the array at a random position.


Did you like this challenge?

Click on a star to rate it!

Average rating 1.6 / 5. Vote count: 51

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,