Problem looping through a 4D array

Hello,

You are almost there I think.

I don’t understand this code by @RichardDL ; therefore I have difficulties to help:

  // RichardDL's code for finding 12 bit binary numbers with 3 bits ON
  for (num  = 0; num < 4096; num++) {
    if (is3bits(num)) {
      count3++;
      myBinaryList.append(num);
    }
  }

Does this make all patterns for ONE gray scale? I don’t understand.

In my code

In my code, I assume you have a list “permuts” that holds for each gray scale ALL the permuts (in the class “ListOfPermuts ”.

Therefore you’d say:

in the constr of class “ListOfPermuts” loop over all the patterns in myBinaryList (but only for the current gray scale!!! So the myBinaryList must be made new within the for loop in draw???
This is the for loop I am referring to

  // fill permuts 
  // i represents gray value 
  for (int i=0; i<256; i++) {
    // make new myBinaryList here? 
    permuts[i] = new  ListOfPermuts( i );  // constr uses myBinaryList? 
  }//for

)

and then in the constr I mentioned:


    binaryListLength = myBinaryList.size();

    for (int i = 1; i < binaryListLength; i++) {

      println(myBinaryList.get(i));

      // USE myBinaryList here !!!!
      Field f1 = new Field(   myBinaryList.get(i)   );  // but in the constr of class Field I don't know how to get the bits from the int? 
      listOfPermutations.add(f1);
    } //for

but in the constr of class Field I don’t know how to get the bits from the int to make the pattern


One fault

One fault (I think): my bad.

PixelRepresentation carries
boolean[][] fieldArray = new boolean [ 4 ][ 3 ]; // !!! should be 3 4
as part of representing an image

but class Field also has this
as part of representing permutations.

Chrisir

1 Like