This this may take a
long time with pencil and paper, so here is the encoded solution.
Click here to view the secret text
×
import java.applet.Applet; import java.util.Arrays; import java.awt.*; public class The_8_Gates_of_Bill extends Applet{ boolean [] Doors = new boolean[8]; boolean [] [] Reachable = new boolean[8][256]; boolean [] [] UnReachable; int [][] Path = new int [8][256]; int NOfPossibilities = 0; int[] PathLength = new int[256]; int NOfImp = 0; public void StrikeOrb(int Orb){ switch(Orb){ case 0: Toggle(0); Open(2); Close(4); break; case 1: Open(2); Close(3); Open(6); break; case 2:Toggle(2); Close(6); Open(7); break; case 3: Open(0) ; Close(2); Toggle(4); break; case 4:Close(0) ; Open(3); break; case 5: Toggle(1); Open(2); Close(4); Open(5); break; case 6:Toggle(3) ; Toggle(4); break; case 7: Open(2) ; Close(6); break; case 8: Close(7); break; }/*End switch(Orb)*/ }/*End method StrikeOrb*/ public void Toggle(int i){ if(Doors == false){ Doors = true; }else{ Doors = false; } } public void Open(int i){ Doors = true; } public void Close(int i){ Doors = false; } public boolean Compare(int index){ boolean Matches = true; look: for (int k = 0; k < Doors.length; k++){ if(Doors[k] != Reachable[k][index]){ Matches = false; break look; } } return Matches; } public void AddToIndex(int start, int path){ boolean FoundMatch = false; for (int i = 0; i <= NOfPossibilities; i++) { if (Compare(i) == true){ FoundMatch = true; } } if (FoundMatch == false){ NOfPossibilities = (NOfPossibilities + 1); for (int i = 0; i < Doors.length; i++) { Reachable[NOfPossibilities] = Doors; } for(int i = 0; i < PathLength[start]; i++){ Path[NOfPossibilities] = Path[start]; } Path[PathLength[start]][NOfPossibilities] = path; PathLength[NOfPossibilities] = (PathLength[start] + 1); } } public void ScanForUnReachable(){ UnReachable = new boolean[8][256]; for(int k = 0; k < (1<<Doors.length); k++){ for (int d = 0; d < Doors.length; d++){ if( (k%(2<<d) ) >= (1<<d)){ Doors[d] = true; }else{ Doors[d] = false; } }/*End (int d = 0; d < Doors.length; d++){*/ boolean FoundMatch = false; for (int i = 0; i <= NOfPossibilities; i++) { if (Compare(i) == true){ FoundMatch = true; } } if (FoundMatch == false){ for (int i = 0; i < Doors.length; i++) { UnReachable[NOfImp] = Doors; } NOfImp = (NOfImp + 1); } }/*End for(int k = 0; k < (1<<Doors.length); k++)*/ } public void paint(Graphics g){ int Col = 0; int StartY =0; for(int Ver = 0; Ver <= NOfPossibilities; Ver++){ StartY = (5 + ( (Ver%50) *12)); if( ((Ver%50) == 0) && (Ver != 0) ){ Col++; } for(int Hor = 0; Hor< Doors.length; Hor++){ int StartX = (5 + (Hor*12) + (120*Col ) ); if(Reachable[Hor][Ver] == false){ g.setColor(Color.BLUE); g.fillRect(StartX, StartY, 10, 10); g.setColor(Color.white); if((Path[Hor][Ver]) != (-1)){ g.drawString(String.valueOf(Path[Hor][Ver]), StartX, (StartY + 10)); } }else{ g.setColor(Color.cyan); g.fillRect(StartX, StartY, 10, 10); g.setColor(Color.black); if((Path[Hor][Ver]) != (-1)){ g.drawString(String.valueOf(Path[Hor][Ver]), StartX, (StartY + 10)); } } } }/*End for Ver loop*/ for(int Ver = 0; Ver < NOfImp; Ver++){ StartY = (5 + ( ( (Ver+ NOfPossibilities + 1)%50) *12)); if( ( ( (Ver+ NOfPossibilities + 1)%50) == 0) && (Ver != 0) ){ Col++; } for(int Hor = 0; Hor< Doors.length; Hor++){ int StartX = (5 + (Hor*12) + (120*Col ) ); if(UnReachable[Hor][Ver] == false){ Color DarkBlue = new Color(0, 0, 200); g.setColor(DarkBlue); g.fillRect(StartX, StartY, 10, 10); }else{ Color DarkCyan = new Color(0, 200, 200); g.setColor(DarkCyan); g.fillRect(StartX, StartY, 10, 10); } } }/*End for Ver loop*/ } public void init(){ Arrays.fill(Doors, false); for(int k = 0; k < Doors.length; k++){ Reachable[k][0] = false; } for(int k = 0; k < 8; k++){ for(int l = 0; l < 256; l++){ Path[k][l] = (-1); } } Arrays.fill(PathLength, 0); for(int index = 0; index <= NOfPossibilities; index++){ for(int orb = 0; orb < 9; orb++){ for(int n = 0; n < Doors.length; n++){ Doors[n] = Reachable[n][index]; } StrikeOrb(orb); AddToIndex(index, orb); } } ScanForUnReachable(); repaint(); int Number = 5; Number = (Number - 1); }/*End method init*/ }/*End class*/
Click here to view the secret text
×
width 720, height 610
____________________________
Fatel exception occurred. Post will terminate.