Popular recipes tagged "loops"http://code.activestate.com/recipes/tags/loops/2014-03-08T13:09:41-08:00ActiveState Code RecipesFactorial (Python) 2014-03-08T13:09:41-08:00Johnhttp://code.activestate.com/recipes/users/4189390/http://code.activestate.com/recipes/578848-factorial/ <p style="color: grey"> Python recipe 578848 by <a href="/recipes/users/4189390/">John</a> (<a href="/recipes/tags/factorial/">factorial</a>, <a href="/recipes/tags/loop/">loop</a>, <a href="/recipes/tags/loops/">loops</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/range/">range</a>, <a href="/recipes/tags/simple/">simple</a>). </p> <p>Just a simple factorial program I made in Python 3.</p> Finding complete loops in a map of connected nodes (Python) 2012-04-24T18:47:21-07:00Sachin Joglekarhttp://code.activestate.com/recipes/users/4181845/http://code.activestate.com/recipes/578110-finding-complete-loops-in-a-map-of-connected-nodes/ <p style="color: grey"> Python recipe 578110 by <a href="/recipes/users/4181845/">Sachin Joglekar</a> (<a href="/recipes/tags/circuit/">circuit</a>, <a href="/recipes/tags/connection/">connection</a>, <a href="/recipes/tags/loops/">loops</a>). </p> <p>This module finds loops in a given map.Input is a dictionary like</p> <p>d={1:[2,4,5,6],2:[1,3],3:[2,4,5,6],4:[1,3,5],5:[1,3,4],6:[1,3]}</p> <p>this means node 1 is connected to nodes 2,4,5 and 6 and so on..</p> <p>Output is a list of complete loops. for above examples,output is</p> <p>[[1, 4, 5, 1], [3, 4, 5, 3], [1, 2, 3, 4, 1], [1, 2, 3, 5, 1], [1, 2, 3, 6, 1], [1, 4, 3, 5, 1], [1, 4, 3, 6, 1], [1, 5, 3, 6, 1], [1, 2, 3, 4, 5, 1], [1, 4, 5, 3, 6, 1]]</p>