<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nordschleife</title>
	<atom:link href="http://nordschleife.metaforix.net/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://nordschleife.metaforix.net/blog</link>
	<description>While(1) { read_on() }</description>
	<lastBuildDate>Fri, 27 Jan 2012 20:07:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Facebook Hacker Cup &#8211; Auction</title>
		<link>http://nordschleife.metaforix.net/blog/?p=377</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=377#comments</comments>
		<pubDate>Fri, 27 Jan 2012 20:07:21 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=377</guid>
		<description><![CDATA[import java.util.*; public class Auction { static int m, k; static int earliest; static long n; static long lcm; static int[] firstMod, min, max, minMap, maxMap; public static class Tree { private class Entry { // if min or max is 0, then the subtree is empty int value; int min; int max; boolean exists; [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<div class="CodeRay">
<div class="code">
<pre></pre>
</div></div>
<p>import java.util.*; public class Auction {</p>
<div class="CodeRay">
<div class="code">
<pre>static int m, k; static int earliest; static long n; static long lcm; static int[] firstMod, min, max, minMap, maxMap; public static class Tree { private class Entry { // if min or max is 0, then the subtree is empty int value; int min; int max; boolean exists; public Entry(int value) { this.value = value; } public String toString() { return value+&quot;|m&quot;+min+&quot;|M&quot;+max+&quot;|&quot;+(exists?&quot;T&quot;:&quot;F&quot;); } } Entry[] tree; int size; boolean[] exist; public Tree(int max) { tree = new Entry[2 * max + 2]; exist = new boolean[max + 1]; size = 0; Entry emptyTree = new Entry(0); // dummy entry, used as empty subtree genTree(1, max, 1); for (int i = 0; i &lt; tree.length; i++) { if (tree[i] == null) tree[i] = emptyTree; } } private void genTree(int L, int R, int at) { if (L &gt; R) return; int M = (L + R) / 2; tree[at] = new Entry(M); genTree(L, M - 1, at * 2); genTree(M + 1, R, at * 2 + 1); } public void clear() { size = 0; clear(1); } public void clear(int at) { if (at &gt;= tree.length || tree[at].min == 0) return; tree[at].min = 0; tree[at].max = 0; tree[at].exists = false; exist[tree[at].value] = false; clear(at * 2); clear(at * 2  + 1); } public boolean isEmpty() { return size == 0; } public int first() { return tree[1].min; } public int last() { return tree[1].max; }  public void add(int n) { int at = 1; exist[n] = true; while (true) { if (n &lt; tree[at].value) at *= 2; else if (n &gt; tree[at].value) at = 2 * at + 1; else { if (!tree[at].exists) size++; tree[at].exists = true; break; } } updateMinMax(at); } public void remove(int n) { int at = 1; exist[n] = false; while (true) { if (n &lt; tree[at].value) at *= 2; else if (n &gt; tree[at].value) at = 2 * at + 1; else { if (tree[at].exists) size--; tree[at].exists = false; break; } } updateMinMax(at); } public boolean contains(int n) { return exist[n]; } private void updateMinMax(int at) { while (at &gt;= 1) { Entry L = tree[0], R = tree[0], M = tree[at]; if (at * 2 &lt; tree.length) L = tree[at * 2]; if (at * 2 + 1 &lt; tree.length) R = tree[at * 2 + 1];   if (L.min != 0) M.min = L.min; else if (M.exists) M.min = M.value; else M.min = R.min;  if (R.max != 0) M.max = R.max; else if (M.exists) M.max = M.value; else M.max = L.max;  at /= 2; } } } public static class Sequence { int[] leading, repeat, first; long l, r, mod; public int get(int i) { if (i &lt; l) return leading[(int) i]; i -= l; return repeat[(int) (i % r)]; } public String toString() { return Arrays.toString(leading)+&quot;(&quot;+Arrays.toString(repeat)+&quot;)&quot;; } public Sequence(int p1, long a, long b, long m) { mod = m; first = new int[(int) mod + 1];  int P = p1; List list = new ArrayList(); boolean[] seen = new boolean[(int) (m+1)]; for (int i = 1; i &lt;= n; i++) { if (seen[P]) { int start = list.indexOf(P); leading = new int[start]; repeat = new int[list.size() - start]; for (int j = 0; j &lt; start; j++) leading[j] = list.get(j); for (int j = start; j &lt; list.size(); j++) { repeat[j - start] = list.get(j); first[list.get(j)] = j + 1; } break; } else { list.add(P); } seen[P] = true; P = (int) (((a * P + b) % m) + 1); if (i == n) { leading = new int[(int) n]; repeat = new int[0]; for (int j = 0; j &lt; n; j++) { leading[j] = list.get(j); } } } l = leading.length; r = repeat.length; } }  public static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a%b); } public static long ceil(long a, long b) { // assumes a &gt;= 0 return (a+b-1)/b; } public static long floor(long a, long b) { if (a &lt; 0) return -ceil(-a, b); return a/b; } public static long timesSeen(int p, int w) { if (P.first[p] == 0 || W.first[w] == 0) return 1; int mod = (int) ((((W.first[w] - P.first[p]) % W.r) + W.r) % W.r); long firstSeen = P.r * firstMod[mod] + P.first[p]; long k = Math.min(floor(firstSeen - P.first[p], lcm), floor(firstSeen - W.first[w], lcm)); firstSeen -= k * lcm; return (n - firstSeen) / lcm + 1; } public static void generateMinMax() { boolean[] seen = new boolean[(int)W.r]; int[] seenWhen = new int[k+1]; minMap = new int[(int) P.r]; maxMap = new int[(int) P.r]; earliest = 1000000000; for (int i = 0; i &lt; W.r; i++) { long first = 0; if (P.l + 1 - (W.l + i + 1) &gt; 0) first = ceil(P.l + 1 - (W.l + i + 1), W.r); // get the first time we see it after the leading P terms seenWhen[i] = (int)(W.r * first + W.l + i + 1); earliest = Math.min(earliest, seenWhen[i]); }  if (P.r == 0) return; Tree window = new Tree((int)(W.mod)); for (int start = 0; start &lt; W.r; start++) { long endW = start, L = 0, R = 0; int smallest = earliest; if (seen[start]) continue; window.clear(); int atW = start; //while (smallest &lt;= Math.max(P.l + P.r, W.l + W.r)) { // nope. while (smallest - earliest &lt; P.r) { // nope. seen[atW] = true; int startElement = W.repeat[atW]; long last = seenWhen[atW] + (window.size - 1) * P.r; while (last + P.r &lt;= n) { if (L &gt; R) { R = L; endW = atW; } int next = W.repeat[(int) endW]; if (window.contains(next)) break; window.add(next); last += P.r; endW += P.r; endW %= W.r; R++; } int when = seenWhen[atW]; if (!window.isEmpty() &amp;&amp; when - earliest &lt; P.r) { minMap[when - earliest] = window.first(); maxMap[when - earliest] = window.last(); } window.remove(startElement); seenWhen[atW] += W.r; atW += P.r; atW %= W.r; L++; if (atW == start) { // we've looped, HOPE THIS WORKS RIGHT smallest += W.r; } } }  firstMod = new int[(int)W.r]; for (int i = 0; i &lt; W.r / gcd(P.r, W.r); i++) { firstMod[(int) (P.r * i % W.r)] = i; } } public static Sequence P, W; public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int ca = 1; ca &lt;= t; ca++) { n = in.nextLong(); int p1 = in.nextInt(), w1 = in.nextInt(); m = in.nextInt(); k = in.nextInt(); int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt();  P = new Sequence(p1, a, b, m); W = new Sequence(w1, c, d, k);  generateMinMax();  lcm = 0; if (W.r &gt; 0 &amp;&amp; P.r &gt; 0) lcm = (W.r / gcd(W.r, P.r) * P.r);  min = new int[m+1]; max = new int[m+1]; for (int i = 0; i &lt;= m; i++) min[i] = k+1; // lower bound: 0, upper bound: k+1  for (int i = 0; i &lt; P.l; i++) { min[P.get(i)] = W.get(i); max[P.get(i)] = W.get(i); } for (int i = (int)P.l; i &lt; P.l + P.r; i++) { int j = i; while (j &lt; W.l) { min[P.get(i)] = Math.min(min[P.get(i)], W.get(j)); max[P.get(i)] = Math.max(max[P.get(i)], W.get(j)); j += P.r; } if (j &lt; n) { int id = j + 1 - earliest; if (minMap[id] &gt; 0) min[P.get(i)] = Math.min(min[P.get(i)], minMap[id]); if (maxMap[id] &gt; 0) max[P.get(i)] = Math.max(max[P.get(i)], maxMap[id]); } }  long terrible = 0; int maxMaxs = 0; for (int i = m; i &gt;= 1; i--) { if (max[i] &gt; maxMaxs) {</pre>
</div></div>
<p>//                  System.out.println(&ldquo;Terrible: &rdquo;+i+&ldquo;,&rdquo;+max[i]+&ldquo; ct=&rdquo;+timesSeen(i,max[i]));</p>
<div class="CodeRay">
<div class="code">
<pre>terrible += timesSeen(i, max[i]); maxMaxs = max[i]; } } long bargains = 0; int minMins = k+1; for (int i = 1; i &lt;= m; i++) { if (min[i] &lt; minMins) { bargains += timesSeen(i, min[i]); minMins = min[i]; } }  System.out.printf(&quot;Case #%d: %d %d%n&quot;, ca, terrible, bargains); } }</pre>
</div></div>
<p>}</p>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/facebook-hacker-cup-auction">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Auction" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Auction" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Auction" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Auction" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Auction', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Auction" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D377&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Auction" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=377</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Hacker Cup &#8211; Alphabet Soup</title>
		<link>http://nordschleife.metaforix.net/blog/?p=376</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=376#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:57:39 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=376</guid>
		<description><![CDATA[Problem statement: Alfredo Spaghetti really likes soup, especially when it containsalphabet pasta. Every day he constructs a sentence from letters,places the letters into a bowl of broth and enjoys delicious alphabetsoup. Today, after constructing the sentence, Alfredo remembered that theFacebook Hacker Cup starts today! Thus, he decided to construct thephrase &#8220;HACKERCUP&#8221;. As he already added [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<div class="h7  " style="">
<div class="Bk" style="margin-bottom: 0px; border-top-style: solid; border-top-color: #efefef; border-right-color: initial; border-left-color: initial; border-bottom-color: initial; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; float: none !important; border-width: 0px;">
<div class="G3 G2" style="padding-top: 0px; background-color: transparent; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-color: initial; border-bottom-color: #d8d8d8; border-left-color: initial; border-top-width: 1px; border-top-style: solid; border-top-color: #d8d8d8; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;">
<div>
<div>
<div class="adn ads" style="padding-bottom: 20px; border-left-width: 1px; border-left-style: solid; border-left-color: transparent; padding-left: 8px;">
<div class="gs" style="margin-left: 44px;">
<div class="ii gt adP adO" style="font-size: 13px; margin-top: 5px; margin-right: 15px; margin-bottom: 0px; margin-left: 0px; padding-bottom: 5px;">
<div>Problem statement:
<p />Alfredo Spaghetti really likes soup, especially when it contains<br />alphabet pasta. Every day he constructs a sentence from letters,<br />places the letters into a bowl of broth and enjoys delicious alphabet<br />soup.
<p />Today, after constructing the sentence, Alfredo remembered that the<br />Facebook Hacker Cup starts today! Thus, he decided to construct the<br />phrase &#8220;HACKERCUP&#8221;. As he already added the letters to the broth, he<br />is stuck with the letters he originally selected. Help Alfredo<br />determine how many times he can place the word &#8220;HACKERCUP&#8221;<br />side-by-side using the letters in his soup.
<p />Input<br />The first line of the input file contains a single integer T: the<br />number of test cases. T lines follow, each representing a single test<br />case with a sequence of upper-case letters and spaces: the original<br />sentence Alfredo constructed.
<p />Output<br />Output T lines, one for each test case. For each case, output &#8220;Case<br />#t: n&#8221;, where t is the test case number (starting from 1) and n is the<br />number of times the word &#8220;HACKERCUP&#8221; can be placed side-by-side using<br />the letters from the sentence.
<p />Constraints<br />1 &lt; T &le; 20<br />Sentences contain only the upper-case letters A-Z and the space character<br />Each sentence contains at least one letter, and contains at most 1000<br />characters, including spaces<br />Example input<br />5<br />WELCOME TO FACEBOOK HACKERCUP<br />CUP WITH LABEL HACKERCUP BELONGS TO HACKER<br />QUICK CUTE BROWN FOX JUMPS OVER THE LAZY DOG<br />MOVE FAST BE BOLD<br />HACK THE HACKERCUP
<p />Example output<br />Case #1: 1<br />Case #2: 2<br />Case #3: 1<br />Case #4: 0<br />Case #5: 1
<p />Solution:
<p />Very easy problem, just iterate through the sentence, and find least<br />occurrence in the alphabets contained in &#8220;HACKERCUP&#8221; (notice there are<br />2 Cs).
<p />import java.io.File;<br />import java.io.FileNotFoundException;<br />import java.util.Scanner;
<p />public class Alphabet {<br />&nbsp; &nbsp; &nbsp; &nbsp;public static void main(String[] args) throws FileNotFoundException {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Scanner sc = new Scanner (new File(args[0]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int t = sc.nextInt();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sc.nextLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int i=1; i&lt;= t; i++) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String s = sc.nextLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char[] ch = s.toCharArray();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int[] al = new int[7];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int c = 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int i1=0; i1&lt;ch.length; i1++) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;switch (ch[i1]) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;H&#8217;: al[0]++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;A&#8217;: al[1]++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;C&#8217;: c++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;K&#8217;: al[2]++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;E&#8217;: al[3]++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;R&#8217;: al[4]++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;U&#8217;: al[5]++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case &#8216;P&#8217;: al[6]++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;default: break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int min = c/2;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int j=0; j&lt;al.length; j++) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (al[j]&lt;min)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;min = al[j];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&#8220;Case #&#8221;+i+&#8221;: &#8220;+min);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp;}
<p />}</div>
</p></div>
</p></div>
</p></div>
</p></div>
</p></div>
</p></div>
</p></div>
</p></div>
<p>&nbsp;</p>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/facebook-hacker-cup-alphabet-soup">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Alphabet+Soup" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Alphabet+Soup" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Alphabet+Soup" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Alphabet+Soup" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Alphabet+Soup', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Alphabet+Soup" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D376&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Alphabet+Soup" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=376</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Hacker Cup &#8211; Billboard</title>
		<link>http://nordschleife.metaforix.net/blog/?p=372</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=372#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:44:42 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=372</guid>
		<description><![CDATA[Problem statement: We are starting preparations for Hacker Cup 2013 really early. Our first step is to prepare billboards to advertise the contest. We have text for hundreds of billboards, but we need your help to design them. The billboards are of different sizes, but are all rectangular. The billboard widths and heights are all [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>Problem statement:
<p /> We are starting preparations for Hacker Cup 2013 really early. Our <br />first step is to prepare billboards to advertise the contest. We have <br />text for hundreds of billboards, but we need your help to design them.
<p /> The billboards are of different sizes, but are all rectangular. The <br />billboard widths and heights are all integers. We will supply you with <br />the size in inches and the text we want printed. We want you to tell <br />us how large we can print the text, such that it fits on the billboard <br />without splitting any words across lines. Since this is to attract <br />hackers like yourself, we will use a monospace font, meaning that all <br />characters are of the same width (e.g.. &#8216;l&#8217; and &#8216;m&#8217; take up the same <br />horizontal space, as do space characters). The characters in our font <br />are of equal width and height, and there will be no additional spacing <br />between adjacent characters or adjacent rows. If you print a word on <br />one line and print the next word on the next line, you do not need to <br />print a space between them.
<p /> Let&#8217;s say we want to print the text &#8220;Facebook Hacker Cup 2013&#8243; on a <br />350&#215;100&#8243; billboard. If we use a font size of 33&#8243; per character, then <br />we can print &#8220;Facebook&#8221; on the first line, &#8220;Hacker Cup&#8221; on the second <br />and &#8220;2013&#8243; on the third. The widest of the three lines is &#8220;Hacker <br />Cup&#8221;, which is 330&#8243; wide. There are three lines, so the total height <br />is 99&#8243;. We cannot go any larger.
<p /> Input <br />The first line of the input file contains a single integer T: the <br />number of test cases. T lines follow, each representing a single test <br />case in the form &#8220;W H S&#8221;. W and H are the width and height in inches <br />of the available space. S is the text to be written.
<p /> Output <br />Output T lines, one for each test case. For each case, output &#8220;Case <br />#t: s&#8221;, where t is the test case number (starting from 1) and s is the <br />maximum font size, in inches per character, we can use. The size must <br />be an integral number of inches. If the text does not fit when printed <br />at a size of 1&#8243;, then output 0.
<p /> Constraints <br />1 ? T ? 20 <br />1 ? W, H ? 1000 <br />The text will contain only lower-case letters a-z, upper-case letters <br />A-Z, digits 0-9 and the space character <br />The text will not start or end with the space character, and will <br />never contain two adjacent space characters <br />The text in each case contains at most 1000 characters
<p /> Example input <br />5 <br />20 6 hacker cup <br />100 20 hacker cup 2013 <br />10 20 MUST BE ABLE TO HACK <br />55 25 Can you hack <br />100 20 Hack your way to the cup
<p /> Example output <br />Case #1: 3 <br />Case #2: 10 <br />Case #3: 2 <br />Case #4: 8 <br />Case #5: 7
<p /> Solution:
<p /> Since the width and height are fairly small, simulation is feasible. <br />Solve the problem by iterating font size from 1 until the billboard <br />cannot contain all the words. Fill the billboard line by line. <br /><code>  import java.io.File;  import java.io.FileNotFoundException;  import java.util.Scanner;   public class Billboards {         public static void main(String[] args) throws FileNotFoundException {                 Scanner sc = new Scanner (new File(args[0]));                 int t = sc.nextInt();                 for (int i=1; i&lt;= t; i++) {                         int w = sc.nextInt();                         int h = sc.nextInt();                         sc.skip(" ");                         String s = sc.nextLine();                         String[] sa = s.split(" ");                         int size = 0;                         for (int j=1; j&lt;10000; j++) {                                 int saPtr = 0;                                 int currH = h;                                 while (true) {                                         currH -= j;                                         if (currH &lt; 0)                                                 break;                                         int currW = w;                                          while (currW &gt;=  (sa[saPtr].length()*j) ) {                                                  currW -= sa[saPtr].length()*j;                                                 currW -= j;                                                 saPtr++;                                                 if (saPtr == sa.length) {                                                         size = j;                                                         break;                                                 }                                         }                                         if (size == j)                                                 break;                                 }                                 if (size &lt; j)                                         break;                         }                         System.out.println("Case #"+i+": "+size);                 }          }   }   </code>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/facebook-hacker-cup-billboard">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Billboard" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Billboard" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Billboard" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Billboard" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Billboard', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Billboard" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D372&amp;title=Facebook+Hacker+Cup+%26%238211%3B+Billboard" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=372</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My 2011 in numbers</title>
		<link>http://nordschleife.metaforix.net/blog/?p=371</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=371#comments</comments>
		<pubDate>Sat, 31 Dec 2011 17:02:45 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=371</guid>
		<description><![CDATA[169 &#8211; new friends on Facebook 116 &#8211; people in my Google+ circles 54 &#8211; Facebook events joined &#160; 77 &#8211; days spent in London over the summer 29 &#8211; days spent at home 4 &#8211; kg put on at home &#160; 0.16 &#8211; thickness of my new Macbook Air in inches (4mm) 10.7 &#8211; [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<div class='p_embed p_image_embed'> <img alt="111207-lg-23a2011rev" height="305" src="http://getfile5.posterous.com/getfile/files.posterous.com/temp-2011-12-31/vgJfkcttimJJsqdvzlsmJDzBrDkxxhwCJAsIdHuslEigtCBqIedfmiJleskb/111207-lg-23a2011rev.jpg.scaled1000.jpg" width="580" /> </div>
<p> 169 &#8211; new friends on Facebook</p>
<p>116 &#8211; people in my Google+ circles</p>
<p>54 &#8211; Facebook events joined</p>
<p>&nbsp;</p>
<p>77 &#8211; days spent in London over the summer</p>
<p>29 &#8211; days spent at home</p>
<p>4 &#8211; kg put on at home</p>
<p>&nbsp;</p>
<p>0.16 &#8211; thickness of my new Macbook Air in inches (4mm)</p>
<p>10.7 &#8211; version of Mac OS running on the Macbook Air</p>
<p>2.3.4 &#8211; version of updated Android running on my Samsung Galaxy S and Nook Color</p>
<p>26 &#8211; apps downloaded from Mac App store</p>
<p>&nbsp;</p>
<p>8.83 &#8211; percentage increase in my stock portfolio value</p>
<p>5.5 &#8211; estimated rate of inflation</p>
<p>0.5 &#8211; Bank of England base rate</p>
<p>240 &#8211; share price of Barclays Plc when I joined</p>
<p>155 &#8211; share price when I left</p>
<p>&nbsp;</p>
<p>60 &#8211; miles cycled from London to Cambridge</p>
<p>28 &#8211; miles cycled from Cambridge to Ely and back</p>
<p>&nbsp;</p>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/my-2011-in-numbers">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371&amp;title=My+2011+in+numbers" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371&amp;title=My+2011+in+numbers" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371&amp;title=My+2011+in+numbers" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371&amp;title=My+2011+in+numbers" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371&amp;title=My+2011+in+numbers', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371&amp;title=My+2011+in+numbers" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D371&amp;title=My+2011+in+numbers" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=371</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From &#8220;The Great Dictator&#8221;</title>
		<link>http://nordschleife.metaforix.net/blog/?p=370</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=370#comments</comments>
		<pubDate>Thu, 22 Dec 2011 19:30:28 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=370</guid>
		<description><![CDATA[I&#39;m sorry, but I don&#39;t want to be an emperor. That&#39;s not my business. I don&#39;t want to rule or conquer anyone. I should like to help everyone if possible; Jew, Gentile, black man, white. We all want to help one another. Human beings are like that. We want to live by each other&#39;s happiness, [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'><span style="color: rgb(51,51,51); font-family: Arial,Helvetica,sans-serif; font-size: 13px; line-height: 18px; background-color: rgb(255,255,255);">I&#39;m sorry, but I don&#39;t want to be an emperor. That&#39;s not my business. I don&#39;t want to rule or conquer anyone. I should like to help everyone if possible; Jew, Gentile, black man, white. We all want to help one another. Human beings are like that. We want to live by each other&#39;s happiness, not by each other&#39;s misery. We don&#39;t want to hate and despise one another. In this world there is room for everyone, and the good earth is rich and can provide for everyone. The way of life can be free and beautiful, but we have lost the way. Greed has poisoned men&#39;s souls, has barricaded the world with hate, has goose-stepped us into misery and bloodshed. We have developed speed, but we have shut ourselves in. Machinery that gives abundance has left us in want. Our knowledge has made us cynical; our cleverness, hard and unkind. We think too much and feel too little. More than machinery, we need humanity. More than cleverness, we need kindness and gentleness. Without these qualities, life will be violent and all will be lost. The airplane and the radio have brought us closer together. The very nature of these inventions cries out for the goodness in men; cries out for universal brotherhood; for the unity of us all. Even now my voice is reaching millions throughout the world, millions of despairing men, women, and little children, victims of a system that makes men torture and imprison innocent people. To those who can hear me, I say, do not despair. The misery that is now upon us is but the passing of greed, the bitterness of men who fear the way of human progress. The hate of men will pass, and dictators die, and the power they took from the people will return to the people. And so long as men die, liberty will never perish. Soldiers! Don&#39;t give yourselves to brutes, men who despise you, enslave you; who regiment your lives, tell you what to do, what to think and what to feel! Who drill you, diet you, treat you like cattle, use you as cannon fodder. Don&#39;t give yourselves to these unnatural men &#8211; machine men with machine minds and machine hearts! You are not machines, you are not cattle, you are men! You have the love of humanity in your hearts! You don&#39;t hate! Only the unloved hate; the unloved and the unnatural. Soldiers! Don&#39;t fight for slavery! Fight for liberty! In the seventeenth chapter of St. Luke, it is written that the kingdom of God is within man, not one man nor a group of men, but in all men! In you! You, the people, have the power, the power to create machines, the power to create happiness! You, the people, have the power to make this life free and beautiful, to make this life a wonderful adventure. Then in the name of democracy, let us use that power. Let us all unite. Let us fight for a new world, a decent world that will give men a chance to work, that will give youth a future and old age a security. By the promise of these things, brutes have risen to power. But they lie! They do not fulfill that promise. They never will! Dictators free themselves but they enslave the people. Now let us fight to fulfill that promise. Let us fight to free the world! To do away with national barriers! To do away with greed, with hate and intolerance! Let us fight for a world of reason, a world where science and progress will lead to all men&#39;s happiness. Soldiers, in the name of democracy, let us all unite! Hannah, can you hear me? Wherever you are, look up Hannah! The clouds are lifting! The sun is breaking through! We are coming out of the darkness into the light! We are coming into a new world; a kindlier world, where men will rise above their hate, their greed, and brutality. Look up, Hannah! The soul of man has been given wings and at last he is beginning to fly. He is flying into the rainbow! Into the light of hope, into the future! The glorious future, that belongs to you, to me and to all of us.</span>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/from-the-great-dictator">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370&amp;title=From+%26%238220%3BThe+Great+Dictator%26%238221%3B" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370&amp;title=From+%26%238220%3BThe+Great+Dictator%26%238221%3B" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370&amp;title=From+%26%238220%3BThe+Great+Dictator%26%238221%3B" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370&amp;title=From+%26%238220%3BThe+Great+Dictator%26%238221%3B" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370&amp;title=From+%26%238220%3BThe+Great+Dictator%26%238221%3B', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370&amp;title=From+%26%238220%3BThe+Great+Dictator%26%238221%3B" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D370&amp;title=From+%26%238220%3BThe+Great+Dictator%26%238221%3B" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=370</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dear Steve</title>
		<link>http://nordschleife.metaforix.net/blog/?p=369</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=369#comments</comments>
		<pubDate>Thu, 06 Oct 2011 18:01:06 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=369</guid>
		<description><![CDATA[Thank you for all the &#34;dings&#34; you have brought to the universe. Thank you for all well designed products that work out of the box. Thank you for delivering revolutionary products time and again, from the original Mac to Pixar movies, iPod, OS X, iPhone, Macbook Air, iPad and more in the pipeline. Thank you [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>Thank you for all the &quot;dings&quot; you have brought to the universe. Thank you for all well designed products that work out of the box. Thank you for delivering revolutionary products time and again, from the original Mac to Pixar movies, iPod, OS X, iPhone, Macbook Air, iPad and more in the pipeline. Thank you for making business cool again &#8211; user experience instead of bottom line, no debt instead of capital efficiency. Most of all, thank you for telling the world that it&#39;s all right to think different.
<p />
<div>You will be missed.</div>
<p />
<div><iframe src="http://www.youtube.com/embed/jULUGHJCCj4?wmode=transparent" allowfullscreen frameborder="0" height="417" width="500"></iframe></div>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/dear-steve">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369&amp;title=Dear+Steve" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369&amp;title=Dear+Steve" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369&amp;title=Dear+Steve" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369&amp;title=Dear+Steve" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369&amp;title=Dear+Steve', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369&amp;title=Dear+Steve" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D369&amp;title=Dear+Steve" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=369</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password storage 101</title>
		<link>http://nordschleife.metaforix.net/blog/?p=368</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=368#comments</comments>
		<pubDate>Sat, 03 Sep 2011 17:59:42 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=368</guid>
		<description><![CDATA[4. I have decided to write a basic tutorial because I have been shocked multiple times in the past few weeks knowing how many large organizations keep their users&#39; passwords. It&#39;s easy to assume that website operators would have basic knowledge in computer security, but I have found such assumption false. This post is mainly for [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>4. I have decided to write a basic tutorial because I have been shocked multiple times in the past few weeks knowing how many large organizations keep their users&#39; passwords. It&#39;s easy to assume that website operators would have basic knowledge in computer security, but I have found such assumption false.
<p /> This post is mainly for website operators. <b>For average users</b>, I offer two pieces of advice:
<p />1. Ignore advice to use a non-repeated strong password that&#39;s at least 8 characters long, contains special characters etc., you won&#39;t be able to remember 50 different passwords in your head. Instead, use a moderately strong password, such as your initials+date of birth, or full name of your favorite actress that <i>can be remembered</i>. On when to repeat the same password, see advice 2.
<p /> 2. Beware that many companies and governments don&#39;t store your password safely. A database administrator in the company or a hacker who gains access to the database may be able to see your password in the form of plain text (i.e., what you have entered into the form). A good (enough) test for that is to register your account with a random temporary password, and click the &quot;Forget my password&quot; link. If they send you an email with your password, be very careful! The best practice is probably to write down the password somewhere convenient. Instead, if they email you with a link to reset password or a temporary password to log on, then it probably is safe, and you can use the same password <b>with caution</b>.
<p />
<div>Now, for <b>operators</b> of services that require logging in,</div>
<p />
<div>1. Never store your users&#39; passwords in plain text!</div>
<p />
<div>The reason is simple, unscrupulous database administrators and hackers who gain access to the database will be able to pretend to be your users. Worse yet, your users trusted you enough to use the same set of login details for all her services, all her accounts would be vulnerable to impersonation. Remember that the firewall doesn&#39;t even need to be breached as people from within the company will be able to view the data as part of their daily job. Imagine a disgruntled employee post all details of your clients on Wikileaks.</div>
<p />
<div>Also, use lots of common sense, and <a href="http://serverfault.com/questions/293217/our-security-auditor-is-an-idiot-how-do-i-give-him-the-information-he-wants">do not blindly rely on security consultants</a> (especially not one who ask you to do stupid things). It will be you who suffer reputation loss when bad things happen.</div>
<p />
<div>2. Never encrypt users&#39; passwords</div>
<p />
<div>Same reason as reason 1, your employees and hackers know how to decrypt. Security by obscurity has proven again and again to not work.</div>
<p />
<div>3. Never apply hashing algorithm directly on the password</div>
<p />
<div>Good effort, but not good enough. Since employees and hackers know how the password is processed, they can use a <a href="http://en.wikipedia.org/wiki/Rainbow_table">Rainbow table</a> to compare matches using brute force attack. It&#39;s likely that a few days or a few months are needed to produce the rainbow table, but all 30 million passwords will be recovered together. If a common hashing algorithm is used, there may well be a rainbow table freely available on a magical place called the Internet.</div>
<p />
<div>4. Use a long, randomized salt</div>
<p />
<div>If the same <a href="http://en.wikipedia.org/wiki/Cryptographic_salt">encryption salt</a> is used across all accounts, we encounter the same problem described in advice 3 &#8211; the hacker can generate his own rainbow table for your site. Whenever a new account is created or password reset, generate a new long, random salt, and store the salt in the database as well (it&#39;s not meant to be secret), and now we are onto something.  When storing the password to the database, apply the hashing function to the plain text password appended to the salt, i.e., hash(passwd.Append(salt)) or equally valid, append the hash of the password to the salt, then hash again, i.e., hash ( hash(passwd).Append(salt)). Now, a rainbow table cannot be generated. The problem is that a password can still be recovered in a few days or months if a simple fast hashing function is used, but it takes 30 million times a few days or months to recover all those passwords for your 30 million customers. Not bad, but long way to go.</div>
<p />
<div>5. Use a slow hashing algorithm</div>
<p />
<div>By using a collision resistant hashing algorithm (read: not MD5, possibly not SHA-1 either. I would personally use SHA-256 or better), the main worry is brute force attack. The aim is to use the slowest possible (and still sensible) way to generate the hash. There are algorithms designed specifically for this purpose, <a href="http://codahale.com/how-to-safely-store-a-password/">bcrypt</a> is a good example. A good way is to apply hashing algorithm multiple times. For instance, hashedPw = hash(passwd.Append(salt)); for (int i=0; i&lt;1000000; i++) hashedPw = hash(hashedPw);</div>
<div>Be careful of cycles. Remember that if the hashing algorithm takes 1ms, a hacker can try 1000 passwords a second. If it takes 200ms, he can only try 5. And a difference of 199ms makes no difference to the user. Do not try to use sleep() to slow down in an artificial way, the hacker doesn&#39;t need to put that in his code. Read on if you worry about the extra server load.</div>
<p />
<div>6. Use a challenge-response protocol</div>
<p />
<div>Don&#39;t validate the hash at the server! First, you&#39;ll need super-computers to keep up with the large number of users, and second, even if you are rich to buy the super-computers, there may be a eavesdropper ready to steal your user&#39;s password during transmission. Use <a href="http://en.wikipedia.org/wiki/Challenge-response_authentication">challenge-response authentication</a> instead. The server generates a random string, and encrypts it with the hash. Since the string is one time, the encryption technique can be one that&#39;s fast and simple (e.g., DES). If the random string is &quot;apple&quot;, the server send encrypt(hash, &quot;apple&quot;) to the client. The client&#39;s computer then does the computation of hash from the password, decrypts the message, and sends back &quot;apple&quot; to the server.</div>
<p />
<div>7. Other miscellaneous points</div>
<p />
<div>Invest in a good firewall to keep the users&#39; information safe. Information other than password can still be valuable to a crime organization.</div>
<div>Allow unlimited characters since after all, storage doesn&#39;t matter because you are only saving the hash which has fixed length.</div>
<div>Allow every possible character on the planet, support unicode because there is no reason not to.</div>
<div>Limit the number of failed log-in and exponentially increase the time out between each failed log-in to prevent brute force attack.</div>
<div>Read the whole post again, double check to make sure you have done everything mentioned, and only then, consider forcing your users to use secure password.</div>
<p />
<div>8. Centralize risk</div>
<p />
<div>If you are not sure if you understand all those mentioned and have implemented them correctly, don&#39;t create your own log-in page. There are people who know and understand how to manage their users&#39; information, and are willing to help. Almost all your users would have an account with an <a href="http://en.wikipedia.org/wiki/OpenID">OpenID</a> provider. <a href="http://openid.net/add-openid/">It&#39;s easy to add OpenID to your site! </a></div>
<div>If you can&#39;t secure your users&#39; information, definitely use OpenID. Even if you can, still consider using OpenID because it&#39;s so much easier.</div>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/password-storage-101">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368&amp;title=Password+storage+101" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368&amp;title=Password+storage+101" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368&amp;title=Password+storage+101" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368&amp;title=Password+storage+101" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368&amp;title=Password+storage+101', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368&amp;title=Password+storage+101" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D368&amp;title=Password+storage+101" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=368</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoffeeScript</title>
		<link>http://nordschleife.metaforix.net/blog/?p=367</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=367#comments</comments>
		<pubDate>Fri, 02 Sep 2011 19:12:27 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=367</guid>
		<description><![CDATA[A higher level language than JavaScript. Think about C vs C++. http://jashkenas.github.com/coffee-script/ Posted via email from ramblings of a comsci student]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>A higher level language than JavaScript. Think about C vs C++.
<p /> <a href="http://jashkenas.github.com/coffee-script/">http://jashkenas.github.com/coffee-script/</a>
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/coffeescript">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367&amp;title=CoffeeScript" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367&amp;title=CoffeeScript" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367&amp;title=CoffeeScript" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367&amp;title=CoffeeScript" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367&amp;title=CoffeeScript', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367&amp;title=CoffeeScript" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D367&amp;title=CoffeeScript" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=367</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimize for speed</title>
		<link>http://nordschleife.metaforix.net/blog/?p=359</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=359#comments</comments>
		<pubDate>Sat, 20 Aug 2011 17:59:20 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=359</guid>
		<description><![CDATA[We always hear that premature optimization is the root of all evil, and that machines are cheap while programmers are expensive. While those are generally true in today&#8217;s desktop computing environment, it is certainly not true for server applications. Fact: servers are expensive. It costs a lot of money to build a data-center, provide power, [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>We always hear that premature optimization is the root of all evil, <br />and that machines are cheap while programmers are expensive. While <br />those are generally true in today&#8217;s desktop computing environment, it <br />is certainly not true for server applications.
<p /> Fact: servers are expensive. It costs a lot of money to build a <br />data-center, provide power, cooling, and backup for servers, have the <br />personnel to maintain them etc. When you need hundreds of thousands of <br />them, having software that run 20% faster can have significant cost <br />benefits.
<p /> Also, data centers and power supply generally cannot be expanded. <br />Thus, companies are stuck with the number of machines that they can <br />use, so they have to be careful when allocating resources.
<p /> There is a saying that software development is to make it run, make it <br />right, make it fast. However, it is extremely difficult to optimize <br />after building the software due to time pressure, and users&#8217; new <br />feature requests. We are therefore forced by reality to optimize <br />early, optimize often.
<p /> The first step after getting a problem statement is to choose a <br />programming language. It is necessary to choose a language that has a <br />good compiler such that many advanced optimization techniques are done <br />by it. Next, use libraries provided by CPU manufacturers, e.g., Intel <br />and AMD. Those libraries are built with targeted CPUs in mind, and <br />they provide significant speed-up for complex calculations. Then, use <br />data-structures that allow the fastest algorithms to be implemented. <br />Use a hash table instead of tree, use a binary file instead of XML. <br />Write multi-threaded code to take advantage of multiple CPU cores when <br />appropriate. Write assembly code when it&#8217;s absolutely necessary.
<p /> Even then, a general purpose CPU may just be too slow. For floating <br />point calculation intensive applications, give GPGPUs a try, be warned <br />that the high latency from CPU to GPU is a major limitation. Or better <br />yet, build your own specialized hardware! The large range of FPGAs <br />offered by Xilinx and Altera could prove life saving for many where <br />complicated calculations have to be performed many times.
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/optimize-for-speed">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359&amp;title=Optimize+for+speed" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359&amp;title=Optimize+for+speed" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359&amp;title=Optimize+for+speed" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359&amp;title=Optimize+for+speed" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359&amp;title=Optimize+for+speed', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359&amp;title=Optimize+for+speed" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D359&amp;title=Optimize+for+speed" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=359</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JIRA, Perforce, Confluence, NUnit, and Cruise Control &#8211; the joy of working in a large company</title>
		<link>http://nordschleife.metaforix.net/blog/?p=358</link>
		<comments>http://nordschleife.metaforix.net/blog/?p=358#comments</comments>
		<pubDate>Thu, 04 Aug 2011 20:21:30 +0000</pubDate>
		<dc:creator>kaise</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nordschleife.metaforix.net/blog/?p=358</guid>
		<description><![CDATA[I have been in my role for 5 weeks now with 4 weeks to go, developing applications for a large company. Things have been going really smoothly so far, completed two projects, tested them, and packaged them in a nice installer. It&#8217;s very different working for a big company compared to working alone or in [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>I have been in my role for 5 weeks now with 4 weeks to go, developing <br />applications for a large company. Things have been going really <br />smoothly so far, completed two projects, tested them, and packaged <br />them in a nice installer.
<p /> It&#8217;s very different working for a big company compared to working <br />alone or in a small team. The workflow tends to be team oriented, work <br />is supposed to be well documented so that the next person can take <br />over. After all, on average a third of the team members leave every <br />single year.
<p /> My biggest takeaway has to be getting real experience doing test <br />driven development (TDD), in which for each function, I have to write <br />tests before writing real code. The tests are supposed to fail, while <br />writing real code is supposed to make those tests pass. Unit testing <br />is of real help when refactoring is needed to make maintenance <br />possible.
<p /> After the unit tests pass on the local machine, source code is <br />supposed to be checked into a repository using Perforce, a version <br />control system similar to Subversion. The Cruise Control build server <br />automatically detects the change in repository, and triggers a build <br />project. The project is built and have unit test done on the build <br />server again, hopefully everything is done successfully.
<p /> Every task is assigned using a system called JIRA, which is designed <br />to complement test driven development. Tasks are supposed to be <br />simple, doing one thing at a time. Each JIRA is designed to be done in <br />less than a week. Developers log the amount of work done, and assign <br />someone else in the team to accept their implementations. Things then <br />have to be recorded down into a wiki like system called Confluence so <br />that the rest of the team know what&#8217;s going on.
<p /> Working in a team of 20 instead of anywhere between 1-5 that we are <br />used to in school is that task assignment becomes even more important. <br />It&#8217;s possible for a school project to have 5 persons doing the same <br />thing, but you just cannot have 20 people looking at the same piece of <br />code. It&#8217;s very nice to have very helpful team members who help to get <br />me going when I get stuck.
<p style="font-size: 10px;">  <a href="http://posterous.com">Posted via email</a>   from <a href="http://comsci.tk/jira-perforce-confluence-nunit-and-cruise-con">ramblings of a comsci student</a>  </p>
</p></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358&amp;title=JIRA%2C+Perforce%2C+Confluence%2C+NUnit%2C+and+Cruise+Control+%26%238211%3B+the+joy+of+working+in+a+large+company" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358&amp;title=JIRA%2C+Perforce%2C+Confluence%2C+NUnit%2C+and+Cruise+Control+%26%238211%3B+the+joy+of+working+in+a+large+company" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358&amp;title=JIRA%2C+Perforce%2C+Confluence%2C+NUnit%2C+and+Cruise+Control+%26%238211%3B+the+joy+of+working+in+a+large+company" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358&amp;title=JIRA%2C+Perforce%2C+Confluence%2C+NUnit%2C+and+Cruise+Control+%26%238211%3B+the+joy+of+working+in+a+large+company" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358&amp;title=JIRA%2C+Perforce%2C+Confluence%2C+NUnit%2C+and+Cruise+Control+%26%238211%3B+the+joy+of+working+in+a+large+company', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358&amp;title=JIRA%2C+Perforce%2C+Confluence%2C+NUnit%2C+and+Cruise+Control+%26%238211%3B+the+joy+of+working+in+a+large+company" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fnordschleife.metaforix.net%2Fblog%2F%3Fp%3D358&amp;title=JIRA%2C+Perforce%2C+Confluence%2C+NUnit%2C+and+Cruise+Control+%26%238211%3B+the+joy+of+working+in+a+large+company" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://nordschleife.metaforix.net/blog/?feed=rss2&#038;p=358</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

