Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to make a loop for this problem!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75380] Re: [mg75355] How to make a loop for this problem!
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 27 Apr 2007 05:26:35 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

uniqueArrays[n_Integer?Positive] :=
    Module[{data = {}, t, adt},
      While[Length[data] < n,
        t = Table[Random[Integer], {3}, {3}];
        adt = Append[data, t];
        If[Length[Union[adt]] != Length[data],
          data = adt]];
      data];

data=uniqueArrays[512];

Each element of data is a 3x3 array

data[[38]]

{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}

And@@(Dimensions[#] == {3,3}& /@ data)

True

There are 512 arrays

Length[data]==512

True

There are no duplicates

Length[Union[data]]==Length[data]

True


Bob Hanlon

---- pskmaths at googlemail.com wrote: 
> Hi all,
> 
> This comand:
> A = Array[Random[Integer] &, {3, 3}]
> generates a 3x3 random matrix its terms between 0 and 1.
> 
> I need to make a loop that geerates a finite number of matrices, let's
> say 512 and this loop check that non of the matrices is equal to
> another one (no repeated matrices)
> 
> I can geerate thoses random, matrices with this command:
> Do[Print[Array[Random[Integer] &, {3, 3}]], {512}]
> but I may have two matrices that are equal and also as far as I know I
> cann't use the out put because of the command, Print.
> 
> 



  • Prev by Date: Suppress Arrowheads (Combinatorica)
  • Next by Date: Re: How to make a loop for this problem!
  • Previous by thread: Re: How to make a loop for this problem!
  • Next by thread: Re: How to make a loop for this problem!