<?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/"
				  >
<channel>
<title>Tsenkov's blog</title>
<link>http://tsenkov.net</link>
<image><title>Nikolay Tsenkov</title>
<link>http://www.gravatar.com/avatar/79dea0f7da459630f481229a5f18a6f7?s=180</link>
<url>http://www.gravatar.com/avatar/79dea0f7da459630f481229a5f18a6f7?s=180</url>
</image>
<language>en-us</language>
<lastBuildDate>Fri, 04 Oct 2019 00:17:07 +0300</lastBuildDate>
<pubDate>Mon, 03 Sep 18 00:00:00 +0300</pubDate>
<description><![CDATA[A poor presentation of the beauty of creation. By Nikolay Tsenkov.]]></description>
<item>
<title>a16z Crash Course on Sales</title>
<link>http://tsenkov.net/2018/09/03/a16z-crash-course-on-sales</link>
<pubDate>Mon, 03 Sep 2018 00:00:00 +0300</pubDate>
<description><![CDATA[<p><em>Just watched an amazing crash-course (under 1h in total) on Sales by&nbsp;Peter Levine and a16z - <a href="https://www.youtube.com/watch?v=jmJgb4GqIXw&amp;list=PLM4u6XbiXf5rtyzi7g-5ObKubmZFiTIlD">All Things Sales</a>.</em></p>

<p><em>Here are my notes with screenshots from the series (all rights to the graphics belong to a16z). Enjoy!</em></p>

<h2><strong>Understanding and defining a Sales Channel</strong></h2>

<ul>
	<li>Channel types
	<ul>
		<li>Direct-to-Consumer</li>
		<li>Channel Partner</li>
		<li>OEM (Original Equipment Manufacturer)
		<ul>
			<li>They can have both:
			<ul>
				<li>DtC</li>
				<li>CP</li>
			</ul>
			</li>
		</ul>
		</li>
	</ul>
	</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-1.png" style="width:80%" /></p>

<ul>
	<li>Having multiple touch-points to end-users (coming from different channels) might produce &ldquo;Channel Conflict&rdquo;</li>
</ul>

<h2><strong>How Much to Spend on Marketing vs. Sales? (Sales Engagement)</strong></h2>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-2.png" style="width:80%" /></p>

<ul>
	<li>When you start-up, pick where you are</li>
</ul>

<h2><strong>Market Segmentation</strong></h2>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-3.png" style="width:80%" /></p>

<h2><strong>Why Build a Sales Organization</strong></h2>

<p style="text-align:center"><strong><img alt="" src="/images/all-things-sales-4.png" style="width:80%" /></strong></p>

<h2><strong>Building a Sales Organization</strong></h2>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-4-1.png" style="width:80%" /></p>

<ul>
	<li>Who do I hire
	<ul>
		<li>Initiation Phase:</li>
	</ul>
	</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-5.png" style="width:80%" /></p>

<ul style="margin-left:40px">
	<li>Transition Phase:
	<ul>
		<li>The original sales people;</li>
		<li>VP of Sales.</li>
	</ul>
	</li>
	<li>Execution Phase:</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-6.png" style="width:80%" /></p>

<ul>
	<li>When do I hire?
	<ul>
		<li>2-3 people at Initiation Phase.</li>
		<li>Hire <strong>VP of Sales</strong> during the Transition phase.</li>
		<li>Most of the rest should be hired after that initial Sales Team has figured out the Repeatable Sales Model, generating 3x their annual salaries.</li>
	</ul>
	</li>
	<li>How do I hire?
	<ul>
		<li>The initial Sales Team should be scrappy and without too many habits from corporate.
		<ul>
			<li>They need to be <strong>hungry for achievement</strong> (moving Big Rocks out of the way) and agile to sell <strong>everywhere</strong> and to <strong>everyone</strong></li>
		</ul>
		</li>
		<li>At the Execution Phase people should have a corporate background to be able to operate in a bit more mechanical way</li>
	</ul>
	</li>
	<li>You should keep the original sales people at the Execution Phase of the original product and hopefully put them to open new markets or even start all-ver-again at the Initiation Phase on a <strong>new product</strong></li>
	<li>Promote the original people once you get to the Transition Phase and promote them again at the beginning of the Execution Phase</li>
</ul>

<h2><strong>Setting the Sales Number</strong></h2>

<ul>
	<li>On it depends how much you will put into Engineering, Marketing, Sales etc.</li>
	<li>On it depends the valuation of the company</li>
	<li>Bottoms-up Forcasting</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-8.png" style="width:80%" /></p>

<ul>
	<li>Top-down Forecasting</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-9.png" style="width:80%" /></p>

<ul>
	<li>Growth on both should match up</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-10.png" style="width:80%" /></p>

<h2><strong>Sales Quotas</strong></h2>

<ul>
	<li><strong>Total Quota</strong> is

	<ul>
		<li>number-of-sales-reps * sales-rep-quota</li>
	</ul>
	</li>
	<li><strong>Company Quota </strong>is:
	<ul>
		<li>TQ * 0.8</li>
		<li>it accounts for people leaving and reps not meeting their SRQ</li>
	</ul>
	</li>
	<li>Even if the CQ is reasonable and met, the TQ shouldn&rsquo;t be larger than +20% of TQ, because this would mean that no one from the sales reps will meet their SRQ and they will not make their commission and they will leave the company</li>
</ul>

<h2><strong>The Coverage Matrix</strong></h2>

<ul>
	<li>Routes to market vs Customer Segments</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-11.png" style="width:80%" /></p>

<h2><strong>Managing a Sales Organization: Forcasting</strong></h2>

<ul>
	<li>Forecasting Accuracy
	<ul>
		<li>Its about longterm investment</li>
		<li>balancing growth and burn impossible without forcasting</li>
		<li>Transparency
		<ul>
			<li>make people write down truthful information about sales</li>
			<li>otherwise forecast will be inaccurate</li>
		</ul>
		</li>
		<li>pre-IPO, it is the most important factor</li>
	</ul>
	</li>
</ul>

<h2><strong>Managing a Sales Organization: Revenue Composition</strong></h2>

<ul>
	<li>On what value do you pay your sales force? Pay only on growth!
	<ul>
		<li>ARR
		<ul>
			<li>[&radic;] new</li>
			<li>[&radic;] upgrade</li>
			<li>[x] recurring</li>
		</ul>
		</li>
	</ul>
	</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-16.png" style="width:80%" /></p>

<h2><strong>Compensation</strong></h2>

<ul>
	<li>3-4x their compensation should be generated by the sales force</li>
	<li>should be uncapped compensation plan</li>
	<li>compensation shouldn&rsquo;t go down above target quota is reached</li>
	<li>example:</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-12.png" style="width:80%" /></p>

<h2><strong>Pipeline</strong></h2>

<ul>
	<li>Predicting what you are going to do within a quota:</li>
</ul>

<p style="text-align:center"><img alt="" src="/images/all-things-sales-13.png" style="width:80%" /></p>

<h2><strong>Measure Sales Force Productivity</strong></h2>

<p style="text-align:center"><strong><img alt="" src="/images/all-things-sales-14.png" style="width:80%" /></strong></p>

<ul>
	<li>At least 70% should make their annual quota</li>
	<li>meeting company quota with smaller % of people meeting their quota is not OK</li>
</ul>

<h2><strong>Simplify Sales Compensation</strong></h2>

<p style="text-align:center"><strong><img alt="" src="/images/all-things-sales-15.png" style="width:80%" /></strong></p>

<ul>
	<li>Better to have an <strong>imperfect &amp; clear</strong> compensation plan is better than perfect &amp; complex one</li>
</ul>

<h2><strong>Takeaway for Technical Founders: How to think about Sales</strong></h2>

<ul>
	<li>Think about Sales early</li>
	<li>Sales is 50% of the health of the company</li>
</ul>
]]></description>
</item>
<item>
<title>Don't give me a Painkiller - find me a Cure!</title>
<link>http://tsenkov.net/2017/06/05/dont-give-me-a-painkiller-find-me-a-cure</link>
<pubDate>Mon, 05 Jun 2017 00:00:00 +0300</pubDate>
<description><![CDATA[<p>Few weeks ago, I went on one of the startup events, here in Sofia. Although my work @ <a href="http://universless.com">UNIVERSLESS</a> has nothing to do with this, I have a long interest in startups, so I am always excited at the possibility to learn more. But I never felt like these events are for learning new things, as much as they are meant for networking. This time, though, the selection of speakers really caught my attention and I couldn&#39;t miss it, so I went.</p>

<p>Everything was great - awesome speakers, very interesting panelists and discussions formed, the crowd behaved quite alright.<br />
But during one of the panels, someone said something, which really stuck with me and I&#39;ve meant to post something about it ever since:</p>

<blockquote>
<p>&quot;Don&#39;t give me a vitamin, give me a Painkiller.&quot;</p>
</blockquote>

<p>Now, obviously, the context to this statement, was the impact of a startup&#39;s solution to their user&#39;s problem.</p>

<p>But I think it also, perhaps accidentally, showed everything that is wrong with commercialism (and capitalism) in one sentence... It shows everything that is wrong with our (western) way of thinking about problems and solutions. Not only that the moral side to a &quot;solution&quot; is almost never considered, as long as there&#39;s profit, but a solution would usually &quot;treat a symptom&quot; instead of &quot;curing the disease&quot;.</p>

<blockquote>
<p>- &quot;Don&#39;t give me a painkiller - find me a Cure.&quot;</p>
</blockquote>

<p>Why not have it this way? It&#39;s so much better! Instead of treating that pain, we attack the cause, we get rid of the &quot;sickness&quot;.</p>

<p>You might say &quot;Well, yes, if we can - we should cure it. But sometimes painkillers are the only option.&quot;. That&#39;s correct, but we shouldn&#39;t base our primary approach to solving problems, on situations that are supposed to be a minority and not the norm.</p>

<p>This is not the first time I have thought about this, in fact, every time someone mentions the possibility of the world being in the new startup bubble, the first thought that comes to my mind is not about the huge number of failed startups - it&#39;s the questionably &quot;positive&quot; change, which those that get to a billion&nbsp;dollars bring.</p>
]]></description>
</item>
<item>
<title>Following the rules of Tomorrow.</title>
<link>http://tsenkov.net/2016/09/19/following-the-rules-of-tomorrow</link>
<pubDate>Mon, 19 Sep 2016 00:00:00 +0300</pubDate>
<description><![CDATA[<p style="text-align:center"><img alt="Picture of Albert Einstein" src="/images/Albert_Einstein_(Nobel).png" style="height:198px; margin-left:15px; margin-right:15px; width:140px" /></p>

<p style="text-align:center"><span style="font-size:10px">Albert Einstein, official 1921 Nobel Prize in Physics photograph, <a href="https://commons.wikimedia.org/wiki/File:Albert_Einstein_(Nobel).png">source Wikipedia</a></span></p>

<p><em>&quot;It would be foolish to despise tradition. But with our growing self-consciousness and increasing intelligence we must begin to control tradition and assume a critical attitude toward it, if human relations are ever to change for the better. We must try to recognize what in our accepted tradition is damaging to our fate and dignity&mdash;and shape our lives accordingly.&quot;</em><br />
<span style="font-size:14px">-- Albert Einstein, from his famous writing on racial inequality in the US - &quot;The Negro Question&quot; [1].</span></p>

<h3>These words are immortal.</h3>

<p>Ignoring not only issues like racial inequality, but also preventable human deaths (wars, unregulated gun ownership, dictatorships, refugees of war etc.), climate change, religious extremism, gender inequality, preventable animal deaths... For me feels like burying your head in the sand and comforting yourself behind rules, which you already know to be unjust...</p>

<p>Fortunately, opinions and actions on most of these are a matter of choice - you either excuse yourself with the popular beliefs and socially accepted, etc. or you do what you know will, someday, be a law and a rule for everyone else to follow.</p>

<p>One thing makes me very optimistic - so much more people, each and every day, follow the rules of tomorrow. Not needing a shepherd nor a government to &quot;make&quot; them do it. :)</p>

<p>Don&#39;t forget Reality - it&#39;s right here, it&#39;s right now, you should operate according to its laws, but don&#39;t do all the stupid s*** allowed by society, either.</p>

<p><a href="http://www.onbeing.org/program/albert-einstein-the-negro-question-1946">[1] On Being, &quot;ALBERT EINSTEIN: THE NEGRO QUESTION (1946)&quot;</a></p>
]]></description>
</item>
<item>
<title>How to make a Skype HTML &quot;Contact Me&quot; link for accounts id'ed with email or phone?</title>
<link>http://tsenkov.net/2016/09/19/how-to-make-a-skype-html-contact-me-link-on-accounts-ided-with-email-or-phone</link>
<pubDate>Mon, 19 Sep 2016 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>There is no skype name for the new skype accounts...</h3>

<p>Sort of... There is one but it&#39;s hidden, auto-generated and it isn&#39;t used for login.</p>

<p>To find your skype name:</p>

<ul>
	<li>Open Skype&#39;s Preferences -&gt; Messaging;</li>
	<li>Look for a setting named &quot;Identify SMS Messages by:&quot;;</li>
	<li>There should be an option &quot;My Skype Name (live:...).</li>
</ul>

<p>Everything withing the&nbsp;parentheses is your skype name &quot;live:...&quot; etc.</p>

<p>I first decided to look for my skype name by searching for my account in Add Contact, but there I get a different string which&nbsp;<strong>doesn&#39;t work</strong>.</p>

<p>Once you have the name...</p>

<h3>You can use skype&#39;s Contact me button generator</h3>

<p>Which is located, <a href="https://www.skype.com/en/developer/create-contactme-buttons/" target="_blank">here</a>.</p>

<h3>Or you can build your own</h3>

<p>For <em>call</em> html links (replace &quot;live...&quot; with your skype name):</p>

<pre class="brush:xml;">
&lt;a href=&quot;skype:live:...?call&quot; target=&quot;_blank&quot;&gt;
    Call me
&lt;/a&gt;</pre>

<p>For <em>add</em> html links (replace &quot;live...&quot; with your skype name):</p>

<pre class="brush:xml;">
&lt;a href=&quot;skype:live:...?add&quot; target=&quot;_blank&quot;&gt;
    Contact me
&lt;/a&gt;</pre>

<h3>Thanks to</h3>

<p>Hristo Kosev (you can follow him on twitter <a href="https://twitter.com/hkosev" target="_blank">@hkosev</a>) who helped me figure this out.</p>

<p>Cheers!</p>
]]></description>
</item>
<item>
<title>What can hackers teach developers?</title>
<link>http://tsenkov.net/2015/08/28/what-can-hackers-teach-developers</link>
<pubDate>Fri, 28 Aug 2015 00:00:00 +0300</pubDate>
<description><![CDATA[<p>Before giving my answer&nbsp;I want to clarify that I do consider &quot;hackers&quot; to be developers, but unlike the previous question, with &quot;hackers&quot; I&nbsp;refer&nbsp;to developers in startups -&nbsp;people who build MVP&#39;s fast, getting the product to customers&nbsp;before running out of money. Of course, this would be valid for all types of engineering (not only web or even only&nbsp;software). Also, I must say that I am not a &quot;hacker&quot; and this simply is what I found interesting and useful while working on a recent project, together, with people having the hacker mindset and skills.</p>

<p>These few guidelines might not be the most useful thing if you don&#39;t want to go out of the comfort of working for stable, already-successful companies. But if you want to try and work in a startup (or you want to build a product), this is a short list of things, I am sure you will appreciate in time.</p>

<h3>So here it goes...</h3>

<p><strong>1. If you can&#39;t &quot;fool&quot; yourself into thinking you will finish The New Project in a weekend, then you need to sit down and rethink carefully, if you should start it at all.</strong> Otherwise, you might very well have a year&#39;s worth of work ahead of you. There isn&#39;t a serious product you can complete in a weekend&#39;s time, but there is <strong>an iteration</strong> of a serious product you &quot;might&quot; be able to complete in 48h, such that will be buggy, only doing a single thing essential for your idea, but ready to test with potential customers. We (humans) are not as good, on estimating work, as we like to think we are. Actually,&nbsp;if you can see the possibility of getting the first iteration of a product done in 48h, it still might take 4 weeks. That&#39;s OK - it will not take a year, right?</p>

<p><strong>2. Get things done.</strong> There was a post recently, I think it was by Sam Altman, the current president of YCombinator (probably the most famous startup incubator), who said something along these lines - After YC is over, because the peer pressure isn&#39;t there anymore, many startups don&#39;t work as hard and get on the spiral of doing &#39;fake work&#39;. Fake work is both easier and more fun than real work. If your experience is coming from working for well-established and stable companies, this is something you might be struggling with. I don&#39;t like the term &quot;fake work&quot; and I honestly don&#39;t think he meant &quot;fake&quot; in the literal sense of the word. But anything that isn&#39;t the highest priority of the product and company, right now, is probably what he called fake work. These refactorings that will make our code-base shine, making software architects go &quot;Wow!&quot;, while your customers wait for fixes or the business waits for critical features to get that revenue going, is bad prioritizing. The reason many people don&#39;t actually understand the importance of this is very simple, actually - many established companies don&#39;t have these problems. When all the core features are in place, the company is getting a good revenue and sales are growing, then it&#39;s time to fix, clean, build new features (in order of priority). But the people that got that product to reach such momentum, needed to prioritize very successfully and never do &quot;fake work&quot;.</p>

<p><strong>3. Sell first, build later.</strong> Building something cool that no one will see or use is worthless. Go out there and test the idea, before you even start building. This is something I&#39;ve stupidly done, myself, and is something I will never repeat again. Even if you don&#39;t actually charge money before you build it - talk to people, build toys, pivot reasonably (not to be too far away from what made you passionate about solving a problem, but not before reaching a problem you are sure your solution is truly worth it) and test the demand for your products or features in advance. And if things don&#39;t work, you haven&#39;t invested so much to be more than 1st degree &quot;devastated&quot;. :) There is no way to easily let go of ideas and products you believe in, but it&#39;s definitely easier to do it a month in, than, say, after a year.</p>

<p><strong>4. Don&#39;t look down on hackers, to be a hacker is a skill, not lack of one.</strong> I have, in my own experience, fooled myself I can do things fast, the way hackers in startups do, without lifting a finger and changing anything in my approach. <em>&quot;Not writing tests, building things that will work no matter how exactly are they designed, making unscalable one-time solutions, I can do that. This is an easy way.&quot;</em>. Boy, was I wrong... If you have years of TDD/BDD development under your belt, you are in for a big surprise - switching off an instinct is not an easy thing to do. And not only that, you need to be able to deal with the stress of developing things that are prototype-like under the hood, but are used in the real world and can break at any time, could be hard to fix and simply couldn&#39;t be scaled in many cases. I am not in any way sarcastic, this is something that startups currently need to do, in order to survive (read &quot;succeed&quot;). <em>&quot;We don&#39;t have time to build a few things Great, we have the time to build many things OK. Once we get to Series A, or even B, we will hire some smart kids to get into the code base and clean it up.&quot;</em> This is what I&#39;ve heard from founders.</p>

<p>So, these are things that many developers, especially people working in stable and already successful companies, don&#39;t necessarily know or even think about. But if you want to be on the forefront of technology, I believe you do need to learn how to be a &quot;hacker&quot;.</p>

<p>Cheers!</p>
]]></description>
</item>
<item>
<title>Looking for my next challenge!</title>
<link>http://tsenkov.net/2015/06/02/looking-for-my-next-challenge</link>
<pubDate>Tue, 02 Jun 2015 00:00:00 +0300</pubDate>
<description><![CDATA[<p>Couple of days ago I released my synthesizer <a href="http://nicroto.github.io/viktor">Viktor NV-1</a> and&nbsp;it went...&nbsp;<strong>NUTS</strong>!</p>

<p style="text-align:center"><img alt="" src="/images/viktor-nv-1.png" style="height:335px; width:631px" /></p>

<h3>I was on&nbsp;the front page of Hacker News for 17 hours!</h3>

<p>Viktor held <strong>#1 </strong>position&nbsp;on&nbsp;<a href="http://www.reddit.com/r/javascript/comments/382p19/viktor_nv1_synthesizer/">Reddit r/Javascript</a> for 10h (I went to sleep, at 4am, so it might&#39;ve been longer than that) and it still was on the front page, over a day later... Incredible...</p>

<p>People&nbsp;loved it!&nbsp;How can I tell, you ask - let me answer that with a question:&nbsp;Have you ever seen a discussion on the HN with over 50 comments and <a href="https://news.ycombinator.com/item?id=9640218">not&nbsp;a single one to be&nbsp;tiny bit negative</a>?</p>

<p>They posted about it on twitter, facebook, ello... everywhere. In a single day the site got over <strong>5600 unique visitors</strong>. Few hours in, someone&nbsp;posted a <a href="https://www.youtube.com/watch?v=ZU8FE9xLBdM">session recording with the NV-1</a> on youtube! This one was especially close to my heart... Thank you <a href="https://twitter.com/FluxSauce">Jon Peck</a>! This made me so happy!</p>

<p>And now... now the madness is almost over. On one hand, I am starting to feel the withdrawal&nbsp;from all this attention, but on the other, I&nbsp;will finally get a good night sleep (after 3 sleepless nights).</p>

<h3>So what&#39;s with this title &quot;next challenge&quot;?</h3>

<p>Viktor is, by far, my favorite project and I will continue working on it in my spare time. Together with the project I&#39;ve been working on, full-time, for 1.5y now, <a href="https://pagehopapp.com">Pagehop</a>.</p>

<h3>Starting today, I am looking for my next professional challenge.</h3>

<p>I love working on Pagehop, it&#39;s my first independent project, which I saw all the way from an idea, through&nbsp;more than a year of hard work and 3 major releases. I&#39;ve poured all my energy, savings and time in it and I am proud of what I&#39;ve built.</p>

<p>Maybe&nbsp;because of the freemium-like model I used for it, or because I didn&#39;t have the resources to popularize it, or maybe people just didn&#39;t like it so much (this one is very hard to admit, but there is no point in lying yourself),&nbsp;it never really took off. I will continue rolling out updates, whenever I can. That&#39;s a promise. But it&#39;s time to move on...</p>

<h3>So what am I good at?</h3>

<p>Well, lets see what have I been working on:</p>

<ul>
	<li><a href="http://nicroto.github.io/viktor" style="line-height: 20.7999992370605px;">Viktor NV-1</a>&nbsp;is a synthesizer built for the browser</li>
	<li><a href="https://pagehopapp.com">Pagehop</a> is a desktop app, a launcher for the Web</li>
	<li>I&#39;ve built a large portion of this&nbsp;<a href="http://www.telerik.com/appbuilder">web IDE</a></li>
	<li>Built a couple and improved a few of these&nbsp;<a href="http://www.telerik.com/products/aspnet-ajax.aspx">web UI components</a></li>
</ul>

<p>You can see many more smaller projects, posted on my github account (<a href="https://github.com/nicroto/boxtree">boxtree</a>, <a href="https://github.com/nicroto/AlgoView">AlgoView</a>, <a href="https://github.com/nicroto/license-key">license-key</a> etc.).</p>

<p>So through the years, this is what my competency became like:</p>

<ul>
	<li><strong>Languages:</strong> Javascript/HTML/CSS, Swift, Objective-C, C#, PHP</li>
	<li><strong>Server &amp;&nbsp;Desktop&nbsp;technologies:</strong> Node.js (Express/Browserify/Babel/Grunt/Should), ASP.NET (WebForms/MVC), Zend, MySQL, Cocoa</li>
	<li><strong>Web Technologies:</strong> CommonJS &amp; AMD, Web Audio &amp; MIDI API&#39;s, Angular.js, Bootstrap, Stylus, jQuery, Polymer and many other libs</li>
	<li><strong>Tools:</strong> git/TFS, iTerm, SublimeText/Xcode/VisualStudio, Pixelmator</li>
</ul>

<h3>My dream job</h3>

<p>Having just scratched the surface of what&#39;s possible with Web Audio, I want more! A gig with Web Audio would be an awesome opportunity for me to do what I love and earn my <em>food and shelter</em> at the same time.</p>

<p>I love <strong>Javascript</strong>/<strong>HTML</strong>/<strong>CSS</strong>,&nbsp;<strong>Node.js</strong>,&nbsp;<strong>Web Audio</strong>,&nbsp;<strong>Angular.js</strong> (with <strong>Browserify</strong>),&nbsp;<strong>Bootstrap</strong>, I love the <strong>Web</strong>.</p>

<p>So, to be 99% naive, the best position I imagine&nbsp;for myself, would be to continue working on sound synthesis&nbsp;in a web DAW&nbsp;platform.</p>

<p>At almost the same level of awesomeness would be, if I could do an interesting work with the above technologies (or a subset of them).</p>

<h3>Why am I writing this?</h3>

<p>I don&#39;t expect people to start offering me jobs, without lifting a finger on my side. But this write-up is an insight of what I like doing, which I imagine would be useful, to teams considering me.</p>

<h3>I can&#39;t wait!</h3>

<p>I am so excited for this next step in my life.&nbsp;I rarely commit&nbsp;less than a year on a project, so you can imagine how big of a&nbsp;deal this is for me.</p>

<p><a href="https://bg.linkedin.com/pub/nikolay-tsenkov/38/754/955">This</a> is my LinkedIn profile and <a href="http://tsenkov.net/contacts">here</a>&nbsp;is the rest my contact information.</p>

<p>&nbsp;</p>

<p>Cheers!</p>
]]></description>
</item>
<item>
<title>2h to my first product release</title>
<link>http://tsenkov.net/2014/09/30/2h-to-my-first-product-release</link>
<pubDate>Tue, 30 Sep 2014 00:00:00 +0300</pubDate>
<description><![CDATA[<p>It&#39;s around 9pm, on a Tuesday evening. At almost 20 &deg;C outside, it&#39;s pretty warm for the season, but the sun has long sat down. My window was open almost through the entire day and I can hear how the whole city is going quieter. Not unlike most days, I am sitting at my desk, at home, working.</p>

<p>But something is completely different, tonight. Instead of finishing my tasks for the day, I am preparing for them to start. Instead of having a glass of wine, I am drinking a coffee I just boiled in the kitchen...</p>

<p>In 2 hours, I expect an event so important to me, that... I can&#39;t possible explain.</p>

<p>At precisely 8pm UTC (11pm here in Bulgaria), I am going to have my first independent product release. I am releasing my app, Pagehop, you can <a href="https://pagehopapp.com/">check it out</a> (or not).</p>

<p>To calm myself down, and kill sometime between tasks, I decided to write this post. But it&#39;s not for you, Dear Reader, sorry - I am writing this, so I can remember &quot;what was it like&quot;, just hours before everything changed... Or didn&#39;t...</p>

<p>So, what is it like?</p>

<p>I have build something that I like and use and am passionate about.</p>

<p>So many lessons learned, along the way - incorporating the company (done that on my own, with some advice from friends), taking care of accounting, dealing with the government, banks, payment providers... the list goes on and on. So many details tweaked... sometimes I lose the big picture, drilling on something too small, but this is, too, a valuable experience and a lesson.</p>

<p>And here I am, finally, about to reach this huge milestone in my work, and in my life...</p>

<p>I am scared shi*less. So many things can go wrong... I don&#39;t have the time to list them, before tomorrow.</p>

<p>Will people like what I did? Will the site handle the traffic? Will there be any traffic, or will Pagehop&#39;s first breathing hours be in a &quot;cold. empty. room&quot;?</p>

<p>So many things going through my mind...</p>

<p>And there it is...</p>

<p style="text-align:center"><img alt="Image of a reminder notification for Scaling website resources for release." src="/images/scale-reminder.png" style="max-width:480px; width:100%" /></p>

<p>... a reminder pops-up, telling me to scale the resources of the website and pre-warm it for release. This happens as I write this post...</p>

<p>I&#39;m getting back to work.</p>

<p>So, future Me, I don&#39;t know &quot;what happened&quot;, yet, but I will do my best to make you read this, with pride.</p>
]]></description>
</item>
<item>
<title>School should be fun</title>
<link>http://tsenkov.net/2014/09/03/school-should-be-fun</link>
<pubDate>Wed, 03 Sep 2014 00:00:00 +0300</pubDate>
<description><![CDATA[<p>Couple of weeks ago, I was at the gym, training, when this kid,&nbsp;around the age of 10,&nbsp;came up to me and started asking me about exercises.</p>

<p>From the very first word he said, I noticed that there is something weird and unfamiliar about that kid. He was talking a bit slow, no accent, perfect Bulgarian language, but there was something different about him...</p>

<p>Later on, I overheard&nbsp;another kid asking him:</p>

<p>&nbsp;- So your thoughts are in Norwegian?</p>

<p>&nbsp;- Yes, they are, I think...&nbsp;- he said.</p>

<p>Then I connected the dots and realized what was different about him - he was living in Norway with his Bulgarian parents.</p>

<p>At the end of the workout, before I went out, I decided to ask the kid about the school he goes to.</p>

<p>He said he&#39;ll be in the 5th grade (or maybe even 6th, I forgot)&nbsp;this year and he hasn&#39;t been graded, yet... In Bulgaria, things are very different. We have grades from the very beginning of school and from 2nd grade on, you can be left to repeat a grade, if you can&#39;t keep up with the rest of the kids.</p>

<p>I&#39;ve heard before about such an education&nbsp;system (no grades in the first school years) being used in western countries and I&nbsp;think this, probably, is the better approach.</p>

<p>Still, there is a very important component in the success of any system - <strong>fun</strong>.</p>

<p>I believe, that every educational system, with or without grades, should be fun. Kids should learn how to have fun working on problems and studying. Kids shouldn&#39;t be forced to study, until the required data gets in their heads.&nbsp;Instead, they should enjoy the process of studying.&nbsp;This is how they actively will want to learn and improve, not only while there is a teacher over their heads, but for the rest of their lives.</p>
]]></description>
</item>
<item>
<title>Thanks for my life, Russia</title>
<link>http://tsenkov.net/2014/09/01/thanks-for-my-life-russia</link>
<pubDate>Mon, 01 Sep 2014 00:00:00 +0300</pubDate>
<description><![CDATA[<p>As expected, on my last post <a href="http://tsenkov.net/2014/08/29/russophiles-and-burgers">Russophiles and burgers</a>, I got a response, roughly&nbsp;stating that the current government in Ukraine, doesn&#39;t hold the best interest of the Ukrainian people, and that I should be grateful&nbsp;to Russia for my <strong>life (better yet - &quot;existence&quot;)</strong>... Here is the comment:</p>

<blockquote>
<div style="font-style: italic;">
<p>This is not about hate. This is about reality.</p>

<p>What would YOU do or think if there was a definite fascist government in Macedonia, and some Macedonian lands with people there, who were Bulgarians by nature and soul, did not approve their rulers and future, and would rather be part of Bulgaria than Macedonia?...</p>

<p>And what did Russia to us? Well, let&#39;s put it like this: if it wasn&#39;t Russia, you would most probably not exist. ;)</p>
</div>
</blockquote>

<p>I will not comment the example for Macedonia, (almost) at all, but I will say that I felt like I am reading a letter send by the means of pigeon and it&#39;s medieval&nbsp;time again. Except for the fascist&nbsp;part, we wouldn&#39;t know what that was, back then.</p>

<p>Here is my answer to the rest of it.</p>

<p>So, let me get this straight - you think that the Ukrainian government, <strong>the government that wants Ukraine to be part of the European Union</strong>, is a <strong>&quot;definite fascist&quot;</strong> government? How did the entire world, besides Russia, miss&nbsp;that fact? Coming to think of it,&nbsp;I don&#39;t even remember Russia, making such statement...&nbsp;So far, they just say, <em>they don&#39;t even have any part in the entire conflict</em>.</p>

<p>I wouldn&#39;t be alive, if it wasn&#39;t for Russia... At first this line got me angry, but then I remembered... you <strong>were</strong> right - I really wouldn&#39;t be alive if it wasn&#39;t for Russia! :)</p>

<p>Gosh, when I was a kid, I remember going from a hospital to a hospital, getting a surgery after surgery and if the conditions were just a <em>tiny bit worse...</em>&nbsp;I wouldn&#39;t be here writing these comments in Facebook,&nbsp;drinking my morning coffee.</p>

<p>I am grateful to Russia (truly), that they didn&#39;t accepted us in the Soviet Union, because if they had, <strong>I don&#39;t think I would be alive</strong>. If these hospitals were just a tiny bit less unstocked and filthy, I wouldn&#39;t be alive.</p>

<p>I am grateful to Russia for insisting,&nbsp;Bulgaria to be a country that should suffer reparations after the WWII and be considered a loser in the war, while we weren&#39;t before they had their say. Yes, we deserved it! Yep, <strong>the same country that started the war</strong> with Hitler, told us, small piece of land that was forced to get into the fight, bare-footed, with rocks and sticks, <strong>that we. are. guilty.</strong> for it. Thanks.</p>

<p>I am grateful that Russia gave us the communism, forcing all people to give their livestock,&nbsp;riches and land to stupidity, naming anyone that disagree an <em>&quot;enemy to the nation&quot;</em> (my great grand father was one of your enemies, at least Russia says so), killing him or throwing him in jail, putting this <strong>mark of disgrace on his/her family</strong>.</p>

<p>My great grandmother and her son (my grandfather) are also grateful for being deported from their home on the other side of the country with a bag of clothes, no money, but great prospects for the future in our (then) communist country, because they are the family of an &quot;enemy of the nation&quot;...</p>

<p>My father is also grateful, that didn&#39;t get the chance to go study after high-school, because of the big red stamp in his record - &quot;family of enemy of the nation&quot;.</p>

<p>If I was a kid, that was brought up to live by 2 crackheads&nbsp;and a bottle of bad whiskey, I&#39;d still be grateful for my life, but that&#39;s just about it.</p>

<p>(Sorry Mom &amp; Dad, you aren&#39;t crackheads, I&#39;m just trying to make a point. Love you!)</p>
]]></description>
</item>
<item>
<title>Russophiles and burgers</title>
<link>http://tsenkov.net/2014/08/29/russophiles-and-burgers</link>
<pubDate>Fri, 29 Aug 2014 00:00:00 +0300</pubDate>
<description><![CDATA[<p style="text-align:center"><img alt="Merry Christmas from Russia" src="/images/from-russia-with-love.jpg" style="max-width:300px; width:100%" /></p>

<p style="text-align:center"><span style="font-size:10px"><em>Image from 9gag.com</em></span></p>

<p>Let me throw some oil into the fire - I don&#39;t understand all the people in Bulgaria, working for western companies, driving western cars, listening western music and wearing western clothes, but being (non)secret(but loud) Russian sympathizers in the social networks, during the latest events in Ukraine... Why?</p>

<p>What did Russia ever do for you? If you so desire, you can mention that they freed Bulgaria from the Ottoman Empire, but these are so different times... and this was so long ago... that Communism is a lot easier to remember and unnatural to leave out, when you consider the goods and the bads we&#39;ve seen from this country.</p>

<p>No matter what you will say, the facts are - you choose to continue living in the European Union, you use every convenience of the western way of living and Capitalism. Until you spit up that burger, start working for Lukoil and you move to a <a href="http://www.npr.org/blogs/thesalt/2014/05/27/314961287/how-soviet-kitchens-became-hotbeds-of-dissent-and-culture">stalinka</a> in your beloved paradise (which people, without the privileges of the uncontrollable gun-use, try so desperately to leave), your points don&#39;t have any weight.</p>

<p><strong>You say something, but you always do another.</strong></p>

<p>And if there is such a comment - no, I don&#39;t approve the U.S. invading territories on the principle &quot;They can use some freedom.&quot;, just to be able to get some oil in the tank. The same way, I am not OK with Russia, exploiting a riot in a DIFFERENT country to get some new lands.</p>

<p>This is not OK (all of it) and it shouldn&#39;t be happening any more.</p>
]]></description>
</item>
<item>
<title>Krav Maga</title>
<link>http://tsenkov.net/2014/07/29/krav-maga</link>
<pubDate>Tue, 29 Jul 2014 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>Yesterday I had my first class in Krav Maga.</h3>

<p>As expected, all the ground exercises are challenging for me. But even in the standing stance - the guard is different from boxing, especially when defending against an attacker with a knife - you even have to change to southpaw depending on where the knife is. I am eager to see what I can transfer as a knowledge and experience from boxing (open-hand hitting will not be very natural for quite awhile).</p>

<p>I have to say, I am worried that I can injure myself fairly easy in this sort of thing. Besides all the bruises from falling, I have sprained a bit a wrist and an ankle and it was only my first time.</p>

<p>I didn&#39;t like the level of physical exercise, though. At first I thought it&#39;s all because I am new and the instructor didn&#39;t wanted to make me quit or something, but I didn&#39;t see anyone doing many conditioning exercises - pretty much everything was technical.</p>

<p>The instructor seems to be very good at what he does. He definitely set the sense of respect after he threw me out for getting in 2min early and with the shoes on. :) He told so much interesting trivia about Krav Maga, Karate, Judo, even boxing, that I couldn&#39;t memorize it all (and it was just an hour workout). A lot to be learned from this guy.</p>

<p>Overall -&nbsp;I think I found a new challenge for myself. :) Probably I still don&#39;t know what I am talking about, but the way I see it now, I will be doing Krav Maga for the technique and boxing &amp; running for conditioning.</p>
]]></description>
</item>
<item>
<title>If you need a break, take it right away!</title>
<link>http://tsenkov.net/2014/05/27/if-you-need-a-break-take-it-right-away</link>
<pubDate>Tue, 27 May 2014 00:00:00 +0300</pubDate>
<description><![CDATA[<h6><em>I wrote a bigger post, initially, and then I decided to cut the cr** and leave it as this:</em></h6>

<p>If you don&#39;t believe in what you do - quit and start something you believe in.</p>

<p>When you feel exhausted, stop working and rest for a day.</p>

<p>When you rest, don&#39;t just sit back at home - it will depress you. Do something completely different from your work (you will get a new perspective on your life).</p>

<p>Good luck!</p>
]]></description>
</item>
<item>
<title>Pixelmator is awesome!</title>
<link>http://tsenkov.net/2014/05/14/pixelmator-is-awesome</link>
<pubDate>Wed, 14 May 2014 00:00:00 +0300</pubDate>
<description><![CDATA[<p>Today I learned (few of) the basics of drawing with Pixelmator.</p>

<p>It&#39;s an amazing app, <a href="http://pixelmator.com">the site</a>&nbsp;is awesome, the sample videos and tutorials are awesome, it&#39;s definitely a competitor to Photoshop and its price is 14 euro (Photoshop is in the hundreds).</p>

<p>For a start I followed <a href="http://www.pxm-tuts.com/tutorials/icon-design/create-simple-3d-metal-bucket-pixelmator/">this tutorial</a>&nbsp;and&nbsp;here is the result.</p>

<p style="text-align:center"><img alt="3d metal bucket with Apple's logo upfront" src="/images/bucket-transparent.png" style="border:none; max-width:400px; width:100%" /></p>

<p>:)</p>
]]></description>
</item>
<item>
<title>JavaScript awesomeness: generating an independent to outer variables function, containing runtime-derived data</title>
<link>http://tsenkov.net/2014/03/18/javascript-awesomeness-generating-an-independent-to-outer-variables-function-containing-runtime-derived-data</link>
<pubDate>Tue, 18 Mar 2014 00:00:00 +0200</pubDate>
<description><![CDATA[<h3>Problem</h3>

<p>Generating an independent to outer variables function, containing data derived during runtime, with a real parse-able function, not a messy unreadable, multiline&nbsp;string.</p>

<p>So, basically, I want to have a real function to be a template, which will during runtime be filled with some data and regenerated.</p>

<p>For example, the following:</p>

<pre class="brush:jscript;">
var initialFunc = function() {
	var someObject = {
		prop: valueToReplace
	};
	return someObject;
};</pre>

<p>might later become:</p>

<pre class="brush:jscript;">
var initialFunc = function() {
	var someObject = {
		prop: &quot;this was derived during runtime&quot;
	};
	return someObject;
};</pre>

<h3>Why</h3>

<p>You are probably wondering why not just generate it like that in first place - because the data is gathered during runtime.</p>

<p>Then the options are:</p>

<ul>
	<li>Concatenate a (sometimes really) big,&nbsp;multiline, messy string;</li>
	<li>This solution.</li>
</ul>

<h3>Solution</h3>

<p>Here is how the regeneration process would look like:</p>

<pre class="brush:jscript;">
var generated = new Function( &quot;(&quot; + function(valueToSwap) {
	var someObject = {
		prop: valueToSwap
	};
	return someObject;
} + &quot;)(\&quot;&quot; + value + &quot;\&quot;);&quot; );
// the quotes are only necessary for string params of course</pre>

<p>What this baby does, is:</p>

<ul>
	<li>Converts the passed real parsed function to string</li>
	<li>Creates a function wrapping a self execution function and</li>
	<li>The self execution function passes itself the needed parameters</li>
</ul>

<p>I would recommend on creating a func that generates the parameter list, that is passed, so there are no hardly readable parts of the generation.</p>

<p>That&#39;s it.</p>

<p>Comments on <a href="https://news.ycombinator.com/item?id=7423025">HN</a>.</p>
]]></description>
</item>
<item>
<title>Addictions</title>
<link>http://tsenkov.net/2013/07/21/addictions</link>
<pubDate>Sun, 21 Jul 2013 00:00:00 +0300</pubDate>
<description><![CDATA[<p>This is a list of facts, that really <strong>shocked me</strong> when I read them, about different types of drug addictions.</p>

<h3>Cocaine</h3>

<p>1. There isn&#39;t a physical addiction, only psychological.<a href="http://en.wikipedia.org/wiki/Cocaine#Addiction"><sup><span style="font-size:11px">[1</span><span style="font-size:11px">]</span></sup></a></p>

<p>2. Studies from the last 20-30 years show that babies delivered to addicted mothers, don&#39;t suffer any developmental problems.<a href="http://www.philly.com/philly/health/20130721__Crack_baby__study_ends_with_unexpected_but_clear_result.html"><sup><span style="font-size:11px">[2</span><span style="font-size:11px">]</span></sup></a></p>

<h3>Heroin</h3>

<p>1.&nbsp;Like most opioids, unadulterated heroin does not cause many long-term complications other than dependence and constipation. Most of the harm during the usage of unadulterated heroin comes &quot;<em>d</em><span style="color:rgb(0, 0, 0); font-family:sans-serif"><em>ue to increased vulnerability to infectious agents, particularly viruses and intracellular bacteria</em>&quot;.</span><a href="http://en.wikipedia.org/wiki/Heroin#Adverse_effects"><sup><span style="font-size:11px">[3</span><span style="font-size:11px">]</span></sup></a></p>

<p>2. Most of the overdoses are result of unexpected purity of the drug - the average purity of street heroin in the UK varies between 30% and 50%, and since the tolerance for this drug develops relatively fast, unexpected <em>&quot;better quality&quot;</em> often kills addicts.<a href="http://en.wikipedia.org/wiki/Heroin#Adverse_effects"><sup><span style="font-size:11px">[4</span><span style="font-size:11px">]</span></sup></a></p>

<h3><span style="color:rgb(0, 0, 0); font-family:sans-serif">Alcohol</span></h3>

<p>1. It&#39;s more dangerous to&nbsp;the human fetus during pregnancy, than powder and crack cocaine.<a href="https://en.wikipedia.org/wiki/Fetal_alcohol_syndrome"><sup><span style="font-size:11px">[5</span><span style="font-size:11px">]</span></sup></a></p>

<p>2. It has a worse long-term effect on addict&#39;s physical health than heroin and any form of cocaine.<sup><a href="http://www.bbc.co.uk/news/uk-11660210"><span style="font-size:11px">[6</span><span style="font-size:11px">]</span></a></sup></p>

<h3>Tobacco</h3>

<p>1. It is as harmful as cocaine in the long-term.<sup><a href="http://www.bbc.co.uk/news/uk-11660210">[7]</a></sup></p>

<p>2. Tobacco is more harmful than Amphetamines, Cannabis, Methadone, Anabolic Steroids, Ecstasy and LSD.<a href="http://www.bbc.co.uk/news/uk-11660210"><sup>[8]</sup></a></p>

<h3>Substances and&nbsp;level of Harm</h3>

<p><em>* This image is taken from the above linked post of BBC News UK: <a href="http://www.bbc.co.uk/news/uk-11660210">&quot;Alcohol more harmful than heroin&quot;</a></em></p>

<p style="text-align:center"><img alt="Chart of Substances and their level of Harm" src="/images/harm-score.gif" style="border-radius:0px; border:none; max-width:464px; width:100%" /></p>
]]></description>
</item>
<item>
<title>Are we all Sleeper Agents?</title>
<link>http://tsenkov.net/2013/06/26/are-we-all-sleeper-agents</link>
<pubDate>Wed, 26 Jun 2013 00:00:00 +0300</pubDate>
<description><![CDATA[<h3 style="text-align:center"><img alt="Mugshots" src="/images/sleeper-agents.png" style="margin-left:20px; margin-right:20px; max-width:152px; opacity:0.9; width:100%" /></h3>

<h3>Yesterday morning I woke up thinking...</h3>

<p>... &quot;<em>How great it would be to refresh my blog&#39;s design?</em>&quot;. I powered-on my computer and 5-6 hours later,&nbsp;my blog looked as it does right now. It was so pleasant to restyle and re-imagine stuff: I removed the old logo (it was an image) with a simplistic header, changed the backgrounds everywhere, added some &quot;<em>glassish</em>&quot; effect to all boxes, changed fonts, even fixed some bugs and so on.</p>

<p>It was a joy, not a chore.</p>

<p>I woke up with this thought and jumped right into it.</p>

<h3>I love waking up with an idea!</h3>

<p>It&#39;s a common thing for me - sometimes the first thing that comes to my mind when I open my eyes in the morning, becomes my task for the entire day.</p>

<p>Don&#39;t get me wrong, I am not always obsessing over work or programming. For example, few days back I woke up thinking about fishing. Yep! The same day I got my old fishing gear up&amp;ready, and the next morning (5am), we (together with my girlfriend) were walking to a near-by dam with 3l&nbsp;of water, 3 sandwiches, a fishhook and fishing tackle. We had a great day, even caught some fish (we let them all go, though).</p>

<p><img alt="Vesi about to catch her first fish (ever) :)" src="/images/Vesi.png" style="margin:0px 10px; max-width:551px; width:100%" /></p>

<p><em>Here is Vesi, about to catch her first fish, ever.</em></p>

<p><em><img alt="Me, resting the fishhook on piece of wood someone left on the shore." src="/images/Niki.png" style="float:right; margin-left:20px; margin-right:20px; max-width:641px; width:100%" /></em></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><em>And me, resting the fishhook on piece of wood someone left on the shore.</em></p>

<h3>None of these&nbsp;2&nbsp;impulsive decisions, took more than 2 days to execute.</h3>

<p>4 months back, I woke up with the idea that I need to get healthier and more athletic and this same day I found a fitness club at close proximity and started training. It was 3 times a week, early in the morning. Then a month after, I started boxing. By that time I was training 5 times a week (3 times fitness, 2 times boxing). Then, a month after, I started running in the mornings. Now I exercise 2 times/day for 5 days/week, to bring it to a total of 10 workouts/week (running, fitness and boxing). My running was 2km every morning with about 4km walk through this amazing park which is 10 min away from home. Two weeks after I started running I made them to 3km and the same amount of walk.</p>

<p>So, yeah, I do have history for impulsive decisions that changed my life for long periods of time. I have at least a few more examples, that I could share with you, but that&#39;s not really my point.</p>

<h3>Just a fraction of a second... Picture... Or sound... Or smell... Chemical reaction in the brain... Decision...</h3>

<p>It&#39;s unbelievable, so easy it is to take a turn into a different direction. Well, the process is usually far from easy, but the decision... sometimes all it takes is a moment.</p>

<p>I find this to be fascinating. That is why I decided to share it with you, Dear Readers.</p>

<p>So, what do you think? Are we all Sleeper Agents? If we can make that turn in a second or less, changing our lives for months, even years... If just a smile of a random person on the street, or a feeling, which our dream left us with, when we woke up, can &quot;<em>activate</em>&quot; a passion, a striving or appetite we never knew we had... Then, perhaps, maybe, kind-of,&nbsp;we all are Sleeper Agents. But for our own dreams, not for someone else&#39;s bad/good/cruel intentions.</p>
]]></description>
</item>
<item>
<title>TopCoder SRM 146 DIV2 problems and solutions</title>
<link>http://tsenkov.net/2013/04/08/topcoder-srm-146-div2-problems-and-solutions</link>
<pubDate>Mon, 08 Apr 2013 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>Back in the gym...</h3>

<p>I had my first workout today, but I still have work to post from my week of sickness/coding.</p>

<p>I started to work my way up from the first available SRM in the Arena. (only 10 years worth of competitions ahead)</p>

<p>This is the third set of problems I have solved.</p>

<h3>Official Pages</h3>

<p><a href="http://community.topcoder.com/stat?c=round_overview&amp;er=5&amp;rd=4535">Here </a>is the official&nbsp;page of the competition.</p>

<p>And <a href="http://community.topcoder.com/tc?module=Static&amp;d1=match_editorials&amp;d2=srm146">this</a>&nbsp;is the editorial page.</p>

<p>Lets check &#39;em solutions out...</p>

<h3>Task: Yahtzee</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p>This task is about the scoring in the first phase of the die-game Yahtzee, where five dice are used. The score is determined by the values on the upward die faces after a roll. The player gets to choose a value, and all dice that show the chosen value are considered active. The score is simply the sum of values on active dice.</p>

			<p>Say, for instance, that a player ends up with the die faces showing 2, 2, 3, 5 and 4. Choosing the value two makes the dice showing 2 active and yields a score of 2 + 2 = 4, while choosing 5 makes the one die showing 5 active, yielding a score of 5.</p>

			<p>Your method will take as input a int[] <strong>toss</strong>, where each element represents the upward face of a die, and return the maximum possible score with these values.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>YahtzeeScore</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>maxPoints</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>int[]</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>int</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>int maxPoints(int[] toss)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>toss</strong> will contain exactly 5 elements.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each element of <strong>toss</strong> will be between 1 and 6, inclusive.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{ 2, 2, 3, 5, 4 }</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 5</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">The example from the text.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{ 6, 4, 1, 1, 3 }</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 6</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">Selecting 1 as active yields 1 + 1 = 2, selecting 3 yields 3, selecting 4 yields 4 and selecting 6 yields 6, which is the maximum number of points.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{ 5, 3, 5, 3, 3 }</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 10</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p><em>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</em></p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;

class YahtzeeScore
{
    public int maxPoints(int[] toss)
    {
        int[] faces = new int[6];
        int highest = 0, face, index;
        for (int i = 0; i &lt; 5; i++)
        {
            face = toss[i];
            index = face - 1;
            faces[index] += face;
            if (faces[index] &gt; highest)
            {
                highest = faces[index];
            }
        }
        return highest;
    }
}</pre>

<h3>Task: Rectengular Grid</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p>Given the <strong>width</strong> and <strong>height</strong> of a rectangular grid, return the total number of rectangles (NOT counting squares) that can be found on this grid.</p>

			<p>For example, <strong>width</strong> = 3, <strong>height</strong> = 3 (see diagram below):</p>

			<pre>
 __ __ __
|__|__|__|
|__|__|__|
|__|__|__|</pre>

			<p>In this grid, there are 4 2x3 rectangles, 6 1x3 rectangles and 12 1x2 rectangles. Thus there is a total of 4 + 6 + 12 = 22 rectangles. Note we don&#39;t count 1x1, 2x2 and 3x3 rectangles because they are squares.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>RectangularGrid</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>countRectangles</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>int, int</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>long</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>long countRectangles(int width, int height)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Notes</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td>rectangles with equals sides (squares) should not be counted.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>width</strong> and <strong>height</strong> will be between 1 and 1000 inclusive.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
3</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
3</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 22</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">See above</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
5</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
2</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 31</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<pre>
 __ __ __ __ __
|__|__|__|__|__|
|__|__|__|__|__|</pre>

									<p>In this grid, there is one 2x5 rectangle, 2 2x4 rectangles, 2 1x5 rectangles, 3 2x3 rectangles, 4 1x4 rectangles, 6 1x3 rectangles and 13 1x2 rectangles. Thus there is a total of 1 + 2 + 2 + 3 + 4 + 6 + 13 = 31 rectangles.</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
10</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
10</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 2640</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
1</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
1</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 0</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>4)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
592</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
964</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 81508708664</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p><em>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</em></p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;

class RectangularGrid
{
    public long countRectangles(int width, int height)
    {
        long result = 0;
        for (int i = 1; i &lt;= width; i++)
        {
            for (int j = 1; j &lt;= height; j++)
            {
                if (i != j)
                {
                    result += (width - i + 1) * (height - j + 1);
                }
            }
        }
        return result;
    }
}</pre>

<h3>Task: Bridge Crossing</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p>A well-known riddle goes like this: Four people are crossing an old bridge. The bridge cannot hold more than two people at once. It is dark, so they can&#39;t walk without a flashlight, and they only have one flashlight! Furthermore, the time needed to cross the bridge varies among the people in the group. For instance, let&#39;s say that the people take 1, 2, 5 and 10 minutes to cross the bridge. When people walk together, they always walk at the speed of the slowest person. It is impossible to toss the flashlight across the bridge, so one person always has to go back with the flashlight to the others. What is the minimum amount of time needed to get all the people across the bridge?</p>

			<p>In this instance, the answer is 17. Person number 1 and 2 cross the bridge together, spending 2 minutes. Then person 1 goes back with the flashlight, spending an additional one minute. Then person 3 and 4 cross the bridge together, spending 10 minutes. Person 2 goes back with the flashlight (2 min), and person 1 and 2 cross the bridge together (2 min). This yields a total of 2+1+10+2+2 = 17 minutes spent.</p>

			<p>You want to create a computer program to help you solve new instances of this problem. Given an int[] <strong>times</strong>, where the elements represent the time each person spends on a crossing, your program should return the minimum possible amount of time spent crossing the bridge.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>BridgeCrossing</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>minTime</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>int[]</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>int</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>int minTime(int[] times)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Notes</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td>In an optimal solution, exactly two people will be sent across the bridge with the flashlight each time (if possible), and exactly one person will be sent back with the flashlight each time. In other words, in an optimal solution, you will never send more than one person back from the far side at a time, and you will never send less than two people across to the far side each time (when possible).</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>times</strong> will have between 1 and 6 elements, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each element of <strong>times</strong> will be between 1 and 100, inclusive.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{ 1, 2, 5, 10 }</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 17</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">The example from the text.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{ 1, 2, 3, 4, 5 }</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 16</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">One solution is: 1 and 2 cross together (2min), 1 goes back (1min), 4 and 5 cross together (5min), 2 goes back (2min), 1 and 3 cross together (3min), 1 goes back (1min), 1 and 2 cross together (2min). This yields a total of 2 + 1 + 5 + 2 + 3 + 1 + 2 = 16 minutes spent.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{ 100 }</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 100</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">Only one person crosses the bridge once.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{ 1, 2, 3, 50, 99, 100 }</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 162</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p><em>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</em></p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
class BridgeCrossing
{
    public int minTime(int[] times)
    {
        Array.Sort(times);
        if (times.Length == 1)
        {
            return times[0];
        }
        else if (times.Length == 2)
        {
            return Math.Max(times[0], times[1]);
        }

        List&lt;int&gt; right = new List&lt;int&gt;(times);
        List&lt;int&gt; left = new List&lt;int&gt;();

        int time = 0;
        bool moveLeft = true;
        // -1 0 1
        int probeStage = 1;
        while (right.Count &gt; 0)
        {
            if (moveLeft)
            {
                int first, second;
                switch (probeStage)
                {
                    case 1:
                        first = right[0];
                        second = right[1];
                        left.Insert(0, first);
                        left.Insert(1, second);
                        right.RemoveRange(0, 2);
                        time += second;
                        probeStage = -1;
                        break;
                    case 0:
                        int lastIndex = right.Count - 1;
                        first = right[lastIndex - 1];
                        second = right[lastIndex];
                        left.Add(first);
                        left.Add(second);
                        right.RemoveRange(lastIndex - 1, 2);
                        time += second;
                        break;
                }
                moveLeft = false;
            }
            else
            {
                int firstLeft = left[0];
                int firstRight = right[0];
                left.RemoveAt(0);
                int index = 1;
                if (firstLeft &lt; firstRight)
                {
                    index = 0;
                }
                right.Insert(index, firstLeft);
                probeStage++;
                moveLeft = true;
                time += firstLeft;
            }
        }
        return time;
    }
}</pre>

<h3>Summary</h3>

<p>I am particularly proud of my solution to the <strong>Rectangular Grid</strong> problem. What I am doing there is:</p>

<ul>
	<li>Iterate through all possible rectangles which are not square (i &ne; j) and can be contained into the main rectangle.</li>
	<li>calculate the number of times this shapes can be placed within the main rectangle.</li>
</ul>

<p>Analytically, I managed to derive to calculate their number:</p>

<p>&nbsp; &nbsp;&nbsp;(x - x0 + 1) * (y - y0 + 1) for every inner rectangle.</p>

<p>I think the solution was quite elegant and compact.</p>

<p><strong>Bridge Crossing</strong> wasn&#39;t very hard to see through (luck maybe). The algorithm is consistent of the repetition of this complex action:</p>

<ol>
	<li>Get the fastest couple on the left side;</li>
	<li>Return the fastest element back on the right side;</li>
	<li>Get the slowest (with highest sum, also) couple on the left side;</li>
	<li>Return the second element passed in step 1. back on the right.</li>
</ol>

<p>ââThis is repeated until all elements are on the left side.</p>

<p>For ease I am sorting the elements at the beginning and then always insert at sorted positions the elements I am moving.</p>

<p>I hope my solutions (and bragging) would be of assistance to you, dear reader.</p>

<p>ÐÐ¾Ð²Ð¸Ð¶Ð´Ð°Ð½Ðµ! (&quot;See you!&quot; in Bulgarian)</p>
]]></description>
</item>
<item>
<title>TopCoder SRM 145 DIV2 problems and solutions</title>
<link>http://tsenkov.net/2013/04/06/topcoder-srm-145-div2-problems-and-solutions</link>
<pubDate>Sat, 06 Apr 2013 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>As promised...</h3>

<p>I am posting the problems and solutions of the SRM 145, held on 6th May 2003.</p>

<h3>Official Pages</h3>

<p><a href="http://community.topcoder.com/stat?c=round_overview&amp;er=5&amp;rd=4530">Here</a> is the the official page of the match in TopCoder&#39;s Archive.</p>

<p><a href="http://community.topcoder.com/tc?module=Static&amp;d1=match_editorials&amp;d2=srm145">Here</a> is the editorial page.</p>

<p>And now the problem statements and my solutions...</p>

<h3>Task: Dither Counter</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p>Sometimes when computer programs have a limited number of colors to use, they use a technique called dithering. Dithering is when you use a pattern made up of different colors such that when the colors are viewed together, they appear like another color. For example, you can use a checkerboard pattern of black and white pixels to achieve the illusion of gray.</p>

			<p>You are writing a program to determine how much of the screen is covered by a certain dithered color. Given a computer screen where each pixel has a certain color, and a list of all the solid colors that make up the dithered color, return the number of pixels on the screen that are used to make up the dithered color. Each pixel will be represented by a character in <strong>screen</strong>. Each character in <strong>screen</strong> and in <strong>dithered</strong> will be an uppercase letter (&#39;A&#39;-&#39;Z&#39;) representing a color.</p>

			<p>Assume that any pixel which is a color contained in <strong>dithered</strong> is part of the dithered color.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>ImageDithering</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>count</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>string, string[]</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>int</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>int count(string dithered, string[] screen)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>dithered</strong> will contain between 2 and 26 upper case letters (&#39;A&#39;-&#39;Z&#39;), inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>There will be no repeated characters in <strong>dithered</strong>.</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>screen</strong> will have between 1 and 50 elements, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each element of <strong>screen</strong> will contain between 1 and 50 upper case letters (&#39;A&#39;-&#39;Z&#39;), inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>All elements of <strong>screen</strong> will contain the same number of characters.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;BW&quot;</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;AAAAAAAA&quot;,
 &quot;ABWBWBWA&quot;,
 &quot;AWBWBWBA&quot;,
 &quot;ABWBWBWA&quot;,
 &quot;AWBWBWBA&quot;,
 &quot;AAAAAAAA&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 24</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">Here, our dithered color could consist of black (B) and white (W) pixels, composing a shade of gray. In the picture, there is a dithered gray square surrounded by another color (A).</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;BW&quot;</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;BBBBBBBB&quot;,
 &quot;BBWBWBWB&quot;,
 &quot;BWBWBWBB&quot;,
 &quot;BBWBWBWB&quot;,
 &quot;BWBWBWBB&quot;,
 &quot;BBBBBBBB&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 48</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">Here is the same picture, but with the outer color replaced with black pixels. Although in reality, the outer pixels do not form a dithered color, your algorithm should still assume they are part of the dithered pattern.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;ACEGIKMOQSUWY&quot;</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX&quot;,
 &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX&quot;,
 &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX&quot;,
 &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX&quot;,
 &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX&quot;,
 &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 150</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">A picture of vertical stripes, every other stripe is considered part of the dithered color.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;CA&quot;</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;BBBBBBB&quot;,
 &quot;BBBBBBB&quot;,
 &quot;BBBBBBB&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 0</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">The dithered color is not present.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>4)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;DCBA&quot;</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;ACBD&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 4</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">The order of the colors doesn&#39;t matter.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p><em>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</em></p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;

class ImageDithering
{
    public int count(string dithered, string[] screen)
    {
        string allPixels = String.Join(&quot;&quot;, screen);
        int count = 0;
        char[] types = dithered.ToCharArray();
        foreach (char type in types)
        {
            foreach (char pixel in allPixels)
            {
                if (pixel == type)
                {
                    count++;
                }
            }
        }
        return count;
    }
}</pre>

<h3>Task: Exercise Machine</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p>You are writing firmware for an exercise machine. Each second, a routine in your firmware is called which decides whether it should display the percentage of the workout completed. The display does not have any ability to show decimal points, so the routine should only display a percentage if the second it is called results in a whole percentage of the total workout.</p>

			<p>Given a string <strong>time</strong> representing how long the workout lasts, in the format &quot;hours:minutes:seconds&quot;, return the number of times a percentage will be displayed by the routine. The machine should never display 0% or 100%.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>ExerciseMachine</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>getPercentages</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>string</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>int</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>int getPercentages(string time)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>time</strong> will be a string formatted as <tt>&quot;HH:MM:SS&quot;</tt>, HH = hours, MM = minutes, SS = seconds.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>The hours portion of <strong>time</strong> will be an integer with exactly two digits, with a value between 00 and 23, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>The minutes portion of <strong>time</strong> will be an integer with exactly two digits, with a value between 00 and 59, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>The seconds portion of <strong>time</strong> will be an integer with exactly two digits, with a value between 00 and 59, inclusive</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>time</strong> will not be &quot;00:00:00&quot;.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;00:30:00&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 99</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">The standard 30 minute workout. Each one percent increment can be displayed every 18 seconds.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;00:28:00&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 19</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">The 28 minute workout. The user completes 5 percent of the workout every 1 minute, 24 seconds.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;23:59:59&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 0</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">This is the longest workout possible, given the constraints. No percentages are ever displayed on the screen.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;00:14:10&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 49</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>4)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;00:19:16&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 3</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p><em>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</em></p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;

class ExerciseMachine
{
    public int getPercentages(string time)
    {
        int[] parts = new int[3];
        int count = 0;
        string buffer = &quot;&quot;;
        foreach (char symbol in time)
        {
            if (symbol == &#39;:&#39;)
            {
                parts[count] = Int16.Parse(buffer);
                buffer = &quot;&quot;;
                count++;
            }
            else
            {
                buffer += new string(symbol, 1);
            }
        }
        parts[count] = Int16.Parse(buffer);
        int seconds = parts[0] * 3600 + parts[1] * 60 + parts[2];
        count = 0;
        for (int i = 1; i &lt; 100; i++)
        {
            if (((i * seconds) % 100) == 0)
            {
                count++;
            }
        }
        return count;
    }
}</pre>

<h3>Task: Vending Machine</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p><em>Note that in the following problem statement, all quotes and angle brackets are for clarity</em></p>

			<p>A certain vending machine delves out its goods from a rotating cylinder, which can rotate around in both clockwise and counter-clockwise directions. The cylinder has a number of shelves on it, and each shelf is divided into a number of columns. On the front of the machine, there is a panel of doors that extends the entire height of the column. There is one door for each shelf, which is the width of one column. When a purchase is made, the user uses two buttons to rotate the cylinder so their purchase is located at a door. They make their purchase by sliding the appropriate door open, and removing the item (there can only be one item per column on a particular shelf). The cylinder can rotate in a complete circle, and so there are always two ways to get from a particular column to another column.</p>

			<p>Because the vending machine company wants to sell the most expensive items possible, and the machine can only show one column at a time, the machine will always try to put forth the most expensive column available. The price of a column is calculated by adding up all the prices of the remaining items in that column. The most expensive column is defined to be the one with the maximum price. If 5 minutes have elapsed since the last purchase was made, the machine rotates the cylinder to the most expensive column. If, however, another purchase has been made before the 5 minutes are up, the rotation does not occur, and the 5 minute timer is reset.</p>

			<p>Recently, some machines&#39; rotating motors have been failing early, and the company wants to see if it is because the machines rotate to show their expensive column too often. To determine this, they have hired you to simulate purchases and see how long the motor is running.</p>

			<p>You will be given the <strong>prices</strong> of all the items in the vending machine in a string[]. Each element of <strong>prices</strong> will be a single-space separated list of integers, which are the prices (in cents) of the items. The Nth integer in the Mth element of <strong>prices</strong> represents the price of the Nth column in the Mth shelf in the cylinder. You will also be given a string[] <strong>purchases</strong>. Each element in <strong>purchases</strong> will be in the format:<br />
			<tt>&quot;&lt;shelf&gt;,&lt;column&gt;:&lt;time&gt;&quot;</tt><br />
			&lt;shelf&gt; is a 0-based integer which identifies the shelf that the item was purchased from. &lt;column&gt; is a 0-based integer which identifies the column the item was purchased from. &lt;time&gt; is an integer which represents the time, in minutes, since the machine was turned on.</p>

			<p>In the simulation, the motor needs to run for 1 second in order to rotate to an adjacent column. When the machine is turned on, column 0 is facing out, and it immediately rotates to the most expensive column, even if the first purchase is at time 0. The machine also rotates to the most expensive column at the end of the simulation, after the last purchase. Note that when an item is purchased, its price is no longer used in calculating the price of the column it is in. When the machine rotates to the most expensive column, or when a user rotates the cylinder, the rotation is in the direction which takes the least amount of time. For example, in a 4-column cylinder, if column 0 is displayed, and the cylinder is rotated to column 3, it can be rotated backwards, which takes 1 second, versus rotating forwards which takes 3 seconds.</p>

			<p>If a user tries to purchase an item that was already purchased, this is an incorrect simulation, and your method should return -1. Otherwise, your method should return how long the motor was running, in seconds.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>VendingMachine</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>motorUse</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>string[], string[]</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>int</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>int motorUse(string[] prices, string[] purchases)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Notes</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td>When rotating to the most expensive column, if two columns have the same price, rotate to the one with the lowest column number (see example 0).</td>
		</tr>
		<tr>
			<td>-</td>
			<td>If two purchases are less than 5 minutes apart, the machine does not perform a rotation to the most expensive column between the purchases. If two purchases are 5 or more minutes apart, the machine rotates to the most expensive column between the two purchases.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>prices</strong> will have between 1 and 50 elements, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each element of <strong>prices</strong> will have between 5 and 50 characters, is a single-space separated list of integers, and has no leading or trailing spaces.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each element of <strong>prices</strong> will have the same number of integers in it.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each element of <strong>prices</strong> will have at least 3 integers in it.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each integer in <strong>prices</strong> will be between 1 and 10000, inclusive, and will not contain leading 0&#39;s.</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>purchases</strong> will have between 1 and 50 elements, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each element of <strong>purchases</strong> will be in the format <tt>&quot;&lt;shelf&gt;,&lt;column&gt;:&lt;time&gt;&quot;</tt> (angle brackets and quotes are for clarity only), where &lt;shelf&gt;, &lt;column&gt;, and &lt;time&gt; are all integers.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>In each element of <strong>purchases</strong>, &lt;shelf&gt; will be between 0 and M - 1, inclusive, where M is the number of elements in prices.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>In each element of <strong>purchases</strong>, &lt;column&gt; will be between 0 and N - 1, inclusive, where N is the number of integers in each element of prices.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>In each element of <strong>purchases</strong>, &lt;time&gt; will be between 0 and 1000, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>In each element of <strong>purchases</strong>, &lt;shelf&gt;, &lt;column&gt;, and &lt;time&gt; will not contain extra leading 0&#39;s.</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>purchases</strong> will be sorted in strictly ascending order by &lt;time&gt;. This means that each purchase must occur later than all previous ones.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{&quot;100 100 100&quot;}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;0,0:0&quot;, &quot;0,2:5&quot;, &quot;0,1:10&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 4</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>The vending machine has three columns, and only one row. Since all three items are the same price, they are all the most expensive, and therefore, the lowest numbered column is rotated to. Since the machine starts out at column 0, no rotation is performed before the first purchase. The starting configuration is (*&#39;s denote the currently displayed column):</p>

									<pre>
 
+-----+-----+-----+
| 100 | 100 | 100 |
+*****+-----+-----+</pre>

									<p>In the first purchase, the customer does not rotate the cylinder because the item he wants is already displayed. The configuration of the vending machine is now:</p>

									<pre>
+-----+-----+-----+
|  0  | 100 | 100 |
+*****+-----+-----+</pre>

									<p>Since the next purchase is at least 5 minutes away, the machine performs a rotation to the most expensive column. Both column 1 and 2 are now 100 apiece, so it rotates to the smallest index of these, column 1. The fastest way there is to rotate forward 1 column, yielding 1 second of motor use:</p>

									<pre>
+-----+-----+-----+
|  0  | 100 | 100 |
+-----+*****+-----+</pre>

									<p>The next customer purchases the item in column 2, which is 1 column away, so add 1 second to the motor use. Because another 5 minutes passes, the most expensive column is displayed, which is now column 1. Add 1 more second for the rotation. The configuration is now:</p>

									<pre>
+-----+-----+-----+
|  0  | 100 |  0  |
+-----+*****+-----+</pre>

									<p>The final customer purchases from column 1, (which is already displayed), and the final most expensive column is rotated to. Since all columns are the same price again (0), column 0 is displayed. It takes 1 second to get back there, so add 1 more second.</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{&quot;100 200 300 400 500 600&quot;}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;0,2:0&quot;, &quot;0,3:5&quot;, &quot;0,1:10&quot;, &quot;0,4:15&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 17</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>The most expensive column during this whole example is column 5. Since all purchases are at least 5 minutes apart, the most expensive column is rotated to each time.</p>

									<p>Before the purchases start, add 1 second for rotating to column 5.<br />
									The first purchase is 3 columns away, so add 3 seconds to get there, and 3 seconds to get back to column 5<br />
									The second purchase is 2 columns away, so add 4 seconds to get there and back.<br />
									The third purchase is also 2 columns away, so add 4 more seconds.<br />
									The final purchase is only one column away, so add 2 more seconds.</p>

									<p>The final configuration is:</p>

									<pre>
+-----+-----+-----+-----+-----+-----+
| 100 |  0  |  0  |  0  |  0  | 600 |
+-----+-----+-----+-----+-----+*****+</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{&quot;100 200 300 400 500 600&quot;}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;0,2:0&quot;, &quot;0,3:4&quot;, &quot;0,1:8&quot;, &quot;0,4:12&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 11</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>This is the same as example 1, except now, the purchases are all less than 5 minutes apart.</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{&quot;100 100 100&quot;}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;0,0:10&quot;, &quot;0,0:11&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: -1</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>The second purchase is illegal since the item was already purchased</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>4)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{&quot;100 200 300&quot;,
 &quot;600 500 400&quot;}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{&quot;0,0:0&quot;, &quot;1,1:10&quot;, &quot;1,2:20&quot;,
 &quot;0,1:21&quot;, &quot;1,0:22&quot;, &quot;0,2:35&quot;}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 6</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>A two-row example. The configurations just before each purchase are:</p>

									<pre>
purchase 1:
+-----+-----+-----+
| 100 | 200 | 300 |
+-----+-----+-----+
| 600 | 500 | 400 |
+*****+-----+-----+

purchase 2:
+-----+-----+-----+
|  0  | 200 | 300 |
+-----+-----+-----+
| 600 | 500 | 400 |
+-----+*****+-----+

purchase 3:
+-----+-----+-----+
|  0  | 200 | 300 |
+-----+-----+-----+
| 600 |  0  | 400 |
+-----+-----+*****+

purchase 4:
+-----+-----+-----+
|  0  | 200 | 300 |
+-----+-----+-----+
| 600 |  0  |  0  |
+-----+-----+*****+

purchase 5:
+-----+-----+-----+
|  0  |  0  | 300 |
+-----+-----+-----+
| 600 |  0  |  0  |
+-----+*****+-----+

purchase 6:
+-----+-----+-----+
|  0  |  0  | 300 |
+-----+-----+-----+
|  0  |  0  |  0  |
+-----+-----+*****+

final:
+-----+-----+-----+
|  0  |  0  |  0  |
+-----+-----+-----+
|  0  |  0  |  0  |
+*****+-----+-----+</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p><em>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</em></p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;
using System.Text.RegularExpressions;

class VendingMachine
{
    struct Purchase
    {
        public int Row;
        public int Col;
        public int Minute;
    }

    public int motorUse(string[] prices, string[] purchases)
    {
        int[,] dPrices = this.ParsePrices(prices);
        Purchase[] dPurchases = this.ParsePurchases(purchases);
        int col = 0;
        int result = 0;
        result += this.GotoHighest(ref col, dPrices);

        // Algorithm
        for (int i = 0; i &lt; dPurchases.Length; i++)
        {
            int purchaseMotorCost = this.MakePurchase(dPurchases[i], ref col, ref dPrices);
            // already empty
            if (purchaseMotorCost == -1) return -1;
            result += purchaseMotorCost;
            if ( ((i + 1) == dPurchases.Length ) ||
                 ((dPurchases[i + 1].Minute - dPurchases[i].Minute) &gt;= 5) )
            {
                result += this.GotoHighest(ref col, dPrices);
            }
        }
        return result;
    }

    private int GotoHighest(ref int col,int[,] dPrices)
    {
 	    int highestCol = 0;
 	    int highestPrice = 0;
        int rowsCount = dPrices.GetLength(0);
        int colsCount = dPrices.GetLength(1);
        for (int i = 0; i &lt; colsCount; i++)
        {
            int currentColPrice = 0;
            for (int j = 0; j &lt; rowsCount; j++)
            {
                currentColPrice += dPrices[j, i];
            }
            if (currentColPrice &gt; highestPrice)
            {
                highestCol = i;
                highestPrice = currentColPrice;
            }
        }
        int distance = this.CalculateClosestDistance(col, highestCol, colsCount);
        col = highestCol;
        return distance;
    }

    private int MakePurchase(Purchase purchase, ref int col, ref int[,] dPrices)
    {
        int colsCount = dPrices.GetLength(1);
        if (dPrices[purchase.Row, purchase.Col] == 0) return -1;

        dPrices[purchase.Row, purchase.Col] = 0;
        int distance = this.CalculateClosestDistance(col, purchase.Col, colsCount);
        col = purchase.Col;
        return distance;
    }

    private int CalculateClosestDistance(int current, int destination, int last)
    {
        return Math.Min(
            Math.Min(Math.Abs(current - destination), last - current + destination),
            current + (last - destination)
        );
    }

    private int[,] ParsePrices(string[] prices)
    {
        Regex regex = new Regex(&quot;\\s&quot;);
        int colCount = regex.Split(prices[0]).Length;
        int[,] result = new int[prices.Length, colCount];
        for (int i = 0; i &lt; prices.Length; i++)
        {
            string[] items = regex.Split(prices[i]);
            for (int j = 0; j &lt; items.Length; j++)
            {
                result[i, j] = Int32.Parse(items[j]);
            }
        }
        return result;
    }

    // &quot;x,y:n&quot;
    private Purchase[] ParsePurchases(string[] purchases)
    {
        Purchase[] result = new Purchase[purchases.Length];
        for (int i = 0; i &lt; purchases.Length; i++)
        {
            string[] data = Regex.Split(purchases[i], &quot;,|:&quot;);
            result[i] = new Purchase();
            result[i].Row = Int32.Parse(data[0]);
            result[i].Col = Int32.Parse(data[1]);
            result[i].Minute = Int32.Parse(data[2]);
        }
        return result;
    }
}</pre>

<h3>Summary</h3>

<p>The first one is solved in m(the size of the screen) * n(the size of the dither), could it be solved in less operations (smaller complexity)?</p>

<p>The second task has an interesting solution (which solves it in linear time). I got to it analytically, finally deriving the equation:</p>

<p>&nbsp; &nbsp;&nbsp;<em>((percentage</em>â&nbsp;<em>* seconds) % 100) = 0</em></p>

<p>And instead iterating through all the seconds (which also <strong>would be in linear time</strong> if you think about it), I iterate though the whole-number percentage values (1-99).</p>

<p>The third task had too many sub-tasks that needed to be solved, starting from the parsing of the input data. But the distilled algorithm is in the public method alone.</p>

<p>Until my next post. Ð§Ð°Ð¾! (&quot;Bye&quot; in Bulgarian)</p>
]]></description>
</item>
<item>
<title>TopCoder SRM 144 DIV2 problems and my solutions</title>
<link>http://tsenkov.net/2013/04/04/topcoder-srm-144-div2-problems-and-my-solutions</link>
<pubDate>Thu, 04 Apr 2013 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>I got the flu...</h3>

<p>I spent some time at home (since last Friday), sick, and I decided to do some programming contest problems.</p>

<p>This will be the first of series of&nbsp;posts about problems and solutions of old (if I participate in an actual competition, then&nbsp;new as well)&nbsp;TopCoder problems.</p>

<h3>SRM (Single-Round Match) 144 DIV2 (the 2nd division)</h3>

<p>This competition was held on 30 April 2003. It was the oldest available in the TopCoder Arena (app, in which coders compete and practice on old tasks).</p>

<h3>Official page for the competition</h3>

<p><a href="http://community.topcoder.com/stat?c=round_overview&amp;er=5&amp;rd=4515">Here </a>is the official page with statitics, winners and problem statements.</p>

<p>And <a href="http://community.topcoder.com/tc?module=Static&amp;d1=match_editorials&amp;d2=srm144">here</a>&nbsp;is the official &quot;editorials&quot; (summary of the best approaches to the problem&#39;s solutions).</p>

<p>Lets check out the tasks and my solutions...</p>

<h3>Task: Time</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>Computers tend to store dates and times as single numbers which represent the number of seconds or milliseconds since a particular date. Your task in this problem is to write a method whatTime, which takes an int, <strong>seconds</strong>, representing the number of seconds since midnight on some day, and returns a string formatted as &quot;&lt;H&gt;:&lt;M&gt;:&lt;S&gt;&quot;. Here, &lt;H&gt; represents the number of complete hours since midnight, &lt;M&gt; represents the number of complete minutes since the last complete hour ended, and &lt;S&gt; represents the number of seconds since the last complete minute ended. Each of &lt;H&gt;, &lt;M&gt;, and &lt;S&gt; should be an integer, with no extra leading 0&#39;s. Thus, if <strong>seconds</strong> is 0, you should return &quot;0:0:0&quot;, while if seconds is 3661, you should return &quot;1:1:1&quot;.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>Time</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>whatTime</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>int</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>string</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>string whatTime(int seconds)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>seconds</strong> will be between 0 and 24*60*60 - 1 = 86399, inclusive.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
0</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: &quot;0:0:0&quot;</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
3661</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: &quot;1:1:1&quot;</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
5436</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: &quot;1:30:36&quot;</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
86399</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: &quot;23:59:59&quot;</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;

public class Time
{
    public string whatTime(int seconds)
    {
        int hConst = 3600;
        int mConst = 60;
        int hours = seconds / hConst;
        seconds = seconds % hConst;
        int mins = seconds / mConst;
        seconds = seconds % mConst;
        return hours + &quot;:&quot; + mins + &quot;:&quot; + seconds;
    }
}</pre>

<h3>Task: Binary Code</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p>Let&#39;s say you have a binary string such as the following:</p>

			<p><tt>011100011</tt></p>

			<p>One way to encrypt this string is to add to each digit the sum of its adjacent digits. For example, the above string would become:</p>

			<p><tt>123210122</tt></p>

			<p>In particular, if <tt>P</tt> is the original string, and <tt>Q</tt> is the encrypted string, then <tt>Q[i] = P[i-1] + P[i] + P[i+1]</tt> for all digit positions <tt>i</tt>. Characters off the left and right edges of the string are treated as zeroes.</p>

			<p>An encrypted string given to you in this format can be decoded as follows (using <tt>123210122</tt> as an example):</p>

			<ol>
				<li>Assume <tt>P[0] = 0</tt>.</li>
				<li>Because <tt>Q[0] = P[0] + P[1] = 0 + P[1] = 1</tt>, we know that <tt>P[1] = 1</tt>.</li>
				<li>Because <tt>Q[1] = P[0] + P[1] + P[2] = 0 + 1 + P[2] = 2</tt>, we know that <tt>P[2] = 1</tt>.</li>
				<li>Because <tt>Q[2] = P[1] + P[2] + P[3] = 1 + 1 + P[3] = 3</tt>, we know that <tt>P[3] = 1</tt>.</li>
				<li>Repeating these steps gives us <tt>P[4] = 0</tt>, <tt>P[5] = 0</tt>, <tt>P[6] = 0</tt>, <tt>P[7] = 1</tt>, and <tt>P[8] = 1</tt>.</li>
				<li>We check our work by noting that <tt>Q[8] = P[7] + P[8] = 1 + 1 = 2</tt>. Since this equation works out, we are finished, and we have recovered one possible original string.</li>
			</ol>

			<p>Now we repeat the process, assuming the opposite about <tt>P[0]</tt>:</p>

			<ol>
				<li>Assume <tt>P[0] = 1</tt>.</li>
				<li>Because <tt>Q[0] = P[0] + P[1] = 1 + P[1] = 0</tt>, we know that <tt>P[1] = 0</tt>.</li>
				<li>Because <tt>Q[1] = P[0] + P[1] + P[2] = 1 + 0 + P[2] = 2</tt>, we know that <tt>P[2] = 1</tt>.</li>
				<li>Now note that <tt>Q[2] = P[1] + P[2] + P[3] = 0 + 1 + P[3] = 3</tt>, which leads us to the conclusion that <tt>P[3] = 2</tt>. However, this violates the fact that each character in the original string must be &#39;0&#39; or &#39;1&#39;. Therefore, there exists no such original string <tt>P</tt> where the first digit is &#39;1&#39;.</li>
			</ol>

			<p>Note that this algorithm produces at most two decodings for any given encrypted string. There can never be more than one possible way to decode a string once the first binary digit is set.</p>

			<p>Given a string <strong>message</strong>, containing the encrypted string, return a string[] with exactly two elements. The first element should contain the decrypted string assuming the first character is &#39;0&#39;; the second element should assume the first character is &#39;1&#39;. If one of the tests fails, return the string &quot;NONE&quot; in its place. For the above example, you should return <tt>{&quot;011100011&quot;, &quot;NONE&quot;}</tt>.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>BinaryCode</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>decode</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>string</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>string[]</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>string[] decode(string message)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong>message</strong> will contain between 1 and 50 characters, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Each character in <strong>message</strong> will be either &#39;0&#39;, &#39;1&#39;, &#39;2&#39;, or &#39;3&#39;.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;123210122&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: { &quot;011100011&quot;,  &quot;NONE&quot; }</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>The example from above.</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;11&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: { &quot;01&quot;,  &quot;10&quot; }</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>We know that one of the digits must be &#39;1&#39;, and the other must be &#39;0&#39;. We return both cases.</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;22111&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: { &quot;NONE&quot;,  &quot;11001&quot; }</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>Since the first digit of the encrypted string is &#39;2&#39;, the first two digits of the original string must be &#39;1&#39;. Our test fails when we try to assume that <tt>P[0] = 0</tt>.</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;123210120&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: { &quot;NONE&quot;,  &quot;NONE&quot; }</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">
									<p>This is the same as the first example, but the rightmost digit has been changed to something inconsistent with the rest of the original string. No solutions are possible.</p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>4)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;3&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: { &quot;NONE&quot;,  &quot;NONE&quot; }</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>5)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
&quot;12221112222221112221111111112221111&quot;</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 
{ &quot;01101001101101001101001001001101001&quot;,
  &quot;10110010110110010110010010010110010&quot; }</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;

public class BinaryCode
{
    public string[] decode(string message)
    {
        short[] coded = new short[message.Length];
        char[] digitChars = message.ToCharArray();
        for (short i = 0; i &lt; digitChars.Length; i ++)
        {
            coded[i] = Int16.Parse(Convert.ToString(digitChars[i]));
        }
        return new string[] {
            this.DecodeWithAssumption(0, coded),
            this.DecodeWithAssumption(1, coded)
        };
    }

    private string DecodeWithAssumption(short first, short[] coded)
    {
        int length = coded.Length;
        short[] init = new short[length];
        init[0] = first;

        for (short i = 1; i &lt; coded.Length; i++)
        {
            // P(n) = Q(n - 1) - P(n - 2) - P(n - 1);
            short digit = (short)(this.GetDigit(i - 1, coded) - this.GetDigit(i - 2, init) - this.GetDigit(i - 1, init));
            if (digit == 1 || digit == 0)
            {
                init[i] = digit;
            }
            else
            {
                return &quot;NONE&quot;;
            }
        }
        for (short i = 0; i &lt; init.Length; i++)
        {
            // Q(n) = P(n - 1) + P(n) + P(n + 1);
            short checkValue = (short)(this.GetDigit(i - 1, init) + this.GetDigit(i, init) + this.GetDigit(i + 1, init));
            if (checkValue != coded[i])
            {
                return &quot;NONE&quot;;
            }
        }
        return String.Join(&quot;&quot;, Array.ConvertAll&lt;short, string&gt;(init, Convert.ToString));
    }

    private short GetDigit(int index, short[] arr)
    {
        if (index &lt; 0 || index &gt;= arr.Length)
        {
            return 0;
        }
        else
        {
            return arr[index];
        }
    }
}</pre>

<h3>Task: Power Outage</h3>

<table>
	<tbody>
		<tr>
			<td colspan="2">
			<h3>Problem Statement</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<p>You work for an electric company, and the power goes out in a rather large apartment complex with a lot of irate tenants. You isolate the problem to a network of sewers underneath the complex with a step-up transformer at every junction in the maze of ducts. Before the power can be restored, every transformer must be checked for proper operation and fixed if necessary. To make things worse, the sewer ducts are arranged as a tree with the root of the tree at the entrance to the network of sewers. This means that in order to get from one transformer to the next, there will be a lot of backtracking through the long and claustrophobic ducts because there are no shortcuts between junctions. Furthermore, it&#39;s a Sunday; you only have one available technician on duty to search the sewer network for the bad transformers. Your supervisor wants to know how quickly you can get the power back on; he&#39;s so impatient that he wants the power back on the moment the technician okays the last transformer, without even waiting for the technician to exit the sewers first.</p>

			<p>You will be given three int[]&#39;s: <strong><tt>fromJunction</tt></strong>, <strong><tt>toJunction</tt></strong>, and <strong><tt>ductLength</tt></strong> that represents each sewer duct. Duct i starts at junction (<strong><tt>fromJunction[i]</tt></strong>) and leads to junction (<strong><tt>toJunction[i]</tt></strong>). <strong><tt>ductlength[i]</tt></strong> represents the amount of minutes it takes for the technician to traverse the duct connecting <strong><tt>fromJunction[i]</tt></strong> and <strong><tt>toJunction[i]</tt></strong>. Consider the amount of time it takes for your technician to check/repair the transformer to be instantaneous. Your technician will start at junction 0 which is the root of the sewer system. Your goal is to calculate the minimum number of minutes it will take for your technician to check all of the transformers. You will return an int that represents this minimum number of minutes.</p>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Definition</h3>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>Class:</td>
						<td>PowerOutage</td>
					</tr>
					<tr>
						<td>Method:</td>
						<td>estimateTimeOut</td>
					</tr>
					<tr>
						<td>Parameters:</td>
						<td>int[], int[], int[]</td>
					</tr>
					<tr>
						<td>Returns:</td>
						<td>int</td>
					</tr>
					<tr>
						<td>Method signature:</td>
						<td>int estimateTimeOut(int[] fromJunction, int[] toJunction, int[] ductLength)</td>
					</tr>
					<tr>
						<td colspan="2">(be sure your method is public)</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Constraints</h3>
			</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong><tt>fromJunction</tt></strong> will contain between 1 and 50 elements, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong><tt>toJunction</tt></strong> will contain between 1 and 50 elements, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong><tt>ductLength</tt></strong> will contain between 1 and 50 elements, inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong><tt>toJunction</tt></strong>, <strong><tt>fromJunction</tt></strong>, and <strong><tt>ductLength</tt></strong> must all contain the same number of elements.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Every element of <strong><tt>fromJunction</tt></strong> will be between 0 and 49 inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Every element of <strong><tt>toJunction</tt></strong> will be between 1 and 49 inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td><strong><tt>fromJunction[i]</tt></strong> will be less than <strong><tt>toJunction[i]</tt></strong> for all valid values of i.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Every (<strong><tt>fromJunction[i]</tt></strong>,<strong><tt>toJunction[i]</tt></strong>) pair will be unique for all valid values of i.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>Every element of <strong><tt>ductlength</tt></strong> will be between 1 and 2000000 inclusive.</td>
		</tr>
		<tr>
			<td>-</td>
			<td>The graph represented by the set of edges (<strong><tt>fromJunction[i]</tt></strong>,<strong><tt>toJunction[i]</tt></strong>) will never contain a loop, and all junctions can be reached from junction 0.</td>
		</tr>
		<tr>
			<td colspan="2">
			<h3>Examples</h3>
			</td>
		</tr>
		<tr>
			<td>0)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{0}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{1}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{10}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 10</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">The simplest sewer system possible. Your technician would first check transformer 0, travel to junction 1 and check transformer 1, completing his check. This will take 10 minutes.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>1)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{0,1,0}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{1,2,3}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{10,10,10}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 40</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">Starting at junction 0, if the technician travels to junction 3 first, then backtracks to 0 and travels to junction 1 and then junction 2, all four transformers can be checked in 40 minutes, which is the minimum.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>2)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{0,0,0,1,4}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{1,3,4,2,5}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{10,10,100,10,5}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 165</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">Traveling in the order 0-1-2-1-0-3-0-4-5 results in a time of 165 minutes which is the minimum.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>3)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{0,0,0,1,4,4,6,7,7,7,20}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{1,3,4,2,5,6,7,20,9,10,31}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{10,10,100,10,5,1,1,100,1,1,5}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 281</pre>
						</td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td colspan="2">Visiting junctions in the order 0-3-0-1-2-1-0-4-5-4-6-7-9-7-10-7-8-11 is optimal, which takes (10+10+10+10+10+10+100+5+5+1+1+1+1+1+1+100+5) or 281 minutes.</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td>4)</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td>
			<table>
				<tbody>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<pre>
{0,0,0,0,0}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{1,2,3,4,5}</pre>
									</td>
								</tr>
								<tr>
									<td>
									<pre>
{100,200,300,400,500}</pre>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<pre>
Returns: 2500</pre>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>

<blockquote>
<p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.</p>
</blockquote>

<h3>Solution</h3>

<pre class="brush:csharp;">
using System;

public class PowerOutage
{
    public int estimateTimeOut(int[] fromJunction, int[] toJunction, int[] ductLength)
    {
        int fullTime = 0;
        foreach (int timeSpan in ductLength)
        {
            fullTime += timeSpan * 2;
        }

        return fullTime - this.GetBiggestTimeSpanFrom(0, fromJunction, toJunction, ductLength);
    }

    private int GetBiggestTimeSpanFrom(int start, int[] fromJunction, int[] toJunction, int[] ductLength)
    {
        int duration = 0;

        for (int i = 0; i &lt; toJunction.Length; i++)
        {
            if (fromJunction[i] == start)
            {
                duration = Math.Max(duration, ductLength[i] + this.GetBiggestTimeSpanFrom(toJunction[i], fromJunction, toJunction, ductLength));
            }
        }

        return duration;
    }
}</pre>

<h3>Summary</h3>

<p>As you can see my solutions are written in C#. You probably are wondering <em><strong>why do I always explicitly specify the type of all variables?</strong></em></p>

<p>Well, in the TopCoder arena only .NET 2.0 is supported and with this only an old C# spec as well. So no vars, no LINQ. Unfortunately.</p>

<p>Without too much to say about the first problem, BinaryCode was pretty fun one and PowerOutage was pretty hard (of course for me) to grasp.</p>

<p>BinaryCode gets straight forward once you come up with the 2 formulas (in comments, check the solution).</p>

<p>PowerOutage&nbsp;needs careful examination of the problem statement and really the hard thing about it, is to find out that:</p>

<p>&nbsp; &nbsp; 2 * (the sum of all distances) - (the longest distance)</p>

<p>is actually what you need to calculate. From here the harder task is to calculate the longest path. I have written a very elegant&nbsp;solution to this problem (check the recursive method), but the idea was from a contestant with nickname <a href="http://community.topcoder.com/tc?module=MemberProfile&amp;cr=23103979">KodeFuPanda</a>. If you ever read this - You Rock!</p>

<p>I hope this was interesting and fun for you guys. ÐÐ¾ ÑÐºÐ¾ÑÐ¾! (&quot;see you soon&quot; in Bulgarian)</p>
]]></description>
</item>
<item>
<title>Friends</title>
<link>http://tsenkov.net/2013/01/24/friends</link>
<pubDate>Thu, 24 Jan 2013 00:00:00 +0200</pubDate>
<description><![CDATA[<h3>
	What about them?</h3>
<p>
	They are the ones that get you out of trouble.<br />
	Friends, help each-other, no matter the cost.</p>
<p>
	They are the people to open your eyes, when you are about to do something stupid.<br />
	They are the people to push you, when you are missing an opportunity.</p>
<h3>
	What is a friendship?</h3>
<p>
	I consider friendship to be a strong connection with a person with whom you share big part of your past, present and you are hoping this to continue into the future.</p>
<p>
	As with any other relationship, you need to put much effort and dedication in it. That&#39;s how the bond becomes stronger, that&#39;s how <strong>you write the history which connects you</strong>.</p>
<h3>
	Drinking, joking and laughing is something that you do even with your enemies.</h3>
<p>
	That&#39;s the easy part. Everything is great, life&#39;s good, you enjoy it.<br />
	But when things get ugly, and if something bad happens to your friend,&nbsp;<strong>you have to help</strong>.</p>
<p>
	Helping someone in need, is<strong>&nbsp;the only time you build a true friendship</strong>.</p>
<h3>
	What about friendships built on something positive?</h3>
<p>
	Although I keep answering my own questions, here, ask yourself the following:</p>
<p>
	&nbsp;- Isn&#39;t the single most important relationship in your life, supposed to be with your husband or wife? If so, why do you think, in pretty much any religion out there, the marriage vows always include something similar to the following:</p>
<blockquote>
	<p>
		<em>I ...take you... for my lawful wife/husband, to have and to hold, from this day forward, for better, for worse, for richer, for poorer, in sickness and in health...</em></p>
</blockquote>
<h3>
	Friendship isn&#39;t about equality and it&#39;s all about kindness and gratefulness.</h3>
<p>
	But the true friends are not those that only keep you company &quot;<em>for better, for richer and in health</em>&quot;, true friends are right there with you &quot;<em>&nbsp;for worse, for poorer and in sickness</em>&quot;.</p>
<p>
	My appeal to you is - don&#39;t leave your friends in pain, just because you might get hurt if helping.</p>
]]></description>
</item>
<item>
<title>Icenium Mist</title>
<link>http://tsenkov.net/2012/10/24/icenium-mist</link>
<pubDate>Wed, 24 Oct 2012 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>What is Icenium?</h3>

<p style="text-align:center"><img alt="" src="/images/icenium-logo.png" style="border:none; box-shadow:none; max-width:130px; width:100%" /></p>

<p>For the last 10 months I&#39;ve been working on the <a href="http://icenium.com">Icenium</a> team, here at Telerik.</p>

<p>Icenium is Telerik&#39;s brand new SaaS solution for mobile application development, currently targeting Android and iOS.</p>

<p>There are 2 basic ideas behind Icenium:</p>

<ul>
	<li>Use HTML, JavaScript and CSS to build your mobile apps;</li>
	<li>Build them once, run them everywhere.</li>
</ul>

<h3>Icenium Mist &amp; Graphite</h3>

<p>Icenium provides not 1, but 2 environments in which the developers can build their applications.</p>

<p style="text-align:center"><img alt="" src="/images/mist-and-graphite.png" style="max-width:500px; width:100%" /></p>

<p><strong>Graphite&nbsp;</strong>is a desktop client application for Microsoft Windows. It&#39;s the richest of the two environments (for now :P).</p>

<p><strong>Mist&nbsp;</strong>is the browser-based development environment.</p>

<p>My primary job was to work on the architecture and the development of Mist.&nbsp;That&#39;s why I will try to give you a bit better idea of this aspect of Icenium.</p>

<h3>What can you do in Mist?</h3>

<h4>Create your project</h4>

<p>You can choose from one of our 3 default templates:</p>

<ul>
	<li>Blank;</li>
	<li>jQuery Mobile;</li>
	<li>KendoUI Mobile.</li>
</ul>

<h4>File operations</h4>

<p>You can do all the file operations available in any other dev environment.</p>

<p>You can upload your files.</p>

<p>You can even import projects from archive.</p>

<p>And if you want to, you can export your projects.</p>

<h4>Version Control</h4>

<p>User&#39;s of Mist can use all the local version control operations available - commit, revert, rollback.</p>

<h4>Debug and Inspect in Simulators</h4>

<p>We support simulators for 4 devices:</p>

<ul>
	<li>iPhone;</li>
	<li>iPad;</li>
	<li>Samsung Galaxy SII;</li>
	<li>Android Tablet (as generic resolution factor 1024x600).</li>
</ul>

<p>Our simulators can be zoomed and rotated.</p>

<p>Also you can set mock data for simulating Geo Location.</p>

<p style="text-align:center"><img alt="" src="/images/simulator-mist.png" style="max-width:664px; width:100%" /></p>

<h4>Code Syntax Colorization</h4>

<p>We currently provide colorization for JavaScript, HTML, CSS and XML.&nbsp;</p>

<h4>Code Folding</h4>

<p>We support folding of your code. Our intentions are to take it even further - level folding with optional key shortcuts.</p>

<p style="text-align:center"><img alt="" src="/images/mist-code-folding.png" style="max-width:280px; width:100%" /></p>

<p>Our editor also supports<strong>&nbsp;Auto Tag Closing</strong>,&nbsp;<strong>Highlight Matching Identifiers</strong>,&nbsp;<strong>Tab Indention on Selection</strong>,&nbsp;<strong>Smart Indention</strong>.</p>

<h4>ProjectProperties</h4>

<p>Users can set rich variety of project specific settings:</p>

<ul>
	<li>Device orientations (Landscape and Portrait);</li>
	<li>Application version;</li>
	<li>Permissions;</li>
	<li>Used Plugins;</li>
	<li>etc.</li>
</ul>

<h4>QR Code and Build for App Stores</h4>

<p>From Mist you can build your app and deploy it to any supported device.</p>

<p>We generate QR code so you scan it with a device and get the application on it initially and then you can pull the latest version of your app, by using a simple gesture on the device.</p>

<p>This way we even&nbsp;<strong>add functionality that is now available only in Mist&nbsp;</strong>- the ability to easily share your application during development:</p>

<ul>
	<li>Let&#39;s say you are on an event (conference for example) and you want to show sample on which you currently work on - you load your project in Mist, run build for it and let people scan the QR code from the screen of your device. Cool, isn&#39;t it? :)</li>
</ul>

<p>Here is an example of our QR Code generation:</p>

<p style="text-align:center"><img alt="" src="/images/mist-qrcode.png" style="max-width:500px; width:100%" /></p>

<p>Closing the end-to-end scenario, you can finally upload your provisions and certificates and build for Google Play as well as for iOS App Store.</p>

<p style="text-align:center"><img alt="" src="/images/mist-publish.png" style="max-width:550px; width:100%" /></p>

<h3>Current limitations compared to Graphite</h3>

<h4>Find &amp; Replace</h4>

<p>This is a feature that we will definitelly implement for future releases. It&nbsp;<em>will&nbsp;</em>be possible to execute Find &amp; Replace at least on solution and file levels.</p>

<h4>Code Editor - Syntax and Logical&nbsp;Error Reporting (unused variables etc.), Smart Autocompletion</h4>

<p>The only static analysis we currently make, is for code syntax colorization.</p>

<p>All the missing features are on our backlog and we will eventually implement them in Mist.</p>

<h4>Code Navigation</h4>

<p>We haven&#39;t put too much thougth on this and we&#39;ll probably emphasize on&nbsp;<strong>coding experience</strong>&nbsp;and not so much on tools that&nbsp;<em>work mostly for strongly typed languages</em>.</p>

<h4>Code Refactoring</h4>

<p>For now we are thinking about Identifier Rename&nbsp;(variable rename).</p>

<h4>Remote Version Control Operations</h4>

<p>Not yet implemented in Mist, Graphite already has&nbsp;<strong>clone</strong>&nbsp;and&nbsp;<strong>push</strong>&nbsp;from/to remote repository.</p>

<p>These and even more (<strong>pull&nbsp;</strong>for example) remote operations will be implemented in Mist for our next releases.</p>

<h3>Summary</h3>

<p><strong>Icenium Mist supports the end-to-end scenario:</strong></p>

<ul>
	<li>You can create a new project;</li>
	<li>Implement your application using Mist&#39;s environment;</li>
	<li>Use Version Control along the way;</li>
	<li>Use simulators for testing and debugging;</li>
	<li>Use real devices for testing and debugging;</li>
	<li>Share and Demonstrate easily your app (QR Code);</li>
	<li>Set all your project settings and properties;</li>
	<li>Build for app stores.</li>
</ul>

<p>You can use it wherever you are. Supported are the following browsers:</p>

<ul>
	<li>Chrome;</li>
	<li>Firefox;</li>
	<li>Safari;</li>
	<li>IE9.</li>
</ul>

<p>Plus, we work on <strong>Mobile Chrome for Android</strong> and <strong>Mobile Safari for iOS</strong>.</p>

<p>Work from anywhere on your applications. :)</p>

<p><a href="http://docs.icenium.com/icenium-mobile-app-development/using-icenium-mist/using-icenium-mist">Here</a> you can check Mist&#39;s documentation.</p>
]]></description>
</item>
<item>
<title>Fear</title>
<link>http://tsenkov.net/2012/08/11/fear</link>
<pubDate>Sat, 11 Aug 2012 00:00:00 +0300</pubDate>
<description><![CDATA[<p>
	&nbsp;</p>
<div style="text-align: center; ">
	Screams the air sharpen,</div>
<div style="text-align: center; ">
	I am laying in my room.</div>
<div style="text-align: center; ">
	Others&#39; pain my mind has darkened...</div>
<div style="text-align: center; ">
	Why the light is going down so soon?</div>
<div style="text-align: center; ">
	&nbsp;</div>
<div style="text-align: center; ">
	The door&#39;s lock will soon be snapping,</div>
<div style="text-align: center; ">
	the hinges will start to creak...</div>
<div style="text-align: center; ">
	Wind the curtains will be shaking...</div>
<div style="text-align: center; ">
	The fear takes away the words to speak...</div>
]]></description>
</item>
<item>
<title>The Last Thought</title>
<link>http://tsenkov.net/2012/05/22/the-last-thought</link>
<pubDate>Tue, 22 May 2012 00:00:00 +0300</pubDate>
<description><![CDATA[<p>
	&nbsp;</p>
<div style="text-align: center; ">
	When the ground is shaking</div>
<div style="text-align: center; ">
	beneath your feet.</div>
<div style="text-align: center; ">
	When the sun is far</div>
<div style="text-align: center; ">
	in space so deep.</div>
<div style="text-align: center; ">
	&nbsp;</div>
<div style="text-align: center; ">
	When the stars are lighting</div>
<div style="text-align: center; ">
	your way straight down.</div>
<div style="text-align: center; ">
	When you&#39;re sinking faster</div>
<div style="text-align: center; ">
	than the sound rebounds.</div>
<div style="text-align: center; ">
	&nbsp;</div>
<div style="text-align: center; ">
	Then you have the time</div>
<div style="text-align: center; ">
	for one last thought.</div>
<div style="text-align: center; ">
	No chance for saving,</div>
<div style="text-align: center; ">
	no last resort.</div>
<div style="text-align: center; ">
	&nbsp;</div>
<div style="text-align: center; ">
	But it takes a life</div>
<div style="text-align: center; ">
	to figure out,</div>
<div style="text-align: center; ">
	what that thought would be</div>
<div style="text-align: center; ">
	this final shout.</div>
]]></description>
</item>
<item>
<title>What if I fail?</title>
<link>http://tsenkov.net/2012/04/16/what-if-i-fail</link>
<pubDate>Mon, 16 Apr 2012 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>Do you dream?</h3>

<p>I probably couldn&#39;t&nbsp;count how many dreams I had in my life. At different stages of my personal development I wanted to become a doctor, a lawyer, a programmer, a musician, a scientist, an athlete and so on and so on.</p>

<p>Some of the dreams came true, some didn&#39;t. To be honest the ratio fulfilled-unfulfilled is a lot in favor for those dreams that never came to life.</p>

<h3>But you shouldn&#39;t stop dreaming.</h3>

<p>By the time I write this I am just about to turn 25 years, so I am not the wisest man alive, I am aware of it.</p>

<p>Within the great uncertainty in me, though, there are few things I am deeply, almost unchangeably sure of. One of these things is Dreaming.</p>

<p>If you stop dreaming, than you stop aiming. If you are not aiming, you can&#39;t achieve much. And even if you are the luckiest man/woman, and say, the stars align some day so you turn out rich (materially)&nbsp;enough to be considered successful, you will never feel it as an achievement of yours.</p>

<h3>âWhat&#39;s the point of dreaming about something you are sure will never come true?</h3>

<p>In my humble opinion<strong>&nbsp;there isn&#39;t such a thing</strong>. But then again, I am the kind of guy, that believes&nbsp;<strong>everything is possible</strong>.</p>

<p>I honestly believe in this -&nbsp;<strong>âif&nbsp;you want something bad enough, you get it</strong>.</p>

<h3>Of course, it takes a lot of courage.</h3>

<p>To follow what seems crazy to your surroundings requires bravery. And very often your dream is so past the line of sanity for your friends and family, that they will try to do everything in their power to prevent you from following it.</p>

<p>Don&#39;t blame them for anything, but trying to help you, that&#39;s what they think they are doing.</p>

<p>Instead, you should show them results. The most powerful point of all.</p>

<p>And here comes the hardest question...</p>

<h3>What if I fail?</h3>

<p>You do the same as if you&nbsp;<em>fell&nbsp;</em>-&nbsp;<strong>YOU GET UP</strong>.</p>

<p>There is a technique applicable for many creative problems called &quot;Trial &amp; Error&quot;. Basically, you try different things, learning from your errors along the way.</p>

<p>That&#39;s how you get there. You try, and you fail, and then try again, and then fail again, but (as a&nbsp;<a href="http://gyoshev.net/">friend</a>&nbsp;of mine says) &quot;fail better&quot;.</p>

<h3>âThe biggest failure of all is if you never try.</h3>

<p>That&#39;s right, &quot;regret&quot; is a b****.</p>

<p>Try thinking about your past and the most miserable failure you have experienced, because you dared to try.</p>

<p>Now think about the opportunity you wanted so badly, but you never took.</p>

<p>Well, guess what, &quot;failure&quot; might hit you harder for a day, a month or even a year, but &quot;regret&quot; stays in your mind for the rest of your life.</p>

<h3>&quot;It should never be too late&quot;, but I wouldn&#39;t test this hypothesis...</h3>

<p>A person I respect very much, once said to me:</p>

<blockquote>
<p><em>&quot;If you don&#39;t succeed in your field until you are 27 years old, the chances are - you never will...&quot;</em></p>
</blockquote>

<p>Although I am not in-favor of postponing your dreams and I really&nbsp;admire this guy, I only partially agree with his statement.</p>

<p>In my opinion the following is closer to the truth:</p>

<blockquote>
<p><em>&quot;If you are not at least&nbsp;<strong>âwalking the&nbsp;</strong><strong>way</strong>â&nbsp;<strong>to a life-changing&nbsp;</strong><strong>dream</strong>â until you are settled/married/have a family, the chances are - you never will.&quot;</em></p>
</blockquote>

<p>Following a big dream, such as career in certain profession or the development of your own business, is never easy and requires much dedication and sacrifices. And when person already has many responsibilities, this process becomes incredibly hard.</p>

<h3>Family or Career?</h3>

<p>Perhaps, this is one of the oldest questions that bothered the human mind.</p>

<p>I think the two&nbsp;<strong>can&nbsp;</strong>be combined and I intend to try doing so in my life.</p>

<p>A. Einstein, on the other hand, thought differently:</p>

<blockquote>
<p><em>&quot;One has either time for science or family. But not both.&quot;</em></p>
</blockquote>

<h3>I have a dream...</h3>

<p>Someday, I want to develop a product and create my own Software Company.</p>

<p>There, I&#39;ve said it.</p>

<p>It is a big dream and ambitious one, too.</p>

<p>And maybe I am blind for many of the factors that are to be considered, but&nbsp;<strong>that blindly I believe in my dream and myself&nbsp;</strong>and I am committed to make it real.</p>

<h3>Dream -&gt; Vision -&gt; Ambition -&gt; Hard Work -&gt; Reality.</h3>

<p>These are the stages I see in following a dream.</p>

<p>The statement hidden in this progression is - when you have a dream, create a vision of it in the real world, shape it so it fits or if it doesn&#39;t<strong>&nbsp;shape the world for it</strong>, gain ambition and excitement for your future creation, work hard on it and&nbsp;<strong>results will come</strong>.</p>

<p>I think the hardest of all, is to decide to follow your dream.</p>

<h3>I want to wait for the right time, but will experience ever be enough?</h3>

<p>Would Apple be the same or even existing if Jobs and Wozniak decided to wait for becoming more experienced at what they did?</p>

<p>Would Google be more than a small research project&nbsp;if Larry Page and Sergey Brin had decided to concentrate on their PhD studies?</p>

<p>I don&#39;t know the answer to these questions, but I think they are worth thinking for.</p>

<p>What I am sure of, is: with youth comes naivete&nbsp;and even&nbsp;stupidity, but&nbsp;<strong>courage as well</strong>.</p>

<h3>There is limit for the knowledge which mind can handle, but there is limit for dealing with the unknown, too...</h3>

<p>I don&#39;t seem to recall which great scientist said this to his students:</p>

<blockquote>
<p><em>&quot;My dear students, I&nbsp;</em><em><strong>don&#39;t know&nbsp;</strong>more than you!&quot;</em></p>
</blockquote>

<p>And then he painted the following picture:</p>

<p style="text-align:center"><img alt="Picture showing that the student's knowledge had a shorter border to the unknown." src="/images/border-with-the-unknown.png" style="border-radius:0px; border:none; max-width:250px; width:100%" /></p>

<p style="text-align:left">The circles represent the explored, by a teacher and student, area of all knowledge there is.</p>

<p style="text-align:left">The person who knows more is also more aware of how much&nbsp;he&nbsp;doesn&#39;t know.</p>

<h3 style="text-align:left">Dare to dream, and dare to try.</h3>

<p style="text-align:left">Arguably, in every success, there is at least a little part of luck, but as wiser&nbsp;than me&nbsp;people already said:</p>

<blockquote>
<p style="text-align:left"><em>&quot;Fortune favors the brave!&quot;</em></p>
</blockquote>

<p style="text-align:left">My wish for you, dear readers: be brave and follow your dreams.</p>
]]></description>
</item>
<item>
<title>Audio Interface for Home Recording</title>
<link>http://tsenkov.net/2012/04/01/audio-interface-for-home-recording</link>
<pubDate>Sun, 01 Apr 2012 00:00:00 +0300</pubDate>
<description><![CDATA[<h3>Me: Why this device is better than the other? MusicGearExpert: It simply is...</h3>

<p>I have made a research through the last 3-4 days on Audio Interfaces. And because there is much pain involved in deciding which Audio Interface suits better your needs, I decided to share what were my findings on this topic and if you are searching for a similar thing, hopefully to give your&nbsp;<em>quest</em>&nbsp;a nice kick-start.</p>

<h3>What turned out to be best for me?</h3>

<p>While I started by primarily focusing on the affordable end, I slowly climbed the price-latter and ended up ordering a pretty expensive box -&nbsp;<a href="http://www.rme-audio.de/en_products_babyface.php">RME Babyface</a>.</p>

<p>I haven&#39;t got the device, yet, so there probably will be a follow-up post about it (if not even more than 1) and review on its quality.</p>

<p>I want to save you guys some effort in searching, because there is a good change for the outcome to be either one of:</p>

<ol>
	<li>You will make the same choice and will waste a lot of time;</li>
	<li>You will buy something that will not be as good as RME&nbsp;Babyface... and you will waste a lot of time.</li>
</ol>

<p>Of course, there always is the possibility that you will find something I didn&#39;t. If you do, please, don&#39;t share it with me - I am totally crying, if I gave so much money for nothing. Just kidding - please, feel free to post a comment.</p>

<h3>For what are you going to use this device?</h3>

<p>Before reading through, you should know what I am intending to use this Audio Interface (AI) for - recording:</p>

<ul>
	<li>vocals;</li>
	<li>guitar (amp&amp;mic / DI);</li>
	<li>bass (DI);</li>
	<li>VSTi tracks.</li>
</ul>

<p>What this basically mean is - I need:</p>

<ol>
	<li><strong>microphone preamps&nbsp;integrated</strong>&nbsp;in the AI (<strong>I</strong>&nbsp;<strong>don&#39;t need more than</strong>&nbsp;<strong>two</strong>);</li>
	<li>very good Analog-Digital, Digital-Analog convertors (who doesn&#39;t?);</li>
	<li>expansion capabilities;</li>
	<li>some raw DSP effects (Reverb, Compressor) and EQ integrated in the hardware;</li>
	<li>very low latency.</li>
</ol>

<p>This is the order-by-importance of these factors, as well.</p>

<p>I picked the winner in the first 2 categories (preamps and convertors).</p>

<h3>What is today&#39;s (1st of April, 2012) choice for AI in the 300-600&euro;&nbsp;price-range?</h3>

<p>There are many devices, but I am going to mention only these that&nbsp;<strong>I think&nbsp;</strong>are worthy for such purpose (as stated above). All of them have at least 2 mic preamps and interface with&nbsp;<strong>USB 2.0</strong>.</p>

<p>Starting from the lowest price:</p>

<h3>Propellerhead Balance<img alt="propellerhead's balance audio interface" src="/images/propellerhead-balance.png" style="float:right; margin:25px; max-width:300px; width:100%" /></h3>

<p>This device is designed by software engineers (visually and functionally, but of course not electronically). It looks amazing and I have read and watched whatever I could find about it on the web.</p>

<p>The company that makes it, is responsible for the famous music production software&nbsp;<strong>Reason</strong>.</p>

<p>This of course means that the devices has some integration with it, which might be nice if that&#39;s what you are using.</p>

<p>It comes bundled with&nbsp;<strong>Reason Essentials</strong>&nbsp;software, which &quot;<em>essentially</em>&quot; is a skinnier version of Reason with less instruments and effects.</p>

<p>Very nice feature, but only available if used with Reason Essentials:</p>

<ul>
	<li><strong>ClipSafe&nbsp;</strong>- recording audio track in 2 modes simultaneously -&nbsp;<strong>regular&nbsp;</strong>and&nbsp;<strong>13 dB less</strong>. If your sound clips due to higher input for example, you can get the lowest volume track, where such clip doesn&#39;t exist, with a single click.</li>
</ul>

<p>One big other benefit for owners of older version of Reason (3, 4, 5) is that they get a free upgrade to Reason 6.</p>

<p><strong>Summary:</strong></p>

<ul>
	<li><strong>Price at thomann.de (at the time I am writing this):</strong>&nbsp;349&euro;</li>
	<li>24 bit, 96 kHz</li>
	<li>It comes with Reason Essentials</li>
	<li>The setup is known to be very easy</li>
	<li>Very intuitive interface</li>
	<li>High quality preamps and AD/DA convertors</li>
	<li>No hardware DSP</li>
	<li>No expansion</li>
	<li>You loose ClipSafe if you use it with something different than Reason Essentials</li>
</ul>

<h3>Steinberg UR28M</h3>

<p><img alt="Steinberg UR28M Audio Interface" src="/images/steinberg-ur28m.png" style="float:left; margin:25px; max-width:200px; width:100%" />This device also comes with software -&nbsp;<strong>Cubase AI6</strong>. This is&nbsp;<strong>very nice</strong>&nbsp;since you shouldn&#39;t worry about &quot;<em>yet another purchase</em>&quot; before you start recording your music.</p>

<p>It&#39;s 24 bit, 96 kHz, has Class-A preamps, high-end AD and DA convertors. It&#39;s expandable through a S/PDIF I/O and has more than enough outs (6 analogs).</p>

<p>Looks pretty good on the outside, has a lot of controls and state indicators, making it a bit nicer for people preferring knobs versus software.</p>

<p>It&#39;s relatively small, but&nbsp;<strong>it&#39;s not bus-powered (has an external power supply)</strong>, therefore it&#39;s more of a desktop device which isn&#39;t as easily portable (not a bad thing for my needs).</p>

<p>The best feature it has is the hardware&nbsp;<strong>DSP with REV-X reverb</strong>&nbsp;and integration with some VST plugins which are executed within the box with&nbsp;<strong>near-zero latency&nbsp;</strong>monitoring. As much as I understood of the scattered information on the web, this type of monitoring works only for the specified effects.</p>

<p>With the&nbsp;<strong>dspMixFx technology</strong>&nbsp;integrated (I think it&#39;s both a software console and hardware) one has the flexibility of creating many different mixes, with option for example to apply DSP effects only for monitoring, only for recording or both.</p>

<p>There is a lot of superstition going on around Steinberg hardware, since it pretty much is Yamaha hardware. I have researched this device for quite some time, written in some forums and not a single guy, could say whether or not the preamps or the convertors are any worse than RME Babyface. It&#39;s like, because Steinberg is Yamaha, no one wants to risk and try the device. The only thing that I found as a comparison with such a high-end device were few words on a blog, in which the&nbsp;<strong>author compared it with Apogee Duet</strong>:&nbsp;<a href="http://www.gearjunkies.com/news_info.php?news_id=7038">http://www.gearjunkies.com/news_info.php?news_id=7038</a></p>

<p>According to few people the device isn&#39;t exactly shining as setup and very intuitive interface (I haven&#39;t tried it, so I can&#39;t be 100% sure).</p>

<p><strong>Summary:</strong></p>

<ul>
	<li><strong>Price at thomann.de (at the time I am writing this):</strong>&nbsp;385&euro;</li>
	<li>24 bit, 96 kHz</li>
	<li>Comes with Cubase AI6</li>
	<li>High quality preamps and AD/DA convertors</li>
	<li>Hardware DSP and near-zero latency on integrated effects (and some supported VST plugins)</li>
	<li>S/PDIF I/O port</li>
	<li>dspMixFx technology for advanced mix routing</li>
	<li>Not very portable - pretty heavy and requires external power supply</li>
</ul>

<h3>MOTU UltraLite<img alt="MOTU UltraLite Audio Interface" src="/images/motu-ultralite.png" style="float:right; margin:25px; max-width:280px; width:100%" /></h3>

<p>...and we are going higher! Not only as price, but as quality, too.</p>

<p>MOTU UltraLite is exactly what I imagined as my dream Audio Interface - both as look and features.</p>

<p>To uneducated eye (like my own for example) it looks a bit like&nbsp;<strong>old car radio</strong>, where you need a degree in Electronics in order to check the news on channel 2. Yes, that&#39;s how I like it.</p>

<p>It&#39;s beautiful - with all the knobs and labels around, and the big display, with so many Ins and Outs - it&#39;s absolutely fabulous!</p>

<p>It&#39;s the first device we are looking in, that is 24 bit&nbsp;<strong>192 kHz</strong>. Has 6 balanced inputs, separately from them 2 Class-A microphone preamps, high quality AD/DA convertors,&nbsp;<strong>10 outputs</strong>, hardware DSP with Reverb,&nbsp;<strong>Compressor&nbsp;</strong>and EQ, S/PDIF I/O and supports both FireWire and USB 2.0.</p>

<p>As the UR28M it comes with software for advanced mix routing through the even bigger amount of outs it offers - CueMix FX.</p>

<p>One big feature is - this device is also a standalone mixer. You can use it on a live gig.</p>

<p>The powerful (and complete) DSP, the big amount of outputs, the mix flexibility, and the fact it works as standalone, makes it a pretty great device.</p>

<p>On the downside - the software it comes with, works only on Mac.</p>

<p><strong>Summary:</strong></p>

<ul>
	<li><strong>Price at thomann.de (at the time I am writing this):</strong>&nbsp;433&euro;</li>
	<li>24 bit,&nbsp;<strong>192</strong>&nbsp;kHz</li>
	<li>High quality preamps and AD/DA convertors</li>
	<li>Hardware DSP with Reverb, Compressor and EQ (every vocalist&#39;s dream-set)</li>
	<li><strong>10 Outs, 8 Ins</strong></li>
	<li>S/PDIF I/O port</li>
	<li>CueMix FX for advanced mix routing</li>
	<li>Supports both FireWire and USB</li>
	<li>Works as standalone mixer</li>
	<li>Bus-powered with optional PSW</li>
	<li>Not too advanced software which is supported only on Mac</li>
</ul>

<h3>And finally The Winner - RME Babyface</h3>

<p><img alt="RME Babyface Audio Interface." src="/images/rme-babyface.png" style="float:left; margin:25px; max-width:300px; width:100%" />I found out about this AI about 5 minutes after I started searching. And until I closed that research, I did my best to go any other direction with similar quality and less of a price, but I couldn&#39;t...</p>

<p>It&#39;s like the whole world is in-loved in this little device and there was review upon review giving it 11 on a scale to 10 as a sound quality, so I gave up.</p>

<p>Like the MOTU, it&#39;s 24 bit, 192 kHz AI. It has a total of 22 channels.&nbsp;</p>

<p>What makes it different from all the others (except the minimalistic look) is this passage of text that I found periphrased in many different articles and forum threads:</p>

<blockquote>
<p><em>RME Babyface features the&nbsp;<strong>latest 192 kHz AD- and DA-converters</strong>, including two reference class microphone preamps.</em></p>

<p><em>The Babyface delivers two high end analog recording channels and four analog playback channels, plus ADAT and MIDI I/O. It combines excellent analog circuit design with AD/DA converter chips of the latest generation. RME&rsquo;s efficient SteadyClock jitter suppression technology ensures an AD- and DA-conversion of the&nbsp;highest reference quality.</em></p>

<p><em>...</em></p>

<p><em>The extremely low THD+N values let&nbsp;<strong>these preamps surpass those of other devices that cost several times the price of the Babyface</strong>.</em></p>
</blockquote>

<p><em>(Quote is from here:&nbsp;<a href="http://www.gearjunkies.com/news_info.php?news_id=6979">http://www.gearjunkies.com/news_info.php?news_id=6979</a>)</em></p>

<p>Apparently RME placed their current best AD and DA convertors on the Babyface.&nbsp;<strong>This is why I bought this unit.</strong></p>

<p>There are a couple of truly great features that are not available on any of the other devices.</p>

<p>Number one such feature for me is the OS-specific firmware - the device runs a different firmaware when an OS (Windows or Mac) is detected, so the performance is ... well &quot;<em>optimized</em>&quot; seems inappropriate to say here - &quot;maximized&quot;. No matter how far did this approach took them, it truly shows a lot -&nbsp;<strong>they do the best they can to make a brilliant device</strong>.</p>

<p>Another thing that&#39;s worth to mention is the&nbsp;<strong>absolutely positive feedback on RME&#39;s support</strong>. There is like no one who said something against these guys on the forums. Everywhere I read, people are totally impressed with RME&#39;s customer service.</p>

<p>Finally, I found no evidence of issues with drivers in any setup of supported Windows and Mac versions.</p>

<p><strong>Summary:</strong></p>

<ul>
	<li><strong>Price at thomann.de (at the time I am writing this):</strong>&nbsp;539&euro;</li>
	<li>24 bit, 192 kHz</li>
	<li><strong>Highest quality preamps and AD/DA convertors in the &lt;1000&euro; price-range</strong></li>
	<li>Hardware DSP with Reverb, Echo and EQ</li>
	<li>22 channels (10 Ins - 12 Outs)</li>
	<li>ADAT I/O capable of 192 kHz (usable as optical S/PDIF I/O port, as well)</li>
	<li>OS-optimized Firmware (detecting when Windows or Mac - 2 separate firmwares included)</li>
	<li>Bus-powered with optional PSW</li>
	<li>TotalMix FX for advanced routing</li>
	<li>Separate Headphones DA convertor with full 192 kHz sound</li>
	<li>Not having Compressor in the DSP is something that I miss here</li>
</ul>

<h3>I hope this will help you</h3>

<p>I am sure I missed a lot of features there or even got something wrong, but if you decide to use this subset of devices to choose from, then:</p>

<ul>
	<li>pick the winner;</li>
	<li>validate my assumptions;</li>
	<li>check for negative feedback on the web;</li>
	<li>and if all checks out - that&#39;s it.</li>
</ul>

<p>I hope my research will be helpful for you.</p>

<p>I wish you much inspiration and music!</p>
]]></description>
</item>
<item>
<title>When worlds collide</title>
<link>http://tsenkov.net/2012/03/28/when-worlds-collide</link>
<pubDate>Wed, 28 Mar 2012 00:00:00 +0300</pubDate>
<description><![CDATA[<h3 style="text-align: center; ">
	When worlds collide</h3>
<div style="text-align: center; ">
	You live your life&nbsp;and make decisions,</div>
<div style="text-align: center; ">
	based on your mind,&nbsp;what it believes in.</div>
<div style="text-align: center; ">
	You have a problem -&nbsp;then you need solution.</div>
<div style="text-align: center; ">
	That&#39;s when you turn&nbsp;to next dimension.</div>
<div style="text-align: center; ">
	&nbsp;</div>
<div style="text-align: center; ">
	To know the world,&nbsp;you make a copy.</div>
<div style="text-align: center; ">
	And in your mind&nbsp;you walk right through it.</div>
<div style="text-align: center; ">
	Solution comes,&nbsp;some times it doesn&#39;t...</div>
<div style="text-align: center; ">
	The &quot;copy&quot; changes, sometimes it mustn&#39;t...</div>
<div style="text-align: center; ">
	&nbsp;</div>
<div style="text-align: center; ">
	The gap then grows,&nbsp;between the two.</div>
<div style="text-align: center; ">
	The difference shows&nbsp;like red and blue.</div>
<div style="text-align: center; ">
	And soon, one day&nbsp;it comes to end.</div>
<div style="text-align: center; ">
	Which world wins -&nbsp;you will determine.</div>
<div style="text-align: center; ">
	&nbsp;</div>
<div style="text-align: center; ">
	And if you&#39;ve seen&nbsp;a &quot;copy&quot; winning,</div>
<div style="text-align: center; ">
	then you would know&nbsp;these words true meaning:</div>
<div style="text-align: center; ">
	&quot;When worlds collide&nbsp;in one another,</div>
<div style="text-align: center; ">
	the most believed&nbsp;will beat the other!&quot;</div>
]]></description>
</item>
<item>
<title>New ruby for my dynamic collection</title>
<link>http://tsenkov.net/2012/03/18/new-ruby-for-my-dynamic-collection</link>
<pubDate>Sun, 18 Mar 2012 00:00:00 +0200</pubDate>
<description><![CDATA[<p>
	<em>Note: I have written this post, like 3 weeks ago, but never had the time to actually finish it. Today, I am staying sick at home and while I definitely don&#39;t feel in shape for doing work on any of my projects, I JUST CAN&#39;T GET AWAY FROM MY PC. I hope you will enjoy it. Here it goes...</em></p>
<p>
	<strong><span style="white-space: nowrap; ">At the beginning...</span></strong></p>
<p>
	I started my journey as a programmer on static language as many other programmers did. The first language that I learned was Visual Basic 6.0 (in my high school years). I then continued my exploration with C, C++, Java and C#. Around my 3rd year at the university (studying Informatics), I had school web projects to make. This was the first time I was exposed to a dynamic language (PHP to be more specific).</p>
<p>
	<strong>&quot;Exposed&quot;, sounds like I took a radiation hit.</strong></p>
<p>
	Well, to be honest, by the time it pretty much seemed so. Getting used to the comfort of knowing so much about your code at compile time, has totally blinded me about the power of dynamic languages. It seemed so...&quot;wrong&quot; is the first word that comes to mind.</p>
<p>
	So, how did I started using DLs - long story short - I started developing for the web. I discovered JavaScript and the expressiveness it carries blew me away. So, dear reader, if you haven&#39;t tried any DL, yet -&nbsp;<a href="https://developer.mozilla.org/en/JavaScript/Guide">https://developer.mozilla.org/en/JavaScript/Guide</a>&nbsp;Check this out!</p>
<p>
	<strong>Let us finally proceed on-topicâ!</strong></p>
<p>
	So, I decided to look at some unexplored by me DL.</p>
<h4>
	My choice was <strong>Ruby</strong>.</h4>
<p>
	Dynamic, reflective, programming language, designed by the Japanese computer scientist Yukihiro &quot;Matz&quot; Matsumoto.</p>
<p>
	Looking for tutorials I found this one:</p>
<p>
	<a href="http://tryruby.org/">http://tryruby.org</a>.</p>
<p>
	This tutorial is amazing. It took about <em>30-40 minutes</em>&nbsp;to finish&nbsp;(including the time I spent toying around with the exercises) and it&#39;s worth every second. I strongly recommend it if you want to get a feel of the language and the basic features it has.</p>
<p>
	I think, what makes this tutorial great, is the way they create <strong>interactivity </strong>- on the page you have a <strong>Ruby console</strong>, in which you can freely type-in and test the assignments, the examples and whatever language feature you want to try. I think I learned more for Ruby by playing outside the scope of the samples than actually doing the exercises (I guess this was part of the intention).</p>
<h4>
	âWhat made a real good impression about Ruby</h4>
<p>
	While I haven&#39;t gone deep in the language, nor any of the frameworks (rails), I spotted some pretty neat features.</p>
<p>
	The first thing that made impression to me, is the <strong>&quot;everything-is-an-object&quot;</strong> concept.</p>
<pre class="brush:ruby;">
# Everything, including a literal, is an object, so this works:
-199.abs                                         # 199
&quot;ice is nice&quot;.length                             # 11
&quot;ruby is cool.&quot;.index(&quot;u&quot;)                       # 1
&quot;Nice Day Isn&#39;t It?&quot;.downcase.split(&quot;&quot;).uniq.sort.join  # &quot; &#39;?acdeinsty&quot;</pre>
<p>
	In JavaScript, there is almost the same notion. But you can&#39;t directly invoke methods on Number scalar type for example.</p>
<p>
	A feature that I haven&#39;t seen previously -<strong> method (function) returning more than one result</strong>. Here is an example of creating a getter and setter to a variable:</p>
<pre class="brush:ruby;">
def create_set_and_get(initial_value=0) 
  closure_value = initial_value
  return Proc.new {|x| closure_value = x}, Proc.new { closure_value }
end

setter, getter = create_set_and_get  # ie. returns two values</pre>
<p>
	This masks a little bit, one other feature, which will be more obvious in the next example:</p>
<pre class="brush:ruby;">
def initialize(name, age)
    @name, @age = name, age
end</pre>
<p>
	<strong>Multiple assignment</strong>. It makes so much sense, yet, non of the languages I used implements it.</p>
<p>
	One example at&nbsp;<a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)">http://en.wikipedia.org/wiki/Ruby_(programming_language)</a>&nbsp;struck me the most - see how methods are created as extensions for the base type String:</p>
<pre class="brush:ruby;">
COLORS = { :black   =&gt; &quot;000&quot;,
           :red     =&gt; &quot;f00&quot;,
           :green   =&gt; &quot;0f0&quot;,
           :yellow  =&gt; &quot;ff0&quot;,
           :blue    =&gt; &quot;00f&quot;,
           :magenta =&gt; &quot;f0f&quot;,
           :cyan    =&gt; &quot;0ff&quot;,
           :white   =&gt; &quot;fff&quot; }
 
class String
  COLORS.each do |color,code|
    define_method &quot;in_#{color}&quot; do
      &quot;&lt;span style=\&quot;color: ##{code}\&quot;&gt;#{self}&lt;/span&gt;&quot;
    end
  end
end

&quot;Hello, World!&quot;.in_blue
# =&gt; &quot;&lt;span style=\&quot;color: #00f\&quot;&gt;Hello, World!&lt;/span&gt;&quot;</pre>
<p>
	In the class String (extending the base type String) we are iterating through an associative array (hash in Ruby&#39;s terminology) and creating methods from every couple provided.</p>
<p>
	That&#39;s what I am talking about when I say that <strong>dynamic languages are expressive</strong>.</p>
<p>
	<strong>What made a bad impression</strong></p>
<p>
	If I didn&#39;t liked something I learned about Ruby - it&#39;s the method/function parameters listing. It can be done with or without parentheses, i.e.:</p>
<pre class="brush:ruby;">
def initialize(name, age)
    @name, @age = name, age
end</pre>
<p>
	or</p>
<pre class="brush:ruby;">
def initialize name, age
    @name, @age = name, age
end</pre>
<p>
	Same goes for calling method/function.&nbsp;It looks confusing to me.</p>
<p>
	But then again - I am just a tourist not a local. :)</p>
<p>
	<strong>Summary</strong></p>
<p>
	I think it definitely worth checking Ruby out. Many unique concepts and very expressive code.</p>
]]></description>
</item>
<item>
<title>Hello, World!</title>
<link>http://tsenkov.net/2012/02/11/hello-world</link>
<pubDate>Sat, 11 Feb 2012 00:00:00 +0200</pubDate>
<description><![CDATA[<p>Hello, World!<img alt="Nikolay Tsenkov - profile picture." src="/images/Me-ProfilePicture.png" style="float:right; margin:10px 25px; max-width:175px; width:100%" /></p>

<div>
<p>This is my first blog post.</p>

<p>My name is Nikolay Tsenkov and I have to say - I wanted to start blogging for quite some time now.</p>

<p>Few things about me:</p>

<ul style="list-style-type:square">
	<li>I am a software developer, currently employed by Telerik Corp;</li>
	<li>I enjoy any hobby involving Computer Science;</li>
	<li>Recently, I got interested in embedded systems and electronics (just bought an Arduino and made a small lamp blinking, yey!):</li>
</ul>

<p style="text-align:center"><img alt="my electrocin HelloWorld" src="/images/Arduino-HelloWorld.png" style="margin-left:5px; margin-right:5px; max-width:599px; width:100%" /></p>

<ul style="list-style-type:square">
	<li>I love singing, playing guitar and piano (here is me, screaming at my first concert with The Telerockers - a band I made with some colleagues from work):</li>
</ul>

<p style="text-align:center"><img alt="Singing at my first and only concert with The Telerockers" src="/images/SingingTelerockersFirstConcert.png" style="margin-left:5px; margin-right:5px; max-width:350px; width:100%" /></p>

<ul style="list-style-type:square">
	<li>I have a beautiful, beautiful girlfriend whom I love very much:</li>
</ul>

<p style="text-align:center"><img alt="My girlfriend." src="/images/Sandanski-MyGirlfriend.png" style="margin-bottom:5px; margin-top:5px; max-width:350px; width:100%" /></p>

<ul style="list-style-type:square">
	<li>And last, but not least, I have a great family which I&#39;m very proud of (FLTR - my brother, mother and father and me at the far right):</li>
</ul>

<p style="text-align:center"><img alt="My Family." src="/images/Family.png" style="max-width:450px; width:100%" /></p>

<p>In a nutshell, that&#39;s pretty much all about me.</p>

<p>Finally, I want to share what I intend to use this blog for. I will blog mainly about &quot;Life&quot;, &quot;Programming&quot;, &quot;Music&quot;, &quot;Science&quot; and &quot;Poetry&quot;. For now, these are my intentions.</p>

<p>I hope you will find my thoughts on these topics interesting and I can&#39;t wait to see the first responses.</p>

<p>&nbsp;</p>
</div>

<p>Regards,</p>

<p>Nikolay Tsenkov</p>
]]></description>
</item>
</channel>
</rss>