• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I create an array of arrays without any repetition of values?

 
Shuaib Yunus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a 5*3 array table that is generated with non-repeating values, but I cant seem to shuffle all the arrays efficiently without repeating values. Please help.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all welcome to the Javaranch!

Something like:

Create the array.
Fill the array with number 1 through 15
start loop
get random x
get random y
get random x2
get random y2
swap(array[x][y], array[x2][y2])
end loop
 
Shuaib Yunus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, it was helpful. My program works perfectly.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic