<?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>Francesco Laurita&#039; s blog</title>
	<atom:link href="http://francesco-laurita.info/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://francesco-laurita.info/wordpress</link>
	<description>Words...just words</description>
	<lastBuildDate>Mon, 21 Mar 2011 20:36:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>CodeIgniter &#8211; How to load a view within a view</title>
		<link>http://francesco-laurita.info/wordpress/2011/01/24/codeigniter-how-to-load-a-view-within-a-view/</link>
		<comments>http://francesco-laurita.info/wordpress/2011/01/24/codeigniter-how-to-load-a-view-within-a-view/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 15:25:18 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[codeigniter load view within view file]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/?p=173</guid>
		<description><![CDATA[In this page I explain how to &#8220;include&#8221; or load multiple views by keeping the controller code less verbose as possible. Hope this help!]]></description>
			<content:encoded><![CDATA[<div id="attachment_170" class="wp-caption alignleft" style="width: 160px"><a href="http://francesco-laurita.info/wordpress/wp-content/uploads/2011/01/ci_logo_flame.jpg"><img class="size-thumbnail wp-image-170  " title="CodeIgniter" src="http://francesco-laurita.info/wordpress/wp-content/uploads/2011/01/ci_logo_flame-150x150.jpg" alt="CodeIgniter Logo" width="150" height="150" /></a><p class="wp-caption-text">CodeIgniter</p></div>
<p>In <a href="/wordpress/codeigniter-loading-views-within-a-view-file/" target="_self">this page</a> I explain how to &#8220;include&#8221; or load multiple views by keeping the controller code less verbose as possible.</p>
<p>Hope this help!</p>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2011/01/24/codeigniter-how-to-load-a-view-within-a-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Hacker Cup &#8211; Almost solution (Facebook Hacker Cup Test Round)</title>
		<link>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-almost-solution-facebook-hacker-cup-test-round/</link>
		<comments>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-almost-solution-facebook-hacker-cup-test-round/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 01:22:22 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook hacker cup 2011]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[facebook hacker cup almost]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/?p=156</guid>
		<description><![CDATA[For two integersÂ a andÂ c, we defineÂ a and a third integerÂ b to beÂ almost factors ofÂ c by choosing the minimalÂ b that minimizes &#124;ab-c&#124;. Your task will be to determineÂ b givenÂ a andÂ c. Input Your input file will consist of a single integerÂ N, the number of test cases in the file, followed by N pairs of integersÂ a andÂ c. All <a href='http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-almost-solution-facebook-hacker-cup-test-round/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>For two integersÂ <strong>a</strong> andÂ <strong>c</strong>, we defineÂ <strong>a</strong> and a third integerÂ <strong>b</strong> to beÂ <strong>almost factors</strong> ofÂ <strong>c</strong> by choosing the minimalÂ <strong>b</strong> that minimizes |<strong>ab</strong>-<strong>c</strong>|. Your task will be to determineÂ <strong>b</strong> givenÂ <strong>a</strong> andÂ <strong>c</strong>.</p>
<h2>Input</h2>
<p>Your input file will consist of a single integerÂ <strong>N</strong>, the number of test cases in the file, followed by N pairs of integersÂ <strong>a</strong> andÂ <strong>c</strong>. All tokens in the input will be separated by some whitespace.</p>
<h2>Output</h2>
<p>Your output should consist ofÂ <strong>N</strong> newline-separated integers, each one representingÂ <strong>b</strong> for the corresponding pair (<strong>a</strong>,Â <strong>c</strong>) in the input.</p>
<h2>Constraints</h2>
<p>5 â‰¤Â <strong>N</strong> â‰¤ 20<br />
1 â‰¤Â <strong>a</strong>,Â <strong>c</strong> â‰¤ 10<sup>10</sup></p>
<p><strong>Sample input:</strong></p>
<pre class="brush: plain; title: ; notranslate">
5
18 24
77 176
34 144
24 426
273 628
</pre>
<p><strong>Sample output:</strong></p>
<pre class="brush: plain; title: ; notranslate">
1
2
4
18
2
</pre>
<p><strong>Code (C++):</strong></p>
<pre class="brush: cpp; title: ; notranslate">
//============================================================================
// Name        : almost.cpp
// Author      : Francesco Laurita
// Version     : 1.0
// Copyright   : Francesco Laurita
// Description :
//============================================================================

#include &lt;algorithm&gt;
#include &lt;iostream&gt;
using namespace std;

int main() {
	int ntest, a, c, b;
	cin &gt;&gt; ntest;
	while (ntest--) {
		cin &gt;&gt; a;
		cin &gt;&gt; c;
		b = c / a;
		if (abs((b + 1) * a - c) &lt; abs(b * a - c)) {
			b++;
		}
		cout &lt;&lt; b &lt;&lt; endl;
	}
	return 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-almost-solution-facebook-hacker-cup-test-round/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Facebook Hacker Cup 2011 Qualification Round &#8211; Double squares solution</title>
		<link>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-double-squares-solution/</link>
		<comments>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-double-squares-solution/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 01:03:11 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook hacker cup 2011]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[facebook hacker cup double squares]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/?p=151</guid>
		<description><![CDATA[A double-square number is an integerÂ X which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 32+ 12. Your task in this problem is, givenÂ X, determine the number of ways in which it can be written as the sum of two squares. For example, 10 <a href='http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-double-squares-solution/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>A double-square number is an integerÂ <strong>X</strong> which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 3<sup>2</sup>+ 1<sup>2</sup>. Your task in this problem is, givenÂ <strong>X</strong>, determine the number of ways in which it can be written as the sum of two squares. For example, 10 can only be written as 3<sup>2</sup> + 1<sup>2</sup> (we don&#8217;t count 1<sup>2</sup> + 3<sup>2</sup> as being different). On the other hand, 25 can be written as 5<sup>2</sup> + 0<sup>2</sup> or as 4<sup>2</sup> + 3<sup>2</sup>.</p>
<h3>Input</h3>
<p>You should first read an integerÂ <strong>N</strong>, the number of test cases. The nextÂ <strong>N</strong> lines will containÂ <strong>N</strong> values ofÂ <strong>X</strong>.</p>
<h3>Constraints</h3>
<p>0 â‰¤Â <strong>X</strong> â‰¤ 2147483647<br />
1 â‰¤Â <strong>N</strong> â‰¤ 100</p>
<h3>Output</h3>
<p>For each value ofÂ <strong>X</strong>, you should output the number of ways to writeÂ <strong>X</strong> as the sum of two squares.</p>
<p><strong>Sample input:</strong></p>
<pre class="brush: plain; title: ; notranslate">
5
10
25
3
0
1
</pre>
<p><strong>Sample output:</strong></p>
<pre class="brush: plain; title: ; notranslate">
1
2
0
1
1
</pre>
<p><strong>Code (C++):</strong></p>
<pre class="brush: cpp; title: ; notranslate">
//============================================================================
// Name        : doublesquare.cpp
// Author      : Francesco Laurita
// Version     : 1.0
// Copyright   : Francesco Laurita
// Description :
//============================================================================

#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;math.h&gt;
using namespace std;

bool check(const int a, const int b, const int c) {
	return pow(a,2) + pow(b,2) == c;
}
int main(int argc, char **argv) {

	ifstream fp(argv[1]);
	if (!fp){
		cerr &lt;&lt; &quot;Unable to open file!\n&quot;;
		return 1;
	}

	int ntest;
	fp &gt;&gt; ntest;
	fp.ignore();
	int a, b;
	for (int i = 0; i &lt; ntest; i++) {
		int current, found;
		fp &gt;&gt; current;
		b = sqrt(current);
		a = sqrt(current - (pow(b,2)));
		found = 0;
		while (a &lt;= b &amp;&amp; b &gt;= 0) {
			if (check(a, b, current)) {
				found++;
			}
			b--;
			a = sqrt(current - (pow(b,2)));
		}
		cout &lt;&lt; found &lt;&lt; endl;
	}
	fp.close();
	return 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-double-squares-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Hacker Cup 2011 Qualification Round Studious Student solution</title>
		<link>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-studious-student-solution/</link>
		<comments>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-studious-student-solution/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 23:48:51 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook hacker cup 2011]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[facebook hacker cup studious student]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/?p=147</guid>
		<description><![CDATA[At the first look it seems just a simple sort problem, but it isn&#8217;t! It involves sorting operations on all strings permutation. Since the bound of 9 words is really low I just apply the sort operation on all of permutations (9!) You&#8217;ve been given a list of words to study and memorize. Being a <a href='http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-studious-student-solution/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>At the first look it seems just a simple sort problem, but it isn&#8217;t! It involves sorting operations on all strings permutation.</p>
<p>Since the bound of 9 words is really low I just apply the sort operation on all of permutations (9!)</p>
<p>You&#8217;ve been given a list of words to study and memorize. Being a diligent student of language and the arts, you&#8217;ve decided to not study them at all and instead make up pointless games based on them. One game you&#8217;ve come up with is to see how you can concatenate the words to generate the lexicographically lowest possible string.</p>
<h3>Input</h3>
<p>As input for playing this game you will receive a text file containing an integerÂ <strong>N</strong>, the number of word sets you need to play your game against. This will be followed byÂ <strong>N</strong> word sets, each starting with an integerÂ <strong>M</strong>, the number of words in the set, followed byÂ <strong>M</strong> words. All tokens in the input will be separated by some whitespace and, aside fromÂ <strong>N</strong> andÂ <strong>M</strong>, will consist entirely of lowercase letters.</p>
<h3>Output</h3>
<p>Your submission should contain the lexicographically shortest strings for each corresponding word set, one per line and in order.</p>
<h3>Constraints</h3>
<p>1 &lt;=Â <strong>N</strong> &lt;= 100<br />
1 &lt;=Â <strong>M</strong> &lt;= 9<br />
1 &lt;= all word lengths &lt;= 10</p>
<p><strong>Sample input:</strong></p>
<pre class="brush: plain; title: ; notranslate">
5
6 facebook hacker cup for studious students
5 k duz q rc lvraw
5 mybea zdr yubx xe dyroiy
5 jibw ji jp bw jibw
5 uiuy hopji li j dcyi
</pre>
<p><strong>Sample output:</strong></p>
<pre class="brush: plain; title: ; notranslate">
cupfacebookforhackerstudentsstudious
duzklvrawqrc
dyroiymybeaxeyubxzdr
bwjibwjibwjijp
dcyihopjijliuiuy
</pre>
<p><strong>The code (C++):</strong></p>
<pre class="brush: cpp; title: ; notranslate">
//============================================================================
// Name        : studious-student.cpp
// Author      : Francesco Laurita
// Version     : 1.0
// Copyright   : Francesco Laurita
// Description : Studious Student solution (FB hacke cup qualification round)
//============================================================================

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;algorithm&gt;
using namespace std;

bool compare(const string a, const string b) {
	string aa = a;
	string bb = b;
	if (aa + bb &lt; bb + aa) {
		return true;
	}
	return false;
}
int main(int argc, char **argv) {
	ifstream fp(argv[1]);
	string *current = NULL;
	int nlines;

	if (!fp) {
		cerr &lt;&lt; &quot;Unble to open file!&quot; &lt;&lt; endl;
		return 1;
	}

	fp &gt;&gt; nlines;
	fp.ignore();

	for (int i = 0; i &lt; nlines; i++) {

		string result;
		int nword;
		string line, token;
		getline(fp, line);

		stringstream ss(line);
		ss &gt;&gt; nword;
		current = new string[nword];
		for (int j = 0; j &lt; nword; j++) {
			ss &gt;&gt; token;
			current[j] = token;
		}
		std::sort(current, current + nword, compare);

		for (int j = 0; j &lt; nword; j++) {
			result.append(current[j]);
		}
		cout &lt;&lt; result &lt;&lt; endl;

	}

	fp.close();
	delete[] current;
	return 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-2011-qualification-round-studious-student-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Hacker Cup &#8211; Characters solution (Facebook Hacker Cup Test Round)</title>
		<link>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-characters-solution-facebook-hacker-cup-test-round/</link>
		<comments>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-characters-solution-facebook-hacker-cup-test-round/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 22:46:02 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook hacker cup 2011]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[facebook hacker cup characters]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/?p=142</guid>
		<description><![CDATA[Problem: Characters You&#8217;re interested in figuring out the number of case-insensitive unique characters in some string. This sounds simple and easily-automated, so you just decide to just go for it. Input Your input will consist of an integerÂ N followed by a newline.Â N test cases will follow, all separated by newlines. Each test case is a <a href='http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-characters-solution-facebook-hacker-cup-test-round/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<h2>Problem: Characters</h2>
<p>You&#8217;re interested in figuring out the number of case-insensitive unique characters in some string. This sounds simple and easily-automated, so you just decide to just go for it.</p>
<h2>Input</h2>
<p>Your input will consist of an integerÂ <strong>N</strong> followed by a newline.Â <strong>N</strong> test cases will follow, all separated by newlines. Each test case is a string of letters containing some combination of letters (upper- and lower-case are allowed), the space character, and the characters contained in the stringÂ <strong>?!.&#8217;$%&amp;*:;,</strong>.</p>
<h2>Output</h2>
<p>Your output should consist of one integer per case, separated by whitespace, indicating the number of case-insensitive unique characters contained in the input string.</p>
<h2>Constraints</h2>
<p>5 â‰¤Â <strong>N</strong> â‰¤ 25<br />
Input strings will not exceed 100 characters in length.</p>
<p><strong>Sample input:</strong></p>
<pre class="brush: plain; title: ; notranslate">
5
Lorem ipsum
Eclipse is a pretty nice editor.
This is not a very interesting case.
The quick brown fox jumps over the lazy dog
Bonk.
</pre>
<p><strong>Sample output:</strong></p>
<pre class="brush: plain; title: ; notranslate">
10
15
15
27
5
</pre>
<p><strong>The code (C):</strong></p>
<pre class="brush: cpp; title: ; notranslate">
/*
 ============================================================================
 Name        : characters-c.c
 Author      : Francesco Laurita
 Version     : 1.0
 Copyright   : Francesco Laurita
 Description :
 ============================================================================
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;ctype.h&gt;
#define CACHE_SIZE 50
char cache[CACHE_SIZE] = { '&#92;&#48;' };

void add(char c) {
	char *chr = strchr(cache, c);
	//if char is not present into the current cache, it will be appended
	if (chr == NULL)
		cache[strlen(cache)] = c;
}
int main(int argc, char **argv) {

	FILE *fp = fopen(argv[1], &quot;r&quot;);
	if (!fp) {
		fprintf(stderr, &quot;Unable to open file\n&quot;);
		return EXIT_FAILURE;
	}
	char current;
	//Skip the first line
	while((current = fgetc(fp)) != '\n'){;}

	//Read the whole file char by char
	while (1) {

		current = fgetc(fp);

		if (current != '\n' &amp;&amp; current != EOF) {
			add(tolower(current));
		} else {//EOL or EOF
			printf(&quot;%d\n&quot;, (int) strlen(cache));
			bzero(cache, CACHE_SIZE);
		}

		if (current == EOF)
			break;
	}

	fclose(fp);
	return EXIT_SUCCESS;
}
</pre>
<p><strong>PHP Version:</strong></p>
<pre class="brush: php; title: ; notranslate">
#!/usr/bin/php
&lt;?php
$data = file($argv[1]);
if (!$data) exit(1);
array_shift($data);
foreach ($data as $row){
    $row = strtolower(trim($row));
    echo count(array_unique(str_split($row))) . &quot;\n&quot;;
}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-characters-solution-facebook-hacker-cup-test-round/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Hacker Cup â€“ Reverser solution (Facebook Hacker Cup Test Round)</title>
		<link>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-reverser-solution-facebook-hacker-cup-test-round/</link>
		<comments>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-reverser-solution-facebook-hacker-cup-test-round/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 22:13:54 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook hacker cup 2011]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[facebook hacker cup reverser]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/?p=119</guid>
		<description><![CDATA[I&#8217;ve lost the competition! The first round was so buggy that I was not able to submit anything! BTW, just for fun I have solved some problems of Â &#8221;Facebook Hacker Cup Test Round&#8220;. Problem: Reverser You&#8217;ve intercepted a series of transmissions encrypted using an interesting and stupid method, which you have managed to decipher. The <a href='http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-reverser-solution-facebook-hacker-cup-test-round/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve lost the competition!</p>
<p>The first round was so buggy that I was not able to submit anything! BTW, just for fun I have solved some problems of Â &#8221;<strong>Facebook Hacker Cup Test Round</strong>&#8220;.</p>
<p><strong>Problem: Reverser</strong></p>
<p>You&#8217;ve intercepted a series of transmissions encrypted using an interesting and stupid method, which you have managed to decipher. The messages contain only spaces and lowercase English characters, and are encrypted as follows: for all words in a sentence, the ith word (1-based) word is replaced with the word generated by applying the following recursive operation f(word, i):</p>
<div id="_mcePaste"><em>If the length of word is less than or equal to i,</em></div>
<div id="_mcePaste"><em>return word.</em></div>
<div id="_mcePaste"><em>Otherwise, return f(right half of word, i) +Â f(left half of word, i).</em></div>
<div><em><br />
</em></div>
<div id="_mcePaste">If word is of odd length, it is split such that the right side is longer. You&#8217;ve decided to have a little fun with whoever is sending the messages, and to broadcast your own messages encrypted in the same style that they are using.</div>
<div>
<div><strong>Input</strong></div>
<div>Your input will begin with an integer N, followed by a newline and then N test cases. Each case consists of an unencrypted sentence containing only spaces and lowercase letters, and cases are newline-separated. There will be no leading or trailing spaces in a sentence and there will be at most 1 space character between any otherwise-adjacent characters</div>
<div><strong>Output</strong></div>
<div>Output, for each case and separated by newlines, the contents of the encrypted sentence after applying the encoding method describe above to it. You may ignore traditional capitalization rules and stick to all lowercase letters.</div>
<div><strong>Constraints</strong></div>
<div>5 â‰¤ N â‰¤ 25</div>
<div>Sentences will contain no more than 100 characters.</div>
<div><strong>Sample input:</strong></div>
</div>
<pre class="brush: plain; title: ; notranslate">
5
this is a short sentence
this encryption is lame
racecar
test problems are pretty easy to solve
q we rty uiop</pre>
<div><strong>Sample Output:</strong></div>
<pre class="brush: plain; title: ; notranslate">
siht is a ortsh encesent
siht oniptrycen is lame
racecar
tset msleobpr are ttypre easy to solve
q we rty uiop
</pre>
<p><strong>The code (C++):</strong></p>
<pre class="brush: cpp; title: ; notranslate">
//============================================================================
// Name        : reverse-cpp.cpp
// Author      : Francesco Laurita
// Version     : 1.0
// Copyright   : Francesco Laurita
// Description :
//============================================================================

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;math.h&gt;
#include &lt;vector&gt;
using namespace std;

string apply(string in, int pos){
	int slen = in.length();
	if (slen &lt;= pos){
		return in;
	}else{
		int mid = ceil(slen / 2);
		string right = in.substr(mid,slen);
		string left  = in.substr(0,mid);
		return apply(right,pos) + apply(left,pos);
	}
}
int main(int argc, char **argv) {

	ifstream fp(argv[1]);
	if (!fp){
		cerr &lt;&lt; &quot;Unble to open file!&quot; &lt;&lt; endl;
		return 1;
	}
	int nlines;
	fp &gt;&gt; nlines;
	fp.ignore();
	for (int i = 0; i &lt; nlines; i++){
		string line,tok;
		getline(fp,line);
		stringstream ss(line);
		vector&lt;string&gt; tokens;
		int j = 1;
		while (ss &gt;&gt; tok){
			tokens.push_back(apply(tok,j));
			j++;
		}
		for (vector&lt;string&gt;::iterator it = tokens.begin(); it != tokens.end(); ++it){
			cout &lt;&lt; *it;
			if (it != tokens.end()-1)
				cout &lt;&lt; &quot; &quot;;
		}
		tokens.empty();
		cout &lt;&lt; endl;
	}
	fp.close();
	return 0;
}
</pre>
<p>Code is also available on pastebin:Â <a href="http://pastebin.com/nW2KBiyZ">http://pastebin.com/nW2KBiyZ</a></p>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2011/01/24/facebook-hacker-cup-reverser-solution-facebook-hacker-cup-test-round/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ma vieni!</title>
		<link>http://francesco-laurita.info/wordpress/2010/11/02/ma-vieni/</link>
		<comments>http://francesco-laurita.info/wordpress/2010/11/02/ma-vieni/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 19:02:51 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/?p=114</guid>
		<description><![CDATA[Non aggiornavo il mio blog da anni! Da quando i blog si sono svalutati, da quando Facebook, Twitter e tutti i social network hanno invaso la nostraÂ la mia quotidinitÃ . Non aggiorno un po&#8217; perchÃ¨ non ho nulla di particolarmente interessante da farvi leggere, Non aggiorno perchÃ¨ preferisco essere un &#8220;lurker&#8221;. Pubblico questo post unicamente per <a href='http://francesco-laurita.info/wordpress/2010/11/02/ma-vieni/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Non aggiornavo il mio blog da anni! Da quando i blog si sono svalutati, da quando Facebook, Twitter e tutti i social network hanno invaso la nostraÂ la mia quotidinitÃ .</p>
<p>Non aggiorno un po&#8217; perchÃ¨ non ho nulla di particolarmente interessante da farvi leggere, Non aggiorno perchÃ¨ preferisco essere un &#8220;lurker&#8221;.</p>
<p>Pubblico questo post unicamente per testare gli ultimi upgrade di wordpres <img src='http://francesco-laurita.info/wordpress/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Cya!</p>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2010/11/02/ma-vieni/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pics-style (London-Stonehenge)</title>
		<link>http://francesco-laurita.info/wordpress/2007/02/19/pics-style-london-stonehenge/</link>
		<comments>http://francesco-laurita.info/wordpress/2007/02/19/pics-style-london-stonehenge/#comments</comments>
		<pubDate>Mon, 19 Feb 2007 15:49:25 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[pics]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/2007/02/19/pics-style-london-stonehenge/</guid>
		<description><![CDATA[UK: London , Stonehenge (Spring 2006)]]></description>
			<content:encoded><![CDATA[<p><a href="http://francesco-laurita.info/wordpress/pics-from-spring-2006-london-stonehenge/" title="London pics">UK: London , Stonehenge (Spring 2006)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2007/02/19/pics-style-london-stonehenge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Marco Deambrogio: Il giro del mondo in moto</title>
		<link>http://francesco-laurita.info/wordpress/2007/02/14/marco-deambrogio-il-giro-del-mondo-in-moto/</link>
		<comments>http://francesco-laurita.info/wordpress/2007/02/14/marco-deambrogio-il-giro-del-mondo-in-moto/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 21:56:59 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[books]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/2007/02/14/marco-deambrogio-il-giro-del-mondo-in-moto/</guid>
		<description><![CDATA[57.000 Kilometri in solitaria, 8 mesi a bordo di una due ruote.Questa Ã¨ l&#8217;ennesima avventura di Marco Deambrogio, un uomo che ha fatto della parola &#8220;avventura&#8221; una ragione di vita. Pagina dopo pagina vengo rapito, le parole lette si trasformano in immagini, focalizzo Marco sulla sua BMW che sfreccia sulle lunghe infinite strade, rapito dalla <a href='http://francesco-laurita.info/wordpress/2007/02/14/marco-deambrogio-il-giro-del-mondo-in-moto/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://francesco-laurita.info/wordpress/wp-content/uploads/2007/02/libro.jpg" alt="Marco Deambrogio" align="left" /> 57.000 Kilometri in solitaria, 8 mesi a bordo di una due ruote.Questa Ã¨ l&#8217;ennesima avventura di <a href="http://www.marcodeambrogio.com" target="_blank">Marco Deambrogio</a>, un uomo che ha fatto della parola &#8220;avventura&#8221; una ragione di vita.</p>
<p>Pagina dopo pagina vengo rapito, le parole lette si trasformano in immagini, focalizzo Marco sulla sua BMW che sfreccia sulle lunghe infinite strade, rapito dalla solitudine, dai giri del motore e dall&#8217;irrefrenabile voglia di scoprire cosa si nasconde dietro la prossima curva.<br />
Poi ci sono io, sulla mia moto, e come Marco alzo di tanto in tanto la visiera per odorare sfuggenti profumi dei luoghi che ho attaversato. Non posso fare a meno di sentirmi in sintonia, di capirlo dal profondo dell&#8217;anima.</p>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2007/02/14/marco-deambrogio-il-giro-del-mondo-in-moto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fortune approda sul telefonino!</title>
		<link>http://francesco-laurita.info/wordpress/2007/02/14/fortune-approda-sul-telefonino/</link>
		<comments>http://francesco-laurita.info/wordpress/2007/02/14/fortune-approda-sul-telefonino/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 09:39:00 +0000</pubDate>
		<dc:creator>Francesco</dc:creator>
				<category><![CDATA[hacking]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[work_stuff]]></category>

		<guid isPermaLink="false">http://francesco-laurita.info/wordpress/2007/02/14/fortune-approda-sul-telefonino/</guid>
		<description><![CDATA[Su Linux esiste il programma &#8220;fortune&#8221; che, proprio come farebbe un &#8220;biscottino della fortuna&#8221;, mostra frasi, detti, leggi e magari qualche insulto sul tuo terminale. &#8220;Fortune&#8221; si fa piccolo piccolo e arriva sul tuo cellulare Continua&#8230;]]></description>
			<content:encoded><![CDATA[<p>Su Linux esiste il programma &#8220;fortune&#8221; che, proprio come farebbe un &#8220;biscottino della fortuna&#8221;, mostra frasi, detti, leggi e magari qualche insulto sul tuo terminale.</p>
<p>&#8220;Fortune&#8221; si fa piccolo piccolo e arriva sul tuo cellulare <img src='http://francesco-laurita.info/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p align="center"> <a href="http://francesco-laurita.info/wordpress/wp-content/uploads/2007/02/screen-mobile.png" title="Screenshot mobile"><img src="http://francesco-laurita.info/wordpress/wp-content/uploads/2007/02/screen-mobile.thumbnail.png" alt="Screenshot mobile" /></a></p>
<p><a href="http://francesco-laurita.info/wordpress/fortune-for-mobile/">Continua&#8230;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://francesco-laurita.info/wordpress/2007/02/14/fortune-approda-sul-telefonino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

