<?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>Gawain’s World &#187; Family</title>
	<atom:link href="http://gawain.org/blog/category/family/feed/" rel="self" type="application/rss+xml" />
	<link>http://gawain.org/blog</link>
	<description>Learning to drive upside down...</description>
	<lastBuildDate>Sun, 05 Feb 2012 12:00:00 +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>Geek dad vs. Normal dad: A homework story</title>
		<link>http://gawain.org/blog/2009/09/21/geek-dad-vs-normal-dad/</link>
		<comments>http://gawain.org/blog/2009/09/21/geek-dad-vs-normal-dad/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 00:37:26 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Family]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/?p=511</guid>
		<description><![CDATA[When I was in school, math homework was my nemesis. The seemingly endless (and at the time, seemingly pointless) repetition drove me crazy. As a kid, I wasn&#8217;t given much sense of the practical usefulness of any of the things I was being taught. I had much more important things to occupy my mind with, ]]></description>
			<content:encoded><![CDATA[<p>When I was in school, math homework was my nemesis. The seemingly endless (and at the time, seemingly pointless) repetition drove me crazy. As a kid, I wasn&#8217;t given much sense of the practical usefulness of any of the things I was being taught. I had much more important things to occupy my mind with, like Star Wars, Led Zeppelin, and astronomy.</p>
<p>I&#8217;m a dreamer. I am blessed with the type of personality that allows me to focus for long periods on things. <em>If they interest me.</em> Conversely, if something <strong>doesn&#8217;t</strong> interest me, to this day I still find it extremely hard to concentrate. I get especially irked if I sense that something is being done inefficiently or is unnecessarily repetitive. I mean, after all that&#8217;s why we invented computers, right?</p>
<p>Fast forward to 2009 and I&#8217;m helping my daughter with her math homework. She&#8217;s working on a sort of &#8216;math trick&#8217; with number palindromes. That&#8217;s a number like 2447442 that reads the same forward and backward. One creates this via an iterative process. You reverse numbers and add them together. If you don&#8217;t have a palindrome you take the output of the previous operation and repeat until you get a palindrome. Or not.</p>
<p>Most of the first batch of problems went pretty well. My daughter was doing her work and I was checking the results with a calculator. Finally we came to the last couple of examples. Here&#8217;s where the problem started. It turned out we had misread one part of the instructions concerning how to handle decimals. Thus, we started out with a number that never became a palindrome. Sarah quickly gave up. Then my wife and I filled up a couple sheets of scratch paper with numbers that quickly spiraled into the Land of the Insanely Huge. I even went upstairs and banged out numbers on the calculator for twenty minutes. By this time, we were all miserable, so we agreed to take it up the next day.</p>
<p>So now I was irked (see above) and the wheels were turning. This wasn&#8217;t hard from a mathematical point of view. It just involved some juggling and a whole bunch of repetitive calculations. Perfect job for a script!</p>
<p>Any normal dad would&#8217;ve probably just re-read the instructions, fixed the calculation and called it good. Me? Geek dad? Nooooooo&#8230; I couldn&#8217;t leave it alone. I went upstairs and set to work on a command-line PHP script to expunge the drudgery from this thankless chore once and for all!</p>
<p>When it was done I had fun checking Sarah&#8217;s work, and discovered an earlier example she&#8217;d gotten wrong. For the record, we made sure our daughter understood the process and I only used the script to check her work, not give her the answers.</p>
<p>This is a total hack written late at night, so no flames please! Suggestions for improving it are welcome, however. I may create a web-ready version of this and stick it on the site if anybody&#8217;s interested in searching out new and amazing number palindromes. Aside from that, it&#8217;s now basically a solution to a nonexistent problem. And I can once again sleep at night.</p>
<pre class="brush: php;">
#! /usr/bin/php

&lt;?
	# The input number.

	$input = $argv[1];

	# Set up some variables
	$palindrome = 0;
	$limit = 10000; // how many iterations?
	$iterations = 0;

# ------------------------------------------------------------#
# Main 'while' loop
# ------------------------------------------------------------#

while($palindrome === 0 &amp;&amp; $iterations &lt;= $limit) {
	$iterations++;

	echo 'Testing: ' . $input . &quot;\r\n&quot;;

	$result = testInput($input);

	if(is_numeric($result)) {
		echo &quot;Palindrome found! : &quot; . $result . &quot;\r\n&quot;;
		break;
	} else {
		# next iteration, please.
		$input = genNewInput($input);
	}
} // end while

# ------------------------------------------------------------#
# Function: genNewInput
# ------------------------------------------------------------#
function genNewInput($input) {
	$fwd_array = str_split($input);
	$rev_array = array_reverse($fwd_array);

	# add reversed numbers together
	$fwd_num = implode($fwd_array);
	$rev_num = implode($rev_array);

	echo 'Adding: ' . $fwd_num  . ' + ' . $rev_num . &quot;\r\n&quot;;

	$input = $fwd_num + $rev_num;
	return $input;
}

# ------------------------------------------------------------#
# Function: testInput
# ------------------------------------------------------------#
function testInput($input) {

	$fwd_array = str_split($input);
	$rev_array = array_reverse($fwd_array);

	# get the digit count
	$digit_count = count($fwd_array);

	$r = $digit_count - 1; // zero indexed

	# Determine if the output is a palindrome
	for($f=0;$f&lt;$digit_count;$f++) {

		# inner loop. this takes the new input and tests it. If it passes, we've found our palindrome! If not, it continues the outer loop with the next input number.

		# compare the numbers.
		if($fwd_array[$f] === $fwd_array[$r]) {
			$r--;

			if($f === ($digit_count - 1)) {
				# BINGO!
				return $input;
			} else {
				continue;
			}

		} else {
			return false;
		}
	}
}

?&gt;
</pre>
<p>[Note: I had originally posted more code here. I'm going to bring this back up as a separate page at a later date.]</p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2009/09/21/geek-dad-vs-normal-dad/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Rainbows and Rituals</title>
		<link>http://gawain.org/blog/2008/08/07/rainbows-and-rituals/</link>
		<comments>http://gawain.org/blog/2008/08/07/rainbows-and-rituals/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 17:00:37 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Family]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/?p=138</guid>
		<description><![CDATA[One year ago yesterday we arrived on the island of Kauai. When we got to our condo in Princeville it was dark outside, but this sight greeted us early the next morning. From our porch we could see beyond the cliffs to the ocean. The air smelled so clean, with just a hint of tropical ]]></description>
			<content:encoded><![CDATA[<p><a href="http://gawain.org/blog/wp-content/uploads/2008/08/hawaii_rainbow.jpg"><img class="alignnone size-full wp-image-139" title="hawaii_rainbow" src="http://gawain.org/blog/wp-content/uploads/2008/08/hawaii_rainbow.jpg" alt="" width="500" height="335" /></a></p>
<p>One year ago yesterday we arrived on the island of Kauai. When we got to our condo in Princeville it was dark outside, but this sight greeted us early the next morning. From our porch we could see beyond the cliffs to the ocean. The air smelled so clean, with just a hint of tropical flowers. A light rain was alternating with sunshine. This rainbow lasted for about 10 minutes as the palm trees waved slowly in the breeze. There were little doves landing on our railing making cooing sounds while obviously waiting for a handout and <a href="http://en.wikipedia.org/wiki/Hawaiian_Goose" target="_blank">Hawaiian geese </a>nosing around on the lawn below. It was about as relaxing as it could possibly be.</p>
<p>Adding to the slightly surreal vibe were a young casually dressed Asian couple pacing back and forth on the lawn in some kind of enigmatic ritual. They would begin about 50 feet apart and would then walk very slowly past each other looking straight ahead as if in some kind of trance before turning around again. They did this each morning for the next several days.</p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2008/08/07/rainbows-and-rituals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Gaggle of Grossed Out Gals</title>
		<link>http://gawain.org/blog/2008/08/02/a-gaggle-of-grossed-out-gals/</link>
		<comments>http://gawain.org/blog/2008/08/02/a-gaggle-of-grossed-out-gals/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 21:39:58 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Family]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/?p=134</guid>
		<description><![CDATA[We went to our dear friend Teasi&#8217;s birthday party yesterday and had a great time. At the end of the party Teasi wanted all her girlfriends together for a group photo. This is what ensued when the birthday girl suggested that she do the picture with her eyelids turned inside out. Eeeeewwww!]]></description>
			<content:encoded><![CDATA[<p><a href="http://gawain.org/blog/wp-content/uploads/2008/08/080802_teasi.jpg"><img class="alignnone size-medium wp-image-135" title="080802_teasi" src="http://gawain.org/blog/wp-content/uploads/2008/08/080802_teasi.jpg" alt="" width="300" height="201" /></a></p>
<p>We went to our dear friend Teasi&#8217;s birthday party yesterday and had a great time. At the end of the party Teasi wanted all her girlfriends together for a group photo. This is what ensued when the birthday girl suggested that she do the picture with her eyelids turned inside out. Eeeeewwww!</p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2008/08/02/a-gaggle-of-grossed-out-gals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Winter&#8217;s not over yet.. Or is it?</title>
		<link>http://gawain.org/blog/2008/03/08/winters-not-over-yet-or-is-it/</link>
		<comments>http://gawain.org/blog/2008/03/08/winters-not-over-yet-or-is-it/#comments</comments>
		<pubDate>Sun, 09 Mar 2008 02:53:17 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Family]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/2008/03/08/winters-not-over-yet-or-is-it/</guid>
		<description><![CDATA[Here&#8217;s two pictures taken within an hour of each other. It hasn&#8217;t decided whether to be winter or spring around here, so we&#8217;re getting both at the same time. Sledding, snowball fights and flowers&#8230; A perfect combo for a Saturday in March]]></description>
			<content:encoded><![CDATA[<p><img src="/blog/wp-content/uploads/2008/03/080309_sledding_flowers.jpg" alt="Sledding and Flowers" width="500" height="500" /></p>
<p>Here&#8217;s two pictures taken within an hour of each other. It hasn&#8217;t decided whether to be winter or spring around here, so we&#8217;re getting both at the same time. Sledding, snowball fights and flowers&#8230; A perfect combo for a Saturday in March.</p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2008/03/08/winters-not-over-yet-or-is-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yes, we have neurotic dogs.</title>
		<link>http://gawain.org/blog/2008/01/11/yes-we-have-neurotic-dogs/</link>
		<comments>http://gawain.org/blog/2008/01/11/yes-we-have-neurotic-dogs/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 02:26:28 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Family]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/?p=83</guid>
		<description><![CDATA[This picture makes me laugh out loud every time I see it. This is Chili after she found a marvelously tasty goodie lying on the floor in plain sight. She had retreated to the privacy of the &#8220;dog approved&#8221; chair to consume her prize when the long arm of the law suddenly appeared. It was ]]></description>
			<content:encoded><![CDATA[<p><img src="/blog/wp-content/uploads/2008/01/chili_guilty.jpg" alt="Copyright © 2007 Gawain Reifsnyder" width="500" height="281" /></p>
<p>This picture makes me laugh out loud every time I see it. This is Chili after she found a marvelously tasty goodie lying on the floor in plain sight. She had retreated to the privacy of the &#8220;dog approved&#8221; chair to consume her prize when the long arm of the law suddenly appeared.</p>
<p>It was like asking Gollum to hand over the ring, please.</p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2008/01/11/yes-we-have-neurotic-dogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

