<?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>~chron &#187; Code</title>
	<atom:link href="http://blog.chron.ws/archives/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.chron.ws</link>
	<description>skyscrapers are nothing... less than nothing!</description>
	<lastBuildDate>Tue, 20 Apr 2010 11:01:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wowhead Talent Calculator URL Codegolf</title>
		<link>http://blog.chron.ws/archives/324</link>
		<comments>http://blog.chron.ws/archives/324#comments</comments>
		<pubDate>Fri, 31 Jul 2009 04:23:12 +0000</pubDate>
		<dc:creator>chronic</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[World of Warcraft]]></category>
		<category><![CDATA[golf]]></category>

		<guid isPermaLink="false">http://blog.chron.ws/?p=324</guid>
		<description><![CDATA[EDIT: Now with extra linebreaks so you can actually read it in my awful layout.

It&#8217;s been ages since I&#8217;ve done any codegolf, so when I stumbled across Gizzmo&#8217;s blog post about the Wowhead talent calculator URL algorithm, I figured it might be fun to dust off the old &#8220;text editor&#8221; and see how it goes.

So, [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span class="caps">EDIT</span>:</strong> Now with extra linebreaks so you can actually read it in my awful layout.</p>

<p>It&#8217;s been ages since I&#8217;ve done any codegolf, so when I stumbled across <a href="http://justgizzmo.com/2009/05/01/blizzard-to-wowhead-talent-converter/">Gizzmo&#8217;s blog post about the Wowhead talent calculator <span class="caps">URL </span>algorithm</a>, I figured it might be fun to dust off the old &#8220;text editor&#8221; and see how it goes.</p>

<p>So, the proposal: given a variable c which contains a World of Warcraft class name (in lower case) and a variable i which contains the talent string in blizzard format, print the wowhead-ified <span class="caps">URL </span>to standard output.  Note that while you can simply use the blizzard calculator strings directly on Wowhead, that wouldn&#8217;t be very interesting code ;]</p>

<p>Mine&#8217;s ruby, as usual.  Here&#8217;s what I&#8217;ve came up with so far:</p>

<code>

<pre>i='30530310500210252210320100000500000000000000000000000005320232030002120000000000000'
c='rogue'

t=0xa031812e3becf8e6cadb9.to_s(7).split(//).map{|v|v.to_i+25}
k='0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789'
d=%w(id er ge in st ue an ck or ht).index(c[-2,2])*3
r=k[d,1]+t[d,3].map{|e|i.slice!(0,e)}.map{|x|x.gsub(/0+$/,'').scan(/(.)(.)?/
).map{|a,b|k[a.to_i*6+b.to_i,1]}*''+(x[/0+$/]?'Z':'')}.join.gsub(/Z+$/,'')
puts'http://www.wowhead.com/?talent#'+r</pre>

</code>

<p>The r and t variables aren&#8217;t strictly necessary (they are only used once each) but that line was getting long enough already, I&#8217;d give my editor an aneurism.  In case it isn&#8217;t obvious, the t= line represents the sizes of the talent trees (since classes have different numbers of talents), the d= line represents the class indices (by the last two characters of each class name since if you do it from the front you need 4 to be unique, I blame warlocks) and the k= line is wowhead&#8217;s crazy encoding constant.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.chron.ws/archives/324/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
