<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0"><id>tag:blogger.com,1999:blog-3263316935908175537</id><updated>2025-02-20T12:22:40.028+05:30</updated><category term="math"/><category term="programming"/><category term="program"/><category term="perl"/><category term="Algorithms"/><category term="linux"/><category term="palindrome"/><category term="palindromic number"/><category term="prime"/><category term="project euler"/><category term="stocks"/><category term="technology"/><category term="C#"/><category term="DefineMyWord"/><category term="GRE"/><category term="IDE"/><category term="application"/><category term="apropos"/><category term="artificial intelligence"/><category term="beginner"/><category term="blogging"/><category term="c"/><category term="captcha"/><category term="command line"/><category term="compiler"/><category term="computers"/><category term="cool"/><category term="data"/><category term="diversification"/><category term="economics"/><category term="finance"/><category term="google"/><category term="interesting"/><category term="internet"/><category term="interpreter"/><category term="lisp"/><category term="mac"/><category term="man"/><category term="metcalfe"/><category term="online"/><category term="pc"/><category term="popularity"/><category term="posting"/><category term="probability"/><category term="resources"/><category term="review"/><category term="self development"/><category term="small numbers"/><category term="software"/><category term="song list"/><category term="speeds"/><category term="spoj"/><category term="success recipe"/><category term="unix"/><category term="usability"/><category term="web2.0"/><category term="websites"/><title type="text">The Tao of Programming</title><subtitle type="html">A weblog of algorithms, analyses, adventures and anecdotes from a lover of Math and Programming. 
&lt;br&gt;
(If your device has problems displaying this blog properly, try using &lt;a href="http://goo.gl/MUyY"&gt;http://goo.gl/MUyY&lt;/a&gt;)</subtitle><link href="http://thetaoishere.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default?redirect=false" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/" rel="alternate" type="text/html"/><link href="http://pubsubhubbub.appspot.com/" rel="hub"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default?start-index=26&amp;max-results=25&amp;redirect=false" rel="next" type="application/atom+xml"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><generator uri="http://www.blogger.com" version="7.00">Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><xhtml:meta content="noindex" name="robots" xmlns:xhtml="http://www.w3.org/1999/xhtml"/><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-4549419308392240319</id><published>2012-10-01T02:29:00.001+05:30</published><updated>2012-10-01T02:29:22.156+05:30</updated><title type="text">An Android design flaw and how ADB saved the day</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; My little cousins (5 years and 8 years old) love to play games on my Nexus One - Angry Birds is their latest favorite. However, they have their mid-term examinations going on, and as per their mother's request, I attempted to restrict their game time. Unfortunately, even the little 5 year old is tech savvy enough to unlock the simple slide-to-unlock screen. So, I had to resort to the pattern unlock, which is where the problems started.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Usually, they bring the mobile to me to unlock, I unlock it if it's their break time from studying, and all goes well. Today, however, the little one today decided it was time to become a rebel and try to break the security. She kept on trying different patterns, even persisting through the 'Wait 30 seconds' message, while I was busy elsewhere. Finally, my Android had had enough, and said 'Too many pattern attempts', and asked for my Google login and password.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Now again, I should have been able to give my username and password, set a new pattern and go on my way. However, there were two things combined to make things not so easy: my mobile had both GPRS data and WiFi turned off, and I had enable two-factor auth for my account. Because of the latter, my actual Gmail password did not work in the unlock page, and because of the former, even disabling two-factor auth in my Google account from my laptop made no change. I also tried a few other "solutions" given online such as:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;trying the password 'null' (without quotes)&lt;/li&gt;
&lt;li&gt;calling the mobile from some other number, accessing the notifications area from the incoming call screen, hoping you have some message or mail notifications, finding a clever way to go to the Settings screen from there (this one failed right at the beginning - the notifications area couldn't be opened from the incoming (or ongoing) call screen)&lt;/li&gt;
&lt;li&gt;pressing the menu key repeatedly while the OS is booting up&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; None of these were of any help, and I had at this stage started cursing Android for this poor design and even started thinking maybe an iPhone wasn't such a bad idea after all (blasphemy!).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Finally, my incessant searching led to a forum post that linked to &lt;a href="http://www.androidtablets.net/forum/android-tablet-usage-tips-tricks/6280-forgot-your-unlock-pattern.html"&gt;this post&lt;/a&gt; which started me on the right path. However, the stuff about factory reset at the end of it was pretty discouraging, and the method mentioned seemed pretty ugly too. I kept searching further, which led me to &lt;a href="http://forum.xda-developers.com/showthread.php?t=1913156"&gt;this page&lt;/a&gt;. Combining the info on these two posts, I was able to get my phone unlocked and breathe a sigh of accomplishment! These were my steps:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;I wasn't sure I had USB debugging enabled, but anyway tried connecting the mobile to my laptop.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;I then went to the tools folder under my android-sdk-windows (I already had the Android SDK installed) directory in the Windows command line&lt;/li&gt;
&lt;li&gt;I tried the 'adb devices' command. Thankfully, it listed one device as currently attached. That meant USB debugging was enabled and adb could talk to my device&lt;/li&gt;
&lt;li&gt;Next, I opened the adb shell with 'adb -d shell', and the # prompt popped up&lt;/li&gt;
&lt;li&gt;Then, I opened the settings.db in sqlite as 'sqlite3 data/data/com.android.providers.settings/databases/settings.db'&lt;/li&gt;
&lt;li&gt;By this time, I'd come to know that the mobile_data setting that controls whether the device connects to GPRS data services used to be in the 'system' database table in old Android versions, but has moved to the 'secure' table now. I didn't know which table had it in my phone, so I first tried 'select value from system where name="mobile_data";'. This printed out my input itself, which I guessed to mean no such row in the table (bad design in SQLite here?)&lt;/li&gt;
&lt;li&gt;Now, I tried 'select value from secure where name="mobile_data";'. This time, it printed out 0, which meant mobile_data was in this table and was set to 0, thus disabling GPRS access.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;I set the above value to 1 with 'update secure set value=1 where name="mobile_data";'&lt;/li&gt;
&lt;li&gt;I then finished it off with '.exit', then 'exit', then 'adb reboot'. &lt;/li&gt;
&lt;/ol&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; When the device rebooted now, it had a GPRS data connection on and working. Phew. Now I tried my original Google password (since I had disabled 2-factor auth temporarily), the device checked it with the Google servers and deigned to allow me in. Yay!&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; So, despite my complaints about Android and the iPhone fantasies, it's Android's hackability and openness that allowed me to find a solution much less onerous than a hard reset of the device. That, however, in no way excuses Android's poor design in this area; off the top of my head, one solution would be to special case the Internet access from this lock screen and enable data and WiFi when the username-password check fails once - there are probably much better solutions the fellas at Google could come up with, if only they paid a little attention to this. Also, there doesn't seem to be any option to increase the number of pattern attempts before Android pops this annoying page up - with there being &lt;a href="http://www.quora.com/How-many-combinations-does-Android-9-point-unlock-have"&gt;389112 distinct patterns&lt;/a&gt;, I'd gladly allow 100 attempts before assuming someone's trying to hack my mobile.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; My moral from this story has been to save the application-specific password of my mobile somewhere safe, and to always have USB debugging enabled in the mobile. What's yours?&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link href="http://thetaoishere.blogspot.com/feeds/4549419308392240319/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/4549419308392240319" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4549419308392240319" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4549419308392240319" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2012/10/an-android-design-flaw-and-how-adb.html" rel="alternate" title="An Android design flaw and how ADB saved the day" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-5318119432554727271</id><published>2010-05-07T02:08:00.000+05:30</published><updated>2010-05-07T02:08:24.679+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="compiler"/><category scheme="http://www.blogger.com/atom/ns#" term="IDE"/><category scheme="http://www.blogger.com/atom/ns#" term="interpreter"/><category scheme="http://www.blogger.com/atom/ns#" term="online"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type="text">Online compiler/interpreter/IDE</title><content type="html">&lt;br /&gt;
I had been using &lt;b&gt;&lt;a href="http://www.codepad.org/"&gt;www.codepad.org&lt;/a&gt;&lt;/b&gt; whenever I wanted to run a piece of code and didn't have the required compiler/interpreter in the system I was using. But the main disadvantage with this was that you cannot read input from the user while using this site - scanf(), cin, &amp;lt;STDIN&amp;gt;, etc. (in C, C++, Perl respectively) are promptly ignored. This was often an irritation since I'd have to modify my program to not take an input before testing there, which might not be an easy process (especially given complex data structures).&lt;br /&gt;
&lt;br /&gt;
Today, I came across &lt;b&gt;&lt;a href="http://ideone.com/"&gt;http://ideone.com&lt;/a&gt;&lt;/b&gt;, which is very similar to the above, except that it &lt;b&gt;allows providing input to the program&lt;/b&gt;! Yay! You type (or paste) the program in a text area as in codepad, choose your language from the list, and then click on "click here to paste input (stdin) or additional note". Whatever you type here becomes the input to your program. That's a neat solution to the problem of providing input to remotely-evaluated programs.&lt;br /&gt;
And it supports "more than 40 languages", including Assembler, Common Lisp, and even Whitespace (of course the boring old C, C++, Java, Perl, Python, etc. are there too). It has other goodies like syntax highlighting for all these languages, 'private' pasting for times when you don't want others to see the code, etc. The site is quite very well done. &lt;br /&gt;
&lt;br /&gt;
While we're in the topic, let me also add two more online code evaluation tools (compilers/interpreters):&lt;br /&gt;
&lt;br /&gt;
* &lt;a href="http://lotrepls.appspot.com/"&gt;Lord of the REPLs&lt;/a&gt;: This is a Read-Eval-Print-Loop from Google, where each line you enter is evaluated immediately. Despite the fancy "Lord" name and the Google brand, I haven't found this very useful mainly because: it doesn't preserve function definitions or variables' values after you evaluate them, unlike other REPLs. This makes it hard to run anything more than trivial "hello world" programs. Also, I found it quite buggy at times. &lt;br /&gt;
&lt;br /&gt;* "&lt;a href="http://f9.muktosource.com/"&gt;Compile &amp;amp; Execute&lt;/a&gt;": This is somewhat similar to ideone, allowing you to enter your own input and having a choice of a similar number of languages. However, it doesn't have a 'private' pasting option, and has syntax highlighting for only a few languages. This leads to weird highlighting at times: if you choose to paste Perl code, the Highlight choice remains in cpp (which is the default), so your Perl code gets highlighted as C++ code! Sloppy design like this makes me think this site might not be very well designed.&lt;br /&gt;
&lt;br /&gt;
These two are the only generic code evaluation tools I could find. If you find that none of these do it for you, try googling for something specific to your language. For example, for Python, searching for 'python online (IDE OR compiler OR interpreter)' gives a lot of good results. &lt;br /&gt;
&lt;br /&gt;
If you know some other online code evaluation tool, or have experience with any of the above, do share it in the comments. Thanks!&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;div class="left"&gt;

       &lt;/div&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/5318119432554727271/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/5318119432554727271" rel="replies" title="8 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/5318119432554727271" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/5318119432554727271" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2010/05/online-compilerinterpreteride.html" rel="alternate" title="Online compiler/interpreter/IDE" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-1276553128199480925</id><published>2010-04-01T03:51:00.001+05:30</published><updated>2010-04-01T04:09:21.347+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="perl"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="song list"/><category scheme="http://www.blogger.com/atom/ns#" term="unix"/><title type="text">Songs list from files list</title><content type="html">I had a list of mp3 files like:&lt;br /&gt;
&lt;br /&gt;
ANBE_VAA_ARUGILE.MP3    &lt;br /&gt;
ANBU_THAYAE.MP3    &lt;br /&gt;
ANDANVAN_THEANAKTRU.MP3    &lt;br /&gt;
ANNANENNA.MP3&lt;br /&gt;
&lt;br /&gt;
and wanted the list of song names from this… What shall we do?&lt;br /&gt;
&lt;br /&gt;
* Open Cygwin (Unix emulator within Windows), navigate to that folder, do:   &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ls | cut -d. -f1 |&amp;nbsp; sed –e 's/_/ /g'&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;b&gt;l&lt;/b&gt;i&lt;b&gt;s&lt;/b&gt;t the files in this directory, &lt;b&gt;cut&lt;/b&gt; and extract the &lt;b&gt;1&lt;/b&gt;st &lt;b&gt;f&lt;/b&gt;ield with &lt;b&gt;d&lt;/b&gt;elimiter as &lt;b&gt;.&lt;/b&gt; character, then &lt;b&gt;s&lt;/b&gt;ubstitute space character in place of &lt;b&gt;_&lt;/b&gt; character &lt;b&gt;g&lt;/b&gt;lobally. In other words, get the actual filename removing the .mp3 extension, then replace underscores with spaces.&lt;br /&gt;
&lt;br /&gt;
* Save the above output to a file&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Actually this too should be a part of the above step, like:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ls | cut -d. -f1 |&amp;nbsp; sed –e 's/_/ /g' &amp;gt; ./songnames.txt&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The file songnames.txt now has:&lt;br /&gt;
&lt;br /&gt;
ANBE VAA ARUGILE   &lt;br /&gt;
ANBU THAYAE    &lt;br /&gt;
ANDANVAN THEANAKTRU    &lt;br /&gt;
ANNANENNA&lt;br /&gt;
&lt;br /&gt;
* Open the file in &lt;a href="http://www.vim.org/" title="The world's best text editor! Maybe..."&gt;Vim&lt;/a&gt; editor, and select all the text by pressing &lt;b&gt;ggVG&lt;/b&gt;. Then, press &lt;b&gt;:&lt;/b&gt; to enter command mode, and Vim will show :’&amp;lt;,’&amp;gt; and wait for your input. Type this:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; !perl –lpe "@words = map { ucfirst(lc($_)) } split; $_ = join(\" \", @words)"&lt;br /&gt;
and press enter, and voila, the list has become:&lt;br /&gt;
&lt;br /&gt;
Anbe Vaa Arugile   &lt;br /&gt;
Anbu Thayae    &lt;br /&gt;
Andanvan Theanaktru    &lt;br /&gt;
Annanenna&lt;br /&gt;
&lt;br /&gt;
Beautiful, isn't it? &lt;br /&gt;
Thank God, Unix exists! :)&lt;br /&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/1276553128199480925/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/1276553128199480925" rel="replies" title="2 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/1276553128199480925" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/1276553128199480925" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2010/04/songs-list-from-files-list.html" rel="alternate" title="Songs list from files list" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-7765497694842840136</id><published>2010-03-15T03:07:00.000+05:30</published><updated>2010-03-15T03:07:31.376+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="application"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="DefineMyWord"/><category scheme="http://www.blogger.com/atom/ns#" term="GRE"/><title type="text">Application to fetch Wiktionary definitions</title><content type="html">I am preparing for GRE, and am using &lt;a href="http://ichi2.net/anki/"&gt;Anki &lt;/a&gt;for learning. However, the definitions Anki gives are not very good (that is, the GRE 'card deck' available to use within Anki is not very good), so for every word I'm having to refer Wiktionary to understand it better.&lt;br /&gt;
&lt;br /&gt;
I got lazy to every time copy the word, type wiktionary in Firefox's address bar, and edit the URL to paste the new word. So, I created a small application to do most of the grunt work for me.&lt;br /&gt;
&lt;br /&gt;
Copying the word with Ctrl-C I still have to do, but the rest of the work I can now invoke with a simple shortcut Ctrl-Alt-D. D for Define.&lt;br /&gt;
&lt;br /&gt;
The application executable is available at &lt;a href="http://github.com/sundaryourfriend/DefineMyWord/blob/master/DefineMyWord/bin/Debug/DefineMyWord.exe"&gt;http://github.com/sundaryourfriend/DefineMyWord/blob/master/DefineMyWord/bin/Debug/DefineMyWord.exe&lt;/a&gt;, though this one is built for my machine (64-bit Intel) and might not run on others. Give it a try if you feel like experimenting.&lt;br /&gt;
&lt;br /&gt;
I created this app in C# to learn the language a little (learnt very little of it though). I've placed the code in a Git repository at &lt;a href="http://github.com/sundaryourfriend/DefineMyWord"&gt;http://github.com/sundaryourfriend/DefineMyWord&lt;/a&gt;. Yeah, I call it DefineMyWord for now, until I get a better name. :)&lt;br /&gt;
&lt;br /&gt;
It's probably terrible C# code, and there are a lot of rough edges: I couldn't get Alt-D to make it focus on the address bar (any help on this is welcome), it doesn't store previously opened URLs for now, etc.&lt;br /&gt;
&lt;br /&gt;
After I was deep into creating this app, I realized I could have made a much simpler app to open the Wiktionary page in Firefox when a shortcut was pressed, instead of trying to reinvent the wheel. However, I was too much into the project already, so I told myself that this way I'd be able to add features easily whenever I need. Hope I do add some. &lt;br /&gt;
&lt;br /&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/7765497694842840136/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/7765497694842840136" rel="replies" title="2 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7765497694842840136" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7765497694842840136" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2010/03/application-to-fetch-wiktionary.html" rel="alternate" title="Application to fetch Wiktionary definitions" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-506644120173533486</id><published>2010-03-10T02:19:00.001+05:30</published><updated>2010-03-10T02:30:38.483+05:30</updated><title type="text">Directory permissions in Unix</title><content type="html">There are umpteen pages in the net about permissions in Unix. This is not yet another one of them.&lt;br /&gt;
&lt;br /&gt;
Even after reading many of those umpteen pages, I couldn't remember what the permissions meant on &lt;i&gt;directories&lt;/i&gt;. This is because the names of the permissions are directly related to file operations, and their interpretation for directories is not very straightforward. Even Wikipedia says 'The effect of setting the permissions on a directory (rather than a 
file) is "one of the most frequently misunderstood file permission 
issues" (Hatch 2003).'. &lt;br /&gt;
&lt;br /&gt;
So here I'll try to explain them in a way we can remember.&lt;br /&gt;
You should already know this, but: Unix permissions are of three kinds - read, write, execute. On files, these have obvious meanings - whether you can read the contents of the file, whether you can write to the file, and whether you can execute the file (for example, if it was a script).&lt;br /&gt;
&lt;br /&gt;
Directories too have these permissions. What does 'read' permission on a directory mean? This is the easiest to answer and remember, provided you start thinking of directories as simply special files that have &lt;i&gt;lists&lt;/i&gt; of filenames within them. What does being able to 'read' such a file mean? It means you can get the list of files under the directory. That is, you just have been provided with permissions to see what all files are present under that directory. Note that this permission only means that you can get the &lt;i&gt;names&lt;/i&gt; of the files - reading the files themselves depends on other things. Think of it like this: you somehow get hold of a list of room numbers and names of girls staying in a ladies hostel - this would be the read permission on the directory. But that does not mean you can go and meet any of them, since (a) they might not be willing to meet you - you might not have read permissions on the files, or (b) the security at the hostel might not allow you - you might not have execute permission on the directory (this is explained below).&lt;br /&gt;
That's directory read permissions for you.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Next is the 'write' permission on a directory. Let's continue thinking of directories as special files with list of filenames stored. Then, what would it mean to have write permissions on such a special file? It would mean you could modify the entries in the list, delete entries and add new entries to it. So, a write permission on a directory means you can modify the &lt;i&gt;names &lt;/i&gt;of the files in it, delete files from it or create new files in it.&lt;br /&gt;
Note that with a write permission on a directory, you can change the &lt;i&gt;name&lt;/i&gt; of a file under it, but cannot change the &lt;i&gt;contents&lt;/i&gt; of the file (unless you have write permissions on the file too). Of the three kinds of permissions, write permissions are a little special in that they &lt;i&gt;sort of &lt;/i&gt;allow some modifications on the files - they allow you to rename the files, or delete them.&lt;br /&gt;
A lot of people mistakenly believe that if write permissions on a file are set to off, others cannot delete the file. Now on, hopefully you'll remember that it's the write permissions on the &lt;i&gt;parent directory&lt;/i&gt; that matters, not on the file itself.&lt;br /&gt;
&lt;br /&gt;
Ok finally, we've come to the 'execute' permissions on a directory. Huh? What can it mean to 'execute' a directory? Doesn't make any sense!&lt;br /&gt;
That's because it isn't meant to - they just had one permission name and one functionality left, so they mapped the two. So, what's the functionality here?&lt;br /&gt;
Now imagine the situation at the end of the 'read' permissions paragraph above again, but you don't have the list of room numbers or names with you.You won't have much luck trying to coerce the security into giving you a list of the names of the girls staying there. On the other hand though, if you knew the exact name and room number of a girl, you could tell him those details and ask him to request the girl to come and meet him. Having directory 'execute' permissions alone is like having such a security in front of the directory - if you know the exact path and filename of a file, you can access it, but if you don't, you're out of luck: you can't just peep into the directory and try to find what's there. &lt;br /&gt;
Whether the meeting actually happens depends upon the girl's willingness; and whether you can actually read the contents of the file depends upon the file's own read permissions.&lt;br /&gt;
When you &lt;b&gt;don't&lt;/b&gt; have execute permissions on a directory, it's as if the security was not a helpful person, and instead is a fat old lady who refuses to speak to you, and asks you to simply get out - girls in this hostel are not allowed to meet outsiders(!). &lt;br /&gt;
&lt;br /&gt;
Finally, let's try some combinations to make sure we understood things.&amp;nbsp;What if you have both read and execute permissions on a directory? Well, what if you got hold of a list of room numbers and names of girls, and also had a security in front of the hostel? You could look up any girl, tell the security her room number, and thus try to meet her. &lt;br /&gt;
What if you had read permissions on a directory but no execute permissions? Not much luck here, you got hold of a list of room numbers and names of the girls, but it's of no use - the fat old lady (remember, she appears whenever you don't have directory execute permissions) doesn't care about what details you have, so you have only the list to look at and sigh.&lt;br /&gt;
What does it mean to have read permissions on a file, but not have read or execute permissions on the directory? This means that even though the girl is willing to meet you, you can't find her room number. Worse, you would be blocked even if you somehow had it - the fat old lady again. One thing to remember is that you have to have permissions on &lt;i&gt;each&lt;/i&gt; directory in the path to the file. If the file was at /psgtech/mblock/512/myfile, then you should have permissions on each of the directories psgtech/, mblock/, and 512/. It's as if there was a sequence of securities at each stage to the room.&lt;br /&gt;
&lt;br /&gt;
I hope that explanation helped you understand directory permissions 
in Unix. Please leave a comment if some part of the explanation isn't 
clear.&lt;br /&gt;
&lt;br /&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/506644120173533486/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/506644120173533486" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/506644120173533486" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/506644120173533486" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2010/03/directory-permissions-in-unix.html" rel="alternate" title="Directory permissions in Unix" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-2431893980590098380</id><published>2010-02-12T16:17:00.001+05:30</published><updated>2010-02-12T21:05:51.469+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="computers"/><category scheme="http://www.blogger.com/atom/ns#" term="usability"/><title type="text">Why are computers unusable?!</title><content type="html">&lt;blockquote&gt;
"One of the basic problems with computers -- and one that CS has done depressingly little to address -- is that computers suck. Of course I don't mean they suck at computing, but rather that they suck
 to use." &lt;br /&gt;
"The present situation, where administration of a Windows/Linux machine is a near-impossible task for most users, is untenable."&amp;nbsp;&lt;/blockquote&gt;
&amp;nbsp;- from a comment on &lt;a href="http://geomblog.blogspot.com/2010/02/could-ipad-make-computer-science.html?showComment=1265053983296#c4148106381147745999"&gt;The Geomblog&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I too have been thinking, why are computers so complicated that you have learn so many things to just &lt;i&gt;use&lt;/i&gt; it ? To program the computer, you'd always need to learn things, but why have a big learning curve for users too? It's as if we had to learn car mechanics to drive a car! But things are getting better with time, and I hope and believe that the "appliance" computers they talk about in that post, computers where you plug it in and "it just works", aren't too far in the future. I love programming, but I love my users more - they are the reason my profession exists, and it's my duty to make things as easy as possible to them. &lt;br /&gt;
&lt;br /&gt;
(Why such a short post from my side? To steal from &lt;a href="http://www.arsmathematica.net/archives/2010/01/28/signatures/"&gt;Ars Mathematica&lt;/a&gt;&lt;br /&gt;
: "My normal tendency is to write &lt;span class="highlighted0"&gt;long&lt;/span&gt; &lt;span class="highlighted1"&gt;posts&lt;/span&gt; &lt;span class="highlighted2"&gt;that&lt;/span&gt; I &lt;span class="highlighted3"&gt;never&lt;/span&gt; finish.  I’ll start [...] with 
small &lt;span class="highlighted1"&gt;posts&lt;/span&gt; to see if I can break the habit.")</content><link href="http://thetaoishere.blogspot.com/feeds/2431893980590098380/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/2431893980590098380" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/2431893980590098380" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/2431893980590098380" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2010/02/one-of-basic-problems-with-computers.html" rel="alternate" title="Why are computers unusable?!" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-5120861933286635473</id><published>2009-11-11T05:21:00.012+05:30</published><updated>2009-11-11T05:41:46.808+05:30</updated><title type="text">Perl poetry</title><content type="html">&amp;nbsp;Perl is &lt;a href="http://www.wall.org/%7Elarry/natural.html"&gt;said &lt;/a&gt;to be close to natural language in many ways. But, can you write a poem in it that expresses your heart? Let's see:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="-moz-background-clip: border; -moz-background-inline-policy: continuous; -moz-background-origin: padding; background: rgb(255, 255, 255) none repeat scroll 0% 0%; color: black;"&gt;&lt;span style="color: maroon; font-weight: bold;"&gt;my&lt;/span&gt; $sweetheart&lt;span style="color: purple;"&gt;;&lt;/span&gt;
&lt;span style="color: maroon; font-weight: bold;"&gt;my&lt;/span&gt; $heart &lt;span style="color: #808030;"&gt;=&lt;/span&gt; $yours &lt;span style="color: maroon; font-weight: bold;"&gt;for&lt;/span&gt; $ever&lt;span style="color: purple;"&gt;;&lt;/span&gt;
&lt;span style="color: maroon; font-weight: bold;"&gt;do&lt;/span&gt; &lt;span style="color: purple;"&gt;{&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;accept&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;my&lt;/span&gt; $love&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;my&lt;/span&gt; $dear &lt;span style="color: purple;"&gt;}&lt;/span&gt;, &lt;span style="color: #808030;"&gt;or&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;kill&lt;/span&gt; $me&lt;span style="color: purple;"&gt;;&lt;/span&gt;

&lt;span style="color: maroon; font-weight: bold;"&gt;bless&lt;/span&gt; &lt;span style="color: #808030;"&gt;\&lt;/span&gt;$me&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;my&lt;/span&gt; $Lord&lt;span style="color: purple;"&gt;;&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;join&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;$us&lt;span style="color: #808030;"&gt;,&lt;/span&gt; $together&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;until&lt;/span&gt; eternity&lt;span style="color: purple;"&gt;;&lt;/span&gt; 
&lt;span style="color: #e34adc;"&gt;heaven:&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;our&lt;/span&gt; $home&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;wait&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;for&lt;/span&gt; $us&lt;span style="color: purple;"&gt;;&lt;/span&gt; 

&lt;span style="color: maroon; font-weight: bold;"&gt;my&lt;/span&gt; $soul&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;my&lt;/span&gt; $darling&lt;span style="color: #808030;"&gt;,&lt;/span&gt; say &lt;span style="color: #0000e6;"&gt;"I love you"&lt;/span&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;
let's&lt;span style="color: #808030;"&gt;,&lt;/span&gt; $honey&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;splice&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;@together&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;not&lt;/span&gt; &lt;span style="color: maroon; font-weight: bold;"&gt;split&lt;/span&gt; $ever&lt;span style="color: #808030;"&gt;,&lt;/span&gt;  
                                   &lt;span style="color: #808030;"&gt;and&lt;/span&gt; &lt;span style="color: #008484;"&gt;goto&lt;/span&gt; heaven&lt;span style="color: #808030;"&gt;,&lt;/span&gt; $together&lt;span style="color: purple;"&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Perl indeed does a good job, isn't it?&lt;br /&gt;
So, why am I into this crazy stuff suddenly? Well, there was &lt;a href="http://meetsharmi.blogspot.com/2009/11/love-is-language-between-two-hearts-for.html"&gt;this pos&lt;/a&gt;t in my friend Sharmi's blog that said:&lt;br /&gt;
&lt;blockquote&gt;
Love is the language between two hearts; for everything else there is C#&lt;br /&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
which is apparently a praise of C#. Well, I thought, why for everything &lt;i&gt;else &lt;/i&gt;only? :)&lt;br /&gt;
&lt;br /&gt;
The real deal here is that the above is valid Perl code, and when executed, prints "I love you" repeatedly on the screen. &lt;br /&gt;
&lt;br /&gt;
Now take &lt;i&gt;that&lt;/i&gt;, C#. :)&lt;br /&gt;
&lt;br /&gt;
*Execution instructions: You need Perl 5.10 or above, and probably need to enable the 'say' feature. If you saved the above program as perlpoetry.pl, the invocation might be: perl -Mfeature=say perlpoetry.pl&lt;br /&gt;
This would fill your screen with text, so be ready to press Ctrl-C immediately. :)&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
PS: I do like C#, and in fact think MS did a great service to humanity by relieving many developers from Java. It's just that I love Perl even more. ;)&lt;br /&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/5120861933286635473/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/5120861933286635473" rel="replies" title="8 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/5120861933286635473" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/5120861933286635473" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/11/perl-poetry.html" rel="alternate" title="Perl poetry" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-4315590008592388543</id><published>2009-10-23T01:54:00.002+05:30</published><updated>2009-10-23T01:57:38.134+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="data"/><category scheme="http://www.blogger.com/atom/ns#" term="internet"/><category scheme="http://www.blogger.com/atom/ns#" term="math"/><category scheme="http://www.blogger.com/atom/ns#" term="speeds"/><title type="text">The Internet vs a cycler</title><content type="html">&lt;p&gt;
I’ve been reading &lt;a href="http://www.amazon.com/gp/product/0201657880?ie=UTF8&amp;amp;tag=thta0f-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0201657880"&gt;Programming Pearls&lt;/a&gt;&lt;img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=thta0f-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0201657880" width="1" border="0" /&gt;for some time now. It’s a great book, the kind of book that makes you realize what programming really is about.&lt;/p&gt;
&lt;p&gt;
Among the exercises behind Column 6 in it, there was this strange problem: “At what distances can a courier on a bicycle with a reel of magnetic tape be a more rapid carrier of information than a telephone line that transmits 56,000 bits per second? Than a 1200-bps line?”&lt;/p&gt;
&lt;p&gt;
The thought that a bicycle can be faster than an electronic communication line seems ridiculous indeed, but it turns out it’s not difficult. For the sake of modernity, let’s replace the ‘magnetic tape’ with a hard disk. 1TB disks are common enough these days that I’ll use that for the calculations.&lt;/p&gt;
&lt;p&gt;
Now, let’s calculate the time taken for transmitting ‘g’ Gigabytes of data using both the bicycle method and an Internet line, between two places which are ‘d’ kilometres apart. In the bicycle method, we have two kinds of ‘time’s to consider: the time taken to transfer things to and from the hard disk, and the time taken in the bicycle itself. These days, data transfer rates in hard disks lies around 25MB/s from my experience, so I’ll use that as the transfer rate here. Then, 1 gigabyte will take 1GB/25MB ~= 40 seconds. For g GB, it is 40g seconds. This is for one transfer. Since we do this twice (transferring &lt;em&gt;to&lt;/em&gt; the hard disk, and later back &lt;em&gt;from&lt;/em&gt; it), it’d be 80g seconds in total. In addition, we have the time taken in the bicycle itself. Assuming a minimal speed of 10kmph by the bicycler, the time taken would be d/10 hours, which in seconds would be 360d. So, the total time is 360d + 80g. &lt;/p&gt;
&lt;p&gt;
For a 56kbps Internet line, the time taken for transferring the same g gigabytes would be&amp;#160; the upload time + download time. From &lt;a href="http://forums.cnet.com/5208-6122_102-0.html?threadID=25429"&gt;discussions&lt;/a&gt; in the Internet, it appears that upload speeds were “from 1/2 to less of the the download speed”. Of course, this is not ‘authoritative’, but is good enough for our purposes. The download speed here is 7KB/s (since 56kbps = 7KB/s). Let’s take the upper limit and take the upload speed to be half of download i.e. 3.5KB/s. Then, time taken = 1000,000g/3.5 + 1000,000g/7 seconds (since 1GB ~= 1000,000KB) = 3000,000g/7. So we’ve got to solve for d in:&lt;/p&gt;
&lt;p&gt;
360d + 80g &amp;lt; 3000,000g/7&lt;/p&gt;
&lt;p&gt;
360d &amp;lt; (3000,000 – 560)g/7&lt;/p&gt;
&lt;p&gt;
d &amp;lt; 2999440g/2520&lt;/p&gt;
&lt;p&gt;
d &amp;lt; 1200g (approx.)&lt;/p&gt;
&lt;p&gt;
If g = 1GB, the bicycle is faster for upto a distance of 1200 km.&lt;/p&gt;
&lt;p&gt;
If we are to use the 1TB hard disk to its full capacity, g ~= 1000GB. Substituting that, &lt;/p&gt;
&lt;p&gt;
d &amp;lt; 1,200,000 km&lt;/p&gt;
&lt;p&gt;
which means that upto an astounding distance of about 1200,000 kilometres (that’s about 750,000 miles), a &lt;em&gt;bicycle&lt;/em&gt; with a 1TB hard disk is faster than a 56kbps line for transferring 1TB of data!&lt;/p&gt;
&lt;p&gt;
Now, 56kbps is one of those old dialup lines – the more common internet connection these days is a broadband connection. For purposes of modernity, let’s now assume a 1Mbps connection, which transfers at a rate of 128KB/s. Again, the upload speed is less. And in this case, it appears that upload speeds of 1/4th of download are most common. Hence, let’s assume an uplink of 128/4 = 32KB/s. Then, the inequality is: &lt;/p&gt;
&lt;p&gt;
360d + 80g &amp;lt; 1000,000g/32 + 1000,000g/128&lt;/p&gt;
&lt;p&gt;
360d &amp;lt; 4999920g/128&lt;/p&gt;
&lt;p&gt;
d &amp;lt; 108g&lt;/p&gt;
&lt;p&gt;
Again, substituting g = 1, &lt;/p&gt;
&lt;p&gt;
d &amp;lt; 108 km&lt;/p&gt;
&lt;p&gt;
For 1024 GB (i.e., 1TB data), &lt;/p&gt;
&lt;p&gt;
d &amp;lt; 110,000 km&lt;/p&gt;
&lt;p&gt;
Given that the &lt;a href="http://en.wikipedia.org/wiki/Earth"&gt;earth’s circumference&lt;/a&gt; itself is just 40,000 km, this means that if you need to transfer 1TB of data to anywhere on earth, you’re better off sending a bicycle courier than sending it through today’s internet connections (of course, there’s the issue of crossing the oceans, which we’ll ignore for simplicity ;) )&lt;/p&gt;
&lt;p&gt;
Now, the same is not true if you need to transfer only 1GB – as we saw above, a bicycle is faster only upto 108 km. So, for what amount of data is a bicycle faster to anywhere on earth? Let’s do one final calculation. &lt;/p&gt;
&lt;p&gt;
The maximum distance you’d need to travel on earth is half its circumference (can you see why?). This is 20,000 km. So, let’s make d=20,000 km in the inequality and see what g we get.&lt;/p&gt;
&lt;p&gt;
360*20,000 &amp;lt; 4999920g/128&lt;/p&gt;
&lt;p&gt;
g &amp;gt; 184 GB&lt;/p&gt;
&lt;p&gt;
So, the moral of the story is, even if you have a 1Mbps broadband line, if you need to transfer more than 184 GB of data, you’d achieve better speeds to anywhere on earth by carrying a hard disk on a bicycle than by transferring it through the 1Mbps connection!&lt;/p&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/4315590008592388543/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/4315590008592388543" rel="replies" title="3 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4315590008592388543" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4315590008592388543" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/10/internet-vs-cycler.html" rel="alternate" title="The Internet vs a cycler" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-7641443809428400813</id><published>2009-07-01T15:49:00.016+05:30</published><updated>2009-07-02T10:29:46.148+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="artificial intelligence"/><category scheme="http://www.blogger.com/atom/ns#" term="finance"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="technology"/><title type="text">Programming for the Finance industry</title><content type="html">The last two days, I had a training in finance. While the class was entirely about finance, the trainer mentioned quite a few times how programmers (he called us "IT professionals") had made everything very easy and transparent.&lt;br /&gt;&lt;br /&gt;So, I thought about the various things he had taught, and realised that &lt;span style="font-style:italic;"&gt;finance is probably &lt;span style="font-weight:bold;"&gt;the best&lt;/span&gt; application of textbook programming&lt;/span&gt;. Ok, maybe there are other fields like scientific programming, etc. to compete to that title, but finance is indeed an &lt;span style="font-style:italic;"&gt;extremely&lt;/span&gt; suitable field. &lt;br /&gt;&lt;br /&gt;If you think about it, almost all of finance is about numbers and logic. The two things computers do very well. The &lt;span style="font-style:italic;"&gt;only&lt;/span&gt; two things computers do 'naturally'. &lt;br /&gt;&lt;br /&gt;The trainer told us about one common task that was a chore to do manually until computers took over - checking a stock price every now and then, and performing an action when the price reached a certain value. You can imagine how boring and difficult a job this would have been when done manually.&lt;br /&gt;&lt;br /&gt;I thought about it from a programmer's point of view, and couldn't help smile when I realized how easy this would be to program. Just keep fetching the value, comparing and waiting in a loop until you get to the required value. As I said, a textbook application of programming. &lt;br /&gt;&lt;br /&gt;There were many other things, obviously - finance is full of calculations: calculating the interests, computing dividends, finding the tax taking into account all the various exemptions, etc. Every one of them is just an application of the most basic operations of current computers - number crunching and logic evaluation. &lt;br /&gt;&lt;br /&gt;But, this is looking at only one face of finance - the part which involved tedious manual calculations which are algorithmically specifiable. However, there is another face to finance which is what makes the experts who they are. The part that involves &lt;span style="font-weight:bold;"&gt;judgement&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;If you are any familiar with Artificial Intelligence, you'll know how difficult it is to teach computers to do this. Even most humans find it difficult to give a reasonably correct prediction of how a stock price will change or how an investment will turn out beforehand. How can mere computers which are just number crunching machines do it? &lt;br /&gt;&lt;br /&gt;However, we humans are not an easily-giving-up lot. Using these mere number crunching machines, we're trying to build things that 'think'. We have things like neural networks which try to learn from previous data and project them to the future. We have &lt;a href="http://portal.acm.org/citation.cfm?id=373095"&gt;Genetic Programming&lt;/a&gt; methods to evolve good models of the stock price variations. Of course, it's not foolproof and will probably never be. But, it's a wonder that we've even managed to even take a number-crunching-machine to the level of a (sometimes faulty) thinker. Also, as we give the system more and more data about the economics involved, it will get more and more accurate. Currently, we're giving them only numbers - previous stock prices, possibly the company's profits and losses, and such relevant data. However, we're currently mostly unable to give some important data that a human expert has access to - the news surrounding the company, the quality of the current management, etc. When we one day find a way to feed these things to the computer (or better, have the computer find those things itself), I believe we can expect much better predictions.&lt;br /&gt;&lt;br /&gt;Finance industry has benefited a lot from the 'primitive' types of computation we are now easily able to do - extremely fast mathematical calculations and reliable logic evaluation. It appears it also stands to benefit from the 'newer generations' of computing which are coming up - where computers will cease to be mere machines and will 'understand' and 'think' about things!</content><link href="http://thetaoishere.blogspot.com/feeds/7641443809428400813/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/7641443809428400813" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7641443809428400813" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7641443809428400813" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/07/programming-for-finance-industry.html" rel="alternate" title="Programming for the Finance industry" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-4493066430381082871</id><published>2009-04-27T10:30:00.005+05:30</published><updated>2009-04-28T00:53:04.883+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="math"/><category scheme="http://www.blogger.com/atom/ns#" term="prime"/><category scheme="http://www.blogger.com/atom/ns#" term="program"/><category scheme="http://www.blogger.com/atom/ns#" term="project euler"/><title type="text">Finding the Largest prime factor efficiently</title><content type="html">Long long ago, I wrote an article on &lt;a href="http://thetaoishere.blogspot.com/2008/05/largest-prime-factor-of-number.html"&gt;finding the largest prime factor&lt;/a&gt; of a number (if you haven't read it, I'd recommend reading it now as much of this article won't make sense without that). It was just a fun little thing I did for solving Project Euler, so I didn't expect it would invite such excellent comments and &lt;a href="http://www.reddit.com/r/math/comments/8dmng/largest_prime_factor_of_a_number/"&gt;get posted to Reddit&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;And almost every one of the comments pointed out how the algorithm could be made better. I hadn't really thought there would be more optimal solutions than the ones given out by Project Euler, but turns out there are!&lt;br /&gt;&lt;br /&gt;The first improvement was one I might have done myself if I had tried to do an iterative version myself. In the recursive version, when I find the number is divisible by (say) 2, I divide out the 2 and call the function recursively. Now, if there's another 2 in there (that is, if the number was divisible by 4), the number would again get divided by 2 and another recursive call would occur. When I'm converting this algorithm to an iterative version too, the most natural way would be:&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;pre style="background: rgb(255, 255, 255) none repeat scroll 0% 50%; color: rgb(0, 0, 0); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;my $max_factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;%&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;2&lt;/span&gt; &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;{&lt;/span&gt;&lt;br /&gt;$max_factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;my $i &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;3&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt; $i &lt;span style="color: rgb(128, 128, 48);"&gt;&lt;&lt;/span&gt; $n&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt; $i &lt;span style="color: rgb(128, 128, 48);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;%&lt;/span&gt; $i &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;{&lt;/span&gt;&lt;br /&gt;$max_factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $i&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $i&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;There's a subtle optimization (compared to the recursive version) that has happened here that you probably missed. It's actually  a simple one - in the recursive version, when you've divided n by say 2, you pass it back to the same function - which again tries to divide it by 2. This is good as long as n is divisible by 2, but once you've divided out all the 2's, this becomes just a waste of CPU cycles. In the iterative version, this is avoided because, once we know we've divided out all the 2's, we no longer try dividing by that, and instead move on to greater things. That's a Good Thing, as for big numbers, this optimization might save several cycles.&lt;br /&gt;&lt;br /&gt;But even this turns out to be a naive implementation. As someone in the math subreddit as well as one of the commenters here pointed out, there's another optimization that can be done here - after 2 and 3, what are the prime numbers you have? 5, 7, 11, 13, 17, 19, 23, 29, etc. Is there some common property these numbers have? Why, yes, they are all either of the form 6*n+1 or 6*n-1. Turns out that it has been proved that &lt;a href="http://en.wikipedia.org/wiki/Prime_number#Examples_and_first_properties"&gt;all primes after 2 and 3 are of either of these forms&lt;/a&gt; (second half of second paragraph). So, instead of trying out all the odd&lt;br /&gt;numbers, we can try only the numbers of these forms. The first code I wrote for this purpose was,&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: rgb(255, 255, 255) none repeat scroll 0% 50%; color: rgb(0, 0, 0); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;$i &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;6&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;$factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $i &lt;span style="color: rgb(128, 128, 48);"&gt;-&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;{&lt;/span&gt;&lt;br /&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $factor &lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt; $n &lt;span style="color: rgb(128, 128, 48);"&gt;%&lt;/span&gt; $factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $i &lt;span style="color: rgb(128, 128, 48);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;last &lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $factor&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $factor &lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt; $n &lt;span style="color: rgb(128, 128, 48);"&gt;%&lt;/span&gt; $factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$i &lt;span style="color: rgb(128, 128, 48);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;6&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;That basically just implements the concept of trying out 6n +/- 1 for each value of n. After that, I remembered a comment on the previous post which had made me realize that this is the same as just adding 2 and 4 in alternate iterations of the check. Just for the heck of it, I tried that too:&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: rgb(255, 255, 255) none repeat scroll 0% 50%; color: rgb(0, 0, 0); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;$factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;5&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;&gt;&lt;/span&gt; $factor&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;{&lt;/span&gt;&lt;br /&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $factor &lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt; $n &lt;span style="color: rgb(128, 128, 48);"&gt;%&lt;/span&gt; $factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;$factor &lt;span style="color: rgb(128, 128, 48);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;last &lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;$factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $n&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$n &lt;span style="color: rgb(128, 128, 48);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; $factor &lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;while&lt;/span&gt; $n &lt;span style="color: rgb(128, 128, 48);"&gt;%&lt;/span&gt; $factor &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;$factor &lt;span style="color: rgb(128, 128, 48);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Finally, I put these all in different subroutines in a Perl program, and benchmarked those using Perl's &lt;a href="http://perldoc.perl.org/Benchmark.html"&gt;Benchmark.pm module&lt;/a&gt;. It's a very easy to use module - my entire benchmarking code consists of&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: rgb(255, 255, 255) none repeat scroll 0% 50%; color: rgb(0, 0, 0); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="color: rgb(105, 105, 105);"&gt;# Upper limit for random number generation&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 0); font-weight: bold;"&gt;my&lt;/span&gt; $rangemax &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 140, 0);"&gt;1000_000&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;cmpthese&lt;span style="color: rgb(128, 128, 48);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;-&lt;/span&gt;&lt;span style="color: rgb(0, 140, 0);"&gt;10&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(128, 0, 128);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(105, 105, 105);"&gt;# Recursive =&gt; " largestprimefRecurs((int(rand($rangemax))))",&lt;/span&gt;&lt;br /&gt;Naive_Iteration &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;&gt;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 230);"&gt;" largestprimefNaiveIter(int(rand(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;$rangemax&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;)))"&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;,&lt;/span&gt;&lt;br /&gt;Arcane6nplusminus1 &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;&gt;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 230);"&gt;" largestprimef6n(int(rand(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;$rangemax&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;)))"&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;,&lt;/span&gt;&lt;br /&gt;Arcane6nadding2and4 &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;&gt;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 230);"&gt;" largestprimef6nadding2and4(int(rand(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;$rangemax&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;)))"&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;,&lt;/span&gt;&lt;br /&gt;Arcane6nusingCount &lt;span style="color: rgb(128, 128, 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;&gt;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 230);"&gt;"  largestprimef6nusingCount(int(rand(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;$rangemax&lt;/span&gt;&lt;span style="color: rgb(0, 0, 230);"&gt;)))"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(128, 128, 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;The -10 there asks Benchmark to run each code segment for at least 10 CPU seconds, so that random fluctuations due to irrelevant factors are smoothed out, and we have reliable results.&lt;br /&gt;&lt;br /&gt;You might notice that the call to the recursive version (the original one) is commented out. Due to (what I believe to be) a problem with the Benchmark.pm module, I was not able to benchmark it using this method. Benchmark.pm would report that the recursive function ran thousands of times faster than the newer methods (probably counting the recursive calls too), but other testing revealed it was actually much slower:&lt;br /&gt;&lt;br /&gt;sundar@System:~$ time for (( i=0; i&amp;lt;500; i++ )); do perl &lt;span style="font-weight: bold;"&gt;Recursive&lt;/span&gt;.pl; done;&lt;br /&gt;real    0m&lt;span style="font-weight: bold;"&gt;5.631s&lt;/span&gt;&lt;br /&gt;user    0m3.848s&lt;br /&gt;sys     0m1.556s&lt;br /&gt;&lt;br /&gt;sundar@System:~$ time for (( i=0; i&amp;lt;500; i++ )); do perl &lt;span style="font-weight: bold;"&gt;6nMethod&lt;/span&gt;.pl; done;&lt;br /&gt;real    0m&lt;span style="font-weight: bold;"&gt;3.219s&lt;/span&gt;&lt;br /&gt;user    0m1.692s&lt;br /&gt;sys     0m1.344s&lt;br /&gt;&lt;br /&gt;We see the recursive version is slower by more than 2 seconds! I'm planning to investigate more about this behaviour of Benchmark.pm (a quick googling didn't turn up much), but for now suffice to know the old algorithm is much slower.&lt;br /&gt;&lt;br /&gt;There's another entry in the code there that I haven't talked about: Arcane6nusingCount. [By the way, the 'arcane' naming convention is a tongue-in-cheek reference to &lt;a href="http://www.reddit.com/r/math/comments/8dmng/largest_prime_factor_of_a_number/c08ykts"&gt;this&lt;/a&gt; comment where the commenter said "I get the feeling that [the programmer who wrote this post] would consider that working with 6n +/- 1 as too arcane a method..." :) I couldn't start the function name with the digit 6, so I added 'Arcane' before each one. ;)]&lt;br /&gt;Anyway, that Arcane6nusingCount was a version where I tried to implement the 6n +/- 1 algorithm by keeping a counter of the iterations, and incrementing by 2 or 4 based on whether count%2 was 0 or 1. Turns out this extra mod operation kills performance, as you can see in the benchmark results below.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Benchmark Results:&lt;/span&gt;&lt;br /&gt;Legend:&lt;br /&gt;Due to Blogger's @&amp;amp;%*&amp;amp;%# formatting, I had to change the names to shorter versions as follows:&lt;br /&gt;&lt;pre style="background: rgb(255, 255, 255) none repeat scroll 0% 50%; color: rgb(0, 0, 0); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;Naive_Iteration     : Iter&lt;br /&gt;Arcane6nplusminus1  : 6n+/-1&lt;br /&gt;Arcane6nadding2and4 : Add2,4&lt;br /&gt;Arcane6nusingCount  : Count&lt;br /&gt;&lt;/pre&gt;The percentages are the amounts by which the algorithm in the horizontal (the row) is better than the one in the vertical (the column). The /s amounts are the number of times this subroutine could have been run in one second, averaged over the given inputs. For this test, the inputs were random numbers from 0 to 1000,000, as seen in the code above.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Trial 1&lt;/span&gt;&lt;br /&gt;&lt;table&gt;&lt;br /&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/td&gt;         &lt;td&gt;&lt;span style="font-size:85%;"&gt;Rate    &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Count  &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Iter  &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;6n+/-1  &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Add2,4  &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;Count&lt;/span&gt;&lt;/td&gt;  &lt;td&gt;&lt;span style="font-size:85%;"&gt;45.9/s&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;            &lt;td&gt;&lt;span style="font-size:85%;"&gt;-24%&lt;/span&gt;&lt;/td&gt;               &lt;td&gt;&lt;span style="font-size:85%;"&gt;-35%&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;-39%&lt;/span&gt;&lt;/td&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;Iter&lt;/span&gt;&lt;/td&gt;     &lt;td&gt;&lt;span style="font-size:85%;"&gt;60.1/s&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;31%&lt;/span&gt;&lt;/td&gt;              &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;               &lt;td&gt;&lt;span style="font-size:85%;"&gt;-15%&lt;/span&gt;&lt;/td&gt;             &lt;td&gt;&lt;span style="font-size:85%;"&gt;-20%&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;6n+/-1&lt;/span&gt;&lt;/td&gt;  &lt;td&gt;&lt;span style="font-size:85%;"&gt;70.5/s&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;54%&lt;/span&gt;&lt;/td&gt;             &lt;td&gt;&lt;span style="font-size:85%;"&gt;17%&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;-6%&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;Add2,4&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;75.2/s&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;64%&lt;/span&gt;&lt;/td&gt;             &lt;td&gt;&lt;span style="font-size:85%;"&gt;25%&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;7%&lt;/span&gt;&lt;/td&gt;                  &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Trial 2&lt;/span&gt;&lt;table&gt;&lt;br /&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/td&gt;         &lt;td&gt;&lt;span style="font-size:85%;"&gt;Rate    &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Count  &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Iter  &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;6n+/-1  &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Add2,4  &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;Count&lt;/span&gt;&lt;/td&gt;  &lt;td&gt;&lt;span style="font-size:85%;"&gt;43.1/s&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;            &lt;td&gt;&lt;span style="font-size:85%;"&gt;-25%&lt;/span&gt;&lt;/td&gt;               &lt;td&gt;&lt;span style="font-size:85%;"&gt;-41%&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;-42%&lt;/span&gt;&lt;/td&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;Iter&lt;/span&gt;&lt;/td&gt;     &lt;td&gt;&lt;span style="font-size:85%;"&gt;57.4/s&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;33%&lt;/span&gt;&lt;/td&gt;              &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;               &lt;td&gt;&lt;span style="font-size:85%;"&gt;-22%&lt;/span&gt;&lt;/td&gt;             &lt;td&gt;&lt;span style="font-size:85%;"&gt;-23%&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;6n+/-1&lt;/span&gt;&lt;/td&gt;  &lt;td&gt;&lt;span style="font-size:85%;"&gt;73.6/s&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;71%&lt;/span&gt;&lt;/td&gt;             &lt;td&gt;&lt;span style="font-size:85%;"&gt;28%&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;-2%&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size:85%;"&gt;Add2,4&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;74.9/s&lt;/span&gt;&lt;/td&gt;                &lt;td&gt;&lt;span style="font-size:85%;"&gt;74%&lt;/span&gt;&lt;/td&gt;             &lt;td&gt;&lt;span style="font-size:85%;"&gt;30%&lt;/span&gt;&lt;/td&gt;                 &lt;td&gt;&lt;span style="font-size:85%;"&gt;2%&lt;/span&gt;&lt;/td&gt;                  &lt;td&gt;&lt;span style="font-size:85%;"&gt;--&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;We see that the method of adding 2 and 4 directly (Arcane6nadding2and4) works best, but the one using multiples of 6 and dividing by $i-1 and $i+1 (Arcane6nplusminus1) is only slightly worse. And, in my opinion, it is clearer and more elegant. They're both much better than the naive iterative method, and the original recursive solution is not even comparable to these!&lt;br /&gt;&lt;br /&gt;So, I guess the moral of the story is, look at ways you can optimize your code even if an 'authoritative source' seems to tell you've reached the optimum. Also, where performance is critical, &lt;span style="font-style: italic;"&gt;profile &lt;/span&gt;and &lt;span style="font-style: italic;"&gt;benchmark &lt;/span&gt;your code - they are much more reliable practically than theoretical algorithmic analyses (of course, this is true only when they are done right).&lt;br /&gt;&lt;br /&gt;The program along with benchmarking code is available at: &lt;a href="http://sundaryourfriend.googlepages.com/largestprimefactorBenchmark.pl"&gt;http://sundaryourfriend.googlepages.com/largestprimefactorBenchmark.pl&lt;/a&gt;&lt;br /&gt;To run it, you need to have the Benchmark.pm Perl module installed (which would probably be available by default).&lt;br /&gt;&lt;br /&gt;Have a nice day...</content><link href="http://thetaoishere.blogspot.com/feeds/4493066430381082871/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/4493066430381082871" rel="replies" title="7 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4493066430381082871" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4493066430381082871" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/04/finding-largest-prime-factor.html" rel="alternate" title="Finding the Largest prime factor efficiently" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-438648957245724421</id><published>2009-04-22T02:43:00.019+05:30</published><updated>2009-12-13T01:48:25.364+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="resources"/><category scheme="http://www.blogger.com/atom/ns#" term="websites"/><title type="text">Top ten Internet resources for programmers</title><content type="html">&lt;a href="" name="stackoverflow"&gt;1.&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a href="http://www.stackoverflow.com/" style="font-weight: bold;" target="_blank"&gt;http://www.stackoverflow.com&lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHm60W-k7TSyVePkaNd8VUR1MHBQQWEZRPeC3whxGrDppBx6Qzm6AtYMvcYxyayo05z-FjFx2wkPctHNIFAOSgAYv3q48axadnGM5cYwfTxrXxkQ3-PDQvRTL-ol5Hl2Z6AB-Bo3pow04/s1600-h/stackoverflow-logo.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329817897571890226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHm60W-k7TSyVePkaNd8VUR1MHBQQWEZRPeC3whxGrDppBx6Qzm6AtYMvcYxyayo05z-FjFx2wkPctHNIFAOSgAYv3q48axadnGM5cYwfTxrXxkQ3-PDQvRTL-ol5Hl2Z6AB-Bo3pow04/s320/stackoverflow-logo.png" style="cursor: pointer; float: right; height: 61px; margin: 0pt 0pt 10px 10px; width: 250px;" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
A year ago, this website didn't exist. Now, it's at the top of this list of Internet resources for programmers! Stack Overflow is a place where programmers like you and me ask questions and answer them. Some things that make it great are: each question and answer can be 'voted' on (either +1 or -1), and the answers with the greatest number of votes appear at the top near the question; only programming related questions are allowed, and everything else is 'closed' down; any discussions on the answers go into the 'comments' section which is hidden by default - this means that flamewars and such nonsense are much less here, and mostly hidden from our view too.&lt;br /&gt;
But I can go all day about what &lt;span style="font-style: italic;"&gt;makes&lt;/span&gt; it tick, but you won't really see how good a resource it is until you actually go there and try to search for some programming question you've been having. Chances are, someone else had it before you, and asked it there; in that case, you'd probably find very good answers to your question. If you are so unique that no other questioner thought of what you thought, you can login and post the question yourself - in which case you'd probably start getting answers within minutes, and the answer you wanted would be there within hours.&lt;br /&gt;
All that talk from me isn't probably going to convince you, so &lt;a href="http://www.stackoverflow.com/" target="_blank"&gt;just go try it&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="googlereader"&gt;2.&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a href="http://reader.google.com/" style="font-weight: bold;" target="_blank"&gt;http://reader.google.com&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;(actually, RSS feeds from programming blogs)&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu_cOABVWda65K9y1Z0IymC_es0LFVPR2jaPn-pYykKmkw3g-ECM4JCsFX-3t35WYtPBOTlHgJZ8gdx3rEDYtmYv6HICquipOJuXYjQqBPW5r6COAGsRPBTvE7_M9FDbkmLFwb5pMGWps/s1600-h/google-reader_logo.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329817898140383778" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu_cOABVWda65K9y1Z0IymC_es0LFVPR2jaPn-pYykKmkw3g-ECM4JCsFX-3t35WYtPBOTlHgJZ8gdx3rEDYtmYv6HICquipOJuXYjQqBPW5r6COAGsRPBTvE7_M9FDbkmLFwb5pMGWps/s320/google-reader_logo.jpg" style="cursor: pointer; float: right; height: 134px; margin: 0pt 0pt 10px 10px; width: 136px;" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To be honest, this isn't a resource in itself, but can act as an aggregator of resources. If you're not familiar with the concept of 'feeds' or 'subscription' or 'RSS', here's a simplified view of it: when you add feeds from websites to Google Reader, you're asking it to check the sites for new content now and then, fetch the content automatically whenever it arrives and keep it stored, so that you can read it all in Reader without having to check each site yourself. If this does not seem like a big advantage to you (it didn't to me at first), start using it, and you'll see how much of a convenience it is.&lt;br /&gt;
The most important and common use of Google Reader (for us) is to subscribe to and read programming blogs such as &lt;a href="http://lambda-the-ultimate.org/rss.xml" target="_blank"&gt;Lambda the Ultimate&lt;/a&gt;, &lt;a href="http://www.joelonsoftware.com/rss.xml" target="_blank"&gt;Joel on Software&lt;/a&gt;, etc., (in addition to webcomics such as &lt;a href="http://feeds.feedburner.com/DilbertDailyStrip" target="_blank"&gt;Dilbert&lt;/a&gt; or &lt;a href="http://www.xkcd.com/rss.xml" target="_blank"&gt;xkcd&lt;/a&gt; :) ). Whenever you come across a blog that you consider interesting, click on the orange icon with the three curved lines that appears near the address bar (you &lt;span style="font-style: italic;"&gt;are&lt;/span&gt; using &lt;a href="http://www.getfirefox.com/" target="_blank"&gt;Firefox&lt;/a&gt;, right?), and choose to subscribe using Google.&lt;br /&gt;
And after all this, don't forget to check out Google Reader every day or at least once a week. :)&lt;br /&gt;
While Google Reader might be the simplest for newbies (opinions differ even in this), there are many other feed readers and each one has its own fan base. &lt;a href="http://www.problogger.net/" target="_blank"&gt;ProBlogger&lt;/a&gt; seems to recommend &lt;a href="http://www.newsgator.com/Individuals/FeedDemon/Default.aspx" target="_blank"&gt;FeedDemon&lt;/a&gt;, while other readers like the &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/77" target="_blank"&gt;Sage extension&lt;/a&gt; for Firefox, &lt;a href="http://www.blogger.com/www.bloglines.com/" target="_blank"&gt;Bloglines&lt;/a&gt;, etc. are also very popular.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="IRC"&gt;3.&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a href="http://www.irchelp.org/irchelp/ircprimer.html" style="font-weight: bold;" target="_blank"&gt;IRC&lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjbX6gkIpyBV-VbdPbSHzvZmIOd6NpzMzKdyqdpNxeqZeroIEBsH5Z1qG4QHb_ilDlLiBB44MsfVhWcgFI7BDImIQW9wd5JTHfrauLILofEOXc334vybYUaHVM-fHelLboDqFy_GZLKiQ/s1600-h/icechat-networks__icechat-irc-client.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329820859979057122" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjbX6gkIpyBV-VbdPbSHzvZmIOd6NpzMzKdyqdpNxeqZeroIEBsH5Z1qG4QHb_ilDlLiBB44MsfVhWcgFI7BDImIQW9wd5JTHfrauLILofEOXc334vybYUaHVM-fHelLboDqFy_GZLKiQ/s320/icechat-networks__icechat-irc-client.jpg" style="cursor: pointer; float: right; height: 100px; margin: 0pt 0pt 10px 10px; width: 150px;" /&gt;&lt;/a&gt;&lt;br /&gt;
Internet Relay Chat, simply put, is a set of 'channels' (what you might call chat rooms) each one devoted to a particular subject of interest. For example, there is a channel devoted to Wikipedia (#wikipedia I think), while another one devoted to discussions of mathematics (#math). You probably might find more use for ##c (for C programming), ##c++ (obviously, for C++ programming), etc. Like Google groups, here too, world experts on the field gather, so it's a very good resource if you know how to use it properly. If you're a beginner to IRC, I'd recommend the free &lt;a href="http://www.icechat.net/" target="_blank"&gt;IceChat&lt;/a&gt; client which is very newbie friendly and also powerful. The channels are hosted in things called 'IRC servers'. For programmers, almost the only server we'd need is irc.freenode.net. Connect to it, be polite, and share your knowledge too.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="proggit"&gt;4.&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a href="http://www.reddit.com/r/programming" style="font-weight: bold;" target="_blank"&gt;http://www.reddit.com/r/programming&lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgofaiedEtwUJkgwGqJVs1PNTOv5dwXwCuAQ3IlbHB2DeTvBYsClRyRsYF-mCBoPtbYm_IPUhui1cNoHQCk3Ib1Yx6Qx2mxvro3aKfkjya_-uoa12MO64574DxkRUuyzrAz8ojjp1_wMI8/s1600-h/reddit_programming.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329820861896649298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgofaiedEtwUJkgwGqJVs1PNTOv5dwXwCuAQ3IlbHB2DeTvBYsClRyRsYF-mCBoPtbYm_IPUhui1cNoHQCk3Ib1Yx6Qx2mxvro3aKfkjya_-uoa12MO64574DxkRUuyzrAz8ojjp1_wMI8/s320/reddit_programming.png" style="cursor: pointer; float: right; height: 40px; margin: 0pt 0pt 10px 10px; width: 120px;" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;
Proggit, as it is fondly called, is a rich place where intelligent discussions, incandescent flamewars and &lt;a href="http://en.wikipedia.org/wiki/4chan#Memes" target="_blank"&gt;4chan memes&lt;/a&gt; happen side by side. Like Hacker News (#5 in this list), this too is a place where people share and vote upon links (obviously, links relating to programming). If you have the attitude of a gold miner, ready to dig out gold from among so much dirt and rock, you can learn a real lot from here. Just remember not to get trapped into the memes, for it is said there is no salvation after that.&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="" name="HN"&gt;5.&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a href="http://news.ycombinator.com/" style="font-weight: bold;" target="_blank"&gt;http://news.ycombinator.com/&lt;/a&gt;&lt;br /&gt;
Known as 'Hacker News', it's a site where people post links to things they find interesting, and others vote upon them. This site is for '&lt;a href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#what_is" target="_blank"&gt;hackers&lt;/a&gt;', and so though most of the content is about programming, other brain stimulating things that would interest a hacker would also be present. The ambience here is one of extreme decency and politeness, in contrast to most of the Internet. Some like the UI of the site, some don't, see if it fits you.&lt;br /&gt;
This site would have been much higher in the list if I had written this post a few weeks ago. But in that space, I've come to see that the discussions on Reddit (site #4 in this list) are usually much richer and informative than the ones here. Reddit does have other noise (people attempting at humour and nasty flamewars), but in trying to suppress that noise, HN (Hacker News) has seems to have suppressed some of the useful discussion too.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="wikibooks"&gt;6.&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a href="http://en.wikibooks.org/wiki/Category:Programming" style="font-weight: bold;" target="_blank"&gt;http://en.wikibooks.org/wiki/Category:Programming&lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYXmflmm9zKH1N2tOti7rEnf9-f0pVLUoF1Ri99knEO4AloC7eW1R0yFEZ-dtMeAg-M7Ft5dtSyfp6E5kMGQc29C3JyOTMdxX9zroLcasSijFPG45SqqOOx9kyn3JPQUWcPAsIpztjZZY/s1600-h/Wiki.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329821496151027634" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYXmflmm9zKH1N2tOti7rEnf9-f0pVLUoF1Ri99knEO4AloC7eW1R0yFEZ-dtMeAg-M7Ft5dtSyfp6E5kMGQc29C3JyOTMdxX9zroLcasSijFPG45SqqOOx9kyn3JPQUWcPAsIpztjZZY/s320/Wiki.png" style="cursor: pointer; float: right; height: 135px; margin: 0pt 0pt 10px 10px; width: 135px;" /&gt;&lt;/a&gt;&lt;br /&gt;
Even if you knew about all the other resources here, I'd bet you didn't know this one till now. From &lt;a href="http://en.wikibooks.org/wiki/Regular_Expressions" target="_blank"&gt;Regular Expressions&lt;/a&gt; to &lt;a href="http://en.wikibooks.org/wiki/Computer_Programming/Functional_programming" target="_blank"&gt;Functional Programming&lt;/a&gt;, there's a wealth of information about many programming topics. This along with Wikipedia can take your programming knowledge to a higher plane.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="googlegroups"&gt;7.&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a href="http://groups.google.com/groups/dir?sel=usenet%3Dcomp" style="font-weight: bold;" target="_blank"&gt;comp. heirarchy&lt;/a&gt;&lt;a href="http://groups.google.com/groups/dir?sel=usenet%3Dcomp" style="font-weight: bold;" target="_blank"&gt; in Google groups &lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqnLRh2mpo-uA0uL7Rpo1HXEr4l80QUmwMBW97r9djF8zbXDEv0kl2K5U5uBTUL8G3GCrh4vnTGjL7j1NjwqmJwIJvrGuUzxzaLVR38d8-Ez4Otd2-iQXdjUa0jBk70W6sKAL0Jlqu5u8/s1600-h/google_groups_medium.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329822528438114610" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqnLRh2mpo-uA0uL7Rpo1HXEr4l80QUmwMBW97r9djF8zbXDEv0kl2K5U5uBTUL8G3GCrh4vnTGjL7j1NjwqmJwIJvrGuUzxzaLVR38d8-Ez4Otd2-iQXdjUa0jBk70W6sKAL0Jlqu5u8/s320/google_groups_medium.gif" style="cursor: pointer; float: right; height: 55px; margin: 0pt 0pt 10px 10px; width: 150px;" /&gt;&lt;/a&gt;&lt;br /&gt;
This is a whole list of 'Usenet' groups about computers. Within these, you'll most probably find the groups under &lt;a href="http://groups.google.com/groups/dir?sel=usenet%3Dcomp.lang%2C&amp;amp;" target="_blank"&gt;comp.lang&lt;/a&gt; part most useful, but the others cater to special needs - for eg., if you're into programming for graphics, you might find the &lt;a href="http://groups.google.com/groups/dir?sel=usenet%3Dcomp.graphics%2C&amp;amp;" target="_blank"&gt;comp.graphics&lt;/a&gt; groups useful. These groups have&lt;span style="font-style: italic;"&gt; lots of&lt;/span&gt; experts in the field of the group, which means you'll be interacting with top notch programmers in your area of interest.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="topcoder"&gt;8. &lt;/a&gt;&lt;a href="http://www.topcoder.com/" style="font-weight: bold;" target="_blank"&gt;http://www.topcoder.com&lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK7qEpXTzeql3T59qY6VnQTrYSOX9eJ7q07hhLQqYthbjRi4AHo-KdqBUm59WI21R06_szD-WMO9Y-ZVfb7FnW_Uf4AiG4kPMhSp8z_mqpQbMxxi_szg_khrBmUPRLmBtHjZZS_rT9H0Y/s1600-h/topcoder_logo_rev.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329821501959255922" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK7qEpXTzeql3T59qY6VnQTrYSOX9eJ7q07hhLQqYthbjRi4AHo-KdqBUm59WI21R06_szD-WMO9Y-ZVfb7FnW_Uf4AiG4kPMhSp8z_mqpQbMxxi_szg_khrBmUPRLmBtHjZZS_rT9H0Y/s320/topcoder_logo_rev.jpg" style="cursor: pointer; float: right; height: 62px; margin: 0pt 0pt 10px 10px; width: 320px;" /&gt;&lt;/a&gt;&lt;br /&gt;
A website where you get to 'compete' with other programmers from throughout the world in various 'tournaments', 'marathons', etc. Frankly though, I don't care a bit for the competition or ranking part of it. It contains so many good programming problems that, when you solve them, give you insights into so many things. Also, the &lt;a href="http://www.topcoder.com/tc?module=Static&amp;amp;d1=tutorials&amp;amp;d2=alg_index" target="_blank"&gt;Algorithm Tutorials&lt;/a&gt; here are said to be very good (they are on my 'to read' list :) ).&lt;br /&gt;
Some practical tips (since the UI of TopCoder is less than ideal and you might find it difficult to do things): To register, click on Login in the top right corner (you might have to scroll right a little to see it), then click on Register in the page that comes up. To participate in some tournament or just practice using questions from old tournaments, login to TC (that's the short form of TopCoder), click on Algorithm in the left panel, then on 'Launch Arena'. It would probably ask to install Java Web Start, go ahead and install it. After that, when the arena appears, login again in that window. Then, if you wanna participate in some tournament going on now (they'll send you mail about the schedules from time to time), choose the Active Contests menu. If you just want to try out old questions, choose the Practice Rooms menu. Either way, choose one of the SRMs from the menu. When you've been 'moved' to that room, click on the box that says 'Select one' and choose one of the scores listed there (like 250, 500 and 1000). A programming problem of that score would be presented to you. After this, I guess you'd be able to take off on your own.&lt;br /&gt;
There are other sites like &lt;a href="http://projecteuler.net/"&gt;Project Euler&lt;/a&gt; and &lt;a href="http://www.spoj.pl/problems/classical/"&gt;Sphere Online Judge&lt;/a&gt; (SPOJ) which are somewhat similar to TC. Project Euler is heavily inclined towards mathematics, so I find its scope to be quite narrow. SPOJ is similar to TopCoder in that it too provides several algorithmic problems and allows us to submit solutions to be evaluated and validated. A small disadvantage is that the collection of problems is less than that in TC. But a great advantage in SPOJ is that it allows a wide variety of programming languages - TopCoder is limited to a few mainstream languages: Java, C++, C#, and VB .Net.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="thedailywtf"&gt;9. &lt;/a&gt;&lt;a href="http://www.thedailywtf.com/" style="font-weight: bold;" target="_blank"&gt;http://www.thedailywtf.com&lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsOhO5IKnaLaWrZK2Lx3AguljoSTFg3n1WqGYBUe-Hk_saZlYQao7CI_NtcELxicnRxrvKhWLx5_fe0LFte_Cbq8g6UasE9PHwEUi6QjXzK3x3pRFhVgsrjCm_OdpN1zC9oXhSerW5Kt8/s1600-h/Daily_WTF_logo.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329821496236396242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsOhO5IKnaLaWrZK2Lx3AguljoSTFg3n1WqGYBUe-Hk_saZlYQao7CI_NtcELxicnRxrvKhWLx5_fe0LFte_Cbq8g6UasE9PHwEUi6QjXzK3x3pRFhVgsrjCm_OdpN1zC9oXhSerW5Kt8/s320/Daily_WTF_logo.gif" style="cursor: pointer; float: right; height: 46px; margin: 0pt 0pt 10px 10px; width: 320px;" /&gt;&lt;/a&gt;&lt;br /&gt;
Thought &lt;a href="http://www.urbandictionary.com/define.php?term=THE+INTERNET+%3D+SERIOUS+BUSINESS" target="_blank"&gt;the Internet is serious business&lt;/a&gt;, at times we need to take some time off to laugh out and relax. What if you can learn something while you do that? Well, the Daily WTF (they claim that it means Worse Than Failure) is a place for that. Working programmers tell tales about horrid code and other maladies from their co-workers, which are mostly because of a lack of programming knowledge. The stories are hilarious, but at the end of most of them, you'd be a bit wiser knowing a little more as to how to be a good programmer. Of special mention are the '&lt;a href="http://thedailywtf.com/Series/Feature_Articles.aspx" target="_blank"&gt;Featured Articles&lt;/a&gt;' and '&lt;a href="http://thedailywtf.com/Series/Tales_from_the_Interview.aspx" target="_blank"&gt;Tales from the Interview&lt;/a&gt;' sections.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="" name="google"&gt;10. &lt;/a&gt;&lt;a href="http://www.google.com/" style="font-weight: bold;" target="_blank"&gt;http://www.google.com&lt;/a&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_Y20hyphenhyphensZqsBs0qNmHFOYI_bG5JgGQf1wqDZDfZcp0MHQZCXugz3o7PqCCD3VhjIzkuOR-CdSy5YcJa1T3zn5LL31vuC7NUDkfQ779Uiqu8XO7Wvt5GEJxXGMkGnGT0wwimJrnTNdKrm8/s1600-h/google_logo_plain.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5329821985251527010" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_Y20hyphenhyphensZqsBs0qNmHFOYI_bG5JgGQf1wqDZDfZcp0MHQZCXugz3o7PqCCD3VhjIzkuOR-CdSy5YcJa1T3zn5LL31vuC7NUDkfQ779Uiqu8XO7Wvt5GEJxXGMkGnGT0wwimJrnTNdKrm8/s320/google_logo_plain.png" style="cursor: pointer; float: right; height: 110px; margin: 0pt 0pt 10px 10px; width: 276px;" /&gt;&lt;/a&gt;&lt;br /&gt;
Ok, I can hear your 'Duh!' even from here, but give me a few seconds. To be honest, &lt;span style="font-style: italic;"&gt;no list ever&lt;/span&gt; can contain all of the wonderful programming resources out there. There are just too many forums, too many personal web pages that contain precious wealth of information. With some power googling (I'm planning on making a post on this soon), you can dig all that out. So, this makes Google probably the most useful resource for programmers. The only reason this is on number 10 is that you very probably know about it already (if you didn't, what forest were you living in? :) )&lt;br /&gt;
&lt;br /&gt;
So, if I were to limit myself to 10, those would be it...&lt;br /&gt;
&lt;br /&gt;
I know, I know,  I probably missed &lt;span style="font-style: italic;"&gt;your&lt;/span&gt;&lt;span style="font-style: italic;"&gt; favourite website &lt;/span&gt;out of this list!&lt;br /&gt;
If so, do leave a comment here so that others (including me) might know  and experience its glory. Thanks... :)&lt;br /&gt;
&lt;/div&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/438648957245724421/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/438648957245724421" rel="replies" title="1 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/438648957245724421" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/438648957245724421" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/04/top-ten-internet-resources-for.html" rel="alternate" title="Top ten Internet resources for programmers" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHm60W-k7TSyVePkaNd8VUR1MHBQQWEZRPeC3whxGrDppBx6Qzm6AtYMvcYxyayo05z-FjFx2wkPctHNIFAOSgAYv3q48axadnGM5cYwfTxrXxkQ3-PDQvRTL-ol5Hl2Z6AB-Bo3pow04/s72-c/stackoverflow-logo.png" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-7894217579088838991</id><published>2009-04-15T11:23:00.005+05:30</published><updated>2009-04-15T15:32:35.861+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="c"/><category scheme="http://www.blogger.com/atom/ns#" term="lisp"/><category scheme="http://www.blogger.com/atom/ns#" term="palindrome"/><category scheme="http://www.blogger.com/atom/ns#" term="palindromic number"/><category scheme="http://www.blogger.com/atom/ns#" term="program"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type="text">Lisp by and for the C programmer</title><content type="html">Finally, it's done. That program for &lt;a  href="http://thetaoishere.blogspot.com/2009/04/finding-next-palindrome-given-number.html"&gt;finding the next palindrome given a number&lt;/a&gt;. I had to jump through several hoops and get help from the www and IRC to get it done (thanks to the helpful guys at #lisp - the newbie bashing notwithstanding).&lt;br&gt; &lt;br&gt; Lisp is supposed to be a functional language. To be honest, I myself don't clearly understand what that means; I'm trying to learn little by little. As of now, it seems to me to be a conglomorate of various concepts and language facilities, some of which are present in some languages, and almost no real language seems have all of them. &lt;br&gt; &lt;br&gt; Anyway, because of that, I tried not to make the program entirely C-like, and tried to do it the 'functional' way. Practically to me, it involved using recursion where I would have used iteration in C, and using variables as if they were constants - trying not to modify anything. In functional programming (FP) circles, this is called treating symbols as immutable (I think), and is glorified as a Good Thing. I haven't adhered to it fully (one place that comes to mind is the changing the value of ndigits in increm-left-from-here function), but I feel this is good enough for a C/C++/Perl programmer who understands very little of FP. :)&lt;br&gt; &lt;br&gt; Some descriptions that &lt;span style="font-style: italic;"&gt;might&lt;/span&gt; help understand the program are here. You can try out things with the&lt;a  href="http://common-lisp.net/project/lispbox/#windows"&gt; Lisp in a Box IDE&lt;/a&gt; for Windows (you'll need to install the &lt;a  href="http://common-lisp.net/project/lispbox/LispBox-base.exe"&gt;base installer&lt;/a&gt; and the &lt;a  href="http://common-lisp.net/project/lispbox/LispBox-CLISP.exe"&gt;CLISP module&lt;/a&gt;). Some clarifications: I'm not an expert in Lisp and don't claim to be one, I've described things as I understand them. Also, when making analogies to C, I've tried to take the thing that comes closest to it, but don't take the analogies literally. Concepts in Lisp are quite different from those in C, these are here only to give you a rough idea about them. &lt;br&gt; &lt;span style="font-weight: bold;"&gt;() &lt;a name="syntax"&gt;&lt;/a&gt;syntax&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; The parenthesis syntax here is something that might be very new to you. But it's quite simple, and very consistent. &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; When you see (A B C) in Lisp, what it means is call the function A with arguments B and C (A can also be a &lt;span style="font-style: italic;"&gt;macro&lt;/span&gt;, which I've &lt;a href="#A_macro_is"&gt;explained&lt;/a&gt; under &lt;a href="#incf"&gt;&lt;span style="font-weight: bold;"&gt;incf&lt;/span&gt;&lt;/a&gt;). In C syntax, that might be A(B, C). One good thing about Lisp is, this notation is followed very consistently throughout the language. Even operations like addition are done with this syntax: 1+2 in C will be (+ 1 2) in Lisp. Whenever you see a list (x y z a b c), you can say it's a function call calling function x with arguments y, z, a, b, and c. The only exception to this are literal lists - you know, the lists you use to store data, like C arrays. When you want a list of number 1 to 5, you might try (1 2 3 4 5). But... Lisp sees such lists as function calls, and so tries to 'call' the function 1 with arguments 2, 3, 4, and 5. Surely not what we wanted. So, to tell Lisp that we want a literal list, and not a function call, we have to put a single quote ' before the list. So, '(1 2 3 4 5) will achieve what we wanted. This actually works by changing itself it (quote (1 2 3 4 5)) where quote is a &lt;a href="#A_macro_is"&gt;macro&lt;/a&gt;. But you don't need to understand that to use the single quote. :)&lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;a name="defun"&gt;&lt;/a&gt;defun&lt;/span&gt;: &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; This defines a function, like the sub keyword in Perl. For the C-ers among us, &lt;br&gt; &lt;div style="text-align: center;"&gt;(defun funName (arg1 arg2) &lt;br&gt; (body ...&lt;br&gt; ....))&lt;br&gt; &lt;/div&gt; is very much like&lt;br&gt; &lt;div style="text-align: center;"&gt;void funName(type1 arg1, type2 arg2) &lt;br&gt; { body ... &lt;br&gt; ...}&lt;br&gt; &lt;/div&gt; Immediately, we can notice a few things: In Lisp, we don't specify the type of the arguments that the function takes - it can take whatever it wants. arg1 itself can be an entire list itself, or a number, or a string, or an object, or any type you can imagine (and Lisp can handle :) ). Also, there's no declaration of what the function is going to return - this too can be anything. &lt;br&gt; &lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;a name="incf"&gt;&lt;/a&gt;incf&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; This is a simple macro that increments whatever you give to it as argument. If you're asking 'hello, what is a macro?', congratulations for the careful reading. &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a  name="A_macro_is"&gt;&lt;/a&gt;A macro is a thing that modifies the code at the place where you put it. They are somewhat like the preprocessor macros in C - and before the Lisp fans start grumbling, I'll add - but they're supposed to be much much more powerful. There's an entire book that is almost fully dedicated to doing magic with Lisp macros: &lt;a href="http://www.paulgraham.com/onlisp.html"&gt;On Lisp&lt;/a&gt;. &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; In case you didn't get any clear idea about what macros are from the previous paragraph (yes, I guessed it), I'll explain with this example itself. In my code, in one place, I had &lt;br&gt; &lt;div style="text-align: center;"&gt;(incf i)&lt;br&gt; &lt;/div&gt; While debugging the code, I saw how the incf was expanded: the macro just replaced itself with &lt;br&gt; &lt;div style="text-align: center;"&gt;(setq i (+ i 1))&lt;br&gt; &lt;/div&gt; I myself wrote a macro in this code using the &lt;a href="#defmacro"&gt;&lt;span  style="font-weight: bold;"&gt;defmacro&lt;/span&gt;&lt;/a&gt; command. &lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;a name="defmacro"&gt;&lt;/a&gt;defmacro&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; I described what a &lt;a href="#A_macro_is"&gt;macro&lt;/a&gt; is above. In Lisp, the syntax for macros is very much like the one for functions, with defun replaced by the keyword defmacro. For example, I have defined a macro in this code as:&lt;br&gt; &lt;div style="text-align: center;"&gt;(defmacro get-mid-index (list)&lt;br&gt; `(ceiling (1- (/ (length ,list) 2))))&lt;br&gt; &lt;/div&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; A macro too gets arguments like a function (the argument is 'list' here). What follows after the argument is the &lt;span style="font-style: italic;"&gt;expansion&lt;/span&gt; of the macro, which means the macro is replaced with this thing wherever we call the macro. &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; There are some curious things to note here. First off, the expansion of the macro is not in an ordinary &lt;br&gt; &lt;div style="text-align: center;"&gt;(some code here ... &lt;br&gt; ...) &lt;br&gt; &lt;/div&gt; format here. There is a ` and a , in that code, which makes it special. In &lt;a href="#syntax"&gt;() syntax&lt;/a&gt;, we said that '() makes a literal list - that is, a list that is not evaluated, but is treated as data. The ` (that is the backtick - the thing which is to the left of 1 in the keyboard)&amp;nbsp;is similar to ' but with a difference: while &lt;span style="font-style: italic;"&gt;nothing &lt;/span&gt;within the '() is evaluated, in a `() you can ask Lisp to evaluate certain things alone by putting a comma (,) before it. For example, in this expansion, the 'list' has a comma before it, so it will be evaluated. Since here 'list' is the argument we pass to the macro, it gets evaluated to the actual list which we pass. For example, &lt;br&gt; &lt;div style="text-align: center;"&gt;(get-mid-index digits-of-n)&lt;br&gt; &lt;/div&gt; becomes&lt;br&gt; &lt;div style="text-align: center;"&gt;(ceiling (1- (/ (length digits-of-n) 2)))&lt;br&gt; &lt;/div&gt; That's nifty, right? :)&lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;a name="nth"&gt;&lt;/a&gt;nth&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; nth is a function that returns the n'th element of a list. For example, (nth 2 '(a b c d e)) will return&amp;nbsp;c. Here, it's important to note that Lisp lists are 0-based - the counting starts from 0. So a is the 0th element, b is the 1st, etc. &lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;a name="cond"&gt;&lt;/a&gt;cond&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cond is a 'special form' (which is something like a function or a macro, but they say it's not either of those. I'm yet to understand special forms) which is somewhat like the if() construct of C. Lisp too has an (if ...) syntax, but it is limited to single statements. You can say (if (condition) (do-this) (else-do-that)), but (if (condition) ((do-this) (and-this)) (else-do-that)) is not allowed. In C syntax, it's as if&lt;br&gt; &lt;div style="text-align: center;"&gt;if(condition)&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; do-this;&lt;br&gt; else&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; do-that;&lt;br&gt; &lt;/div&gt; is allowed, but&lt;br&gt; &lt;div style="text-align: center;"&gt;if(condition) {&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; do-this;&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; and-do-this;&lt;br&gt; }&lt;br&gt; else&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; do-that;&lt;br&gt; &lt;/div&gt; is not allowed. In most practical cases, I find that I need to put multiple statements in the if's body, so I rarely use if in Lisp. &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; The cond function is similar to if, but much more flexible. It's syntax is, &lt;br&gt; &lt;div style="text-align: center;"&gt;(cond ((condition1) (do-this) (and-this) (also-this) (and-much-more) ...)&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; ((condition2) (do-that) (and-that) (also-that) (and-much-more) ...)&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (t (do-something) (do-something-else) (and-much-more) ...))&lt;br&gt;&lt;/div&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; In this syntax, cond is followed by many lists. Each list contains one condition and a set of statements. Lisp will look through each of those conditions, and when any of the conditions succeeds (that is, returns true), it will execute the set of statements that are with that conditions. One weird thing about cond is that it requires that at least one of the conditions be true. If not, Lisp will go mad and bite you (or so they say). So, just for safety, it is good practice to put a (t ..) as the last condition, which stands for 'true', so it is a condition that will always be true. If any of the conditions succeeds, Lisp will execute its statements and exit the cond. If none of them succeed, the statements that are with the (t ...) will run. &lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; If you want, you can think of the above cond as equivalent to:&lt;br&gt;&lt;div style="text-align: center;"&gt; if(condition1) {&lt;br&gt; do-this;&lt;br&gt; and-this; &lt;br&gt; also-this;&lt;br&gt; and-much-more; ...&lt;br&gt; }&lt;br&gt; else if(condition2) {&lt;br&gt; do-that;&lt;br&gt; and-that;&lt;br&gt; also-that;&lt;br&gt; and-much-more; ...&lt;br&gt; }&lt;br&gt; ...&lt;br&gt; else {&lt;br&gt; do-something;&lt;br&gt; do-something-else;&lt;br&gt; and-much-more; ...&lt;br&gt; }&lt;/div&gt;&lt;br&gt; Note that the final (t ...) in Lisp is like the final else clause of C. &lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;a name="setq"&gt;&lt;/a&gt;setq&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; setq is like the = assignment of C. i = 1; in C would be (setq i 1) in Lisp. Only today (two days after I finished this code), I read &lt;a  href="http://random-state.net/files/nikodemus-cl-faq.txt"&gt;here&lt;/a&gt; that it is better to use setf for this purpose in Lisp, but so far everyone has told me to use setq, so I'm not sure which one is really better. The author of this FAQ that I linked to seems to know things, so I'm gonna trust him and use setf hereafter. It's really a trivial change, here it would be (setf i 1) instead of (setq i 1). &lt;br&gt; &lt;a style="font-weight: bold;" name="car"&gt;&lt;/a&gt;&lt;span  style="font-weight: bold;"&gt;car &lt;/span&gt;and&lt;span  style="font-weight: bold;"&gt; &lt;/span&gt;&lt;a  style="font-weight: bold;" name="cdr"&gt;&lt;/a&gt;&lt;span  style="font-weight: bold;"&gt;cdr&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; These strange names stand for simple concepts - they give you the first element of the list and the rest of the elements of the list, respectively. (car '(1 2 3)) would be 1. (cdr '(1 2 3)) would be (2 3). As you can see, car returns a single value (which the Lispers call an atom), but cdr returns a list.&lt;br&gt; &lt;span style="font-weight: bold;"&gt;&lt;a name="format"&gt;&lt;/a&gt;format&lt;/span&gt;:&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; The format command is the printf of Lisp. It has many fancy options - it can even iterate through a list and print the elements one by one. Peter Seibel gives a very good explanation of the format function &lt;a  href="http://gigamonkeys.com/book/a-few-format-recipes.html"&gt;here&lt;/a&gt;. One simple example is: &lt;br&gt; &lt;div style="text-align: center;"&gt;(format t "~D~%" n)&lt;br&gt; &lt;/div&gt; is similar to &lt;br&gt; &lt;div style="text-align: center;"&gt;printf("%d\n", n);&lt;br&gt; &lt;/div&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; The 't' argument to format tells it to print the output to the screen (and not to a file or something like that). &lt;br&gt; With this intro, and some help from the Net, I think you'd be able to get a grasp of this program and learn a lot of Lisp in the meantime. Learning Lisp is said to be an &lt;a  href="http://www.catb.org/%7Eesr/faqs/hacker-howto.html#skills1"&gt;enlightening&lt;/a&gt; experience, so I hereby invite you to the path to &lt;a  href="http://en.wikipedia.org/wiki/Nirvana"&gt;Nirvana&lt;/a&gt;, with this piece of code (many thanks to this &lt;a href="http://www.tohtml.com/lisp/"&gt;online syntax highlighter&lt;/a&gt; for producing this HTML): &lt;br /&gt;&lt;pre style='color:#000000;background:#ffffff;'&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; inc-nth &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;n&lt;/span&gt; list&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;incf&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;nth&lt;/span&gt; n list&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  list&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; get-mid-elem &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;list&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;nth&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-mid-index&lt;/span&gt; list&lt;span style='color:#808030; '&gt;)&lt;/span&gt; list&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; mid-inc &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;list&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;inc-nth&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-mid-index&lt;/span&gt; list&lt;span style='color:#808030; '&gt;)&lt;/span&gt; list&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;br /&gt;  list&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; get-digits &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;n&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;cond&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;and&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;&amp;lt;&lt;/span&gt; n &lt;span style='color:#008c00; '&gt;10&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;&gt;=&lt;/span&gt; n &lt;span style='color:#008c00; '&gt;0&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;         &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;list&lt;/span&gt; n&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;&amp;lt;&lt;/span&gt; n &lt;span style='color:#008c00; '&gt;0&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;         &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-digits&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;-&lt;/span&gt; n&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;t&lt;/span&gt; &lt;br /&gt;         &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;append&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-digits&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;floor&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;/&lt;/span&gt; n &lt;span style='color:#008c00; '&gt;10&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;list&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;mod&lt;/span&gt; n &lt;span style='color:#008c00; '&gt;10&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; num-from-digits &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;digits&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;cond&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;=&lt;/span&gt; &lt;span style='color:#008c00; '&gt;1&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;length&lt;/span&gt; digits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;         &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;car&lt;/span&gt; digits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;t&lt;/span&gt;&lt;br /&gt;         &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;+&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;car&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;last&lt;/span&gt; digits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;*&lt;/span&gt; &lt;span style='color:#008c00; '&gt;10&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;num-from-digits&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;butlast&lt;/span&gt; digits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defmacro&lt;/span&gt; get-mid-index &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;list&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  `&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;ceiling&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;1-&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;/&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;length&lt;/span&gt; &lt;span style='color:#666616; '&gt;,list&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#008c00; '&gt;2&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; get-mirrored-num &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;ndigits&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;num-from-digits&lt;/span&gt; &lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;let&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;firsthalf&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;butlast&lt;/span&gt; ndigits &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;floor&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;/&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;length&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#008c00; '&gt;2&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;append&lt;/span&gt; firsthalf&lt;br /&gt;            &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;if&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;evenp&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;length&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;reverse&lt;/span&gt; firsthalf&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;cdr&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;reverse&lt;/span&gt; firsthalf&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; increm-left-from-here &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;index&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;cond&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;nth&lt;/span&gt; index ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#008c00; '&gt;9&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;         &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;progn&lt;/span&gt;&lt;br /&gt;           &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;setf&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;nth&lt;/span&gt; index ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#008c00; '&gt;0&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;           &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;if&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;zerop&lt;/span&gt; index&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;               &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;setq&lt;/span&gt; ndigits &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;cons&lt;/span&gt; &lt;span style='color:#008c00; '&gt;1&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;               &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;setq&lt;/span&gt; ndigits &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;increm-left-from-here&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;1-&lt;/span&gt; index&lt;span style='color:#808030; '&gt;)&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;t&lt;/span&gt; &lt;br /&gt;         &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;inc-nth&lt;/span&gt; index ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;defun&lt;/span&gt; get-next-palin &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;n&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;let&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;ndigits&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-digits&lt;/span&gt; n&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;cond&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;&gt;&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-mirrored-num&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt; n&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;           &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-mirrored-num&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;          &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;t&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-mirrored-num&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;increm-left-from-here&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-mid-index&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt; ndigits&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;let&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;num-cases&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;parse-integer&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;read-line&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;format&lt;/span&gt; &lt;span style='color:#7d0045; '&gt;t&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"~{~D~%~}"&lt;/span&gt; &lt;br /&gt;          &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;loop&lt;/span&gt; &lt;br /&gt;           for i from &lt;span style='color:#008c00; '&gt;1&lt;/span&gt; to num-cases&lt;br /&gt;           collect &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;get-next-palin&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;parse-integer&lt;/span&gt; &lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;read-line&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/7894217579088838991/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/7894217579088838991" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7894217579088838991" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7894217579088838991" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/04/lisp-by-and-for-c-programmer.html" rel="alternate" title="Lisp by and for the C programmer" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-482415404140906970</id><published>2009-04-14T12:10:00.006+05:30</published><updated>2009-04-26T13:44:23.184+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="blogging"/><category scheme="http://www.blogger.com/atom/ns#" term="posting"/><title type="text">I want a "good" editor to create blogs</title><content type="html">It's been happening for quite a while.&lt;br /&gt;&lt;br /&gt;Blogger's post editor has been playing games with me. Especially on my GATE solutions blog, where I like to keep things in a uniform format (dunno why, but it feels good to have similar formatting for similar posts - and all the posts there are similar to one another :) )&lt;br /&gt;&lt;br /&gt;I do a 'blockquote' (that's the double quotes icon in the Compose mode), type something, want to get out of the blockquote mode for the next line, it un-blockquotes all the previous lines too. What the heck?&lt;br /&gt;&lt;br /&gt;I select some text to delete it, Blogger decides I want to delete some surrounding text also and 'helpfully'  deletes. Just for testing, I tried deleting 'Blogger' in the previous line, it deleted 'decides' along with it. What on earth can be the logic behind such a thing?&lt;br /&gt;&lt;br /&gt;And the biggest fail here is that, when I try to undo that stupid deletion to restore order, it &lt;span style="font-weight: bold;"&gt;undoes more than I asked for and deletes some things I typed!&lt;/span&gt; Seriously, what did they think they were doing when they added this 'feature'? Now, just because I wanted to delete something, I have two options - either not do an undo and retype the things near the place I deleted, or do the undo and retype the things I typed recently. What if what I did not remember what I had typed there? I have to juggle back and forth between undo and redo to see what I typed myself, and &lt;span style="font-style: italic;"&gt;retype it myself&lt;/span&gt;! That's really... Worse Than Failure on Blogger's part.&lt;br /&gt;&lt;br /&gt;With all that frustration out of me, what I wanted to say was, I need a new editor to create my blog posts or I think I'll stop blogging from the mere frustration of dealing with this. Don't worry, I don't think the situation is so bad I won't be able to get &lt;span style="font-style: italic;"&gt;any&lt;/span&gt; editor to do the job. :)&lt;br /&gt;&lt;br /&gt;First, I remembered Microsoft Word itself has a 'Post to Blogger' option, so I tried it. Well, what can I say? The HTML it created was, to put it bluntly, &lt;span style="font-style: italic;"&gt;horrible!&lt;/span&gt; I'd have been somewhat ok with that if not for the next fact: when I clicked publish to blogger (or something similar), it told me my username and password would be sent in plaintext and anyone can read them. What? This huge program doesn't have a small place for incuding some SSL agent to do encrypted transmissions? I sure ain't giving my Google username and password in the wild like that.&lt;br /&gt;&lt;br /&gt;There's also a &lt;a href="http://buzz.blogger.com/bloggerforword.html"&gt;Blogger for Word&lt;/a&gt; add-in to Word that probably handles things more securely, but it's development has been discontinued by Google, and what they give for download doesn't work for me in Word 2007.&lt;br /&gt;&lt;br /&gt;Thinking there &lt;span style="font-style: italic;"&gt;should&lt;/span&gt; be some solution for it, I searched throughout the Internets, only ending up reading things like &lt;a href="http://www.massless.org/?archive=2004/07/more-technical-note-on-bloggers"&gt;this&lt;/a&gt; which told me some things about Blogger's WYSIWIG editor worked. Not really what I was looking for, but I learnt something. :)&lt;br /&gt;&lt;br /&gt;So, the option I'm looking at currently is, creating the posts in the &lt;a href="http://www.kompozer.net/"&gt;Kompozer &lt;/a&gt;or some similar editor, copying the resulting HTML here and posting. Quite a lot of work for such a simple task, but it seems there's no other option. Also, Kompozer doesn't seem to have easy buttons for things such as blockquotes, etc. like Blogger's interface, which makes things a bit more difficult. But in a few days' time, I think I'll be ok with anything to get off this  annoying editor.&lt;br /&gt;&lt;br /&gt;So, kind reader, if thou knowest of any editor which can my life more pleasant, kindly bestow thy blessings on poor me and reveal its name. I shall be indebted a lot to thou. Thanks. :)</content><link href="http://thetaoishere.blogspot.com/feeds/482415404140906970/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/482415404140906970" rel="replies" title="5 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/482415404140906970" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/482415404140906970" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/04/i-want-good-editor-to-create-blogs.html" rel="alternate" title="I want a &quot;good&quot; editor to create blogs" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-7158275648808080390</id><published>2009-04-10T00:14:00.006+05:30</published><updated>2009-10-25T02:28:33.156+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="palindrome"/><category scheme="http://www.blogger.com/atom/ns#" term="palindromic number"/><category scheme="http://www.blogger.com/atom/ns#" term="spoj"/><title type="text">Finding the next palindrome given a number</title><content type="html">I recently was looking for websites similar to Project Euler, and came across SPOJ - the &lt;a href="http://www.spoj.pl/problems/classical/"&gt;Sphere Online Judge&lt;/a&gt;. It gives us some problems, then asks us to submit a solution, which it will evaluate and tell if we are worth our salt as programmers ;)&lt;br /&gt;
More details &lt;a href="http://www.trap17.com/forums/Sphere-Online-Judge-spoj-t61121.html"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
There, I came across &lt;a href="http://www.spoj.pl/problems/PALIN/"&gt;this&lt;/a&gt; problem which looked quite interesting. Basically, the challenge is, given a number n, we've got to find the palindromic number which comes after this.&lt;br /&gt;
Some definitions:&lt;br /&gt;
Palindromic number: A number that reads the same either way, like 12421, 57375, 8448, 146641, etc.&lt;br /&gt;
"comes after this": the palindrome number &lt;span style="font-style: italic;"&gt;must&lt;/span&gt; be greater than the given number - given 12321, we must find the &lt;span style="font-style: italic;"&gt;next &lt;/span&gt;palindrome and not return 12321 itself as the answer.&lt;br /&gt;
&lt;br /&gt;
Ok, with those made clear, let's dive into the problem.&lt;br /&gt;
&lt;br /&gt;
On first sight, it seems simple enough: iterate from n+1 checking if each number is a palindrome. Stop when you find a palindrome.&lt;br /&gt;
Unfortunately, that strategy is too slow for our purposes - SPOJ clearly states the inputs can be very huge, in which case this brute force would probably not be able to complete it within the given 9 seconds.&lt;br /&gt;
&lt;br /&gt;
Anyway, we are programmers, and must seek more efficient ways when they exist. Here, it does seem there must be a way to find the next palindrome given a number. What would it be?&lt;br /&gt;
&lt;br /&gt;
My first thought was, simply mirror the number around its centre. Then, we'd surely end up with a palindromic number.&lt;br /&gt;
What I mean is, given a number 16310, mirror the first half values across the central '3' to give 16361. If the number has an even number of digits, just mirror it about the centre of the number, like 3628 to 3663.&lt;br /&gt;
&lt;br /&gt;
That strategy works as long as the resulting 'mirror-imaged' value is greater than the original number. What if it results in a number less than (or equal to) the original? Say, for 41258, it would give 41214, which is less than the original number. Or 12321, which would give 12321 itself, which is equal to the original number.&lt;br /&gt;
&lt;br /&gt;
So my next strategy was, if simple mirror-imaging fails, increment the middle digit and then do a mirror image. So, 41258 would become 41314. 12321 would be 12421.&lt;br /&gt;
&lt;br /&gt;
But again, there's a problem with this approach. What if the number had even number of digits? There is no middle digit to increment. Let's say the number was 4265. It's simple to see that, instead of the middle digit, if we increment the digit to the left of the middle (2 here), and do the mirror image, we'll have the palindrome we want: 4334 in this case.&lt;br /&gt;
&lt;br /&gt;
So far, so good.&lt;br /&gt;
&lt;br /&gt;
Now, onto a big issue: 9. Yes, the digit nine. We saw that when the simple mirroring fails, we increment the middle (or left to middle) digit. Now, what do we get when we increment 9? 10. Oops! We can't put a 10 where 9 was. Want proof? Try 41968. Simple mirroring would give 41914, no luck there. Incrementing the 9 to 10 would give 411014, not a palindrome even. And also, it's surely false that there's no palindrome between 41,968 and 411,014 (that's between forty one thousand and four hundred and eleven thousand).&lt;br /&gt;
&lt;br /&gt;
So, what do we do? Luckily, something we learnt in elementary school - carrying over - seems to help here too. Wherever the 10 occurred, keep the 0 there itself, carry over the 1 to the previous digit. So here, 41968 would become 42068 which on applying mirroring would give 42024.&lt;br /&gt;
&lt;br /&gt;
&lt;del&gt;Here too, there's a caveat: consider the extreme cases: 99999 would give (with repeated carryover) 1000001, and 9999 would give 100001. In both cases there's an extra 0 hanging in there. So far I've not been able to generalize it, and have been keeping the case of all digits being 9 a special case only. In this special case, I do the usual procedure, then remove one of the 0's from the resulting number. Ugly, but works. :) &lt;br /&gt;
&lt;/del&gt;&lt;br /&gt;
EDIT: Turns out if I finish the increment and carrying over parts fully, then mirror image the number according to how many digits it &lt;span style="font-style: italic;"&gt;now&lt;/span&gt; has, the 9999 cases take care of themselves with the original algo itself - no 'special cases' needed. :)&lt;br /&gt;
&lt;br /&gt;
So, I believe this is the complete algorithm to find the next palindrome given a number. I have not thought through the steps very carefully, so if you see any flaws, kindly point them out...&lt;br /&gt;
&lt;br /&gt;
I'm trying to code this thing in the Lisp programming language, so I'm taking baby steps towards the solution. As of now, I'm yet to implement the carrying over for 9 part alone. And I don't have any idea how complex that is going to be.&lt;br /&gt;
&lt;br /&gt;
Update: I finished coding this in Lisp, but lost the code somewhere. I coded it again in Python now, which is available &lt;a href="http://codepad.org/dEy6Myax"&gt;here&lt;/a&gt;. I've put in a &lt;i&gt;lot&lt;/i&gt; of comments so as to make it somewhat easily understandable. Hope this helps the doubting Thomases believe. :)&lt;br /&gt;
&lt;br /&gt;
By the way, my &lt;a href="http://gatesolutions.blogspot.com/"&gt;GATE solutions blog&lt;/a&gt; now has full feed access, which means you can read it fully without leaving the comfort of your RSS reader.&lt;br /&gt;
&lt;br /&gt;
Happy coding :)&lt;br /&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/7158275648808080390/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/7158275648808080390" rel="replies" title="24 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7158275648808080390" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7158275648808080390" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/04/finding-next-palindrome-given-number.html" rel="alternate" title="Finding the next palindrome given a number" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-494452153873860458</id><published>2009-04-02T23:56:00.008+05:30</published><updated>2009-04-06T20:47:59.533+05:30</updated><title type="text">Back to blogging</title><content type="html">Yeow... It's been quite a while since I blogged here. I've been doing somewhat better in my other blog about &lt;a href="http://gatesolutions.blogspot.com/"&gt;GATE question papers' solutions&lt;/a&gt;.&lt;br /&gt;The reason I've not been so active here is, unlike there, here I don't have anything specific to say.. I was just  bloggin whenever I felt I had free time, and also had something technically interesting to write about.&lt;br /&gt;These recent days, I had convinced myself that I was busy, couldn't afford time for blogging, didn't have anything worthy enough to blog about, etc. It's crazy to what extent you can deceive yourself, given this is possibly the most vetti (translated: being without any work) period I have ever had... :)&lt;br /&gt;Meanwhile, &lt;a href="http://vijaykumarm.blogspot.com/"&gt;Vijay&lt;/a&gt; had a look at my blog and was upset that it was fully technical. He recommended I write something 'not-so-technical' and more like a blog. And that seemed like a good idea too, as that would (hopefully) be much easier to do than to analyze and write a technical one...&lt;br /&gt;But what non-technical topic do I know anything about?&lt;br /&gt;I'm a  closet nerd, and hate small talk. I might do it in &lt;acronym title="Real Life"&gt;RL&lt;/acronym&gt; for 'social' reasons (gee, do I hate that word!), but surely not in my blog. This is my space, and shall remain so.&lt;br /&gt;Vijay himself came to the rescue again - 'you think a lot about spiritual and philosophical issues right, why not write articles about that?' he asked. For then, I pointed him to my pseudo home page: &lt;a href="http://sundaryourfriend.googlepages.com"&gt;http://sundaryourfriend.googlepages.com&lt;/a&gt;, but I knew it was heavily outdated and incomplete, and the content wasn't all that mature either. My views and ideas have changed a lot in the mean time (hopefully in a positive gradient), and I've (again hopefully) matured a lot.&lt;br /&gt;So, the conclusion of all this rant is, this is probably going to be the platform for my spiritual or philosophical posts too (unless I decide to start a new blog for it - in which case, I'll surely tell you).&lt;br /&gt;Also, don't get daunted by those two words - By spiritual, I mean things that can improve your life, and by philosophical, I just mean things that I think through deeply.. I'll keep the articles as interesting as Sundar-ly possible. ;)&lt;br /&gt;Finally, I promise you this will be the only nearly-contentless post in my blog (at least for some time), and I'll post something worthwhile as soon as possible... :)</content><link href="http://thetaoishere.blogspot.com/feeds/494452153873860458/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/494452153873860458" rel="replies" title="3 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/494452153873860458" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/494452153873860458" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2009/04/back-to-blogging.html" rel="alternate" title="Back to blogging" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-7388759513942544700</id><published>2008-12-29T12:10:00.004+05:30</published><updated>2009-04-26T13:39:45.548+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="stocks"/><title type="text">The golden rule of stock market investing</title><content type="html">&lt;span style="font-family:georgia;"&gt;&lt;span style="font-size:180%;"&gt;Never invest your emotions in the market.&lt;br /&gt;&lt;span style="font-size:50;"&gt;Remain Rational.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/7388759513942544700/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/7388759513942544700" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7388759513942544700" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/7388759513942544700" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2008/12/golden-rule-of-stock-market-investing.html" rel="alternate" title="The golden rule of stock market investing" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-3918880275000222355</id><published>2008-12-21T13:27:00.002+05:30</published><updated>2008-12-21T13:49:31.156+05:30</updated><title type="text">Solving a Zimbabwe Math Olympiad - Part 1</title><content type="html">Today, while reading &lt;a href="http://bit-player.org/2008/zimaths"&gt;this&lt;/a&gt; entry in bit-player, I saw a link to a &lt;a href="http://www.uz.ac.zw/science/maths/zimaths/zmo96ful.htm"&gt;Maths Olympiad&lt;/a&gt; (an Olympiad is &lt;a href="http://en.wiktionary.org/wiki/olympiad"&gt;supposedly&lt;/a&gt;: period of four years, by which the ancient Greeks reckoned time, being the interval from one celebration of the Olympic games to another. I don't know why they call this an Olympiad...)&lt;br /&gt;&lt;br /&gt;There were 20 questions from various areas of math, and they seemed quite easy and that was attractive to me (as my math workouts these days are very less). So, I've started solving them, and am gonna post my modus operandi for each problem as I solve it.&lt;br /&gt;&lt;br /&gt;The first problem was,&lt;br /&gt;&lt;blockquote&gt;If log&lt;sub&gt;2&lt;/sub&gt;(log&lt;sub&gt;3&lt;/sub&gt; a) = 2, what is the value of a?&lt;/blockquote&gt;Quite very easy, if you ask me. First, to remove any logarithm, you've got to raise both sides to the power of the base of the log. So, here, the first step would be, to raise both sides to the power of 2, so we'll end up with 2^(log&lt;sub&gt;2&lt;/sub&gt;(log&lt;sub&gt;3&lt;/sub&gt;a)) = 2^2 which would reduce to log&lt;sub&gt;3&lt;/sub&gt;a = 4 (since any x to the power of a log&lt;sub&gt;x&lt;/sub&gt;y will leave us with y alone.)&lt;br /&gt;Now, formally, I should have used the same method to remove the next log also. Instead, I found myself thinking, 'Which number's log to the base 3 will be 4?'. The answer to this was stored in my memory's cache as '81', so I determined that was the answer. And I did the ordinary computation method too in order to verify my answer, since the answers don't seem to have been given in that page...&lt;br /&gt;&lt;br /&gt;The second question was:&lt;br /&gt;&lt;blockquote&gt;In triangle ABD, the angular bisector of angle DAB meets BD at  C. If CD=6, BD=10 and AD=9, what is the length of AB?&lt;/blockquote&gt;Ok, this wasn't as easy to me. Geometry has never been a particularly favourite subject of mine, and the theorems were all things I learnt to pass through the exams. I remembered I had read somewhere about angle bisectors and things, but that was all I remembered. :)&lt;br /&gt;No worries, Google to the rescue. I searched for &lt;a href="http://www.google.co.in/search?q=angle+bisector+properties&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a"&gt;properties of angle bisectors&lt;/a&gt; and ended up in this &lt;a href="http://www.cut-the-knot.org/Curriculum/Geometry/AngleBisectorRatio.shtml"&gt;interactive page&lt;/a&gt; where they have some Java applet. Fortunately, my &lt;a href="http://noscript.net/"&gt;NoScript&lt;/a&gt; Firefox extension blocked the Java thingies (they slow down my system &lt;span style="font-style: italic;"&gt;badly&lt;/span&gt;!) and I had what I wanted scrolling down a little itself:&lt;br /&gt;&lt;blockquote&gt;&lt;p&gt;&lt;a name="explanation"&gt;Angle bisectors divide the opposite side in the ratio of the adjacent sides. More accurately, if, in &lt;img src="http://www.cut-the-knot.org/gifs/triangle.gif" width="18" height="20" /&gt;ABC, AD is an angle bisector of angle A, then&lt;/a&gt;&lt;/p&gt;  &lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td width="80"&gt;&lt;br /&gt;&lt;/td&gt;&lt;td&gt;AB/AC = DB/DC&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/blockquote&gt;So now, I have AD, CD and CB, I just need to apply this formula (note that C and D have reversed roles in the problem and the formula.)&lt;br /&gt;&lt;br /&gt;For us, AB/AD = CB/CD which means AB/9 = 4/6 which gives us AB = 6.&lt;br /&gt;I think I cheated by Googling, but what the heck! ;)&lt;br /&gt;&lt;br /&gt;to be continued... (as I solve more problems)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="display: block;font-family:arial;" &gt;&lt;/span&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/3918880275000222355/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/3918880275000222355" rel="replies" title="1 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/3918880275000222355" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/3918880275000222355" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2008/12/solving-zimbabwe-math-olympiad-part-1.html" rel="alternate" title="Solving a Zimbabwe Math Olympiad - Part 1" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-4496061966240594606</id><published>2008-11-29T19:35:00.007+05:30</published><updated>2009-04-26T13:40:29.556+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="diversification"/><category scheme="http://www.blogger.com/atom/ns#" term="economics"/><category scheme="http://www.blogger.com/atom/ns#" term="probability"/><category scheme="http://www.blogger.com/atom/ns#" term="stocks"/><title type="text">Explaining how diversification lowers risk - using probability</title><content type="html">With the economic crisis ringing high and loud everywhere, I decided I must delve into Economics and learn some things, if only to understand those newspaper and &lt;a href="http://www.stockmarketguide.in/2008/11/take-hard-decisions-to-bailout-indian.html"&gt;&lt;/a&gt;&lt;a href="http://www.stockmarketguide.in/2008/11/why-sector-is-crucial-for-stock-market.html"&gt;blog&lt;/a&gt; &lt;a href="http://www.stockmarketguide.in/2008/11/take-hard-decisions-to-bailout-indian.html"&gt;articles&lt;/a&gt;.&lt;a href="http://www.stockmarketguide.in/2008/11/take-hard-decisions-to-bailout-indian.html"&gt; &lt;/a&gt;Fortunately, one of the sites I just stumbled upon, &lt;a href="http://www.sharekhan.com/Default.aspx"&gt;ShareKhan&lt;/a&gt;, has an excellent &lt;a href="http://www.sharekhan.com/KnowledgeCentre/LearningInvest.aspx?ChapterID=7c8d6664-475c-4561-a373-29d6d1d7db84"&gt;tutorial&lt;/a&gt; on stocks and shares. Very informative, and somewhat to my surprise, a very interesting read too.&lt;br /&gt;In it, in &lt;a href="http://www.sharekhan.com/KnowledgeCentre/ChapterArticle.aspx?ArticleID=968883a6-3e46-486e-9dbd-fa2210114768"&gt;this&lt;/a&gt; page, there was an example about risk taking and avoidance. A simplified version of it is:&lt;br /&gt;&lt;blockquote&gt;&lt;span id="Article1_lblDesc"&gt;Which of these options do you think is very risky? Which one is the least risky to invest in?&lt;br /&gt;1. SAIL &lt;br /&gt;2. SAIL &amp;amp;  TISCO&lt;br /&gt;3. SAIL  &amp;amp;  HLL&lt;br /&gt;4.  HLL,  TISCO,  ACC &amp;amp;  Infosys&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;Now, if you have any idea about this thing called diversification at all, you would immediately say the answer - the last one is the least risky.&lt;br /&gt;&lt;br /&gt;The first one here is very risky - you bet all your money on a single horse.&lt;br /&gt;&lt;br /&gt;The second one is slightly better: you place your money on two different companies, but... they are in the same industry (steel), so a problem in the industry itself (which happens ever so often) would still affect you.&lt;br /&gt;&lt;br /&gt;In the third one, you still bet on two companies, but the risk is reduced, possibly by a lot. This is because the two companies deal with widely differing fields, so the chance that both of them will fail you together is quite less.&lt;br /&gt;&lt;br /&gt;The fourth one is perhaps the safest. Quoting from the tutorial itself,&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;blockquote&gt;&lt;div style="text-align: center;"&gt;&lt;span id="Article1_lblDesc"&gt;All these four stocks are leaders in their sectors. The sectors almost cover the entire spectrum of the market. At least two of them will be doing well. &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;That is all fine, but may be you are not convinced. At least, not convinced as much as to bet your money on it. No problem, Math exists to convince you doubting Thomases.&lt;br /&gt;&lt;br /&gt;So, let's begin.&lt;br /&gt;&lt;br /&gt;Assume that the probability that SAIL's shares will yield good returns and will not fail you is P(S), the same for TISCO is P(T) and that for HLL is P(H).&lt;br /&gt;&lt;br /&gt;Now, if you have bought the shares of SAIL and TISCO, the probability that &lt;span style="font-style: italic;"&gt;either&lt;/span&gt; of them will yield you good returns is&lt;br /&gt;&lt;div style="text-align: center;"&gt;P(S U T)&lt;br /&gt;&lt;div style="text-align: left;"&gt;which, as we know from our high school math, can be written as:&lt;br /&gt;&lt;div style="text-align: center;"&gt;P(S U T) = P(S) + P(T) - P(S ∩ T)&lt;br /&gt;&lt;div style="text-align: left;"&gt;Here, P(S ∩ T) represents the amount of correlation between the yields of SAIL and&lt;span style="font-style: italic;"&gt; &lt;/span&gt;TISCO - the probability that both companies will give you good yield. And &lt;span style="font-style: italic;"&gt;this&lt;/span&gt; is where the difference comes between case 2 and case 3. In case 3, we have,&lt;br /&gt;&lt;div style="text-align: center;"&gt;P(S U H) = P(S) + P(H) - P(S ∩ H)&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Now, the conditions so that neither SAIL and TISCO fail you are:&lt;br /&gt;&lt;div style="text-align: left;"&gt;1. When neither company does anything stupid&lt;br /&gt;2. When steel industry is going well and&lt;br /&gt;3. When  entire economic situation is good&lt;br /&gt;&lt;br /&gt;And the conditions for both SAIL and HLL give you good yield are:&lt;br /&gt;1. When neither company does anything stupid&lt;br /&gt;2. When steel industry is going well  &lt;span style="font-style: italic;"&gt;and &lt;/span&gt;the household items market is going well&lt;br /&gt;3. When  entire economic situation is good&lt;br /&gt;&lt;br /&gt;The two seem quite similar, except for the second point. But that small difference can make a large difference to your life. Heck, it might even decide the difference between luxury and bankruptcy!&lt;br /&gt;Ok, that dramatism was unwarranted, but you get the point. The probability that two unrelated industries will be very bright together is somewhat less than the probability that just one industry become bright. P(S ∩ T) is a little more than P(S ∩ H).&lt;br /&gt;&lt;div style="text-align: left;"&gt;When we apply this to the above two equations, we see that P(S U T) becomes less than P(S U H), or to put it in optimistic terms, the probability that the stocks fail someone who diversified more, is quite less than the probability that someone who didn't diversify effectively regrets his decision. Thus, good diversification reduces your risk and increases the probability that you will have a successful yield.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;From the above analysis, it is quite obvious that the lesser the value of (S ∩ H), the better are your chances of success. One way to achieve this is, as we did above, to choose industries that are less correlated with each other.&lt;br /&gt;&lt;br /&gt;However, while writing this, it occurred to me that P(S ∩ H) will be even lesser if the two industries were competing in some sense (in simplistic terms, think car and bike industry, which in some ways are competing with each other - though this is not a perfect example). In such a case, however, an increase in P(S) would decrease P(H), and vice versa. This is due to the very nature of the industries we chose - each one negatively affects the other.&lt;br /&gt;&lt;br /&gt;So, the choice is between choosing&lt;br /&gt;* uncorrelated industries so that P(S) and P(H) can increase simultaneously, but P(S ∩ H) is not quite less, and&lt;br /&gt;* competing industries so that P(S) and P(H) negatively influence each other, but P(S ∩ H) is very less&lt;br /&gt;&lt;br /&gt;Obviously,  there is no single answer: it depends on P(S), P(H) and the trend of P(S ∩ H). There is an equilibrium point: on one side of it, the first strategy works better, while on the other side, the second works better. Do your math and invest wisely. :)&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/4496061966240594606/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/4496061966240594606" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4496061966240594606" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4496061966240594606" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2008/11/explaining-how-diversification-lowers.html" rel="alternate" title="Explaining how diversification lowers risk - using probability" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-4818545498099519700</id><published>2008-11-12T08:54:00.010+05:30</published><updated>2009-04-26T14:01:43.053+05:30</updated><title type="text">Video and voice chat in Gmail</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_WIoDg1h8GxrH0yH15XKPOVT-PqxEDhy9A2p1JdOzSO5R-_QEp4eSvxJh451EUiwB3VVaHbxPa6CGsL_B4MSVpwCGUFOl_3zQBa7aNxDXCfvgIE2s6f8-UXGxEAhPqdUdahf7xwghvDA/s1600-h/gchatstat.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 137px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_WIoDg1h8GxrH0yH15XKPOVT-PqxEDhy9A2p1JdOzSO5R-_QEp4eSvxJh451EUiwB3VVaHbxPa6CGsL_B4MSVpwCGUFOl_3zQBa7aNxDXCfvgIE2s6f8-UXGxEAhPqdUdahf7xwghvDA/s200/gchatstat.bmp" alt="" id="BLOGGER_PHOTO_ID_5267626030599654066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now, it's finally here.&lt;br /&gt;The folks at Google have finally added Video and Voice chatting ability to the Gmail chat program (no, not Gtalk, it's in the chat thingie that's at the side within Gmail itself.) The &lt;a href="http://googleblog.blogspot.com/2008/11/talk-face-to-face-right-from-within.html"&gt;announcement &lt;/a&gt;seems to have been made only in the Google blog, which I kind of find strange since it won't reach most normal users this way. Anyway, it's Google, so they must have something clever in mind.&lt;br /&gt;To use this facility, you first have to download a plugin from &lt;a href="http://www.gmail.com/videochat"&gt;here&lt;/a&gt; and restart your browser. After that, you are supposed to have video and voice chat abilities; it took some time for me to appear, but it did get enabled after some time.&lt;br /&gt;Once the facility gets activated, there are some changes in your chat box. Mainly, the menu that said 'Options' in the lower left hand side of the chat box will now say 'Video &amp;amp; more'.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5sSQHd-Q5M-GwlMGIcihUEiFhU7GEgP99LjDooYrorfROI9EB-Fw-J2nrRScBQZsyS2KdKuwedxkhr-3I2OC0ORvagnQU17RgYh1FooF3voY9gZlkZhGllCI2tDdXr8PrHH5qKeH_pJM/s1600-h/gchatsample.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 180px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5sSQHd-Q5M-GwlMGIcihUEiFhU7GEgP99LjDooYrorfROI9EB-Fw-J2nrRScBQZsyS2KdKuwedxkhr-3I2OC0ORvagnQU17RgYh1FooF3voY9gZlkZhGllCI2tDdXr8PrHH5qKeH_pJM/s200/gchatsample.bmp" alt="" id="BLOGGER_PHOTO_ID_5267625460637191298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Expanding the menu gives:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSg-7WrJp7FxlwIQk4bjxSnAPobGDISUGmN8Dow0TBpNKubzge0fnWNgkum7rfJsZ348L3hyyJxPXRH5rl9o75ypVdU5ZCeA2mqRcaQ3dA-4SAGSm7HnWaTl6qTn-EoIrgg_TCi7VV7f0/s1600-h/gchatvidmenu.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 183px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSg-7WrJp7FxlwIQk4bjxSnAPobGDISUGmN8Dow0TBpNKubzge0fnWNgkum7rfJsZ348L3hyyJxPXRH5rl9o75ypVdU5ZCeA2mqRcaQ3dA-4SAGSm7HnWaTl6qTn-EoIrgg_TCi7VV7f0/s200/gchatvidmenu.JPG" alt="" id="BLOGGER_PHOTO_ID_5267623934475625122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The actual options differ based on whom you are chatting with. If the other person too had this Video chat plugin installed, there would be an option to start a video chat.&lt;br /&gt;So, from now on, you can do voice chat with your friends who are in Gtalk, from within Gmail itself.&lt;br /&gt;And if you have a Webcam, you can show your new haircut or your newest girlfriend to your mom. Have fun! :)</content><link href="http://thetaoishere.blogspot.com/feeds/4818545498099519700/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/4818545498099519700" rel="replies" title="1 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4818545498099519700" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4818545498099519700" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2008/11/video-and-voice-chat-in-gmail.html" rel="alternate" title="Video and voice chat in Gmail" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_WIoDg1h8GxrH0yH15XKPOVT-PqxEDhy9A2p1JdOzSO5R-_QEp4eSvxJh451EUiwB3VVaHbxPa6CGsL_B4MSVpwCGUFOl_3zQBa7aNxDXCfvgIE2s6f8-UXGxEAhPqdUdahf7xwghvDA/s72-c/gchatstat.bmp" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-925782140179817214</id><published>2008-08-24T22:18:00.002+05:30</published><updated>2008-08-24T22:21:29.631+05:30</updated><title type="text">Million dollars...</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs1oXXLCQDPUuRw00Hc6g5ZOiywUry9qLEaLDYgUpaBCajZdJZoiE2bmDPTeYuE3wAw798ueiBaQKw01IfHKU8YxjdbJ7QjOVAlrN6HteWnnxnfb_L8FFo8CYhWvGa8xsuYH537XOqqa4/s1600-h/hobocomplex.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs1oXXLCQDPUuRw00Hc6g5ZOiywUry9qLEaLDYgUpaBCajZdJZoiE2bmDPTeYuE3wAw798ueiBaQKw01IfHKU8YxjdbJ7QjOVAlrN6HteWnnxnfb_L8FFo8CYhWvGa8xsuYH537XOqqa4/s400/hobocomplex.JPG" alt="" id="BLOGGER_PHOTO_ID_5238127424317228642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;This really must have been a coincidence... No, really... ;)&lt;br /&gt;&lt;img src="file:///C:/DOCUME%7E1/Sundar/LOCALS%7E1/Temp/moz-screenshot.jpg" alt="" /&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/925782140179817214/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/925782140179817214" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/925782140179817214" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/925782140179817214" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2008/08/million-dollars.html" rel="alternate" title="Million dollars..." type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs1oXXLCQDPUuRw00Hc6g5ZOiywUry9qLEaLDYgUpaBCajZdJZoiE2bmDPTeYuE3wAw798ueiBaQKw01IfHKU8YxjdbJ7QjOVAlrN6HteWnnxnfb_L8FFo8CYhWvGa8xsuYH537XOqqa4/s72-c/hobocomplex.JPG" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-1465809636616255511</id><published>2008-05-04T12:03:00.020+05:30</published><updated>2018-04-01T19:50:25.338+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="math"/><category scheme="http://www.blogger.com/atom/ns#" term="perl"/><category scheme="http://www.blogger.com/atom/ns#" term="prime"/><category scheme="http://www.blogger.com/atom/ns#" term="program"/><category scheme="http://www.blogger.com/atom/ns#" term="project euler"/><title type="text">Largest prime factor of a number</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;Long live the programming overlords! Today is the day I have begun serious programming again... 'serious' is perhaps a bit too much - programming is never actually serious, it's a sort of fun activity that happens to appear boring and difficult and hence obtains good paychecks from the HR types... ;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;Anyway, I happened to come across the Project Euler and registered in the site. The registration was painless and I fell in love with the site immediately. Problems 1 and 2 were trivial (finding the sum of the multiples of 3 or 5 under 1000, finding the sum of even numbers in the Fibonacci series which are less than 4 million).&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;Problem 3 was a &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-style: italic;"&gt;little&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; more involved. I had to find the largest prime factor of 600851475143. It isn't particularly difficult, but it does call for some thinking. The first method I thought of was to&lt;/span&gt;&lt;/div&gt;
&lt;ol style="font-family: trebuchet ms; font-size: 130%;"&gt;
&lt;li&gt;divide the number by successive integers upto sqrt(&lt;span style="font-weight: bold;"&gt;n&lt;/span&gt;), and&lt;/li&gt;
&lt;li&gt;when the remainder is 0, check whether the divisor is prime,&lt;/li&gt;
&lt;li&gt;if so, store it as answer overwriting the previous value, if any.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;An obvious improvement was to come down from sqrt(&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;) so that the first number to satisfy conditions 2 and 3 would be the answer.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;However, by this time, something seemed fishy in this method. Particularly, it occurred to me that a prime number checking was costly and unnecessary here. Instead, you can go about it using a recursive solution:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;FindLargestPrimeFactor(n):&lt;/span&gt;&lt;br /&gt;
&lt;ol style="font-family: trebuchet ms; font-size: 130%;"&gt;
&lt;li&gt;divide the number by successive integers (each denoted by &lt;span style="font-weight: bold;"&gt;i&lt;/span&gt;)  upto sqrt(&lt;span style="font-weight: bold;"&gt;n&lt;/span&gt;),&lt;/li&gt;
&lt;li&gt;when the remainder is 0, return the maximum among &lt;span style="font-weight: bold;"&gt;i&lt;/span&gt; and FindLargestPrimeFactor(&lt;span style="font-weight: bold;"&gt;n&lt;/span&gt;/&lt;span style="font-weight: bold;"&gt;i&lt;/span&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;It might not be clear at first sight that the algorithm works correctly. There seems to be no check for primality. However, this algorithm exploits the fact that the &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-style: italic;"&gt;smallest &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;factor &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;sf&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; of a number &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; will necessarily be prime. This is because, if it were not prime, its factors would be factors of &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; and hence &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;sf&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; would not be the smallest factor. Thus, we need only find the smallest factor to have a prime factor. Then, we can divide away this factor and again find the smallest factor. This way, we can have all the prime factors of a number.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;In the algorithm, we find a prime factor of &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;, compare it with the largest prime factor of &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;/&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;i&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;, and return the larger number. Thus, finally, we'll have the largest prime factor of the number &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; itself.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;Obviously, we need a limit for the recursion. In this case, this limit occurs when &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;i&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; overflows &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;sn&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;. This means that &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; is prime, and hence we must return &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;n&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; itself as the largest prime number.&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;This was the logic of my program as I coded and finished it. I entered the answer into the Project Euler website (which is projecteuler.net, by the way). After that, I saw the forums in the website and saw that many had implemented my original algorithm which used prime testing. This more efficient recursive solution had missed the neurons of many... With that boost to my &lt;/span&gt;&lt;a href="http://www.hhhh.org/wiml/virtues.html" style="font-family: trebuchet ms; font-size: 130%;"&gt;hubris&lt;/a&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;, I turned to the pdf containing the 'overview' of the problem.&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;Wow, the algorithm described is very close to mine. One improvement is that the recursion has instead become an iteration. This is one area where I stumble every time - converting a recursive program into an iterative one. So I bookmarked this in my mind and moved on.&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;&lt;br /&gt;The next improvement was one that made me feel stupid for not thinking of it earlier. Since I'm going to find only prime factors, I need only use 2 and odd numbers in step 1. So, I can use a separate step for 2 and then start with 3 and increment &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;i&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; by 2. This way, we'll save about half of the iterations...&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(255 , 0 , 0); font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: rgb(255 , 0 , 0); font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%; font-weight: bold;"&gt;UPDATE&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;: There are quite a number of other improvements that &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;must&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; be done to this algorithm. For &lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;t&lt;/span&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;he actual algorithm for this problem (which develops on the algorithm here), see &lt;/span&gt;&lt;a href="http://thetaoishere.blogspot.com/2009/04/finding-largest-prime-factor.html" style="font-family: trebuchet ms; font-size: 130%;"&gt;Finding the Largest prime factor efficiently&lt;/a&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;The final perl program I wrote was:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;courier new&amp;quot;;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;use&lt;/span&gt; &lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;strict&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;use&lt;/span&gt; warnings&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;

&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;my&lt;/span&gt; $magic &lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0 , 140 , 0);"&gt;600851475143&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;

&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;sub &lt;/span&gt;largestprimef&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;sub &lt;/span&gt;max&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$$&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;

&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;print&lt;/span&gt; largestprimef&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$magic&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;sub &lt;/span&gt;largestprimef&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;{&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;my&lt;/span&gt; $n &lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;shift&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;

&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;my&lt;/span&gt; $i&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;return&lt;/span&gt; largestprimef(max&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0 , 140 , 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;,&lt;/span&gt; $n&lt;span style="color: rgb(128 , 128 , 48);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(0 , 140 , 0);"&gt;2)&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$n &lt;span style="color: rgb(128 , 128 , 48);"&gt;%&lt;/span&gt; &lt;span style="color: rgb(0 , 140 , 0);"&gt;2&lt;/span&gt; &lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0 , 140 , 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;my&lt;/span&gt; $sn &lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;sqrt&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$n&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;

&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$i &lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0 , 140 , 0);"&gt;3&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt; $i &lt;span style="color: rgb(128 , 128 , 48);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; $sn&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt; $i &lt;span style="color: rgb(128 , 128 , 48);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0 , 140 , 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;  &lt;span style="color: rgb(128 , 0 , 128);"&gt;{&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;  &lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;last&lt;/span&gt; if&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$n &lt;span style="color: rgb(128 , 128 , 48);"&gt;%&lt;/span&gt; $i &lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0 , 140 , 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;}&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$i &lt;span style="color: rgb(128 , 128 , 48);"&gt;&amp;gt;&lt;/span&gt; $sn&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(105 , 105 , 105);"&gt;#loop ran over, means the number is prime&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;{&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;  return&lt;/span&gt; $n&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;}&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;else&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;{&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;return&lt;/span&gt; max&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$i&lt;span style="color: rgb(128 , 128 , 48);"&gt;,&lt;/span&gt; largestprimef&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$n&lt;span style="color: rgb(128 , 128 , 48);"&gt;/&lt;/span&gt;$i&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;}&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;}&lt;/span&gt;

&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;sub &lt;/span&gt;max&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;$$&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;{&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 0); font-weight: bold;"&gt;sort&lt;/span&gt; &lt;span style="color: rgb(128 , 0 , 128);"&gt;{&lt;/span&gt; $a &lt;span style="color: rgb(64 , 1 , 90);"&gt;&amp;lt;=&amp;gt;&lt;/span&gt; $b &lt;span style="color: rgb(128 , 0 , 128);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;(&lt;/span&gt;@_&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0 , 140 , 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(128 , 128 , 48);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(128 , 0 , 128);"&gt;;&lt;/span&gt;
&lt;span style="color: rgb(128 , 0 , 128);"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;span style="color: rgb(255 , 0 , 0); font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;A few notes about the program here:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li style="font-family: trebuchet ms; font-size: 130%;"&gt;not 'use'-ing the strict and warning pragmas gave a speed improvement of a few milliseconds&lt;/li&gt;
&lt;li style="font-family: trebuchet ms; font-size: 130%;"&gt;first I implemented max in the good old comparison way - if i &amp;gt; j, return i else return j. Turns out perl's sort implementation gives &lt;del&gt;faster results than this&lt;/del&gt; &lt;i&gt;equivalent speed&lt;/i&gt;. I just tried it for the heck of it &lt;del&gt;, and was surprised to see a few milliseconds improvement. Probably the speed improvement came from the removal of 'shift's to get the numbers from @_ to $i and $j.&lt;/del&gt;&lt;i&gt;(that was a temporary illusion; in repeated testing both turned out to be equivalent.&lt;/i&gt;&lt;/li&gt;
&lt;li style="font-family: trebuchet ms; font-size: 130%;"&gt;Since I did the program in Linux, the age old newline problem cropped up. When I pasted the code into blogger, it showed the code as one continuous mess. I had to use &lt;a class="linkification-ext" href="http://www.hashemall.com/" title="Linkification: http://www.hashemall.com/"&gt;http://www.hashemall.com/&lt;/a&gt; for converting the newlines. The site dutifully hashed the program, and thankfully returned my original text with MS Windows newlines in place of Unix ones.. (The hash value under sha-1 was &lt;span id="hash"&gt;b8b7188ad3440084e5db7f44fd70d599f897e33a, in case you are interested... :) )&lt;/span&gt;&lt;/li&gt;
&lt;li style="font-family: trebuchet ms; font-size: 130%;"&gt;&lt;span id="hash"&gt;The final runtime was around 14 ms.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span id="hash"&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt;UPDATE: The code highlighting is courtesy of &lt;/span&gt;&lt;a href="http://www.tohtml.com/perl/" style="font-family: trebuchet ms; font-size: 130%;"&gt;&lt;span style="text-decoration: underline;"&gt;Online syntax highlighter 'tohtml'&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: &amp;quot;trebuchet ms&amp;quot;; font-size: 130%;"&gt; which is an excellent service by the way.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link href="http://thetaoishere.blogspot.com/feeds/1465809636616255511/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/1465809636616255511" rel="replies" title="25 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/1465809636616255511" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/1465809636616255511" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2008/05/largest-prime-factor-of-number.html" rel="alternate" title="Largest prime factor of a number" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>25</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-8600834731953382460</id><published>2007-11-07T01:49:00.001+05:30</published><updated>2009-04-26T13:41:20.870+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="math"/><category scheme="http://www.blogger.com/atom/ns#" term="perl"/><category scheme="http://www.blogger.com/atom/ns#" term="program"/><category scheme="http://www.blogger.com/atom/ns#" term="small numbers"/><title type="text">Law of small numbers and such...</title><content type="html">&lt;blockquote&gt;&lt;p class="Text"&gt; The first strong law of small numbers (Gardner 1980, Guy 1988, Guy 1990) states "There aren't enough small numbers to meet the many demands made of them." &lt;/p&gt; The second strong law of small numbers (Guy 1990) states that "When two numbers look equal, it ain't necessarily so." Guy (1988a) gives 35 examples of this statement, and 40 more in Guy (1990). For example, example 35 notes that the first few values of the interpolating polynomial &lt;img src="http://mathworld.wolfram.com/images/equations/StrongLawofSmallNumbers/inline1.gif" class="inlineformula" alt="(n^4-6n^3+23n^2-18n+24)/24" border="0" height="16" width="195" /&gt; [...] for &lt;img src="http://mathworld.wolfram.com/images/equations/StrongLawofSmallNumbers/inline2.gif" class="inlineformula" alt="n==1" border="0" height="15" width="33" /&gt;, 2, ... are  1, 2, 4, 8, 16, .... Thus, the polynomial appears to give the powers of 2, but then  continues 31, 57, 99, ... (Sloane's &lt;a href="http://www.research.att.com/%7Enjas/sequences/A000127" class="Hyperlink"&gt;A000127&lt;/a&gt;).&lt;/blockquote&gt;I just read this at &lt;a href="http://mathworld.wolfram.com/StrongLawofSmallNumbers.html"&gt;Wolfram &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Mathworld&lt;/span&gt;&lt;/a&gt;; and something flashed within me. What if the &lt;span style="font-style: italic;"&gt;differences&lt;/span&gt; between this poly and the actual powers of two were significant? Well, being terribly bored and having a lot of time to kill, I set out to explore that. I was stuck at the first step itself - I was in Linux, and didn't know any way to do math explorations like this. Had I been in Windows, I would have used &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Matlab&lt;/span&gt; (damn good and surprisingly easy to use). I'm sure there's some 'popular' Free Software for this kind of job, but I was not in a mood to search for software packages and get into dependency hell just yet. So, I just asked myself, can I do it with what&lt;span style="font-style: italic;"&gt; &lt;/span&gt;I &lt;span style="font-style: italic;"&gt;do&lt;/span&gt; know to do in Linux?&lt;br /&gt;Writing C programs. Perl scripts. Shell scripts. For this kind of job, Perl somehow seemed more appropriate. So, I typed out a Perl script to find the differences (here f(n) is the 4&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;th&lt;/span&gt; order polynomial given in the above article):&lt;table&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;n&lt;/td&gt;&lt;td&gt;f(n)&lt;/td&gt;&lt;td&gt;2^n&lt;/td&gt;&lt;td&gt;diff&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;31&lt;/td&gt;&lt;td&gt;32&lt;/td&gt;&lt;td&gt;1&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;57&lt;/td&gt;&lt;td&gt;64&lt;/td&gt;&lt;td&gt;7&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;99&lt;/td&gt;&lt;td&gt;128&lt;/td&gt;&lt;td&gt;29&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;163&lt;/td&gt;&lt;td&gt;256&lt;/td&gt;&lt;td&gt;93&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;/td&gt;&lt;td&gt;256&lt;/td&gt;&lt;td&gt;512&lt;/td&gt;&lt;td&gt;256&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;/td&gt;&lt;td&gt;386&lt;/td&gt;&lt;td&gt;1024&lt;/td&gt;&lt;td&gt;638&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;/td&gt;&lt;td&gt;562&lt;/td&gt;&lt;td&gt;2048&lt;/td&gt;&lt;td&gt;1486&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;/td&gt;&lt;td&gt;794&lt;/td&gt;&lt;td&gt;4096&lt;/td&gt;&lt;td&gt;3302&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;/td&gt;&lt;td&gt;1093&lt;/td&gt;&lt;td&gt;8192&lt;/td&gt;&lt;td&gt;7099&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;/td&gt;&lt;td&gt;1471&lt;/td&gt;&lt;td&gt;16384&lt;/td&gt;&lt;td&gt;14913&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;1941&lt;/td&gt;&lt;td&gt;32768&lt;/td&gt;&lt;td&gt;30827&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;/td&gt;&lt;td&gt;2517&lt;/td&gt;&lt;td&gt;65536&lt;/td&gt;&lt;td&gt;63019&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;/td&gt;&lt;td&gt;3214&lt;/td&gt;&lt;td&gt;131072&lt;/td&gt;&lt;td&gt;127858&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;/td&gt;&lt;td&gt;4048&lt;/td&gt;&lt;td&gt;262144&lt;/td&gt;&lt;td&gt;258096&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;/td&gt;&lt;td&gt;5036&lt;/td&gt;&lt;td&gt;524288&lt;/td&gt;&lt;td&gt;519252&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;/td&gt;&lt;td&gt;6196&lt;/td&gt;&lt;td&gt;1048576&lt;/td&gt;&lt;td&gt;1042380&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;/td&gt;&lt;td&gt;7547&lt;/td&gt;&lt;td&gt;2097152&lt;/td&gt;&lt;td&gt;2089605&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;/td&gt;&lt;td&gt;9109&lt;/td&gt;&lt;td&gt;4194304&lt;/td&gt;&lt;td&gt;4185195&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;/td&gt;&lt;td&gt;10903&lt;/td&gt;&lt;td&gt;8388608&lt;/td&gt;&lt;td&gt;8377705&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;No obvious pattern emerged. Then, on second thoughts, there &lt;span style="font-style: italic;"&gt;did &lt;/span&gt;&lt;span&gt;seem to be some sort of pattern to it. The differences are all increasing. But each one increased by a lesser amount than the previous one. 7/1 is (quite obviously) 7&lt;/span&gt;, 29/7 is slightly greater than 4, 93/29 is slightly greater than 3, etc. As the numbers increased, it seemed that they &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_3"&gt;increased&lt;/span&gt; by successively smaller factors. The numbers had some kind of &lt;span style="font-style: italic;"&gt;geometrical&lt;/span&gt; pattern - sort of like a geometric series where you get successive terms by multiplying each term by a constant ratio. However, in this case, the ratio wasn't exactly constant. Instead, it seemed to be &lt;span style="font-style: italic;"&gt;tending towards&lt;/span&gt; some constant.&lt;br /&gt;&lt;br /&gt;To check this out, I then printed the &lt;span style="font-style: italic;"&gt;quotient &lt;/span&gt;obtained by dividing each difference by its predecessor. Lo and behold, suddenly, there was Light:&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;n&lt;/td&gt;&lt;td&gt;f(n)&lt;/td&gt;&lt;td&gt;2^n&lt;/td&gt;&lt;td&gt;diff&lt;/td&gt;&lt;td&gt;quotient&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;31&lt;/td&gt;&lt;td&gt;32&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;~&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;57&lt;/td&gt;&lt;td&gt;64&lt;/td&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;7&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;99&lt;/td&gt;&lt;td&gt;128&lt;/td&gt;&lt;td&gt;29&lt;/td&gt;&lt;td&gt;4.14285714285714&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;163&lt;/td&gt;&lt;td&gt;256&lt;/td&gt;&lt;td&gt;93&lt;/td&gt;&lt;td&gt;3.20689655172414&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;/td&gt;&lt;td&gt;256&lt;/td&gt;&lt;td&gt;512&lt;/td&gt;&lt;td&gt;256&lt;/td&gt;&lt;td&gt;2.75268817204301&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;/td&gt;&lt;td&gt;386&lt;/td&gt;&lt;td&gt;1024&lt;/td&gt;&lt;td&gt;638&lt;/td&gt;&lt;td&gt;2.4921875&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;/td&gt;&lt;td&gt;562&lt;/td&gt;&lt;td&gt;2048&lt;/td&gt;&lt;td&gt;1486&lt;/td&gt;&lt;td&gt;2.32915360501567&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;/td&gt;&lt;td&gt;794&lt;/td&gt;&lt;td&gt;4096&lt;/td&gt;&lt;td&gt;3302&lt;/td&gt;&lt;td&gt;2.22207267833109&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;/td&gt;&lt;td&gt;1093&lt;/td&gt;&lt;td&gt;8192&lt;/td&gt;&lt;td&gt;7099&lt;/td&gt;&lt;td&gt;2.14990914597214&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;/td&gt;&lt;td&gt;1471&lt;/td&gt;&lt;td&gt;16384&lt;/td&gt;&lt;td&gt;14913&lt;/td&gt;&lt;td&gt;2.10071841104381&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;1941&lt;/td&gt;&lt;td&gt;32768&lt;/td&gt;&lt;td&gt;30827&lt;/td&gt;&lt;td&gt;2.06712264467243&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;/td&gt;&lt;td&gt;2517&lt;/td&gt;&lt;td&gt;65536&lt;/td&gt;&lt;td&gt;63019&lt;/td&gt;&lt;td&gt;2.04427936549129&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;/td&gt;&lt;td&gt;3214&lt;/td&gt;&lt;td&gt;131072&lt;/td&gt;&lt;td&gt;127858&lt;/td&gt;&lt;td&gt;2.02888017899364&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;/td&gt;&lt;td&gt;4048&lt;/td&gt;&lt;td&gt;262144&lt;/td&gt;&lt;td&gt;258096&lt;/td&gt;&lt;td&gt;2.01861440035039&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;/td&gt;&lt;td&gt;5036&lt;/td&gt;&lt;td&gt;524288&lt;/td&gt;&lt;td&gt;519252&lt;/td&gt;&lt;td&gt;2.01185605356147&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;21&lt;/td&gt;&lt;td&gt;6196&lt;/td&gt;&lt;td&gt;1048576&lt;/td&gt;&lt;td&gt;1042380&lt;/td&gt;&lt;td&gt;2.00746458367036&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;22&lt;/td&gt;&lt;td&gt;7547&lt;/td&gt;&lt;td&gt;2097152&lt;/td&gt;&lt;td&gt;2089605&lt;/td&gt;&lt;td&gt;2.00464801703793&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;23&lt;/td&gt;&lt;td&gt;9109&lt;/td&gt;&lt;td&gt;4194304&lt;/td&gt;&lt;td&gt;4185195&lt;/td&gt;&lt;td&gt;2.00286417767951&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;24&lt;/td&gt;&lt;td&gt;10903&lt;/td&gt;&lt;td&gt;8388608&lt;/td&gt;&lt;td&gt;8377705&lt;/td&gt;&lt;td&gt;2.00174782775952&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;So, there you have it: the quotient of dividing each successive difference between 2^n and this f(n) is approaching 2. For n=70 and higher, it was so close to 2 that Perl gave it up and printed it as just 2. So, the quotients are converging towards 2 as far as we can see. Each successive difference, then, is obtained by multiplying the previous difference by a number very close to 2.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;That&lt;/span&gt; is the kind of beauty math has. You obtain a sequence that looks like powers of 2 for small numbers, you find that it deviates from the actual value for higher powers, &lt;span style="font-style: italic;"&gt;then&lt;/span&gt; you find that the &lt;span style="font-style: italic;"&gt;deviation itself&lt;/span&gt; is increasing in powers of two. This thing has some inexplicable beauty to it... :)&lt;br /&gt;So, now that we've found that this thing seems to converge to 2, how do we interpret it? &lt;span style="font-style: italic;"&gt;That's &lt;/span&gt;the kind of thing for which you need mathematical training. If I had had some good math course on series and sequences, &lt;span style="font-style: italic;"&gt;may be&lt;/span&gt; I would know what to do with this. May be I'd theoretically prove that the quotients actually converge to 2 as n tends to infinity. May be we can show that this f(n) can indeed be used to find powers of 2.&lt;br /&gt;For now, let's get into the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;nitty&lt;/span&gt; gritty of this number crunching. First, I wrote this cute little program (any claims to its &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;uncuteness&lt;/span&gt; are by Agents of Satan; avoid them like plague) :&lt;br /&gt;&lt;br /&gt;#!/&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;usr&lt;/span&gt;/bin/&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;perl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;use warnings;&lt;br /&gt;use strict;&lt;br /&gt;&lt;br /&gt;my @range = (6 .. 24); #6 is where the differences start to be non-zero&lt;br /&gt;my $i;&lt;br /&gt;my @diffs;&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;foreach&lt;/span&gt; $i (@range)&lt;br /&gt;{&lt;br /&gt;print $i,"\t\t";&lt;br /&gt;print (( $i**4 - 6*$i**3 + 23*$i**2 - 18*$i + 24 ) / 24, "\t\t");&lt;br /&gt;print 2**($i - 1), "\t\t";&lt;br /&gt;push @diffs, (2**($i - 1) -  (( $i**4 - 6*$i**3 + 23*$i**2 - 18*$i + 24 ) / 24));&lt;br /&gt;print $diffs[$#diffs], "\t\t";&lt;br /&gt;$#diffs &amp;amp;&amp;amp; print $diffs[$#diffs]/$diffs[$#diffs-1];&lt;br /&gt;print "\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Then, I ran the output through &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;txt&lt;/span&gt;2html with --make_tables option. I got the HTML code for a table, which you can see with naked eye by right clicking here and choosing 'View source' (or whatever option reads close to that). Using the code, I made a blog post named 'Law of small numbers and such...'.&lt;br /&gt;&lt;br /&gt;You just finished reading it!</content><link href="http://thetaoishere.blogspot.com/feeds/8600834731953382460/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/8600834731953382460" rel="replies" title="3 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/8600834731953382460" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/8600834731953382460" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2007/11/law-of-small-numbers-and-such.html" rel="alternate" title="Law of small numbers and such..." type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-873653696618200465</id><published>2007-08-28T19:20:00.000+05:30</published><updated>2007-08-28T19:22:16.544+05:30</updated><title type="text">A Gentle Echo on Woman: LOTD</title><content type="html">&lt;a href="http://en.wikisource.org/wiki/A_Gentle_Echo_on_Woman"&gt;http://en.wikisource.org/wiki/A_Gentle_Echo_on_Woman&lt;/a&gt;&lt;br /&gt;The content of the poem isn't completely right (IMHO), but the concept is great. Hats off to Swift's power of imagination and creativity.</content><link href="http://thetaoishere.blogspot.com/feeds/873653696618200465/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/873653696618200465" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/873653696618200465" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/873653696618200465" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2007/08/gentle-echo-on-woman-lotd.html" rel="alternate" title="A Gentle Echo on Woman: LOTD" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-4177518529658268511</id><published>2007-07-29T11:58:00.000+05:30</published><updated>2007-07-29T12:57:45.007+05:30</updated><title type="text"/><content type="html">&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.boardofwisdom.com/default.asp?start=51&amp;topic=1005&amp;amp;listname=Geek"&gt;The Best Geek Quotes, Sayings, and Phrases - 51 to 60&lt;/a&gt;&lt;/strong&gt; &lt;/p&gt;&lt;span class="quote"&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;1. In the beginning GOD created the Bit and the Byte. And from&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;those he created the Word.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;2. And there were two Bytes in the Word; and nothing else existed.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And God separated the One from the Zero; and he saw it was&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;good.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;3. And God said - Let the Data be; And so it happened.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And God said - Let the Data go to their proper places.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And he created floppy disks and hard disks and compact disks.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;4. And God said - Let the computers be, so there would be a place&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;to put floppy disks and hard disks and compact disks.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;Thus God created computers and called them hardware.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;5. And there was no Software yet. But God created programs; small&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;and big... And told them - Go and multiply yourselves and fill&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;all the Memory.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;6. And God said -I will create the Programmer; And the Programmer&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;will make new programs and govern over the computers and&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;programs and Data.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;7. And God created the Programmer; and put him at Data Center;&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And God showed the Programmer the Catalog Tree and said&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;You can use all the volumes and subvolumes but DO NOT USE&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;Windows.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;8. And God said - It is not Good for the programmer to be alone.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;He took a bone from the Programmer's body and created a&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;creature that would look up at the Programmer; and admire&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;the Programmer; and love the things the Programmer does;&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And God called the creature: the User.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;9. And the Programmer and the User were left under the naked DOS&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;and it was Good.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;10. But Bill was smarter than all the other creatures of God.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And Bill said to the User - Did God really tell you not to&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;run any programs ?&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;11. And the User answered - God told us that we can use every&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;program and every piece of Data but told us not to run Windows&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;or we will die.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;12. And Bill said to the User - How can you talk about something&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;you did not even try. The moment you run Windows you will&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;become equal to God. You will be able to create anything you&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;like by a simple click of your mouse.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;13. And the User saw that the fruits of the Windows were nicer and&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;easier to use. And the User saw that any knowledge was useless&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;- since Windows could replace it.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;14. So the User installed the Windows on his computer; and said to&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;the Programmers that it was good.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;15. And the Programmer immediately started to look for new drivers.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And God asked him - What are you looking for? And the&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;Programmer answered - I am looking for new drivers because I&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;can not find them in the DOS. And God said - Who told you need&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;drivers? Did you run Windows?&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And the Programmer said - It was Bill who told us to !&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;16. And God said to Bill - Because of what you did you will be hated&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;by all the creatures. And the User will always be unhappy with you.&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;And you will always sell Windows.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;17. And God said to the User - Because of what you did, the Windows&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;will disappoint you and eat up all your Resources; and you will&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;have to use lousy programs; and you will always rely on the&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;Programmers help.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;18. And God said to the Programmer - Because you listened to the&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;User you will never be happy. All your programs will have errors&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;and you will have to fix them and fix them to the end of time.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;19. And God threw them out of the Data Center and locked the door&lt;/layer&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;and secured it with a password.&lt;/layer&gt;&lt;br /&gt;&lt;br /&gt;&lt;layer title="" owner="" mode="" class="DIIGO-POWER" name="" style=""&gt;20. GENERAL PROTECTION FAULT&lt;/layer&gt;&lt;/span&gt;</content><link href="http://thetaoishere.blogspot.com/feeds/4177518529658268511/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/4177518529658268511" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4177518529658268511" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/4177518529658268511" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2007/07/best-geek-quotes-sayings-and-phrases-51.html" rel="alternate" title="" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3263316935908175537.post-2251745213690627948</id><published>2007-07-19T23:14:00.002+05:30</published><updated>2009-04-26T14:28:16.142+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="captcha"/><category scheme="http://www.blogger.com/atom/ns#" term="cool"/><category scheme="http://www.blogger.com/atom/ns#" term="interesting"/><category scheme="http://www.blogger.com/atom/ns#" term="math"/><title type="text">A cool captcha!</title><content type="html">Are you human?&lt;br /&gt;   This is a question we often get asked when registering for things on the net - the sign up page gives a scrambled image containing some text, and we are asked to type out the characters from that.&lt;br /&gt;   This is to make sure that we are indeed human, and not some software created to make fake registrations for illicit usage. The idea is that software programs cannot 'see' the text within the image, while we humans can.&lt;br /&gt;   Now, &lt;a href="http://random.irb.hr/signup.php"&gt;this site&lt;/a&gt; has a cool new way of doing it: instead of asking to type out letters from an image, it asks us to solve a math problem. It is usually a simple problem which can be solved by anyone with undergrad level math practice. I got 'what is the least zero of the polynomial x^2 + 3x' (the answer is -3).&lt;br /&gt;   While not everyone might be able to solve these problems, the site registration too is not for everyone - it's a registration to download a 'quantum random bit generation service' client; someone downloading &lt;span style="font-style: italic;"&gt;that&lt;/span&gt; can probably solve these problems hands down...&lt;br /&gt;&lt;br /&gt;PS: No, I didn't download the client. I registered only because I heard about this cool method of doing a captcha and wanted to give it a try... :)</content><link href="http://thetaoishere.blogspot.com/feeds/2251745213690627948/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/3263316935908175537/2251745213690627948" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/2251745213690627948" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/3263316935908175537/posts/default/2251745213690627948" rel="self" type="application/atom+xml"/><link href="http://thetaoishere.blogspot.com/2007/07/cool-captcha.html" rel="alternate" title="A cool captcha!" type="text/html"/><author><name>Sundar</name><uri>http://www.blogger.com/profile/00415039983973239001</uri><email>noreply@blogger.com</email><gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://1.bp.blogspot.com/_pTfAhByxcnA/SezTHrIw8JI/AAAAAAAAAOk/UFcT30vLq9M/S220/xkcd+profile.png" width="32"/></author><thr:total>0</thr:total></entry></feed>