The Other Fish: Fish Club

0, "Trout" =>0, "Ray" =>0, "Mackerel" =>0, "Snapper" =>0, "Bass" =>0); //try each one as prez foreach($guys as $iKey=>$iValue) { //set prez $guys[$iKey]=3;$iValue=3; //try remaining guys as vp foreach($guys as $jKey=>$jValue) { if($jValue==$iValue) continue; //each can only hold at most one office $guys[$jKey]=2;$jValue=2; //try remaining guys as vp foreach($guys as $kKey=>$kValue) { if($kValue==$iValue or $kValue==$jValue) continue; //each can only hold at most one office $guys[$kKey]=1;$kValue=1; if($debug) print "
Trying Prez: ".$iKey."; VP: ".$jKey."; Sect'y: ".$kKey.".
"; if($debug==2) {foreach($guys as $thisGuysRank){print "$thisGuysRank";} print"
";}; if($guys['Grouper']>0 and $guys['Snapper']!=3){ if($debug) print "Grouper won't be an officer unless Snapper is President!
"; } else if($guys['Trout']>0 and $guys['Ray'] < $guys['Trout']){ if($debug) print "Trout won't serve if he outranks Ray!
"; } else if($guys['Trout']>0 and $guys['Bass']>0){ if($debug) print "Trout won't serve with Bass under any conditions!
"; } else if($guys['Ray']>0 and $guys['Bass']>0 and $guys['Snapper']>0){ if($debug) print "Ray won't serve with both Snapper & Bass!
"; } else if($guys['Ray']>0 and ($guys['Bass']==3 or $guys['Trout']==1) ){ if($debug) print "Ray won't serve if Bass is President or Trout is secretary!
"; } else if($guys['Mackerel']>0 and ($guys['Mackerel']<$guys['Ray'] or $guys['Mackerel']<$guys['Snapper']) ){ if($debug) print "Mackerel won't serve with Ray or Snapper unless he outranks him!
"; } else if($guys['Snapper']==2){ if($debug) print "Snapper won't be Vice-President!
"; } else if($guys['Mackerel']>0 and $guys['Snapper']==1){ if($debug) print "Snapper won't be secretary if Mackerel is an officer!
"; } else if($guys['Grouper']>0 and $guys['Snapper']>0 and $guys['Bass']==0){ if($debug) print "Snapper won't serve with Grouper unless Bass serves too!
"; } else if($guys['Bass']>0 and $guys['Ray']!=3 and $guys['Bass']!=3){ if($debug) print "Bass won't serve unless either he or Ray is President!
"; } else { print "SOLUTION FOUND! Prez: ".$iKey."; VP: ".$jKey."; Sect'y: ".$kKey.".
"; } $totalCombinations++; $guys[$kKey]=0;$kValue=0; } $guys[$jKey]=0;$jValue=0; } $guys[$iKey]=0;$iValue=0; } print "Total Combinations: $totalCombinations."; ?>