import java.util.*; // // State is // - a BitSet state S // - integer represetation iS // - a counter for how often we have encountered that state // - number of possible elements in set S (number of bits) // // given a collection of states we might access states using the BitSet as a key // public class State { BitSet S; int iS; int counter; int n; public State(BitSet b,int n){ this.n = n; S = b; iS = toInt(b); counter = 1; } // // create a new state, 1st time we have seen it // public State(int v,int n){ this.n = n; S = toBitSet(v); iS = v; counter = 1; } // // create a new state, from an integer // public void inc(){counter++;} // // when we visit an exisiting state increment its counter // public String toString(){return counter +" "+ S +" "+ iS;} private int toInt(BitSet b){ int result = 0; for (int i=n-1;i>=0;i--){ result = result*2; if (b.get(i)) result++; } return result; } // // convert a BitSet to an integer // private BitSet toBitSet(int v){ BitSet b = new BitSet(n); for (int i=0;i