Thursday, April 19, 2012

Java Quick Way to Create an Array with Set of Possibilities

What would be a quick and simple way to create a two-dimensional array with set of possibilities?



For example, if the number is 5, I want the array to be:



{{0,1},{0,2},{0,3},{0,4},{1,2},{1,3},{1,4},{2,3},{2,4},{3,4}}


if the number is 6,



{{0,1},{0,2},{0,3},{0,4},{0,5},{1,2},{1,3},{1,4},{1,5},{2,3},{2,4},{2,5},{3,4},{3,5},{4,5}}


Thanks in advance.





No comments:

Post a Comment