<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dreamshire &#187; Uncategorized</title>
	<atom:link href="http://blog.dreamshire.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dreamshire.com</link>
	<description>Showing what's behind the curtain</description>
	<lastBuildDate>Wed, 01 Sep 2010 02:23:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Source Code for Master Lock Combination Calculator</title>
		<link>http://blog.dreamshire.com/2009/08/29/source-code-for-master-lock-combination-calculator/</link>
		<comments>http://blog.dreamshire.com/2009/08/29/source-code-for-master-lock-combination-calculator/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 09:43:13 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.dreamshire.com/?p=1716</guid>
		<description><![CDATA[Source code in PHP for calculating combination possibilities given the last number in a combination for Master combination locks.]]></description>
			<content:encoded><![CDATA[<p>Code to calculate possible combinations for a Master combination lock given the last number in the combination.  This source is in PHP.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;table summary=&quot;Possible Master Lock Combinations&quot;&gt;
&lt;caption&gt;Possible Combinations&lt;/caption&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  
<span style="color: #000088;">$default_c3</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$c3</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;last_comb&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>? <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;last_comb&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$default_c3</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c3</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$c3</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">39</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$c3</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$default_c3</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c2</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c3</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c2</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">40</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c2</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c1</span><span style="color: #339933;">=</span><span style="color: #000088;">$c3</span><span style="color: #339933;">%</span><span style="color:#800080;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c1</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">40</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c1</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c1</span><span style="color: #339933;">-</span><span style="color: #000088;">$c2</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">2</span> or <span style="color: #000088;">$c1</span><span style="color: #339933;">-</span><span style="color: #000088;">$c2</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">6</span> or <span style="color: #000088;">$c2</span><span style="color: #339933;">-</span><span style="color: #000088;">$c1</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">38</span> or <span style="color: #000088;">$c2</span><span style="color: #339933;">-</span><span style="color: #000088;">$c1</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">34</span> or <span style="color: #990000;">abs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c3</span><span style="color: #339933;">-</span><span style="color: #000088;">$c2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">36</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$c1</span> - <span style="color: #006699; font-weight: bold;">$c2</span> - <span style="color: #006699; font-weight: bold;">$c3</span>&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/table&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.dreamshire.com/2009/08/29/source-code-for-master-lock-combination-calculator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
