// you’re reading...

Uncategorized

Source Code for Master Lock Combination Calculator

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)
Loading ... Loading ...

Code to calculate possible combinations for a Master combination lock given the last number in the combination. This source is in PHP.

<table summary="Possible Master Lock Combinations">
<caption>Possible Combinations</caption>
 
<?php  
$default_c3 = 0;
$c3 = (int) isset($_GET["last_comb"])? $_GET["last_comb"] : $default_c3;
if ($c3<0 || $c3>39) $c3 = $default_c3;
 
for ($c2=($c3+2)%4; $c2<40; $c2+=4)
{
	print "<tr>";
	for ($c1=$c3%4; $c1<40; $c1+=4)
	{
		if ($c1-$c2==2 or $c1-$c2==6 or $c2-$c1==38 or $c2-$c1==34 or abs($c3-$c2)%36==2)
			echo "<td>&nbsp;</td>";
		else
			echo "<td>$c1 - $c2 - $c3</td>";
	}
	print "</tr>\r\n";
}
?>
</table>

Discussion

3 comments for “Source Code for Master Lock Combination Calculator”

  1. Can you make it so that I can run this program on your website? I don’t have php on my computer. This would be an excellent utility for they iPhone.

    Posted by TJ Mathews | September 27, 2009, 3:12 pm
  2. What about for a combination lock with numbers from 0 to 49?

    Posted by matt | June 19, 2010, 8:22 pm

Post a comment