<?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>iOS and Game Development &#187; Software Development</title>
	<atom:link href="http://joyfulgames.com/category/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://joyfulgames.com</link>
	<description>Soli Deo Gloria</description>
	<lastBuildDate>Wed, 25 Aug 2010 02:18:10 +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>Facebook Game with Django on Google App Engine &#8211; Setup</title>
		<link>http://joyfulgames.com/2009/09/07/facebook-game-with-django-on-google-app-engine-setup/</link>
		<comments>http://joyfulgames.com/2009/09/07/facebook-game-with-django-on-google-app-engine-setup/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 15:16:59 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2009/09/07/facebook-game-with-django-on-google-app-engine-setup/</guid>
		<description><![CDATA[Now that I&#8217;ve decided to write a Facebook app using Django on Google App Engine I plan to document as much of the development process as possible. The first steps were purely administrative. I registered a Google App Engine application called &#8220;law-and-gospel&#8221; (lawandgospel was taken). I then registered a Facebook application called &#8220;LawAndGospel.&#8221; Nothing complicated [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Now that I&#8217;ve decided to write a Facebook app using Django on Google App Engine I plan to document as much of the development process as possible. The first steps were purely administrative. I registered a Google App Engine application called &#8220;law-and-gospel&#8221; (lawandgospel was taken). I then registered a Facebook application called &#8220;LawAndGospel.&#8221; Nothing complicated about either of those things so I won&#8217;t bother doing a walk through of those processes.</p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2009/09/07/facebook-game-with-django-on-google-app-engine-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lutheran Inquisition &#8211; Episode 1</title>
		<link>http://joyfulgames.com/2009/04/07/lutheran-inquisition-episode-1/</link>
		<comments>http://joyfulgames.com/2009/04/07/lutheran-inquisition-episode-1/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 01:44:09 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Christian]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2009/04/07/lutheran-inquisition-episode-1/</guid>
		<description><![CDATA[So here&#8217;s the game I&#8217;ve been working on since the start of the year. It&#8217;s a little rough, and I&#8217;m no Ed McMahon, but I hope someone finds it enjoyable. If you want to embed it in your site, copy and paste: &#60;embed src=&#8221;http://joyfulgames.com/LutheranInquisition.swf&#8221; width=&#8221;600&#8243; height=&#8221;400&#8243; /&#62;]]></description>
			<content:encoded><![CDATA[<p></p><p>So here&#8217;s the game I&#8217;ve been working on since the start of the year. It&#8217;s a little rough, and I&#8217;m no Ed McMahon, but I hope someone finds it enjoyable.</p>
<p>If you want to embed it in your site, copy and paste:<br />
&lt;embed src=&#8221;http://joyfulgames.com/LutheranInquisition.swf&#8221; width=&#8221;600&#8243; height=&#8221;400&#8243; /&gt;</p>
<p><embed src="http://joyfulgames.com/flash/LutheranInquisition.swf" width="600" height="400" /></p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2009/04/07/lutheran-inquisition-episode-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Game Development with a Christian Worldview</title>
		<link>http://joyfulgames.com/2009/04/06/game-development-with-a-christian-worldview/</link>
		<comments>http://joyfulgames.com/2009/04/06/game-development-with-a-christian-worldview/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 09:08:03 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Christian]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2009/04/06/game-development-with-a-christian-worldview/</guid>
		<description><![CDATA[In yet another attempt to kick-start this blog, I&#8217;m working through the 31 Days to Build a Better Blog Challenge. The first task is to write an elevator pitch. The short pitch is the title of this post. All posts will deal with &#8220;Game development with a Christian Worldview.&#8221; I think it gives me the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In yet another attempt to kick-start this blog, I&#8217;m working through the <a href="http://www.problogger.net/31-days-to-build-a-better-blog-join-9100-other-bloggers-today/">31 Days to Build a Better Blog Challenge</a>. The first task is to <a href="http://www.problogger.net/archives/2009/04/06/write-an-elevator-pitch-for-your-blog-day-1-31dbbb/">write an elevator pitch</a>. The short pitch is the title of this post. All posts will deal with &#8220;Game development with a Christian Worldview.&#8221; I think it gives me the right amount of latitude in posting anything from code samples and game design to game reviews and recommendations.</p>
<p>The long pitch is:</p>
<blockquote>
<p>Few games ha a distinctly Christian worldview. I hope this blog encourages and assists other game developers in creating games with a Christian worldview. I also hope that the gamers in general will benefit from this blog by understanding the worldview that various games put forth and by helping them find games that exhibit a Christian worldview.</p>
</blockquote>
<p>There are my two pitches and my hope I&#8217;m for a more consistent and useful blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2009/04/06/game-development-with-a-christian-worldview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Someday&#8230;</title>
		<link>http://joyfulgames.com/2009/03/13/someday/</link>
		<comments>http://joyfulgames.com/2009/03/13/someday/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 13:31:43 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2009/03/13/someday/</guid>
		<description><![CDATA[I like the day-job that I have now. It&#8217;s by no stretch perfect, but I occasionally get to learn something new and I enjoy working with the people. The biggest plus is that the workload is reasonable. There&#8217;s the occasional week where I push 55+ hours, but 45 &#8211; 50 is the norm. When I [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I like the day-job that I have now. It&#8217;s by no stretch perfect, but I occasionally get to learn something new and I enjoy working with the people. The biggest plus is that the workload is reasonable. There&#8217;s the occasional week where I push 55+ hours, but 45 &#8211; 50 is the norm.</p>
<p>When I eventually get to the point where I am an independent software developer, there are some things that I want to have setup.</p>
<ol>
<li>Flexible Schedule &#8211; Above all, I want to be able to work when and where I want. Why, my family. I want to be able to pickup in the middle of the day and go to one of the girls&#8217; sporting events. I don&#8217;t mind if I have to stay up late to finish any work I needed to get done, I just want the flexibility.</li>
<li>One top-of-the-line development computer &#8211; I really dislike developing with different OS&#8217;s, different keyboards, different programs installed, etc. It&#8217;s such a pain to context switch. If I need to test in other environments, that&#8217;s another story, but as development; one top-of-the-line system, no older than 30 months, configured the way I want it to work.</li>
<li>A fast internet connection &#8211; This is just a given and the faster the better. Documentation, examples, tools, communication, just about everything a developer does touches the internet. I don&#8217;t want to wait on a download progress bar to get my work done.</li>
<li>My coding standard, best practices, and process &#8211; I know that I have a lot to learn about software development, but working on a team project really stifles your ability to evolve as a developer. Think of a better process, gotta have buy-in from the rest of the team. Find a better coding standard, nobody else see the point in changing the way they format code or name their methods. If I think it&#8217;s worthwhile to reformat every line of code in the project, I should be able to if I&#8217;m improving the quality of the code.</li>
<li>A private office &#8211; I&#8217;ve worked at startups with a common development area and during certain points in the development cycle, this was invaluable. However, in most other situations it&#8217;s just a pain point. When I&#8217;m in development mode, I just need my computer and no distraction.</li>
<li>A great chair and desk &#8211; A bad chair and poor desk setup are just distractions.</li>
</ol>
<p>Looking at the list, I notice one thing, $$$. Except for #1 and #3, I would like to use the phrase &#8220;price is no object.&#8221; That&#8217;s not the reality I live in, but I won&#8217;t settle I these items. I may compromise and look to upgrade in the future, but I won&#8217;t settle.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2009/03/13/someday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Match with Luther</title>
		<link>http://joyfulgames.com/2008/10/11/match-with-luther/</link>
		<comments>http://joyfulgames.com/2008/10/11/match-with-luther/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 06:39:26 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Christian]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/?p=69</guid>
		<description><![CDATA[Here&#8217;s the Flash game I&#8217;ve been working on. A simple little concentration game with Martin Luther looking on. Listen to some interesting sound bytes as you complete matches. You may even hear some words from Fr. Martin.]]></description>
			<content:encoded><![CDATA[<p></p><p>Here&#8217;s the Flash game I&#8217;ve been working on.</p>
<p>A simple little concentration game with Martin Luther looking on. Listen to some interesting sound bytes as you complete matches. You may even hear some words from Fr. Martin.</p>
<p><object width="500" height="425"><param name="movie" value="http://yamabe.net/flash/Match.swf"></param>
<embed src="http://yamabe.net/flash/Match.swf" width="500" height="425" allowscriptaccess="never"></embed><param name="allowscriptaccess" value="never"></param>
</object></p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2008/10/11/match-with-luther/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Development</title>
		<link>http://joyfulgames.com/2008/07/22/flash-development/</link>
		<comments>http://joyfulgames.com/2008/07/22/flash-development/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 15:45:25 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2008/07/22/flash-development/</guid>
		<description><![CDATA[My first/last game was based on Torque Game Builder. While it did have some nice things for game development, it is a little heavyweight for the types of game I want to try to build, and having to package applications feels so 90&#8242;s. So, I&#8217;m going to be using Flash as my development platform, it [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>My <a href="http://joyfulgames.com/2007/10/15/catechism/">first/last game</a> was based on <a href="http://garagegames.com/products/torque/tgb/">Torque Game Builder</a>. While it did have some nice things for game development, it is a little heavyweight for the types of game I want to try to build, and having to package applications feels so 90&#8242;s. So, I&#8217;m going to be using Flash as my development platform, it doesn&#8217;t have some of the game specific functionality of TGB, but it&#8217;s lightweight and deploys just about anywhere. I may go back to TGB if I build a larger game, but for now, Flash is it.</p>
<p>Most of the tutorials and books on Flash development that I&#8217;ve gone through start with dragging and dropping stuff around in the Flash application. Inevitably, as things get more complex, most of the development is done in editor and very little is done using the UI constructor except for splash screens, buttons, and backgrounds. From my understanding, you can do all of this programatically which I&#8217;ve done similarly in the early days of Swing. The Flash editor is not my idea of a great text editor so I went looking for a way to do Flash development without the Flash application. I found this <a href="http://www.pixelate.de/blog/setting-up-a-as3-project-in-textmate">nice article</a> on using TextMate and the Flex SDK to do development. I&#8217;ll go into a little detail on how this is working out in the next post.</p>
<p>So, I&#8217;m all set. I&#8217;m doing Flash development without Flash and I&#8217;ll be updating my progress as I go, so stay tuned&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2008/07/22/flash-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kata Four &#8212; Data Munging</title>
		<link>http://joyfulgames.com/2008/06/06/kata-four-data-munging/</link>
		<comments>http://joyfulgames.com/2008/06/06/kata-four-data-munging/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 06:10:01 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2008/06/06/kata-four-data-munging/</guid>
		<description><![CDATA[Kata Three was a thought exercise, so I&#8217;m moving on to Kata Four. This is a 3 part kata with first being reading temperature data from a file and outputting the day the smallest temperature spread. I didn&#8217;t use RegEx to parse the input lines (I know it&#8217;s really something I should learn), so I [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://codekata.pragprog.com/2007/01/kata_three_how_.html">Kata Three</a> was a thought exercise, so I&#8217;m moving on to <a href="http://codekata.pragprog.com/2007/01/kata_four_data_.html">Kata Four</a>. This is a 3 part kata with first being reading temperature data from a file and outputting the day the smallest temperature spread. I didn&#8217;t use RegEx to parse the input lines (I know it&#8217;s really something I should learn), so I just checked the character offsets. The day was from character 0 &#8211; 3, the max temperature was from 6 &#8211; 7, and the min was from 12 &#8211; 13. Here&#8217;s what I came up with:</p>
<p><span class="level0">def get_smallest_spread(self):</span><br />
<span class="level1">day = 0</span><br />
<span class="level1">spread = 100</span></p>
<p><span class="level1">lines = self.file.readlines()</span><br />
<span class="level1">for line in lines:</span><br />
<span class="level2">if len(line) &gt;= 14:</span><br />
<span class="level3">try:</span><br />
<span class="level4">max = int(line[6:8])</span><br />
<span class="level4">min = int(line[12:14])</span><br />
<span class="level4">if max &#8211; min &lt; spread:</span><br />
<span class="level5">day = int(line[0:4])</span><br />
<span class="level5">spread = max &#8211; min</span><br />
<span class="level3">except:</span><br />
<span class="level4">continue</span></p>
<p><span class="level1">return day</span></p>
<p>The code is pretty straight forward. I just read the lines, extract the appropriate character and turn them into ints and compare them, and then keep track of the smallest spread.</p>
<p>The second part of the kata is to read a data file with soccer (they call it football, but I&#8217;m in the U.S.) team data and output the team with the smallest goals for and goals against differential.</p>
<p><span class="level0">def get_smallest_differential(self):</span><br />
<span class="level1">team = &#8221;</span><br />
<span class="level1">spread = 100</span></p>
<p><span class="level1">lines = self.file.readlines()</span><br />
<span class="level1">for line in lines:</span><br />
<span class="level2">if len(line) &gt;= 52:</span><br />
<span class="level3">try:</span><br />
<span class="level4">gf = int(line[43:45])</span><br />
<span class="level4">ga = int(line[50:52])</span><br />
<span class="level4">if abs(gf &#8211; ga) &lt; spread:</span><br />
<span class="level5">team = line[7:21]</span><br />
<span class="level5">spread = abs(gf &#8211; ga)</span><br />
<span class="level3">except:</span><br />
<span class="level4">continue</span></p>
<p><span class="level1">return team.strip()</span></p>
<p>Not much to comment on, this was pretty much the same code except the offsets were different.</p>
<p>The final part of the kata is to refactor the code to get as much common code a possible. This was pretty easy since the only differences were the offsets to find the values to compare and the value to return. Here&#8217;s what I ended up with:</p>
<p><span class="level0">def get_smallest_spread2(self):</span><br />
<span class="level1">return int(self.generic_spread(6, 8, 12, 14, 0, 4))</span></p>
<p><span class="level0">def get_smallest_differential2(self):</span><br />
<span class="level1">return self.generic_spread(43, 45, 50, 52, 7, 21).strip()</span></p>
<p><span class="level0">def generic_spread(self, r1_start, r1_end, r2_start, r2_end, d_start, d_end):</span><br />
<span class="level1">value = &#8221;</span><br />
<span class="level1">spread = 100</span></p>
<p><span class="level1">lines = self.file.readlines()</span><br />
<span class="level1">for line in lines:</span><br />
<span class="level2">if len(line) &gt;= self.max_index(r1_end, r2_end, d_end):</span><br />
<span class="level3">try:</span><br />
<span class="level4">r1 = int(line[r1_start:r1_end])</span><br />
<span class="level4">r2 = int(line[r2_start:r2_end])</span><br />
<span class="level4">if abs(r1 &#8211; r2) &lt; spread:</span><br />
<span class="level5">value = line[d_start:d_end]</span><br />
<span class="level5">spread = abs(r1 &#8211; r2)</span><br />
<span class="level3">except:</span><br />
<span class="level4">continue</span></p>
<p><span class="level1">return value</span></p>
<p><span class="level0">def max_index(self, v1, v2, v3):</span><br />
<span class="level1">if (v1 &gt;= v2):</span><br />
<span class="level2">if (v1 &gt; v3):</span><br />
<span class="level3">return v1</span><br />
<span class="level2">else:</span><br />
<span class="level3">return v3</span><br />
<span class="level2">return v1</span><br />
<span class="level1">elif (v2 &gt;= v3):</span><br />
<span class="level2">return v2</span></p>
<p><span class="level1">return v3</span></p>
<p>Not exactly elegant, but definitely multipurpose. The max_index method doesn&#8217;t feel like the most elegant way to handle line length checking, but it&#8217;s not a hack so I was pragmatic and did what worked. Other than that I&#8217;m just doing the same string parsing and comparisons, just with the index being passed in.</p>
<p>That&#8217;s my take on kata four. I feel like working on the katas has done what I wanted them to do, which was to get me comfortable with the Python syntax and the flow when doing Python development. Going forward I&#8217;m going to be developing the Tetris knock-off and a web-based address book.</p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2008/06/06/kata-four-data-munging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kata Two &#8212; Karate Chop &#8211; Part 4</title>
		<link>http://joyfulgames.com/2008/05/22/kata-two-karate-chop-part-4/</link>
		<comments>http://joyfulgames.com/2008/05/22/kata-two-karate-chop-part-4/#comments</comments>
		<pubDate>Thu, 22 May 2008 16:35:46 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2008/05/22/kata-two-karate-chop-part-4/</guid>
		<description><![CDATA[The final chop method I came up with was rather uninspired. I used a for loop instead a while loop and used some array manipulation. Here&#8217;s the code: def chopFive(value, list): if len(list) == 0: return -1 index = 0 newList = list found = False for number in range(0, len(list) / 2 + 1): [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The final chop method I came up with was rather uninspired. I used a for loop instead a while loop and used some array manipulation.</p>
<p>Here&#8217;s the code:</p>
<p><span class="level0">def chopFive(value, list):</span><br />
<span class="level1">if len(list) == 0:</span><br />
<span class="level2">return -1</span></p>
<p><span class="level1">index = 0</span><br />
<span class="level1">newList = list</span><br />
<span class="level1">found = False</span></p>
<p><span class="level1">for number in range(0, len(list) / 2 + 1):</span><br />
<span class="level2">tempIndex = len(newList) / 2</span><br />
<span class="level2">if value == newList[tempIndex]:</span><br />
<span class="level3">return index + tempIndex</span><br />
<span class="level2">elif value &gt; newList[tempIndex]:</span><br />
<span class="level3">newList = newList[tempIndex+1:len(newList)]</span><br />
<span class="level3">if len(newList) == 0:</span><br />
<span class="level4">return -1</span><br />
<span class="level3">index += tempIndex + 1</span><br />
<span class="level2">elif value &lt; newList[tempIndex]:</span><br />
<span class="level3">newList = newList[0:tempIndex]</span><br />
<span class="level3">if len(newList) == 0:</span><br />
<span class="level4">return -1</span></p>
<p><span class="level1">return -1</span></p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2008/05/22/kata-two-karate-chop-part-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kata Two &#8212; Karate Chop &#8211; Part 3</title>
		<link>http://joyfulgames.com/2008/05/13/kata-two-karate-chop-part-3/</link>
		<comments>http://joyfulgames.com/2008/05/13/kata-two-karate-chop-part-3/#comments</comments>
		<pubDate>Tue, 13 May 2008 06:41:46 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2008/05/13/kata-two-karate-chop-part-3/</guid>
		<description><![CDATA[Honestly, I had no idea what to try next. So the next suggestion from the kata was to try something functional where you pass slices of the array around. So, I started with passing the value and the list into a function and then returning a new list that had been &#8220;chopped&#8221;. This worked in [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Honestly, I had no idea what to try next. So the next suggestion from the kata was to try something functional where you pass slices of the array around. So, I started with passing the value and the list into a function and then returning a new list that had been &#8220;chopped&#8221;. This worked in finding whether the value was in the list, but it didn&#8217;t return the index of the value if it was in the list. I needed a way to pass back the number of list elements I had disregarded at each pass and sum them to find the index of the value. This was a case where I needed two return values from a function. In most languages I&#8217;d have to return one value and change the value of one of the arguments, but Python allows multiple return values, awesome! I just returned both the number of elements I had thrown out and the new list to search. So starting from no idea what to implement, this became my favorite because I felt I really learned something about Python.</p>
<p>Here&#8217;s the code:</p>
<p><span class="level0">def chopThree(value, list):</span><br />
<span class="level1">if len(list) == 0:</span><br />
<span class="level2">return -1</span></p>
<p><span class="level1">index = 0</span></p>
<p><span class="level1">while len(list) &gt; 0:</span><br />
<span class="level2">throwCount, list = chopThreeFunc(value, list)</span></p>
<p><span class="level1">if throwCount == -1:</span><br />
<span class="level2">return -1</span></p>
<p><span class="level1">index = index + throwCount</span></p>
<p><span class="level1">return index</span></p>
<p><span class="level0">def chopThreeFunc(value, list):</span><br />
<span class="level1">if len(list) == 0:</span><br />
<span class="level2">return -1, []</span></p>
<p><span class="level1">index = len(list) / 2</span><br />
<span class="level1">newList = []</span><br />
<span class="level1">throwCount = 0</span></p>
<p><span class="level1">if list[index] == value:</span><br />
<span class="level2">return index, []</span><br />
<span class="level1">elif value &gt; list[index]:</span><br />
<span class="level2">newList = list[index:len(list)]</span><br />
<span class="level2">if len(list) == 1:</span><br />
<span class="level3">return -1, []</span><br />
<span class="level2">throwCount = index</span><br />
<span class="level1">elif value &lt; list[index]:</span><br />
<span class="level2">newList = list[0:index]</span><br />
<span class="level2">if len(list) == 1:</span><br />
<span class="level3">return -1, []</span></p>
<p><span class="level1">return throwCount, newList</span></p>
<p>For the next implementation, I simply did this in a recursive manner:</p>
<p><span class="level0">def chopFour(value, list):</span><br />
<span class="level1">if len(list) == 0:</span><br />
<span class="level3">return -1</span></p>
<p><span class="level1">return chopFourFunc(0, value, list)</span></p>
<p><span class="level0">def chopFourFunc(count, value, list):</span><br />
<span class="level1">index = len(list) / 2&lt;&lt;/span&gt;</span><br />
<span class="level1">newList = []</span><br />
<span class="level1">throwCount = 0</span></p>
<p><span class="level1">if list[index] == value:</span><br />
<span class="level2">return index + count</span><br />
<span class="level1">elif value &gt; list[index]:</span><br />
<span class="level2">newList = list[index:len(list)]</span><br />
<span class="level2">if len(list) == 1:</span><br />
<span class="level3">return -1</span><br />
<span class="level2">throwCount = index</span><br />
<span class="level1">elif value &lt; list[index]:</span><br />
<span class="level2">newList = list[0:index]</span><br />
<span class="level2">if len(list) == 1:</span><br />
<span class="level3">return -1</span></p>
<p><span class="level1">return chopFourFunc(throwCount, value, newList)</span></p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2008/05/13/kata-two-karate-chop-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kata Two &#8212; Karate Chop &#8211; Part 2</title>
		<link>http://joyfulgames.com/2008/05/08/kata-two-karate-chop-part-2/</link>
		<comments>http://joyfulgames.com/2008/05/08/kata-two-karate-chop-part-2/#comments</comments>
		<pubDate>Thu, 08 May 2008 21:45:33 +0000</pubDate>
		<dc:creator>byamabe</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://joyfulgames.com/2008/05/08/kata-two-karate-chop-part-2/</guid>
		<description><![CDATA[The second way I&#8217;ll implement binary search for Kata Two &#8212; Karate Chop will be with recursion. I haven&#8217;t used recursion much in my day-to-day work, but I&#8217;ve never thought of it as a particularly hard concept to grasp, it just seems that the problems I work aren&#8217;t optimally solved with it. The most interesting [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The second way I&#8217;ll implement binary search for <a href="http://codekata.pragprog.com/2007/01/kata_two_karate.html">Kata Two &#8212; Karate Chop</a> will be with recursion. I haven&#8217;t used recursion much in my day-to-day work, but I&#8217;ve never thought of it as a particularly hard concept to grasp, it just seems that the problems I work aren&#8217;t optimally solved with it. The most interesting part of recursion is finding the condition that ends it. Here&#8217;s my solutions:</p>
<p><span class="level0">def chopTwo(value, list):</span><br />
<span class="level1">upper = len(list) &#8211; 1</span><br />
<span class="level1">lower = 0</span></p>
<p><span class="level1">return chopTwoRec(upper, lower, value, list)</span></p>
<p><span class="level0">def chopTwoRec(upper, lower, value, list):</span><br />
<span class="level1">index = (upper + lower) / 2</span></p>
<p><span class="level1">if index &lt; 0 or upper &lt; lower:</span><br />
<span class="level2">return -1</span><br />
<span class="level1">elif list[index] == value:</span><br />
<span class="level2">return index</span><br />
<span class="level1">elif value &gt; list[index]:</span><br />
<span class="level2">lower = index + 1</span><br />
<span class="level1">elif value &lt; list[index]:</span><br />
<span class="level2">upper = index &#8211; 1</span></p>
<p><span class="level1">return typeTwoRec(upper, lower, value, list)</span></p>
]]></content:encoded>
			<wfw:commentRss>http://joyfulgames.com/2008/05/08/kata-two-karate-chop-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
