<?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>Atomocopter</title>
	<atom:link href="http://kutterer.at/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://kutterer.at</link>
	<description>Explore the formidable net with the Atomocopter</description>
	<lastBuildDate>Tue, 15 Sep 2009 17:51:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use the same mouse and keyboard on different computers</title>
		<link>http://kutterer.at/?p=33</link>
		<comments>http://kutterer.at/?p=33#comments</comments>
		<pubDate>Sun, 16 Aug 2009 16:28:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://kutterer.at/blog/?p=33</guid>
		<description><![CDATA[Today I write about a fine piece of software, which helps a lot to improve your workflow. My desktop consists of several computers, depending on what I&#8217;m working. Very often I ended up with 2 keyboards, one mouse and a notebook, chaos on my desk! But not anymore! I found Synergy to be a great [...]]]></description>
			<content:encoded><![CDATA[<p>Today I write about a fine piece of software, which helps a lot to improve your workflow. My desktop consists of several computers, depending on what I&#8217;m working. Very often I ended up with 2 keyboards, one mouse and a notebook, chaos on my desk! But not anymore! I found Synergy to be a great solution for my problem. Now it&#8217;s almost like I have a second display connected to my main computer. But actually I have two displays (PC, notebook) with two separate computers, each providing CPU capacity. And I even can copy and paste between both of them.</p>
<p>The main work is done by an open source program called <a href="http://synergy2.sourceforge.net/">Synergy</a>. With <a href="http://code.google.com/p/quicksynergy/">QuickSynergy</a>, which provides a GUI for Synergy, the configuration part is done within a few seconds.</p>
<p>To be set up on Ubuntu just do:<br />
<code>sudo apt-get install synergy<br />
sudo apt-get install quicksynergy</code><br />
Launch QuickSynergy on both computers, the one with pluged keyboard and mouse will act as server, the others will be clients. You have to refer to your clients by their host names, IP-adress won&#8217;t work. So make sure your server has a proper <em>/etc/hosts</em> file. Here you can read more about it: <a href="http://gnuski.blogspot.com/2008/02/quicksynergy-quick-howto.html">gnuski.blogspot.com</a>. The interface looks slightly different than on these screenshots, but that&#8217;s not really important.</p>
<p>A side effect is: according to Anton Olsen&#8217;s article on <a href="http://www.wired.com/geekdad/2009/07/100-basic-geek-skills-for-geeks/">Wired</a> this is another step towards complete geekness. Well, with QuickSynergy this is an easy point. <img src='http://kutterer.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kutterer.at/?feed=rss2&amp;p=33</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convex hull with Graham scan</title>
		<link>http://kutterer.at/?p=17</link>
		<comments>http://kutterer.at/?p=17#comments</comments>
		<pubDate>Wed, 05 Aug 2009 13:30:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://kutterer.at/blog/?p=17</guid>
		<description><![CDATA[The convex hull of a finite set of points M can be understood as the minimal convex set which still contains M. A more detailed definition can be found at Wikipedia. One of the best known algorithms to calculate the convex hull is the Graham scan. This algorithm finds a valid solution with a time [...]]]></description>
			<content:encoded><![CDATA[<p>The convex hull of a finite set of points <em>M</em> can be understood as the minimal convex set which still contains <em>M</em>. A more detailed definition can be found at <a href="http://en.wikipedia.org/wiki/Convex_hull">Wikipedia</a>. One of the best known algorithms to calculate the convex hull is the Graham scan. This algorithm finds a valid solution with a time complexity of O(n*log n). The theory behind this algorithm can be found on the web, again the article on <a href="http://en.wikipedia.org/wiki/Graham_scan">Wikipedia</a> is a good point to start.</p>
<p>I implemented this algorithm quick and dirty in Python, here&#8217;s the code:</p>
<p><code><br />
def theta(p0,p1):<br />
&nbsp;&nbsp;        """Actually not an angle but has the same ordering functionality."""<br />
&nbsp;&nbsp;        dx = p1[0] - p0[0]<br />
&nbsp;&nbsp;        dy = p1[1] - p0[1]<br />
&nbsp;&nbsp;        ax = abs(dx)<br />
&nbsp;&nbsp;        ay = abs(dy)<br />
&nbsp;&nbsp;        t=0 if dx==0 and dy == 0 else dy/(ax+ay)<br />
&nbsp;&nbsp;        if dx<0:<br />
&nbsp;&nbsp;&nbsp;&nbsp;                t=2-t<br />
&nbsp;&nbsp;        elif dy<0:<br />
&nbsp;&nbsp;&nbsp;&nbsp;                t=4+t<br />
&nbsp;&nbsp;        return t*90<br />
</code><code><br />
def ccw(p0,p1,p2):<br />
&nbsp;&nbsp;        """clockwise: <0, linear: =0, counter-clockwise: >0"""<br />
&nbsp;&nbsp;        return (p1[0]-p0[0])*(p2[1]-p0[1]) - (p1[1]-p0[1])*(p2[0]-p0[0])<br />
</code><code><br />
def chull(point_set):<br />
&nbsp;&nbsp;        num = len(point_set)<br />
&nbsp;&nbsp;        # get lowest point<br />
&nbsp;&nbsp;        x,y = zip(*point_set)<br />
&nbsp;&nbsp;        min_y = y.index(min(y))<br />
&nbsp;&nbsp;        point_set[0], point_set[min_y] = point_set[min_y], point_set[0]<br />
&nbsp;&nbsp;        # sort by angle<br />
&nbsp;&nbsp;        point_set[1:] = sorted(point_set[1:],<br />
&nbsp;&nbsp;&nbsp;&nbsp;                lambda i,j: cmp(theta(point_set[0],i),theta(point_set[0],j)))<br />
&nbsp;&nbsp;        point_set.insert(0,point_set[-1])<br />
&nbsp;&nbsp;        current = 2<br />
&nbsp;&nbsp;        hull = point_set[0:2]<br />
&nbsp;&nbsp;        for i in range(current, num+1):<br />
&nbsp;&nbsp;&nbsp;&nbsp;                while ccw(point_set[current],point_set[current-1],<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        point_set[i]) >= 0:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        hull.pop()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        current -= 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;                hull.append(point_set[current])<br />
&nbsp;&nbsp;&nbsp;&nbsp;                current +=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;                point_set[current],point_set[i] = point_set[i],point_set[current]<br />
&nbsp;&nbsp;        return hull<br />
</code></p>
<p><a href="http://blog.kutterer.at/wp-content/uploads/2009/08/conv_hull_plot.png"><img class="aligncenter size-full wp-image-24" title="conv_hull_plot" src="http://blog.kutterer.at/wp-content/uploads/2009/08/conv_hull_plot.png" alt="conv_hull_plot" width="317" height="338" /></a></p>
<p>I've written a small plotter tool in Tkinter to visualize what chull does. The green circles mark extremal points. My implementation actually works but has problems when it doesn't get a <em>set</em> of points. If a point appears in the input data (list of tuples) more than once (especially min_y) the program breaks with a "IndexError: pop from empty list". I took theta from one of Sedgewicks books (Algorithms), note that this function doesn't return an euclidean angle.</p>
]]></content:encoded>
			<wfw:commentRss>http://kutterer.at/?feed=rss2&amp;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logic puzzle: How to disarm a bomb with Prolog</title>
		<link>http://kutterer.at/?p=7</link>
		<comments>http://kutterer.at/?p=7#comments</comments>
		<pubDate>Wed, 29 Jul 2009 14:51:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[logic]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[prolog]]></category>
		<category><![CDATA[puzzle]]></category>

		<guid isPermaLink="false">http://kutterer.at/blog/?p=7</guid>
		<description><![CDATA[While fooling around with Prolog I remembered the wonderful puzzle site of Angela and Otto Janko. They provide a huge collection of puzzles, riddles, sudokus and other stuff. Even though the page is in german it&#8217;s a wonderful resource to challenge your brain. I found a simple logic puzzle called &#8220;Die Bombe&#8220;, and of course [...]]]></description>
			<content:encoded><![CDATA[<p>While fooling around with <a href="http://www.swi-prolog.org" target="_blank">Prolog</a> I remembered the wonderful puzzle site of Angela and Otto <a href="http://www.janko.at">Janko</a>. They provide a huge collection of puzzles, riddles, sudokus and other stuff. Even though the page is in german it&#8217;s a wonderful resource to challenge your brain. I found a simple logic puzzle called &#8220;<a href="http://www.janko.at/Raetsel/Logik/012.a.htm">Die Bombe</a>&#8220;, and of course I tried to disarm the bomb. With Prolog! <img src='http://kutterer.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here&#8217;s the riddle (translated) and my solution:</p>
<p>The bomb has 7 flip switches. To disarm the bomb you must put the switches in their correct position. And you got this inforamtions: the bomb detonates when:</p>
<ol>
<li>if switch 3 is on plus 2 and 4 are off, boom!</li>
<li>if 1 and 4 off plus 7 is on, boom!</li>
<li>if 1, 3 and 4 are off, boom!</li>
<li>if 6 is off plus 2 and 3 are on, boom!</li>
<li>if 4 and 3 are on, boom!</li>
<li>if 6 is on and if, as long as 7 is on, 1 is on too, boom!</li>
<li>if 6 is on and, provided 7 is on, 1 is on too, boom!</li>
<li>if 1 and 5 are on plus 7 is off, boom!</li>
<li>if 3 is off plus 4 and 5 are on, boom!</li>
<li>if 1 and 7 are on, boom!</li>
<li>if 5 off and if, as long as 2 and 6 are on, 3 is on too, boom!</li>
<li>if 7 off plus 3 or 4 on, boom!</li>
<li>if switch 6 and 7 are in different positions, boom!</li>
<li>if switch 2, 3 and 5 are off, boom!</li>
<li>if switch 1 and 2 are on and switch 5 and 7 are off, boom!</li>
<li>if 6 and 7 are off, boom!</li>
</ol>
<p>So we are looking for a binary 7-digit permutation. Transcoded to facts we see that none of the following combinations is allowed:<br />
<code><br />
%     1 2 3 4 5 6 7<br />
boom([_,0,1,0,_,_,_]).<br />
boom([0,_,_,0,_,_,1]).<br />
boom([0,_,0,0,_,_,_]).<br />
boom([_,1,1,_,_,0,_]).<br />
boom([_,_,1,1,_,_,_]).<br />
boom([1,_,_,_,_,1,1]).<br />
boom([1,_,_,_,1,_,0]).<br />
boom([_,_,0,1,1,_,_]).<br />
boom([1,_,_,_,_,_,1]).<br />
boom([_,1,1,_,0,1,_]).<br />
boom([_,_,1,1,_,_,0]).<br />
boom([_,_,_,_,_,0,1]).<br />
boom([_,_,_,_,_,1,0]).<br />
boom([_,0,0,_,0,_,_]).<br />
boom([1,1,_,_,0,_,0]).<br />
boom([_,_,_,_,_,0,0]).<br />
</code></p>
<p>The first idea was to generate all possible permutations (with the command permutation/2) and compare them with the given facts. This gives proper solutions, but it is very slow. Here the according code:<br />
<code><br />
% defuse([A,B,C,D,E,F,G]) :-<br />
%     permutation([A,B,C,D,E,F,G,_,_,_,_,_,_,_],[0,0,0,0,0,0,0,1,1,1,1,1,1,1]),<br />
%     not(boom([A,B,C,D,E,F,G])).<br />
</code><br />
And here&#8217;s my optimized defuser:<br />
<code><br />
defuse([A,B,C,D,E,F,G]) :-<br />
per_bin([_,_,_,_,_,_,_],[A,B,C,D,E,F,G]),<br />
not(boom([A,B,C,D,E,F,G])).<br />
per_bin([],[]).<br />
per_bin([X|Xs],[X|Ys]) :- member(X,[0,1]), per_bin(Xs,Ys).<br />
</code></p>
<p>Finally here&#8217;s the file. Note: my provider wont let you download .pl-files, so I renamed it. <a href="http://kutterer.at/blog/wp-content/uploads/2009/07/bombp.txtl">bomb.pl</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kutterer.at/?feed=rss2&amp;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vim &#8211; How to get control over line length in your files</title>
		<link>http://kutterer.at/?p=3</link>
		<comments>http://kutterer.at/?p=3#comments</comments>
		<pubDate>Thu, 04 Jun 2009 16:10:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://kutterer.at/blog/?p=3</guid>
		<description><![CDATA[When editing files with vim the length of your lines is only limited by your machine. Looking at the documentation a line can have a length of at least 32767 characters. But it&#8217;s annoying to read or edit files without reasonable set line breaks, so how can we limit the length of a line to [...]]]></description>
			<content:encoded><![CDATA[<p>When editing files with vim the length of your lines is only limited by your machine. Looking at <a href="http://www.vim.org/htmldoc/vi_diff.html">the documentation</a> a line can have a length of <em>at least</em> 32767 characters. But it&#8217;s annoying to read or edit files without reasonable set line breaks, so how can we limit the length of a line to a more useful amount of characters? With the command <strong>:set tw=72</strong> you can set the text width to 72 chars for newly inserted text. This will not affect lines which already exist in your file, though. Every time your line reaches a length of 72 characters vim will insert automatically a new line.</p>
<p>To reformat already existing text in your files you can use <strong>gq</strong>, followed by a movement, for example the amount of lines you want to change. So if you want to reformat your whole file just press <strong>gggqG</strong> (<strong>gg</strong> jumps to the head of the file, <strong>G</strong> to the bottom). Another trick is to use visual mode, if you want to reformat only one paragraph (all lines between to blank lines) try the following: <strong>vipgq</strong>.</p>
<p>Joining two lines is easy too, just move the cursor to the proper line and hit <strong>J</strong>. Again you can combine this with visual mode (<strong>vipJ</strong>).</p>
]]></content:encoded>
			<wfw:commentRss>http://kutterer.at/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

