public class tester { public static void main(String[] args) { class HiRiQ { //int is used to reduce storage to a minimum... public int config; public byte weight; //initialize to one of 5 reachable START config n=0,1,2,3,4 HiRiQ(byte n) { if (n==0) {config=65536/2;weight=1;} else if (n==1) {config=1626;weight=6;} else if (n==2) {config=-1140868948; weight=10;} else if (n==3) {config=-411153748; weight=13;} else {config=-2147450879; weight=32;} } boolean IsSolved() { return( (config==65536/2) && (weight==1) ); } //transforms the array of 33 booleans to an (int) cinfig and a (byte) weight. public void store(boolean[] B) { int a=1; config=0; weight=(byte) 0; if (B[0]) {weight++;} for (int i=1; i<32; i++) { if (B[i]) {config=config+a;weight++;} a=2*a; } if (B[32]) {config=-config;weight++;} } //transform the int representation to an array of booleans. //the weight (byte) is necessary because only 32 bits are memorized //and so the 33rd is decided based on the fact that the config has the //correct weight or not. public boolean[] load(boolean[] B) { byte count=0; int fig=config; B[32]=fig<0; if (B[32]) {fig=-fig;count++;} int a=2; for (int i=1; i<32; i++) { B[i]= fig%a>0; if (B[i]) {fig=fig-a/2;count++;} a=2*a; } B[0]= count0; if (next) {fig=fig-a/2;count++;} a=2*a; } next= count0; if (next) {fig=fig-a/2;count++;} a=2*a; printB(next); if (i==2 || i==5 || i==12 || i==19 || i==26 || i==29) {System.out.println() ;} if (i==2 || i==26 || i==29) {System.out.print(" ") ;}; } printB(last); System.out.println() ; } } boolean[] B=new boolean[33]; HiRiQ W=new HiRiQ((byte) 0) ; W.print(); System.out.println(W.IsSolved()); HiRiQ X=new HiRiQ((byte) 1) ; X.print(); System.out.println(X.IsSolved()); HiRiQ Y=new HiRiQ((byte) 2) ; Y.print(); System.out.println(Y.IsSolved()); HiRiQ Z=new HiRiQ((byte) 3) ; Z.print(); System.out.println(Z.IsSolved()); HiRiQ V=new HiRiQ((byte) 4) ; V.print(); System.out.println(V.IsSolved()); } }