<?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>Transient Savant &#187; Games</title>
	<atom:link href="http://quasistoic.org/ts/archives/category/games/feed/" rel="self" type="application/rss+xml" />
	<link>http://quasistoic.org/ts</link>
	<description>but still a permanent idiot</description>
	<lastBuildDate>Sun, 06 Jun 2010 07:39:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Perplex City and Magic Squares</title>
		<link>http://quasistoic.org/ts/archives/2006/08/13/magic-square-solver/</link>
		<comments>http://quasistoic.org/ts/archives/2006/08/13/magic-square-solver/#comments</comments>
		<pubDate>Mon, 14 Aug 2006 04:55:20 +0000</pubDate>
		<dc:creator>Danny Dawson</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://quasistoic.org/ts/archives/2006/08/13/magic-square-solver/</guid>
		<description><![CDATA[I vaguely remember hearing about Perplex City when it was first launched, but I was too caught up in just about everything else to take too much notice. I do remember thinking that a worldwide puzzle/scavenger hunt game with an online component sounded right up my alley, but I was disappointed that the &#8220;crossover into [...]]]></description>
			<content:encoded><![CDATA[<p>I vaguely remember hearing about <a href="http://perplexcity.com">Perplex City</a> when it was first launched, but I was too caught up in just about everything else to take too much notice. I do remember thinking that a worldwide puzzle/scavenger hunt game with an online component sounded right up my alley, but I was disappointed that the &#8220;crossover into real-life&#8221; events were centered in a country I had never set foot in.</p>
<p>A number of times since then, I&#8217;ve been reminded of the game&#8217;s existence, most recently when I heard that Perplex City would be having its first official U.S. event right here in San Francisco&#8230;on a day when I already had obligations. In spite of my inability to attend the event, there&#8217;s been a resurgence in my interest, and last Friday while in Berkeley for a concert I picked up a few packs of &#8220;PC&#8221; cards from Games of Berkeley.</p>
<p>Whoo boy, the good times are a-startin&#8217;. I love myself a good mental workout, and the Perplex City cards provide just that in diverse forms and at varying intensity. From pattern-matching to pop-culture knowledge, logic puzzles, physics problems, political trivia all abound.</p>
<p>Probably my favorite aspect of Perplex City problem-solving so far is scripting solutions to some of the more complicated puzzles. When I was working on a solution for card #098 &#8216;Magic Square&#8217;, I came up with <a title="Magic Square Solver" href="http://quasistoic.org/fun/magicsquare/">a script which can be used to solve any 4 by 4 magic square</a>, where the rows, columns, and diagonals all add to the same number.</p>
<p>My first attempt was far less than ideal: it randomly arranged the 16 numbers and then tested to see if everything added up properly (i.e. <a href="http://en.wikipedia.org/wiki/Bogosort">bogosort</a>). When I let it run for ten minutes at a time, it would run through about 12-13 million combinations and not come up with a single solution.</p>
<p>My second attempt used iteration to go through possibilites in a fixed order and guaranteed me a solution eventually&#8230;within the next 56 years (seriously, I calculated), if I let the script run constantly, it would check every possible arrangement of numbers for &#8216;magic squareness&#8217;.</p>
<p>My third attempt is the one I finally found success with. Essentially, it&#8217;s a modified version of the second script where I run validity tests incrementally instead of all at once after a square is constructed. The spaces within a square are filled in a spiral pattern and rows, columns, and diagonals are tested the moment they&#8217;re testable, which results in maximum efficiency.</p>
<p>Where the first script would have required hundreds or possibly thousands of years, and the second script nearly a lifetime, my third script only took about 23 minutes and 35 seconds to find <a title="list of all solutions" href="http://quasistoic.org/fun/magicsquare/all.html">all 924 possible solutions for a 4&#215;4 magic square</a>.</p>
<p>As it turns out, <a title="Perplex City #098 Magic Square solutions" href="http://quasistoic.org/fun/magicsquare/index.php?a=16&#038;e=8">there are 54 unique solutions to the Perplex City Magic Square card</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://quasistoic.org/ts/archives/2006/08/13/magic-square-solver/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
