<?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>Engineering Rapleaf</title>
	<atom:link href="http://blog.rapleaf.com/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rapleaf.com/dev</link>
	<description>For engineers, by engineers.</description>
	<lastBuildDate>Mon, 12 Dec 2011 08:57:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Adventures in Java Garbage Collection Tuning</title>
		<link>http://blog.rapleaf.com/dev/2011/12/07/adventures-in-java-garbage-collection-tuning/</link>
		<comments>http://blog.rapleaf.com/dev/2011/12/07/adventures-in-java-garbage-collection-tuning/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 22:48:16 +0000</pubDate>
		<dc:creator>Sean Carr</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=6423</guid>
		<description><![CDATA[Recently we noticed some intermittent performance issues with our APIs and traced the problem back to garbage collection pauses. This post describes how we identified the problem, what it taught us about Java’s concurrent mark-and-sweep garbage collection, and how we resolved it with just a few tweaks to our JVM parameters. We monitor our API [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we noticed some intermittent performance issues with our APIs and traced the problem back to garbage collection pauses. This post describes how we identified the problem, what it taught us about Java’s concurrent mark-and-sweep garbage collection, and how we resolved it with just a few tweaks to our JVM parameters.</p>
<p>We monitor our API request times very carefully, and while the average is ~5ms, there have always been a small number of outliers that take hundreds of milliseconds. Recently, though, the number of outliers has grown, and the timing info in our logs gave us reason to believe it had to do with garbage collection. The main sign was that calls which should take virtually no time (like memcached) were sometimes taking hundreds of milliseconds even when load was normal.</p>
<p>To confirm our theory, we turned on verbose GC logs with the following flags:</p>
<p><code>-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -verbose:gc -Xloggc:gc-`date +%s`.log</code></p>
<p>We used <code>date</code> to generate a dynamic name for the log so the previous one wouldn’t get overwritten when restarting the server. And to be clear, we were already using <code>-XX:+UseConcMarkSweepGC</code>. If you are concerned about pauses and aren&#8217;t using this collector, you should start using it.</p>
<p>As soon as we looked at the resulting logs it was clear GC was a problem. The garbage collector was running pretty much all the time with minor collections happening at least once a second, if not more frequently, and major collections happening about every 3 minutes. This, all in an app that creates no long lived-objects after startup, so there shouldn’t really be the need for major collections (which are what pause the entire VM).</p>
<p>To make interpreting the GC logs easier we used <a href="http://www.tagtraum.com/gcviewer.html">GCViewer</a>. It was great to be able to visualize our memory usage and compare tweaks we made with our baseline. When we viewed the data as a graph, we noticed a really interesting pattern: after minor collections (the little drops), total memory usage would go up, but after major collections (the big drops), total memory usage would return to the same low level as before. Even though we weren’t leaking memory overall, on a short time scale, it looked like we were.</p>
<div id="attachment_6463" class="wp-caption alignnone" style="width: 531px"><a href="http://blog.rapleaf.com/dev/files/2011/12/original-gc.png"><img class="size-full wp-image-6463" src="http://blog.rapleaf.com/dev/files/2011/12/original-gc.png" alt="" width="521" height="206" /></a><p class="wp-caption-text">Blue line is memory usage. Black lines are major collections.</p></div>
<p>So the key question is: since all of our objects are short lived, why were the minor collections leaving memory around? This type of situation is what a <a href="http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#generations">generational garbage collector</a> is ideally suited for, right? It doesn’t take a deep understanding of Java GC to realize the problem was that our young generation was too small, which caused even some short lived objects to be promoted to the tenured generation.</p>
<p>To understand <em>why</em> this was happening requires a bit more understanding, though. The young generation is split up into three parts: <em>Eden space</em>, and two <em>Survivor spaces</em>. New objects are allocated in Eden, and when minor collections occur the objects that are still live are copied to one of the Survivor spaces. At any given time one of the Survivor spaces is empty and is the destination of the next minor collection. The other Survivor space holds the live objects from the previous minor collection, and gets collected during the next minor collection. Since it’s assumed most objects die young, the Survivor spaces are relatively small.</p>
<p>So what happens when the live objects from a minor collection can&#8217;t fit into a survivor space? The leftover objects are moved to the tenured generation which is only cleaned by major collections. In our case the problem was that the minor collections were so frequent that a decent percentage of objects were still live at each run&#8212;enough that they couldn&#8217;t all fit in the survivor space, causing even relatively short lived objects to be tenured. We realized we had to get minor collections to happen less often and have more space for surviving objects so they aren&#8217;t prematurely tenured.</p>
<p>We played around with some GC parameters to find the right balance for our application and arrived at this:</p>
<p><code>-XX:NewSize=768m -Xms4g</code></p>
<p>Which resulted in a much better GC graph:</p>
<p><a href="http://blog.rapleaf.com/dev/files/2011/12/gc-with-larger-new-size.png"><img class="alignnone size-full wp-image-6473" src="http://blog.rapleaf.com/dev/files/2011/12/gc-with-larger-new-size.png" alt="" width="569" height="140" /></a></p>
<p>Hooray! No more trending up; no more major collections! Problem solved, right?</p>
<p>Well mostly. But there are still special circumstances in which memory usage is not as friendly-looking as in the graph above. At the core of our problems with garbage collection is that we&#8217;re allocating a lot of memory in a very short amount of time. Addressing that issue will be the topic of a follow-up post. (Spoiler: We significantly decrease our memory usage.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/12/07/adventures-in-java-garbage-collection-tuning/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More Compact Than CompactProtocol: TupleProtocol</title>
		<link>http://blog.rapleaf.com/dev/2011/10/17/more-compact-than-compactprotocol-tupleprotocol/</link>
		<comments>http://blog.rapleaf.com/dev/2011/10/17/more-compact-than-compactprotocol-tupleprotocol/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 18:18:41 +0000</pubDate>
		<dc:creator>Bryan Duxbury</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=6193</guid>
		<description><![CDATA[Rapleaf makes extensive use of Thrift&#8216;s CompactProtocol to save space for long-term data storage and for communicating between services. However, this summer, star Rapleaf intern Armaan Sarkar took us to a new level of compact-ness with his work on the new TupleProtocol. While we are completely happy with the CompactProtocol for permanent data storage and [...]]]></description>
			<content:encoded><![CDATA[<p>Rapleaf makes extensive use of <a href="http://thrift.apache.org">Thrift</a>&#8216;s CompactProtocol to save space for long-term data storage and for communicating between services. However, this summer, star Rapleaf intern Armaan Sarkar took us to a new level of compact-ness with his work on the new <a href="https://issues.apache.org/jira/browse/THRIFT-1239">TupleProtocol</a>.</p>
<p>While we are completely happy with the CompactProtocol for permanent data storage and RPC, there is one place where it&#8217;s not a perfect fit. Since all our objects are Thrift structs, we pass those same structs around during our <a href="http://www.cascading.org">Cascading</a> flows. We&#8217;ve built a connector (extremely similar to <a href="https://github.com/nathanmarz/cascading-thrift">this one</a>) that allows these Thrift structs to be serialized in the CompactProtocol when Cascading serializes Tuples between mappers and reducers, and this all works great. However, as part of our never-ending performance efforts, one of the things we are always striving to do is to decrease the amount of data that needs to be shipped between mappers and reducers. You&#8217;re probably thinking, isn&#8217;t the CompactProtocol&#8230; compact? The answer is yes. It&#8217;s the smallest representation we could come up with for a general-purpose Thrift protocol.</p>
<p>But wait! Recall that Thrift as a framework is designed to allow smooth transitions for users using different versions of their schema (like an old client contacting an updated server). Thrift does this by making sure that the data that gets serialized is sufficient to fully describe itself &#8211; serialized messages contain markers about field IDs and field data types. Using these markers, it&#8217;s possible for the Thrift library to skip over unrecognized fields. But this ability comes at the cost of a few bytes of overhead here and there, and these bytes can really add up when you have 200 billion records to move around.</p>
<p>Look back at our imperfect use case: intermediate serialization during a Cascading flow. When would the Thrift schema ever change during a single job? The answer is that it wouldn&#8217;t. This means that the extra bytes that the CompactProtocol spends on the feature to support changing schemas is 100% waste. It would be great if we didn&#8217;t have to pay the cost of a feature we don&#8217;t use.</p>
<p>This is exactly what the TupleProtocol does. Instead of being a general-purpose protocol, TupleProtocol is a purpose-built protocol designed specifically for the case when you know beyond the shadow of a doubt that the schema for a record cannot change. With this precondition, it can avoid writing out the type markers and field IDs and just uses the metadata implicit in the code itself to guide deserialization. For instance, it knows that what&#8217;s coming up next is going to be a string field called &#8220;foo&#8221; because it can assume the writer of the data wrote it exactly to that spec. By dumping this extra overhead, users of the TupleProtocol can see a significant decrease in the size of serialized objects. One sample job we tested saw about a 5% size decrease. The actual savings you see will vary a lot depending on what kind of data you have in your structs, but in general, the more non-string fields you have, the more benefit you&#8217;ll see. For us, just based on the 5% figure, it amounts to tens of gigabytes less shuffle in our biggest jobs.</p>
<p>The TupleProtocol is currently committed to Thrift TRUNK and will be released as part of Thrift 0.8. If you&#8217;d like to try it out now, we&#8217;d love to hear your feedback!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/10/17/more-compact-than-compactprotocol-tupleprotocol/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Interning at Rapleaf</title>
		<link>http://blog.rapleaf.com/dev/2011/09/21/interning-at-rapleaf/</link>
		<comments>http://blog.rapleaf.com/dev/2011/09/21/interning-at-rapleaf/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 23:41:08 +0000</pubDate>
		<dc:creator>Kurt von Laven</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Internship]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=4533</guid>
		<description><![CDATA[Nine months ago, in the middle of Christmas break, I finally found time to work on some of those puzzles I&#8217;d seen flash up beside my Facebook profile ever since declaring computer science as my major.  Beyond their unusually appealing Facebook ads, Rapleaf remained an enigma to me.  The more I learned about them though, [...]]]></description>
			<content:encoded><![CDATA[<p>Nine months ago, in the middle of Christmas break, I finally found time to work on some of those puzzles I&#8217;d seen flash up beside my Facebook profile ever since declaring computer science as my major.  Beyond their unusually appealing Facebook ads, Rapleaf remained an enigma to me.  The more I learned about them though, the more their summer internship program started seeming like a real possibility.  I&#8217;d been impressed by the people I&#8217;d communicated with so far, and decided to go out on a limb, accepting a software engineering position nearly 2000 miles from home.</p>
<p>As my internship draws to a close, I&#8217;d like to share some of my experiences to give you a better sense of what life is like here, <a title="Meet Rapleaf's Intern Class of 2009" href="http://blog.rapleaf.com/blog/2009/07/24/meet-rapleafs-intern-class-of-2009/">just as some former Rapleaf interns have done</a>.</p>
<p>Near the end of my second week, I was shocked when my mentor, an experienced member of the engineering squad charged with helping me adapt and stay on track, asked me what I wanted to do here.  I held my tongue for a bit, because all I could think at first was: &#8220;You mean I get to choose?&#8221;  He explained several of the different projects he thought would be a good fit between Rapleaf&#8217;s vision and my skills and interests: name and postal address normalization, improving the quality of our income data, and improving the quality of our internal-use-only people-search engine.  (For a sense of what name and postal address normalization accomplishes, <a title="Utilities API" href="https://www.rapleaf.com/developers/utilities">try out our name normalizer</a>, and imagine adding the same capability for mailing addresses.)  Income data quality improvement seemed the most appealing, so I started on that.</p>
<p>Reflecting on this summer, I appreciate more fully that I am an extremely lucky person.  Rapleaf engineers consistently tackle sophisticated problems with an inspiring attitude.  We&#8217;re invested in what we do, holding strong opinions about how it should be done, but we respect each other enough to resolve conflicts peacefully and productively.  Such patience is uncommon, yet Rapleafers learn to cultivate and uphold solid relationships with one another.  The maturity and brilliance of our team have enabled me to learn at a tremendous rate.  I receive lots of helpful feedback about the code I write and broader team-wide decisions I propose.  Because Rapleaf&#8217;s management approach is so open to input, my propositions are always taken seriously, even if they&#8217;re bird-brained.  They have given me the confidence to keep trying as well as insights into the tradeoffs our veterans continually have to evaluate.  I never cease to be impressed by how seriously my colleagues take any ethical considerations involved in such debates.</p>
<p>I used to say &#8220;they&#8221; when referring to Rapleaf, but from now on it will be &#8220;we.&#8221;  I am proud to be one of us.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/09/21/interning-at-rapleaf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Puzzle: Coins and Scales Part 2/2</title>
		<link>http://blog.rapleaf.com/dev/2011/09/20/puzzle-coins-and-scales-part-22/</link>
		<comments>http://blog.rapleaf.com/dev/2011/09/20/puzzle-coins-and-scales-part-22/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 18:24:39 +0000</pubDate>
		<dc:creator>Kurt von Laven</dc:creator>
				<category><![CDATA[Puzzles]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=5833</guid>
		<description><![CDATA[There are nine coins, one slightly heavier than the rest.  You have three old-fashioned balances like these that you can use to compare the weights of whichever sets of coins you would like. Exactly one of the balances provides arbitrary readings (neither necessarily right nor necessarily wrong), but you don&#8217;t know which balance lies. Find [...]]]></description>
			<content:encoded><![CDATA[<p>There are nine coins, one slightly heavier than the rest.  You have three old-fashioned balances like <a title="three old-fashioned balances" href="http://www.skinnerinc.com/full/918/657918.jpg">these</a> that you can use to compare the weights of whichever sets of coins you would like. Exactly one of the balances provides arbitrary readings (neither necessarily right nor necessarily wrong), but you don&#8217;t know which balance lies. Find the heavier coin in only four weighings.</p>
<p>This will be the last puzzle from me, because my internship here is drawing to a close. Thanks to all of you for working the puzzles and brightening my day. If you&#8217;re craving more problems, try out our newly updated <a title="Rapleaf's Challenge Questions" href="https://www.rapleaf.com/careers/challenges">challenge questions</a>. Please send any solutions you come up with to challenge@rapleaf.com and, if you have one handy, include a copy of your résumé.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/09/20/puzzle-coins-and-scales-part-22/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Puzzle: Coins and Scales Part 1/2</title>
		<link>http://blog.rapleaf.com/dev/2011/09/13/puzzle-coins-and-scales-part-12/</link>
		<comments>http://blog.rapleaf.com/dev/2011/09/13/puzzle-coins-and-scales-part-12/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 00:34:36 +0000</pubDate>
		<dc:creator>Kurt von Laven</dc:creator>
				<category><![CDATA[Puzzles]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=5313</guid>
		<description><![CDATA[There are eight coins, one of which weighs a slightly different amount from the rest.  You have an old-fashioned balance like this one that you can use to compare the weights of whichever sets of coins you would like.  Find the special coin in only three weighings.  Bonus points if you can also determine whether the [...]]]></description>
			<content:encoded><![CDATA[<p>There are eight coins, one of which weighs a slightly different amount from the rest.  You have an old-fashioned balance like <a title="old-fashioned balance" href="http://trialx.com/curetalk/wp-content/blogs.dir/7/files/2011/05/diseases/Balance-1.jpg">this one</a> that you can use to compare the weights of whichever sets of coins you would like.  Find the special coin in only three weighings.  Bonus points if you can also determine whether the special coin is heavier or lighter than the rest without any additional weighings.</p>
<p>UPDATE: Try the problem with twelve coins instead of eight, although eight coins could still be a good warm-up.</p>
<p>UPDATE: Feel free to share solutions to the eight coin version too!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/09/13/puzzle-coins-and-scales-part-12/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Rapleaf Announces $1 million Rapleaf Personalization Fund</title>
		<link>http://blog.rapleaf.com/dev/2011/09/08/rapfund/</link>
		<comments>http://blog.rapleaf.com/dev/2011/09/08/rapfund/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 15:19:05 +0000</pubDate>
		<dc:creator>gizem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=5783</guid>
		<description><![CDATA[Have a cool idea for a product related to data or personalization? We’ll help you build it! We just launched the Rapleaf Personalization Fund, which provides $1 million of cash and in-kind awards (plus invaluable support from our partners) for cool startups that integrate with our data. The fund is being launched in partnership with [...]]]></description>
			<content:encoded><![CDATA[<p>Have a cool idea for a product related to data or personalization? We’ll help you build it! We just launched the Rapleaf Personalization Fund, which provides $1 million of cash and in-kind awards (plus invaluable support from our partners) for cool startups that integrate with our data. </p>
<p>The fund is being launched in partnership with North Bridge Venture Partners, Rembrandt Ventures, Founders Fund, Highland Capital Partners, SoftTech VC, MIT Entrepreneurship Center, Harvard College Entrepreneurship Forum, Stanford BASES and many more. </p>
<p>Applications are accepted on a rolling basis on the <a href="https://www.rapleaf.com/rapfund">Rapfund site</a>. We’re looking for awesome start-ups based on Rapleaf data that will take personalization to the next level.</p>
<p>To learn more, visit www.rapleaf.com/rapfund </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/09/08/rapfund/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Survive Wiping Your Database</title>
		<link>http://blog.rapleaf.com/dev/2011/09/07/how-to-survive-wiping-your-database/</link>
		<comments>http://blog.rapleaf.com/dev/2011/09/07/how-to-survive-wiping-your-database/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 20:25:06 +0000</pubDate>
		<dc:creator>Eddie Siegel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=5663</guid>
		<description><![CDATA[We use Ruby on Rails pretty heavily at Rapleaf, and we use Rails migrations to manage our database schemas. While Rails migrations are a great way to manage the schema for a single database, we have multiple production databases. Managing multiple schemas has been a bit of a pain point for us in the past, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left"><a href="http://blog.rapleaf.com/dev/files/2011/09/photo1.jpg"><img class="aligncenter size-full wp-image-5673" src="http://blog.rapleaf.com/dev/files/2011/09/photo1.jpg" alt="" width="349" height="431" /></a>We use Ruby on Rails pretty heavily at Rapleaf, and we use Rails migrations to manage our database schemas. While Rails migrations are a great way to manage the schema for a single database, we have multiple production databases. Managing multiple schemas has been a bit of a pain point for us in the past, and during our latest <a title="Keeping It Clean" href="http://blog.rapleaf.com/dev/2010/01/19/keeping-it-clean/">Sweepleaf</a> we set out to create a tool that would help us run multiple sets of migrations from within a single project.</p>
<p style="text-align: left">We ran into some minor difficulties at first. We had some old migrations that used the old naming scheme (they were numbered consecutively instead of using timestamps) and were mixed in with our newer migrations. Since we wanted our new tools to be able to assume that we were using the timestamp naming convention instead of the old consecutive numbering convention, we went back and renamed the old migrations. This seemed to work fine, and our new tools worked great when developing on our local machines.</p>
<p style="text-align: left">About a week went by and everything was fine. Then, all of a sudden, our website went down. We started investigating, and we found that a bunch of important database tables were completely empty. It took a bit of digging around, but eventually we tracked the problem back to a migration that we had renamed a week earlier. Apparently this was the first time that we had tried to run <em>rake db:migrate</em> in production since Sweepleaf, and renaming the migration caused Rails to re-run it (since it now had a different number and looked like a brand new migration, even though it had already been run in the past). To complete the perfect storm, this particular migration happened to be copied from an old <em>schema.rb</em>, which meant that there were <em>:force =&gt; true</em> directives after each <em>create_table</em>. This meant that since this migration had already been run in the past, the tables were dropped and recreated.</p>
<p style="text-align: left">Once we identified the problem, it was simply a matter of restoring the database from our backups. We ran into a few hiccups when trying to replay the database logs, but ultimately we got everything resolved.</p>
<p style="text-align: left">While it seemed like a fiasco at the time, we learned a number of valuable lessons from this incident.</p>
<ol>
<li>Editing old migrations — particularly renaming them — is bad. Just don’t do it.</li>
<li>Back up your databases. Seriously.</li>
<li>Want to be sure something like this never happens? Take “drop table” permissions away from the user that you use to run migrations. Dropping tables is a cleanup task that can be done (carefully) by administrators.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/09/07/how-to-survive-wiping-your-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(Code) Golfing at the office</title>
		<link>http://blog.rapleaf.com/dev/2011/09/06/code-golfing-at-the-office/</link>
		<comments>http://blog.rapleaf.com/dev/2011/09/06/code-golfing-at-the-office/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 00:18:03 +0000</pubDate>
		<dc:creator>gizem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=5143</guid>
		<description><![CDATA[Some doctors watch Grey&#8217;s Anatomy to relax, and some engineers code for fun when they&#8217;re not coding. Well, those engineers are us. Ben P. decided to kick off an internal game of code golf , which we&#8217;re hoping will be the first of many. The objective is to solve a certain problem with the fewest [...]]]></description>
			<content:encoded><![CDATA[<p>Some doctors watch Grey&#8217;s Anatomy to relax, and some engineers code for fun when they&#8217;re not coding. Well, those engineers are us.</p>
<p>Ben P. decided to kick off an internal game of <a href="http://en.wikipedia.org/wiki/Code_golf" target="_blank">code golf</a> , which we&#8217;re hoping will be the first of many. The objective is to solve a certain problem with the fewest number of characters.</p>
<p>SPOILER ALERT: solutions are at the bottom of this post.</p>
<p>&#8212;&#8212;-<br />
<em>Problem 1</em>: implement <a href="http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/" target="_blank">FizzBuzz</a>:</p>
<div>Print the integers 1 to 100,<br />
but replace multiples of 3 with &#8220;Fizz&#8221;<br />
and multiples of 5 with &#8220;Buzz&#8221;<br />
and multiples of both with &#8220;FizzBuzz&#8221;.<br />
(each output should be on a new line)<em></em></div>
<p></p>
<div><em>Language</em>: Ruby<em></em></div>
<div><em>Par</em>: 69 characters</div>
<p>
A couple points for clarification: the output needs to be exactly as specified &#8211; no extraneous quotation marks.  <a href="http://wiki.rapleaf.com/FizzBuzz" target="_blank">Here&#8217;s an example output</a>. You also can&#8217;t rely on the user having an internet connection or anything other than ruby 1.8.7 installed (including bash).<br />
&#8212;&#8212;</p>
<p>Ben gave the team a 4-day deadline. The next day, he announced updates: Alex P. was at 34 characters &#8220;although it might break the rules.&#8221; Gareth was at 63 characters with a normal ruby program.</p>
<p>The winning code was 57 characters long. Below is a 58-character solution we found that does some interesting things, and the internet record is <a href="http://golf.shinh.org/p.rb?FizzBuzz" target="_blank">50 characters</a>. Can you beat that?</p>
<p>Happy hacking!</p>
<p>&nbsp;</p>
<p>&#8212;</p>
<p>58- character solution:</p>
<p>1.upto(?d){|x|puts (y=&#8217;Fizz&#8217;*1[x%3]+&#8217;Buzz&#8217;*1[x%5])[1]?y:x}</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/09/06/code-golfing-at-the-office/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Puzzle: Banter</title>
		<link>http://blog.rapleaf.com/dev/2011/09/06/puzzle-banter/</link>
		<comments>http://blog.rapleaf.com/dev/2011/09/06/puzzle-banter/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 22:01:32 +0000</pubDate>
		<dc:creator>Kurt von Laven</dc:creator>
				<category><![CDATA[Puzzles]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=4453</guid>
		<description><![CDATA[Greg says, &#8220;I&#8217;ll tell Phil the product of two integers, each of which is greater than one, and Sean their sum.&#8221; After Greg whispers to both of them, Phil shrugs, &#8220;I don&#8217;t know Greg&#8217;s numbers.&#8221; &#8220;I already knew that,&#8221; Sean states. &#8220;But now I do!&#8221; Phil exclaims. Sean smirks, &#8220;Well then so do I.&#8221; What might Greg&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Greg says, &#8220;I&#8217;ll tell Phil the product of two integers, each of which is greater than one, and Sean their sum.&#8221;<br />
After Greg whispers to both of them, Phil shrugs, &#8220;I don&#8217;t know Greg&#8217;s numbers.&#8221;<br />
&#8220;I already knew that,&#8221; Sean states.<br />
&#8220;But now I do!&#8221; Phil exclaims.<br />
Sean smirks, &#8220;Well then so do I.&#8221;</p>
<p>What might Greg&#8217;s integers be?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/09/06/puzzle-banter/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Puzzle: Cylon Detector</title>
		<link>http://blog.rapleaf.com/dev/2011/08/30/puzzle-cylon-detector/</link>
		<comments>http://blog.rapleaf.com/dev/2011/08/30/puzzle-cylon-detector/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 20:12:29 +0000</pubDate>
		<dc:creator>Kurt von Laven</dc:creator>
				<category><![CDATA[Puzzles]]></category>

		<guid isPermaLink="false">http://blog.rapleaf.com/dev/?p=4303</guid>
		<description><![CDATA[There is a line of Cylons and humans with more Cylons than humans.  Each creature whispers to you the number of Cylons in front of them.  Cylons can distinguish Cylons from humans, but humans can not, so they simply provide a reasonable guess.  Find a Cylon.]]></description>
			<content:encoded><![CDATA[<p>There is a line of Cylons and humans with more Cylons than humans.  Each creature whispers to you the number of Cylons in front of them.  Cylons can distinguish Cylons from humans, but humans can not, so they simply provide a reasonable guess.  Find a Cylon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapleaf.com/dev/2011/08/30/puzzle-cylon-detector/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

