<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rian J Stockbower</title>
	
	<link>http://rianjs.net</link>
	<description>Experiments in happiness</description>
	<lastBuildDate>Sun, 20 Jan 2013 03:26:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/rianjsnet" /><feedburner:info uri="rianjsnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>How to determine how large a mortgage you can afford using Excel</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/z9Rfo-0wO6E/how-to-calculate-mortgage-principle-from-monthly-payment-excel</link>
		<comments>http://rianjs.net/2013/01/how-to-calculate-mortgage-principle-from-monthly-payment-excel#comments</comments>
		<pubDate>Sun, 20 Jan 2013 03:25:47 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Finance]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1248</guid>
		<description><![CDATA[Note: this is applicable to fixed rate mortgages. Mortgage brokers typically use your gross monthly income to calculate the amount they&#039;re willing to lend you. Frankly, this is a very bad way of calculating what you can actually afford. It is more useful to know what you can reasonably afford each month before you go [...]]]></description>
				<content:encoded><![CDATA[<p><em>Note: this is applicable to fixed rate mortgages.</em></p>
<p>Mortgage brokers typically use your gross monthly income to calculate the amount they&#039;re willing to lend you. Frankly, this is a very bad way of calculating what you can <em>actually</em> afford. It is more useful to know what you can reasonably afford each month before you go house shopping.</p>
<p>If you&#039;ve got a monthly payment in mind that you&#039;re comfortable making, you can use a <a href="http://en.wikipedia.org/wiki/Present_value">present value calculation</a> to come up with the amount you can afford to finance. In Excel, this is very easy with the <code><strong>pv</strong></code> function:</p>
<p><code>=pv(interest rate, number of payments, payment, montly payment)</code></p>
<ul>
<li>Interest rate: If annual percentage rate (APR) is 3.5%, this number will be 3.5%/12 = (0.035/12).</li>
<li>Number of payments: 12 months * 30 years = 360</li>
<li>Payment: What you&#039;re comfortable paying on a mortgage each month.</li>
</ul>
<p>Suppose:</p>
<ul>
<li>You&#039;re willing to spend $1,750 a month on a house</li>
<li>APR: 3.5%</li>
<li>Term: 30 years</li>
</ul>
<p><code>=pv((0.035/12), 360, 1750)</code></p>
<p>You can afford to finance: $389,716.22</p>
<p>When determining what you can afford each month, don&#039;t forget the following:</p>
<ul>
<li>House insurance</li>
<li>Mortgage insurance (PMI)</li>
<li>House taxes, typically calculated as some amount per thousand dollars of assessed house value</li>
<li>Homeowners&#039; fees, if applicable</li>
</ul>
<p>These are things that many renters don&#039;t need to pay, and thus forget to think about when buying their first home.</p>
<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/z9Rfo-0wO6E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2013/01/how-to-calculate-mortgage-principle-from-monthly-payment-excel/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://rianjs.net/2013/01/how-to-calculate-mortgage-principle-from-monthly-payment-excel</feedburner:origLink></item>
		<item>
		<title>Slow carb: week 2</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/WL7fT3_ZP5Y/slow-carb-week-2</link>
		<comments>http://rianjs.net/2012/09/slow-carb-week-2#comments</comments>
		<pubDate>Tue, 04 Sep 2012 16:02:16 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Health]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[slow carb]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1238</guid>
		<description><![CDATA[This past Saturday marked my second cheat day on the slow carb diet. This will be a much shorter post, with the addition of Recipes section. Recipes This week we decided we wanted to eat more savory foods, as the diet can be quite bland. We tried spaghetti squash with home made marinara and turkey [...]]]></description>
				<content:encoded><![CDATA[<p>This past Saturday marked my second cheat day on the slow carb diet. This will be a much shorter post, with the addition of Recipes section.</p>
<p><strong>Recipes</strong><br />
This week we decided we wanted to eat more savory foods, as the diet can be quite bland. We tried spaghetti squash with home made marinara and turkey meatballs with almond flour. It was OK&#8230; the squash wasn&#039;t cooked enough, and the marinara recipe we used wasn&#039;t very good, either (it was essentially tomatoes with onions, and not much &#034;sauce&#034; ugh). Next time we&#039;d bake the squash longer, and use a better marinara recipe.</p>
<p>We also <a href="http://www.skinnytaste.com/2009/01/crock-pot-3-bean-turkey-chili-3125-pts.html">made chili</a> with black beans, kidney beans, and garbanzo beans (chickpeas). We added WAY more veggies: mushrooms, broccoli, red peppers, and we also threw in one ear of raw corn cut off the cob. (Yes, we &#034;cheated&#034;, if you could call &lt; 1/8 of an ear of corn per serving &#034;cheating&#034;.)</p>
<p>It was amazing. So. Bloody. Good. Best food we&#039;ve eaten since being on the diet.</p>
<p><strong>Quantitative</strong></p>
<ul>
<li>Weight: 222.5 (down ~1lb)</li>
<li>Waist: 40&#034; (no change)</li>
<li>Hips: 40&#034; (no change)</li>
</ul>
<p>I spent first 3 days after my cheat day above my weigh-in weight. I suspect I may have weighed in at the perfect time: just evacuated everything, slightly dehydrated, didn&#039;t eat much the day before. (All of these things were unintentional.)</p>
<p><strong>Qualitative</strong></p>
<ul>
<li>Energy levels are still higher and smoother than what I&#039;ve been used to (more on that below)</li>
<li>Weight loss was much less than the first week. I believe my assertion that most of the weight was water weight in the first 3 days was incorrect, and that I continued to shed water weight for most of the week.</li>
<li>I&#039;m really at a &#034;new normal&#034; now as far as preparing food, making lunches, eating food, etc is concerned. It&#039;s easy to say no to most foods, and I cook without thinking.</li>
<li>My allergies seem to be gone. (Weird!) I don&#039;t breathe heavily, nor have I been congested. This doesn&#039;t seem connected to the air quality, so I don&#039;t have any idea why this is true.</li>
</ul>
<p>The most illustrative thing, though, is the bike ride I went on. I hadn&#039;t been on a bike in a month, and I decided to go on one about 2 hours after lunch. Up until that point, I&#039;d had breakfast (two eggs, lentils, half a thick sausage patty) and lunch (cereal-bowl-sized bowl of chili with melted cheddar). I knew I&#039;d be hungry by the end, so I brought some carrots with me to eat when I was done.</p>
<p>About halfway through, I got hungry. In the past, this would have meant I would have hit the wall, unable to bike with any appreciable energy. I did not have this problem. I had no problem sustaining 18-20mph, and when I turned back, I was sustaining 20-22mph, despite being hungry. In fact, these are the fastest speeds I have <em>ever</em> sustained on this course&#8230; even though I hadn&#039;t been on a bike in a month, and my weight loss wasn&#039;t much as a percentage of my starting weight.</p>
<p><em>It was very strange to have my energy levels largely decoupled from my hunger.</em> Similarly, my leg strength was the limiting factor, not my cardiovascular system. This hasn&#039;t been the case since I was in high school, so this is A Very Good Thing.</p>
<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/WL7fT3_ZP5Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2012/09/slow-carb-week-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2012/09/slow-carb-week-2</feedburner:origLink></item>
		<item>
		<title>Slow carb week 1 foods</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/b7Gov7Rj00o/slow-carb-week-1-foods</link>
		<comments>http://rianjs.net/2012/08/slow-carb-week-1-foods#comments</comments>
		<pubDate>Wed, 29 Aug 2012 12:15:57 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Health]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[slow carb]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1233</guid>
		<description><![CDATA[I&#039;ve been asked what I ate during week 1. The answer: pretty boring stuff, mostly. I actually took pictures of most of the food I was eating to send to Laurel, because she was planning on doing the diet, but was away in Israel when I started. The trick is to cook more than one [...]]]></description>
				<content:encoded><![CDATA[<p>I&#039;ve been asked what I ate during week 1. The answer: pretty boring stuff, mostly. I actually took pictures of most of the food I was eating to send to Laurel, because she was planning on doing the diet, but was away in Israel when I started.</p>
<p>The trick is to cook more than one serving at a time, even for things like cooked vegetables. I don&#039;t like frozen veggies, so I generally buy fresh and make 2-4 servings at a time because it saves time and energy. Hooray for dishwashers.</p>
<p>Things cooked in bulk:</p>
<ul>
<li>Lentils: one package tends to last me about a week. I like them a little softer, so I boil them for close to 30 minutes.</li>
<li>Bacon: one package of center cut bacon at a time. I save the bacon rendering for later. Haven&#039;t used it for anything yet.</li>
</ul>
<p>Breakfast tends to be the same thing every day:</p>
<ul>
<li>Lentils (often fried in some oil; the texture is nicer)</li>
<li>3 scrambled eggs, <a href="http://www.youtube.com/watch?v=PUP7U5vTMM0">Gordon Ramsay style</a></li>
<li>3 strips of bacon (microwave them for 20 seconds, and they taste like they&#039;re right out of the pan!)</li>
<li>1 serving (8oz) of V8 juice. This was my savior at the beginning, as it the thing with the &#034;loudest&#034; flavor, and until I adjusted to the subtleties of the other things I was eating, it was the most interesting thing on a daily basis</li>
<li>2 cups coffee with 1 tablespoon of cream per cup</li>
</ul>
<p>Lunches and dinners are generally a meat with a legume and vegetables&#8211;often 2 or more. Sometimes cooked, sometimes raw. If you need rubs for your meats, I recommend Penzeys market (<a href="http://www.penzeys.com/cgi-bin/penzeys/shophome.html">online</a> or <a href="http://www.penzeys.com/cgi-bin/penzeys/penzeysstores.html">retail</a>).</p>
<p>Meats:</p>
<ul>
<li>Steak spiced with a rub or seasoning</li>
<li>Chicken spiced with a rub</li>
<li>Boneless pork chops spiced with a rub</li>
<li>Breadless cheeseburger, using aged swiss cheese, and often topped with salsa</li>
<li>Tuna (usually wrapped in lettuce like a lettuce+tuna roll)</li>
<li>Chicken sausage (grilled or broiled)</li>
</ul>
<p>Sides:</p>
<ul>
<li>Black beans or lentils</li>
<li>Raw cucumbers and carrots</li>
<li>Nathan&#039;s dill pickles</li>
</ul>
<p>Vegetables:</p>
<ul>
<li>Asparagus (sauteed in olive oil with spices, or steamed)</li>
<li>Green beans (steam a bunch, and eat them over the next 2-3 days)</li>
</ul>
<p>Other dishes I make regularly or would make again:</p>
<ul>
<li>Spaghetti squash + slow carb tomato sauce + turkey meatballs, and shredded parmesan on top. Surprisingly good. Make the turkey meatballs with almond meal instead of breadcrumbs.</li>
<li>Two slices of Thin n trim chicken from the deli with a slice of aged swiss in between. Brown it up in a pan (no oil needed!), which melts the cheese. Top with salsa, and eat with a knife and fork like a thick slice of ham.</li>
<li>Lentils mixed with salsa.</li>
</ul>
<p>Things I&#039;d like to try:</p>
<ul>
<li>Grilled kabobs with meat and veggies</li>
<li>A cooked black bean salad/stir fry thing with meat and veggies and beans</li>
<li>A stir fry over lentils or beans.</li>
</ul>
<p>I eat the same things over and over again, which is what most people do (and certainly what I did before the diet). The only real difference is that I&#039;ve changed the things that I repeat.</p>
<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/b7Gov7Rj00o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2012/08/slow-carb-week-1-foods/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2012/08/slow-carb-week-1-foods</feedburner:origLink></item>
		<item>
		<title>Slow carb: week 1</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/N-_yrLLXwcA/slow-carb-week-1</link>
		<comments>http://rianjs.net/2012/08/slow-carb-week-1#comments</comments>
		<pubDate>Sun, 26 Aug 2012 19:45:28 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Health]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[slow carb]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1223</guid>
		<description><![CDATA[Last Saturday, I sat down in the morning, and planned out my strategy for eating for the weekend. I knew I&#039;d essentially be by myself, so if I was going to be miserable, I wouldn&#039;t be bothering anyone. Ideally I need to lose about 40lbs; I&#039;m at 230lbs now and 190lbs would put me at [...]]]></description>
				<content:encoded><![CDATA[<p>Last Saturday, I sat down in the morning, and planned out my strategy for eating for the weekend. I knew I&#039;d essentially be by myself, so if I was going to be miserable, I wouldn&#039;t be bothering anyone. Ideally I need to lose about 40lbs; I&#039;m at 230lbs now and 190lbs would put me at about 5lbs more than my high school weight.</p>
<p>My initial goals for the weekend experiment were modest:</p>
<ul>
<li>Eating entirely slow carb, where the biggest change was replacing starches with beans and lentils</li>
<li>Seeing how I would feel during my first two days: how bad would the transition be?</li>
<li>Putting together some slow carb meals to see if they were palatable</li>
</ul>
<p>Knowing that I&#039;d be doing at least a full month of it at some point, I figured I would just stick with the diet if:</p>
<ul>
<li>The transition was miserable, but I got through it in the two days (why repeat it?)</li>
<li>I was satisfied with the meals I&#039;d created</li>
</ul>
<p>This is how I approached the experiment:</p>
<ul>
<li>I didn&#039;t treat &#034;Tim&#039;s word&#034; as <a href="http://en.wiktionary.org/wiki/received#Adjective">received wisdom</a>, which is fairly unusual in the slow carb world where explanations are often prefaced with &#034;Well, Tim says&#8230;&#034; whenever a newbie asks a question.</li>
<ul>
<li>I haven&#039;t read <em>4 Hour Body</em> (and probably won&#039;t)</li>
<li>I skipped the supplements; &#034;toxins being released&#034; and &#034;flushing the body&#034; and other pseudosciency hand-waving is nothing but <a href="http://rationalwiki.org/wiki/Woo">woo</a> and appeals to <a href="http://en.wikipedia.org/wiki/Magical_thinking">magical thinking</a></li>
<li>When in doubt, I looked at the glycemic index of the food before eating</li>
<li>I deferred to Gary Taubes more often than Tim Ferriss, as <a href="http://www.amazon.com/Good-Calories-Bad-Challenging-Conventional/dp/1400040787/httpriannet-20">Gary&#039;s work</a> is incredibly well sourced</li>
<li>I followed the diet pretty strictly, though I did add a slice of aged swiss cheese to make breadless cheeseburgers and tuna melts</li>
</ul>
<li>I ate any time I felt hungry</li>
<li>I did not count calories</li>
<li>I deferred to sustainability if I was particularly unhappy with something (adding in cheese, for example)</li>
<li>I didn&#039;t exercise any more than usual</li>
</ul>
<p>To make it easy, I planned out all of my meals for the next two days, and made enough inputs to more than last for that time. (I batch cooked all of my legumes, because cooking them is time consuming and generally sucky.) I also bought a bunch of vegetables to have as snacks, as most of my normal snack foods aren&#039;t allowed.</p>
<p>Yesterday (Saturday) was my cheat day. Now for the results&#8230;</p>
<p><strong>Quantitative</strong></p>
<ul>
<li>Down 7lbs (230 -&gt; 223)</li>
<li>Two inches off my waist (42&#034; -&gt; 40&#034;)</li>
<li>I spent about $40 on food this week, <em>way</em> less than normal</li>
</ul>
<p><strong>Qualitative</strong></p>
<ul>
<li>I got a headache the first day, but 800mg ibuprofen cleared it up</li>
<li>I felt a little light headed and dizzy on the first day; this may&#039;ve been psychosomatic.</li>
<li>Day 2 was substantially better, and I didn&#039;t need to approach my routine in a &#034;defensive&#034; fashion; I just went about my life as normal</li>
<li>It was going so well by the end of day 2, I decided to just roll with it indefinitely</li>
<li>I was pissing like a racehorse for the first couple of days (most of the weight loss occurred <em>after</em> this period, oddly enough)</li>
<li>I <em>could not wait</em> for my cheat day for the first 3 days. This urge disappeared almost completely by day 5, and when I added in aged swiss cheese and made a breadless cheeseburger, the results were even better</li>
<li>I stopped getting hungry after 2-3 days. (Not that I don&#039;t get hungry, but if you were to graph hunger over time, it&#039;d look like a slow wave with no sharp spikes. Except on cheat day(!).</li>
<li>I did not get tired in the afternoons the way I normally do. This happened around day 3; I didn&#039;t notice until day 6. Even trying to take a nap was useless; I couldn&#039;t stay asleep for more than 15 minutes.</li>
<li>My energy was quite high this whole week, even after playing frisbee. Normally I&#039;m depleted afterwards, but not this week.</li>
</ul>
<p><strong>Cheat day</strong><br />
My cheat day was not nearly as excellent as I thought it imagined it would be during the first few days. By the end, I was anxious to get back to the slow carb eating. My energy was lower; I had severe hunger spikes.</p>
<p>The strangest thing I noticed?</p>
<p>Unhealthy food is very <em>loud</em>. The tastes are overpowering, and there isn&#039;t much subtlety. It&#039;s like a food version of the <a href="http://www.npr.org/2009/12/31/122114058/the-loudness-wars-why-music-sounds-worse">loudness war</a>: there&#039;s not a lot of dynamic range in processed foods. Even &#034;boring&#034; foods like honey bunches of oats are incredibly sweet. The foods I ended up enjoying the most were fruits, and apple pie. I ate 1/4 of a 12&#034; pie for dinner last night, and I have no regrets for having done so.</p>
<p>I also thoroughly enjoyed the small Hawaiian pizza I ordered, and my normal grape fizzies (grape juice + seltzer). On my next cheat day, I will probably eat a buttload of fruit: strawberries, blueberries, pineapples, apples, and apple pie. Maybe another pizza. That&#039;s about it.</p>
<p><strong>How does this compare to counting calories?</strong><br />
I dieted the &#034;normal&#034; way back in 2010, for about 3 months; eating balanced meals, maintaining a calorie deficit of at least 500 under maintenance load every day except one cheat day per week. I lost 3lbs during that time. On the slow carb diet, I never felt hungry or deprived&#8211;which is more than I can say for my experience in 2010.</p>
<p>There&#039;s an argument to be made that my weight loss is purely do to with releasing water weight by depleting the glycogen stores in my liver&#8211;which theoretically happens whenever you restrict caloric intake. That said, I did not lose any water weight when I was counting calories, and most of my weight loss occurred after the first three days.</p>
<p><strong>Open questions</strong><br />
How sustainable is this? I don&#039;t know. I don&#039;t have an end game right now, and I&#039;m just going with it. I&#039;ve spent a little bit of time thinking about &#034;What comes after&#034;, and I think a longer-term diet plan might look less slow carb and a little more paleo. One thing it won&#039;t be is full of white carbs like it has been; I feel so much better eating this way. My breathing isn&#039;t labored, I don&#039;t get tired during the day, and generally have more energy. As a random aside: I wrote a fair bit of code this week, and it&#039;s the best code I&#039;ve ever written, and my thinking has <em>felt</em> clearer, but it could be placebo.</p>
<p>I&#039;ve also been toying with the idea of going ketogenic, just to see what it&#039;s like (but I probably won&#039;t).</p>
<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/N-_yrLLXwcA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2012/08/slow-carb-week-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2012/08/slow-carb-week-1</feedburner:origLink></item>
		<item>
		<title>sudo make me a sandwich</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/vQRMCyFsftQ/siri-sudo-make-me-a-sandwich</link>
		<comments>http://rianjs.net/2011/10/siri-sudo-make-me-a-sandwich#comments</comments>
		<pubDate>Sat, 15 Oct 2011 15:22:20 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Siri]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1205</guid>
		<description><![CDATA[(Reference)]]></description>
				<content:encoded><![CDATA[<p><img src="http://rianjs.net/media/2011/siri-make-me-a-sandwich.png" alt="Siri make me a sandwich" /></p>
<p>(<a href="http://xkcd.com/149/" title="Sandwich">Reference</a>)</p>
<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/vQRMCyFsftQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2011/10/siri-sudo-make-me-a-sandwich/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2011/10/siri-sudo-make-me-a-sandwich</feedburner:origLink></item>
		<item>
		<title>How-to: Use Mercurial with EditPlus</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/0WIbHo0OvGw/how-to-use-mercurial-with-editplus</link>
		<comments>http://rianjs.net/2011/09/how-to-use-mercurial-with-editplus#comments</comments>
		<pubDate>Fri, 09 Sep 2011 01:20:00 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1189</guid>
		<description><![CDATA[I use EditPlus for most of my non-Visual Studio development. I&#039;ve recently begun extending its functionality to use it as a &#034;lite&#034; PHP IDE by invoking php.exe from the commandline and capturing the output. I&#039;ve also begun using Mercurial as my version control system of choice, and wondered if it would be possible to invoke [...]]]></description>
				<content:encoded><![CDATA[<p>I use EditPlus for most of my non-Visual Studio development. I&#039;ve recently begun extending its functionality to use it as a &#034;lite&#034; PHP IDE by invoking php.exe from the commandline and capturing the output. I&#039;ve also begun using Mercurial as my version control system of choice, and wondered if it would be possible to invoke <code>hg</code> from within EditPlus.</p>
<p>Turns out you can, and it&#039;s quite easy. I find it best to configure Mercurial with an existing set of tools. I&#039;m doing a lot of PHP right now, so that&#039;s where I&#039;ve stuck it.</p>
<ol>
<li>Add Mercurial to your <a href="http://en.wikipedia.org/wiki/PATH_(variable)">PATH</a> <a href="http://en.wikipedia.org/wiki/Environment_variable#DOS_and_Windows">Environment variable</a> using the method I outlined in <a href="http://rianjs.net/2010/11/change-windows-commandline-cmd-appearance-behavior">this post</a>.</li>
<li>In EditPlus, configure your user tools: <strong>Tools &gt; Configure User Tools</strong></li>
<li><strong>Add Tool &gt; Program</strong><br />
<img src="http://rianjs.net/media/2011/editplus-hg-add-tool.png" alt="Add tool"></li>
<p></p>
<li>Fill out the field as displayed, making modifications to suit your preferences:<br />
<img src="http://rianjs.net/media/2011/editplus-hg-configuration.png" alt="EditPlus Mercurial preferences"></li>
<p></ol>
<p><strong>Details</strong></p>
<ul>
<li><code>"$(FileDir)"</code> is the EditPlus variable indicating the directory that your current source file resides in. I have it enclosed in quotes, because sometimes directories or filenames have spaces in them.</li>
<li><code>-v</code> indicates that I prefer verbose output. By default, mercurial will only display output if there has been an error, but I prefer to see success messages as well.</li>
<li><code>-m</code> indicates a commit message.</li>
<li><code>"$(Prompt)"</code> tells EditPlus to display a dialog that I can type in. This is where I put my commit message. I have it enclosed in quotes so I don&#039;t have to worry about spaces breaking the commit message. You may need to escape more exotic characters; I have not tested it.</li>
</ul>
<p><strong>Caution</strong></p>
<p>This method commits the working directory that your source file is in. This may or may not make sense, depending on the directory structure of your project. If you are concerned about the integrity of your <a href="http://en.wikipedia.org/wiki/Atomic_commit">atomic commits</a>, it might make sense to configure your arguments differently, or to commit using the commandline or TortoiseHg.</p>
<p>Here&#039;s the output as I see it in my editor:<br />
<img src="http://rianjs.net/media/2011/editplus-hg-commit-output.png" alt="EditPlus mercurial output capture"></p>
<p>Here is a log of the commit messages as viewed with TortoiseHg:<br />
<img src="http://rianjs.net/media/2011/editplus-tortoisehg-commit-log.png" alt="EditPlus TortoiseHg log file viewer"></li>
<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/0WIbHo0OvGw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2011/09/how-to-use-mercurial-with-editplus/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2011/09/how-to-use-mercurial-with-editplus</feedburner:origLink></item>
		<item>
		<title>Java solution to Project Euler Problem 48</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/YgVHvehYTkw/java-solution-to-project-euler-problem-48</link>
		<comments>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-48#comments</comments>
		<pubDate>Sun, 22 May 2011 11:00:07 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1153</guid>
		<description><![CDATA[Problem 48: The series, 1^1 + 2^2 + 3^3 + &#8230; + 10^10 = 10405071317. Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + &#8230; + 1000^1000. Running time: 125 ms Assessment: Again, very easy and fast using arbitrary-precision arithmetic. Like one of my other solutions, I didn&#039;t limit the [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://projecteuler.net/index.php?section=problems&#038;id=48">Problem 48</a>:</p>
<blockquote><p>The series, 1^1 + 2^2 + 3^3 + &#8230; + 10^10 = 10405071317.</p>
<p>Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + &#8230; + 1000^1000.</p></blockquote>
<p><strong>Running time:</strong> 125 ms</p>
<p><strong>Assessment:</strong> Again, very easy and fast using arbitrary-precision arithmetic. Like one of my other solutions, I didn&#039;t limit the output to just the last ten digits in the series, but you could easily tack that on.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.math.BigInteger</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Problem048
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">long</span> begin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BigInteger</span> sum <span style="color: #339933;">=</span> <span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">ZERO</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BigInteger</span> temp <span style="color: #339933;">=</span> <span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">ONE</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BigInteger</span> GrandTotal <span style="color: #339933;">=</span> <span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">ZERO</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			sum <span style="color: #339933;">=</span> temp.<span style="color: #006633;">pow</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			temp <span style="color: #339933;">=</span> temp.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">ONE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			GrandTotal <span style="color: #339933;">=</span> GrandTotal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>sum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">long</span> end <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>GrandTotal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>end<span style="color: #339933;">-</span>begin <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/YgVHvehYTkw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-48/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-48</feedburner:origLink></item>
		<item>
		<title>Java solution to Project Euler Problem 36</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/TN7wAiTi3dA/java-solution-to-project-euler-problem-36</link>
		<comments>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-36#comments</comments>
		<pubDate>Sat, 21 May 2011 11:00:06 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1149</guid>
		<description><![CDATA[Problem 36: The Fibonacci sequence is defined by the recurrence relation: Fn = F(n-1) + F(n-2), where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://projecteuler.net/index.php?section=problems&#038;id=36">Problem 36</a>:</p>
<blockquote><p>The Fibonacci sequence is defined by the recurrence relation:</p>
<p><code>Fn = F(n-1) + F(n-2), where F1 = 1 and F2 = 1.</code></p>
<p>Hence the first 12 terms will be:</p>
<ul>
<li>F1 = 1</li>
<li>F2 = 1</li>
<li>F3 = 2</li>
<li>F4 = 3</li>
<li>F5 = 5</li>
<li>F6 = 8</li>
<li>F7 = 13</li>
<li>F8 = 21</li>
<li>F9 = 34</li>
<li>F10 = 55</li>
<li>F11 = 89</li>
<li>F12 = 144</li>
</ul>
<p>The 12th term, F12, is the first term to contain three digits.</p>
<p>What is the first term in the Fibonacci sequence to contain 1000 digits?</p></blockquote>
<p><strong>Running time:</strong></p>
<ul>
<li>Checking for a palindrome in Base 10 first: 500ms</li>
<li>Checking for a binary palindrome first: 650ms</li>
</ul>
<p><strong>Assessment:</strong> This problem isn&#039;t super interesting. What I did find interesting was that changing the order of the isPalindrome() comparison resulted in a significant difference in execution times. This makes sense because there are more binary palindromes than Base 10 palindromes. For no particular reason, I expected the compiler to optimize that section so the difference wouldn&#039;t be as stark.</p>
<p>I commented out the slower method so you can play with it if my explanation is unclear.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Problem036
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isPalindrome<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> s2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">reverse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>s2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">long</span> begin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">long</span> Sum <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1000000</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> isPalindrome<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> isPalindrome<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">toBinaryString</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
				Sum <span style="color: #339933;">+=</span> i<span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">/*if (isPalindrome(Integer.toBinaryString(i)) &amp;&amp; isPalindrome(Integer.toString(i)))
				Sum += i;*/</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>Sum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">long</span> end <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>end<span style="color: #339933;">-</span>begin <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/TN7wAiTi3dA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-36/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-36</feedburner:origLink></item>
		<item>
		<title>Java solution to Project Euler Problem 25</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/eDiQ_mVvVWg/java-solution-to-project-euler-problem-25</link>
		<comments>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-25#comments</comments>
		<pubDate>Fri, 20 May 2011 12:00:45 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1142</guid>
		<description><![CDATA[Problem 25: The Fibonacci sequence is defined by the recurrence relation: Fn = F(n-1) + F(n-2), where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://projecteuler.net/index.php?section=problems&#038;id=25">Problem 25</a>:</p>
<blockquote><p>The Fibonacci sequence is defined by the recurrence relation:</p>
<p><code>Fn = F(n-1) + F(n-2), where F1 = 1 and F2 = 1.</code></p>
<p>Hence the first 12 terms will be:</p>
<ul>
<li>F1 = 1</li>
<li>F2 = 1</li>
<li>F3 = 2</li>
<li>F4 = 3</li>
<li>F5 = 5</li>
<li>F6 = 8</li>
<li>F7 = 13</li>
<li>F8 = 21</li>
<li>F9 = 34</li>
<li>F10 = 55</li>
<li>F11 = 89</li>
<li>F12 = 144</li>
</ul>
<p>The 12th term, F12, is the first term to contain three digits.</p>
<p>What is the first term in the Fibonacci sequence to contain 1000 digits?</p></blockquote>
<p><strong>Running time:</strong> 36ms</p>
<p><strong>Assessment:</strong> LOL.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.math.BigInteger</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Problem025
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">long</span> begin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">BigInteger</span> a <span style="color: #339933;">=</span> <span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BigInteger</span> b <span style="color: #339933;">=</span> <span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BigInteger</span> c <span style="color: #339933;">=</span> <span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BigInteger</span> MAX <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> b.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>MAX<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			c <span style="color: #339933;">=</span> a.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			a <span style="color: #339933;">=</span> b<span style="color: #339933;">;</span>
			b <span style="color: #339933;">=</span> c<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;i: &quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">long</span> end <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>end <span style="color: #339933;">-</span> begin <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/eDiQ_mVvVWg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-25/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-25</feedburner:origLink></item>
		<item>
		<title>Java solution to Project Euler Problem 22</title>
		<link>http://feedproxy.google.com/~r/rianjsnet/~3/JCrEuM5K7kM/java-solution-to-project-euler-problem-22</link>
		<comments>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-22#comments</comments>
		<pubDate>Thu, 19 May 2011 12:00:16 +0000</pubDate>
		<dc:creator>Rian</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://rianjs.net/?p=1137</guid>
		<description><![CDATA[Problem 22: Using names.txt (right click and &#039;Save Link/Target As&#8230;&#039;), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example, when the list [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://projecteuler.net/index.php?section=problems&#038;id=22">Problem 22</a>:</p>
<blockquote><p>Using <a href="http://rianjs.net/media/2011/names.txt">names.txt</a> (right click and &#039;Save Link/Target As&#8230;&#039;), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.</p>
<p>For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list. So, COLIN would obtain a score of 938 * 53 = 49714.</p>
<p>What is the total of all the name scores in the file?</p></blockquote>
<p><strong>Running time:</strong></p>
<ul>
<li>File IO: 23ms</li>
<li>5163 names sorted: 79ms</li>
<li>Built the list of names: 154ms</li>
<li>Total runtime: 209ms</li>
</ul>
<p><strong>Assessment:</strong> I broke my time measurements up so I could see how fast each major piece is. I thought that file IO would be the slowest piece of the equation&#8211;I don&#039;t have an SSD&#8211;but it isn&#039;t. In fact, no single piece is really the bottleneck. At less than 0.3 seconds, this is, for practical purposes, instantaneous.</p>
<p>If I were to do this problem again&#8211;probably in C#&#8211;I would approach it the same way, but the code would look a bit cleaner, and certainly less verbose. Using higher-level data structures makes this problem pretty simple.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Iterator</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Problem022
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> NameList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> buildList<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">long</span> BuildListBegin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> temp <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">boolean</span> IsName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">&lt;</span> s.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\&quot;</span>'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>	<span style="color: #666666; font-style: italic;">// Flip the IsName switch if a quotation mark is encountered</span>
				IsName <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>IsName<span style="color: #339933;">;</span>
				i<span style="color: #339933;">++;</span>	<span style="color: #666666; font-style: italic;">// Move along one character so the quote isn't included in temp</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>IsName<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>	<span style="color: #666666; font-style: italic;">// If switch is on, capture characters into temp</span>
				temp <span style="color: #339933;">+=</span> s.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>temp <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>	<span style="color: #666666; font-style: italic;">// Without this, a blank line is included</span>
					<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #009900;">&#123;</span>
					NameList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>temp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					temp <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>	
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			i<span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000066; font-weight: bold;">long</span> SortBegin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Collections</span>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span>NameList<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">long</span> SortEnd <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">long</span> BuildListEnd <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>NameList.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; items sorted in &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>SortEnd<span style="color: #339933;">-</span>SortBegin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;buildList() executed in &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>BuildListEnd<span style="color: #339933;">-</span>BuildListBegin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> readFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> filename<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/*	1) Read each name beginning with &quot; and ending with &quot; into vector of String
		 *	2) Sort names alphabetically
		 */</span>
		<span style="color: #000066; font-weight: bold;">long</span> begin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>filename<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BufferedReader</span> reader<span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> list <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">StringBuffer</span> contents <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> text <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
			reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>text <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				contents.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line.separator&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
			<span style="color: #009900;">&#125;</span>
			list <span style="color: #339933;">=</span> contents.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;File IO: &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> begin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> list<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">long</span> calcValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">long</span> GrandTotal <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		Iterator<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> itr <span style="color: #339933;">=</span> NameList.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>itr.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">String</span> tmp <span style="color: #339933;">=</span> itr.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">int</span> LocalSum <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 
&nbsp;
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> tmp.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'A'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'B'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'C'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'D'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'E'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'F'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'G'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'H'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'I'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'J'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'K'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'L'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'M'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">13</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'N'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">14</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'O'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'P'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Q'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">17</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'R'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">18</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'S'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">19</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'T'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'U'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">21</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'V'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">22</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'W'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">23</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'X'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">24</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tmp.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Z'</span><span style="color: #009900;">&#41;</span>
					LocalSum <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">26</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			LocalSum <span style="color: #339933;">*=</span> <span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			GrandTotal <span style="color: #339933;">+=</span> LocalSum<span style="color: #339933;">;</span>
			i<span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> GrandTotal<span style="color: #339933;">;</span>		
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">long</span> begin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		buildList<span style="color: #009900;">&#40;</span>readFile<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;names.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>calcValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">long</span> end <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Total execution time: &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>end<span style="color: #339933;">-</span>begin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/rianjsnet/~4/JCrEuM5K7kM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-22/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://rianjs.net/2011/05/java-solution-to-project-euler-problem-22</feedburner:origLink></item>
	</channel>
</rss>
