4 Topics

Member Avatar for
Member Avatar for vegaseat

One way to find the shortest distance between a series of surface (x, y) points is to let Python module itertools find the non-repeating combinations of point pairs. Now you can apply the Pythagoras' theorem to find all the distances and the minimum distance.

Member Avatar for gerisam
3
2K
Member Avatar for flebber

I was reading this article [Click Here](http://maxburstein.com/blog/python-shortcuts-for-the-python-beginner/) http://maxburstein.com/blog/python-shortcuts-for-the-python-beginner/ In there was this example from itertools import combinations teams = ["Packers", "49ers", "Ravens", "Patriots"] for game in combinations(teams, 2): print game >>> ('Packers', '49ers') >>> ('Packers', 'Ravens') >>> ('Packers', 'Patriots') >>> ('49ers', 'Ravens') >>> ('49ers', 'Patriots') >>> ('Ravens', 'Patriots') So I …

Member Avatar for vegaseat
0
430
Member Avatar for memomk

ok now lets say we have this code import hashlib,itertools,string m=hashlib.md5() s=string.printable it=itertools.product(s,repeat=1) for i in it: ij="".join(i) m.update(ij) print ij+" "+m.hexdigest() >> 0 cfcd208495d565ef66e7dff9f98764da 1 96a3be3cf272e017046d1b2674a52bd3 2 d2490f048dc3b77a457e3e450ab4eb38 3 eb62f6b9306db575c2d596b1279627a4 4 4100c4d44da9177247e44a5fc1546778 5 d6a9a933c8aafc51e55ac0662b6e4d4a 6 124bd1296bec0d9d93c7b52a71ad8d5b 7 2e9ec317e197819358fbc43afca7d837 8 22975d8a5ed1b91445f6c55ac121505b 9 781e5e245d69b566979b86e28d23f2c7 a 343817fa02440513ce03e9d1f1e44dc7 b b60c52bf4849067f0b57c8bd30985466 c 2d31d97199fb287d6fcb4f82ebd1b3f2 d …

Member Avatar for memomk
0
563
Member Avatar for king_koder

I tried to generate permutations by using itertools module but its not working. [CODE=python] >>>print(permutations([1,2,3],3)) <itertools.permutations object at 0xa917c5c> [/CODE] Why is it so? and how do I make it work properly?

Member Avatar for slate
0
192

The End.