public BinairoRowSolver(int size) { allDoneMask = size.ToMask(); BitCounter bitCounter = new BitCounter(); this.Add(new OpenStartDuosSolver()); this.Add(new OpenEndDuosSolver()); this.Add(new HoleAtStartSolver()); this.Add(new HoleAtEndSolver()); this.Add(new SingleHoleSolver()); this.Add(new ZerosAllDoneSolver(bitCounter)); this.Add(new OnesAllDoneSolver(bitCounter)); this.Add(new ThreeHoleSolver(bitCounter)); this.Add(new FourHoleSolver(bitCounter)); //this.Add(new FiveHoleSolver(bitCounter)); }
public bool Solve(ref ushort row, ref ushort mask, int size) { // check if hole is at start ushort firstOneMask = 0b1000_0000_0000_0000; ushort fullMask = size.ToMask(); if ((mask | firstOneMask) == fullMask) { var bitCounter = new BitCounter(); int countOnes = bitCounter.CountOnes(row, size); if (countOnes < size / 2) { row |= firstOneMask; } mask |= firstOneMask; return(true); } return(false); }
public DuplicateRowSolver(int size, BitCounter counter) { fullMask = size.ToMask(); this.bitCounter = counter; }