Popular recipes by Narayana Chikkam http://code.activestate.com/recipes/users/4174427/2015-12-22T10:49:59-08:00ActiveState Code RecipesFollow Sets Construction (Python) 2015-12-22T10:49:21-08:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/579140-follow-sets-construction/ <p style="color: grey"> Python recipe 579140 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/cfg/">cfg</a>, <a href="/recipes/tags/first/">first</a>, <a href="/recipes/tags/follow/">follow</a>, <a href="/recipes/tags/nullable/">nullable</a>). Revision 2. </p> <p>Language Processors: FOLLOW(A) = {t | (t is a terminal and S ⇒+ α A t β) or (t is EOF and S ⇒∗ αA)}</p> Simple Graph library (Python) 2015-12-22T10:49:59-08:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/579141-simple-graph-library/ <p style="color: grey"> Python recipe 579141 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/graph/">graph</a>). Revision 2. </p> <p>A collection of generally used Graph Algorithms in one place with simple constructs.</p> QuadKeys Generator - useful for N'ary strings generation (Python) 2014-06-12T10:29:35-07:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/578888-quadkeys-generator-useful-for-nary-strings-generat/ <p style="color: grey"> Python recipe 578888 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/quinary/">quinary</a>). </p> <p>As per the standard articles available on the internet, world map could be divided into four section top left, top right, bottom left and bottom right. if we associate numbers to identify them, for eg: 0 -&gt; top left 1 -&gt; top right 2 -&gt; bottom left 3 -&gt; bottom right it would be easier to dig into a tile or a section of the map using this system. A good documentation on the same is available on the 'Bing Map Tile System'. It would be a good idea to have some snippet of code that generates these sequence of numbers in this system so that world map could be traversed in a serial fashion. The class has 3 generator methods that produce the same sequence. Width corresponds to the zoom level.</p> Shuffle (Python) 2013-02-19T11:01:01-08:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/578466-shuffle/ <p style="color: grey"> Python recipe 578466 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/shuffle/">shuffle</a>). </p> <p>Python function to shuffle a deck of cards</p> Infinite Stream Divisor (Python) 2010-07-21T12:50:17-07:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/577326-infinite-stream-divisor/ <p style="color: grey"> Python recipe 577326 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/divisor/">divisor</a>, <a href="/recipes/tags/infinite/">infinite</a>, <a href="/recipes/tags/stream/">stream</a>). </p> <p>Maintain an F.S.A to keep track of the consequent remainders as states, input symbols as driving actions on each state. O(N) is the time complexity to find the given large string [in some radix(R), for some specific divisor(D)], where N is the length of the Input String which confirms to the Language Rules under the alphabet. O(R*D) is the space complexity to keep the F.S.A in memory for lookup!</p> Eight Queens With out Permutations (Python) 2010-07-21T10:11:20-07:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/577325-eight-queens-with-out-permutations/ <p style="color: grey"> Python recipe 577325 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/eight/">eight</a>, <a href="/recipes/tags/queens/">queens</a>). </p> <p>Eight Queens is one of the popular algorithms in backtracking. The solution given below uses simple math to reduce the processing. The logic is keep placing the coins on the board with below rules:</p> <ol> <li>Don't place the coin if there is another coin present in the same row</li> <li>Don't place the coin if there is another coin present in the same col</li> <li>Don't place the coin if there is another coin present in any of the diagonal lines.</li> </ol> <p>Keep repeating the above 3 rules recursively until we keep all the coins. Problem Definition: <a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle" rel="nofollow">http://en.wikipedia.org/wiki/Eight_queens_puzzle</a></p>