Python论坛  - 讨论区

标题:[python-chinese] Python的排列组合算法

2006年03月04日 星期六 18:13

ajax chelsea ajaxchelsea at gmail.com
Sat Mar 4 18:13:50 HKT 2006

翻了半天标准库没有找到排列组合算法,请问Python标准库提供了常用的排列组合算法了吗?大家平时都用什么库来操作排列组合呢?

另外,这个邮件列表跟google group的python.cn组会自动同步吗?
是不是邮件列表里的信件会自动转到group里,而group里的帖子不会自动发给这个邮件列表?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060304/406f5d54/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月05日 星期日 06:28

shhgs shhgs.efhilt at gmail.com
Sun Mar 5 06:28:59 HKT 2006

没有提供,但是你可以自己写,很简单的。

这里我给一个我全排列的,你参考一下。

     1	def FullCombination(choice) :
     2	    class Rotor(object) :
     3	        def __init__(self, choice, parent = None) :
     4	            assert len(choice) >= 1
     5	            self.parent = parent
     6	            self.choice = choice
     7	            self.cursor  = 0
     8	            if len(choice) == 1 :
     9	                self.child = None
    10	            else :
    11	                childChoice = choice[:self.cursor] +
choice[self.cursor + 1:]
    12	                self.child = Rotor(childChoice, self)
    13	        def value(self) :
    14	            if self.child :
    15	                result = self.child.value()
    16	                result.append(self.choice[self.cursor])
    17	                return result
    18	            else :
    19	                return [ self.choice[0], ]
    20	        def next(self) :
    21	            node = self.child
    22	            while node.child :
    23	                node = node.child
    24	            node = node.parent
    25	            while len(node.choice) == node.cursor + 1 :
    26	                node = node.parent
    27	                if not node :
    28	                    return False
    29	            else :
    30	                node.cursor += 1
    31	                cursor = node.cursor
    32	                node_child_choice = node.choice[:cursor] +
node.choice[cursor + 1:]
    33	                node.child = Rotor(node_child_choice, node)
    34	                return True
    35	    rotor = Rotor(choice)
    36	    yield rotor.value()
    37	    while rotor.next() :
    38	        yield rotor.value()
    39	
    40	if __name__ == "__main__" :
    41	    s = ['a', 'b', 'c']
    42	    gen = FullCombination(s)
    43	    for i in gen :
    44	        print i



On 3/4/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
>
> 翻了半天标准库没有找到排列组合算法,请问Python标准库提供了常用的排列组合算法了吗?大家平时都用什么库来操作排列组合呢?
>
> 另外,这个邮件列表跟google
> group的python.cn组会自动同步吗?是不是邮件列表里的信件会自动转到group里,而group里的帖子不会自动发给这个邮件列表?
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月06日 星期一 10:01

ajax chelsea ajaxchelsea at gmail.com
Mon Mar 6 10:01:11 HKT 2006

多谢,比我自己写的灵活,我是把整个list返回的,而不是使用yield

我先写出从m个元素的list里取n个元素的排列算法P(m, n),剩下的组合C(m, n)和全排列,全组合都是基于P(m, n)完成的:

#从m个元素的list里取n个元素的排列算法P(m, n):

def permutation(listobj, length):
    assert listobj != None and 0 < length <= len(listobj)
    if(length == 1):
        return [ [x] for x in listobj ]
    result = []
    for i in range(len(listobj)):
        cp = list(listobj)
        cur = cp[i]
        del cp[i]
        result.extend( [cur] + x for x in permutation(cp, length-1) )
    return result


#然后是组合C(m, n),那个unique函数是我从PythonCookbook里拿过来的:

def combination(listobj, length):
    return unique( map(sort, permutation(listobj, length)) )

#全排列:

def full_permutation(listobj):
    result = []
    [ result.extend(permutation(listobj, n)) for n in range(1,
len(listobj)+1)]
    return result

#全组合:

def full_combination(listobj):
    return unique( map(sort, full_permutation(listobj)) )

#测试一下:


print permutation([1,2,3, 4], 1)
print permutation([1,2,3, 4], 2)
print permutation([1,2,3, 4], 3)
print permutation([1,2,3, 4], 4)

print combination([1,2,3, 4], 1)
print combination([1,2,3, 4], 2)
print combination([1,2,3, 4], 3)
print combination([1,2,3, 4], 4)

print full_permutation([1,2,3,4])
print full_combination([1,2,3,4])

里面有大量的复制操作,效率是相当~~~~低的,大家给点意见



在06-3-5,shhgs <shhgs.efhilt at gmail.com> 写道:
>
> 没有提供,但是你可以自己写,很简单的。
>
> 这里我给一个我全排列的,你参考一下。
>
>     1  def FullCombination(choice) :
>     2      class Rotor(object) :
>     3          def __init__(self, choice, parent = None) :
>     4              assert len(choice) >= 1
>     5              self.parent = parent
>     6              self.choice = choice
>     7              self.cursor  = 0
>     8              if len(choice) == 1 :
>     9                  self.child = None
>    10              else :
>    11                  childChoice = choice[:self.cursor] +
> choice[self.cursor + 1:]
>    12                  self.child = Rotor(childChoice, self)
>    13          def value(self) :
>    14              if self.child :
>    15                  result = self.child.value()
>    16                  result.append(self.choice[self.cursor])
>    17                  return result
>    18              else :
>    19                  return [ self.choice[0], ]
>    20          def next(self) :
>    21              node = self.child
>    22              while node.child :
>    23                  node = node.child
>    24              node = node.parent
>    25              while len(node.choice) == node.cursor + 1 :
>    26                  node = node.parent
>    27                  if not node :
>    28                      return False
>    29              else :
>    30                  node.cursor += 1
>    31                  cursor = node.cursor
>    32                  node_child_choice = node.choice[:cursor] +
> node.choice[cursor + 1:]
>    33                  node.child = Rotor(node_child_choice, node)
>    34                  return True
>    35      rotor = Rotor(choice)
>    36      yield rotor.value()
>    37      while rotor.next() :
>    38          yield rotor.value()
>    39
>    40  if __name__ == "__main__" :
>    41      s = ['a', 'b', 'c']
>    42      gen = FullCombination(s)
>    43      for i in gen :
>    44          print i
>
>
>
> On 3/4/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
> >
> > 翻了半天标准库没有找到排列组合算法,请问Python标准库提供了常用的排列组合算法了吗?大家平时都用什么库来操作排列组合呢?
> >
> > 另外,这个邮件列表跟google
> > group的python.cn组会自动同步吗?是不是邮件列表里的信件会自动转到group里,而group里的帖子不会自动发给这个邮件列表?
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to
> > python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info:
> > http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060306/b7a7b8e1/attachment-0001.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月06日 星期一 10:19

shhgs shhgs.efhilt at gmail.com
Mon Mar 6 10:19:05 HKT 2006

我对自己的算法还是比较满意的。用了链表,每个值给出的时间基本上都是相同的。

把这个算法改写成P(m,n)很简单,只要限定链表的节点数就可以了。
但是要搞出类似的C(m,n)的算法,我现在还没有思路。

全部做成一个set当然很简单,直接做一个set,然后P(m,n)往里面放。但是这个算法我不能满意。我想要一个类似P(m,n)的,能够以比较恒定的内存运算的算法。


On 3/5/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
>
> 多谢,比我自己写的灵活,我是把整个list返回的,而不是使用yield
>
> 我先写出从m个元素的list里取n个元素的排列算法P(m, n),剩下的组合C(m, n)和全排列,全组合都是基于P(m, n)完成的:
>
> #从m个元素的list里取n个元素的排列算法P(m, n):
>
> def permutation(listobj, length):
>     assert listobj != None and 0 < length <= len(listobj)
>     if(length == 1):
>         return [ [x] for x in listobj ]
>     result = []
>     for i in range(len(listobj)):
>         cp = list(listobj)
>         cur = cp[i]
>         del cp[i]
>         result.extend( [cur] + x for x in permutation(cp, length-1) )
>     return result
>
>
> #然后是组合C(m, n),那个unique函数是我从PythonCookbook里拿过来的:
>
> def combination(listobj, length):
>     return unique( map(sort, permutation(listobj, length)) )
>
> #全排列:
>
> def full_permutation(listobj):
>     result = []
>     [ result.extend(permutation(listobj, n)) for n in range(1,
> len(listobj)+1)]
>     return result
>
> #全组合:
>
> def full_combination(listobj):
>     return unique( map(sort, full_permutation(listobj)) )
>
> #测试一下:
>
>
>
> print permutation([1,2,3, 4], 1)
> print permutation([1,2,3, 4], 2)
> print permutation([1,2,3, 4], 3)
> print permutation([1,2,3, 4], 4)
>
> print combination([1,2,3, 4], 1)
> print combination([1,2,3, 4], 2)
> print combination([1,2,3, 4], 3)
> print combination([1,2,3, 4], 4)
>
> print full_permutation([1,2,3,4])
> print full_combination([1,2,3,4])
>
> 里面有大量的复制操作,效率是相当~~~~低的,大家给点意见
>
>
>
> 在06-3-5,shhgs <shhgs.efhilt at gmail.com> 写道:
> > 没有提供,但是你可以自己写,很简单的。
> >
> > 这里我给一个我全排列的,你参考一下。
> >
> >     1  def FullCombination(choice) :
> >     2      class Rotor(object) :
> >     3          def __init__(self, choice, parent = None) :
> >     4              assert len(choice) >= 1
> >     5              self.parent = parent
> >     6              self.choice = choice
> >     7              self.cursor   = 0
> >     8              if len(choice) == 1 :
> >     9                  self.child = None
> >    10              else :
> >    11                  childChoice = choice[:self.cursor] +
> > choice[self.cursor + 1:]
> >    12                   self.child = Rotor(childChoice, self)
> >    13          def value(self) :
> >    14              if self.child :
> >    15                  result = self.child.value()
> >    16                  result.append(self.choice[self.cursor ])
> >    17                  return result
> >    18              else :
> >    19                  return [ self.choice[0], ]
> >    20          def next(self) :
> >    21              node = self.child
> >    22              while node.child :
> >    23                  node = node.child
> >    24              node = node.parent
> >    25              while len(node.choice) == node.cursor + 1 :
> >    26                  node = node.parent
> >    27                  if not node :
> >    28                      return False
> >    29              else :
> >    30                  node.cursor += 1
> >    31                  cursor = node.cursor
> >    32                  node_child_choice =
> node.choice[:cursor] +
> > node.choice[cursor + 1:]
> >    33                  node.child = Rotor(node_child_choice, node)
> >    34                  return True
> >    35      rotor = Rotor(choice)
> >    36      yield rotor.value()
> >    37      while rotor.next() :
> >    38          yield rotor.value()
> >    39
> >    40  if __name__ == "__main__" :
> >    41      s = ['a', 'b', 'c']
> >    42      gen = FullCombination(s)
> >    43      for i in gen :
> >    44          print i
> >
> >
> >
> > On 3/4/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
> > >
> > >
> 翻了半天标准库没有找到排列组合算法,请问Python标准库提供了常用的排列组合算法了吗?大家平时都用什么库来操作排列组合呢?
> > >
> > > 另外,这个邮件列表跟google
> > >
> group的python.cn组会自动同步吗?是不是邮件列表里的信件会自动转到group里,而group里的帖子不会自动发给这个邮件列表?
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to
> > > python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info:
> > > http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> > Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月06日 星期一 10:34

shhgs shhgs.efhilt at gmail.com
Mon Mar 6 10:34:56 HKT 2006

我有思路了,过两天等有空了写出来

这段代码是不是够资格贴到cookbook?

On 3/5/06, shhgs <shhgs.efhilt at gmail.com> wrote:
> 我对自己的算法还是比较满意的。用了链表,每个值给出的时间基本上都是相同的。
>
> 把这个算法改写成P(m,n)很简单,只要限定链表的节点数就可以了。
> 但是要搞出类似的C(m,n)的算法,我现在还没有思路。
>
> 全部做成一个set当然很简单,直接做一个set,然后P(m,n)往里面放。但是这个算法我不能满意。我想要一个类似P(m,n)的,能够以比较恒定的内存运算的算法。
>
>
> On 3/5/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
> >
> > 多谢,比我自己写的灵活,我是把整个list返回的,而不是使用yield
> >
> > 我先写出从m个元素的list里取n个元素的排列算法P(m, n),剩下的组合C(m, n)和全排列,全组合都是基于P(m, n)完成的:
> >
> > #从m个元素的list里取n个元素的排列算法P(m, n):
> >
> > def permutation(listobj, length):
> >     assert listobj != None and 0 < length <= len(listobj)
> >     if(length == 1):
> >         return [ [x] for x in listobj ]
> >     result = []
> >     for i in range(len(listobj)):
> >         cp = list(listobj)
> >         cur = cp[i]
> >         del cp[i]
> >         result.extend( [cur] + x for x in permutation(cp, length-1) )
> >     return result
> >
> >
> > #然后是组合C(m, n),那个unique函数是我从PythonCookbook里拿过来的:
> >
> > def combination(listobj, length):
> >     return unique( map(sort, permutation(listobj, length)) )
> >
> > #全排列:
> >
> > def full_permutation(listobj):
> >     result = []
> >     [ result.extend(permutation(listobj, n)) for n in range(1,
> > len(listobj)+1)]
> >     return result
> >
> > #全组合:
> >
> > def full_combination(listobj):
> >     return unique( map(sort, full_permutation(listobj)) )
> >
> > #测试一下:
> >
> >
> >
> > print permutation([1,2,3, 4], 1)
> > print permutation([1,2,3, 4], 2)
> > print permutation([1,2,3, 4], 3)
> > print permutation([1,2,3, 4], 4)
> >
> > print combination([1,2,3, 4], 1)
> > print combination([1,2,3, 4], 2)
> > print combination([1,2,3, 4], 3)
> > print combination([1,2,3, 4], 4)
> >
> > print full_permutation([1,2,3,4])
> > print full_combination([1,2,3,4])
> >
> > 里面有大量的复制操作,效率是相当~~~~低的,大家给点意见
> >
> >
> >
> > 在06-3-5,shhgs <shhgs.efhilt at gmail.com> 写道:
> > > 没有提供,但是你可以自己写,很简单的。
> > >
> > > 这里我给一个我全排列的,你参考一下。
> > >
> > >     1  def FullCombination(choice) :
> > >     2      class Rotor(object) :
> > >     3          def __init__(self, choice, parent = None) :
> > >     4              assert len(choice) >= 1
> > >     5              self.parent = parent
> > >     6              self.choice = choice
> > >     7              self.cursor   = 0
> > >     8              if len(choice) == 1 :
> > >     9                  self.child = None
> > >    10              else :
> > >    11                  childChoice = choice[:self.cursor] +
> > > choice[self.cursor + 1:]
> > >    12                   self.child = Rotor(childChoice, self)
> > >    13          def value(self) :
> > >    14              if self.child :
> > >    15                  result = self.child.value()
> > >    16                  result.append(self.choice[self.cursor ])
> > >    17                  return result
> > >    18              else :
> > >    19                  return [ self.choice[0], ]
> > >    20          def next(self) :
> > >    21              node = self.child
> > >    22              while node.child :
> > >    23                  node = node.child
> > >    24              node = node.parent
> > >    25              while len(node.choice) == node.cursor + 1 :
> > >    26                  node = node.parent
> > >    27                  if not node :
> > >    28                      return False
> > >    29              else :
> > >    30                  node.cursor += 1
> > >    31                  cursor = node.cursor
> > >    32                  node_child_choice =
> > node.choice[:cursor] +
> > > node.choice[cursor + 1:]
> > >    33                  node.child = Rotor(node_child_choice, node)
> > >    34                  return True
> > >    35      rotor = Rotor(choice)
> > >    36      yield rotor.value()
> > >    37      while rotor.next() :
> > >    38          yield rotor.value()
> > >    39
> > >    40  if __name__ == "__main__" :
> > >    41      s = ['a', 'b', 'c']
> > >    42      gen = FullCombination(s)
> > >    43      for i in gen :
> > >    44          print i
> > >
> > >
> > >
> > > On 3/4/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
> > > >
> > > >
> > 翻了半天标准库没有找到排列组合算法,请问Python标准库提供了常用的排列组合算法了吗?大家平时都用什么库来操作排列组合呢?
> > > >
> > > > 另外,这个邮件列表跟google
> > > >
> > group的python.cn组会自动同步吗?是不是邮件列表里的信件会自动转到group里,而group里的帖子不会自动发给这个邮件列表?
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info:
> > > > http://python.cn/mailman/listinfo/python-chinese
> > > >
> > > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to
> > python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > > Detail Info:
> > http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to
> > python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info:
> > http://python.cn/mailman/listinfo/python-chinese
> >
> >
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月06日 星期一 11:29

Zoom Quiet zoom.quiet at gmail.com
Mon Mar 6 11:29:32 HKT 2006

这些片段的语法颜色是怎么来的?不会是手工右的吧…………

On 3/6/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
>
> 多谢,比我自己写的灵活,我是把整个list返回的,而不是使用yield
>
> 我先写出从m个元素的list里取n个元素的排列算法P(m, n),剩下的组合C(m, n)和全排列,全组合都是基于P(m, n)完成的:
>
> #从m个元素的list里取n个元素的排列算法P(m, n):
>
> def permutation(listobj, length):
>     assert listobj != None and 0 < length <= len(listobj)
>     if(length == 1):
>         return [ [x] for x in listobj ]
>     result = []
>     for i in range(len(listobj)):
>         cp = list(listobj)
>         cur = cp[i]
>         del cp[i]
>         result.extend( [cur] + x for x in permutation(cp, length-1) )
>     return result
>
>
> #然后是组合C(m, n),那个unique函数是我从PythonCookbook里拿过来的:
>
> def combination(listobj, length):
>     return unique( map(sort, permutation(listobj, length)) )
>
> #全排列:
>
> def full_permutation(listobj):
>     result = []
>     [ result.extend(permutation(listobj, n)) for n in range(1,
> len(listobj)+1)]
>     return result
>
> #全组合:
>
> def full_combination(listobj):
>     return unique( map(sort, full_permutation(listobj)) )
>
> #测试一下:
>
>
>
> print permutation([1,2,3, 4], 1)
> print permutation([1,2,3, 4], 2)
> print permutation([1,2,3, 4], 3)
> print permutation([1,2,3, 4], 4)
>
> print combination([1,2,3, 4], 1)
> print combination([1,2,3, 4], 2)
> print combination([1,2,3, 4], 3)
> print combination([1,2,3, 4], 4)
>
> print full_permutation([1,2,3,4])
> print full_combination([1,2,3,4])
>
> 里面有大量的复制操作,效率是相当~~~~低的,大家给点意见
>
>
>
> 在06-3-5,shhgs <shhgs.efhilt at gmail.com> 写道:
> > 没有提供,但是你可以自己写,很简单的。
> >
> > 这里我给一个我全排列的,你参考一下。
> >
> >     1  def FullCombination(choice) :
> >     2      class Rotor(object) :
> >     3          def __init__(self, choice, parent = None) :
> >     4              assert len(choice) >= 1
> >     5              self.parent = parent
> >     6              self.choice = choice
> >     7              self.cursor   = 0
> >     8              if len(choice) == 1 :
> >     9                  self.child = None
> >    10              else :
> >    11                  childChoice = choice[:self.cursor] +
> > choice[self.cursor + 1:]
> >    12                   self.child = Rotor(childChoice, self)
> >    13          def value(self) :
> >    14              if self.child :
> >    15                  result = self.child.value()
> >    16                  result.append(self.choice[self.cursor ])
> >    17                  return result
> >    18              else :
> >    19                  return [ self.choice[0], ]
> >    20          def next(self) :
> >    21              node = self.child
> >    22              while node.child :
> >    23                  node = node.child
> >    24              node = node.parent
> >    25              while len(node.choice) == node.cursor + 1 :
> >    26                  node = node.parent
> >    27                  if not node :
> >    28                      return False
> >    29              else :
> >    30                  node.cursor += 1
> >    31                  cursor = node.cursor
> >    32                  node_child_choice =
> node.choice[:cursor] +
> > node.choice[cursor + 1:]
> >    33                  node.child = Rotor(node_child_choice, node)
> >    34                  return True
> >    35      rotor = Rotor(choice)
> >    36      yield rotor.value()
> >    37      while rotor.next() :
> >    38          yield rotor.value()
> >    39
> >    40  if __name__ == "__main__" :
> >    41      s = ['a', 'b', 'c']
> >    42      gen = FullCombination(s)
> >    43      for i in gen :
> >    44          print i
> >
> >
> >
> > On 3/4/06, ajax chelsea <ajaxchelsea at gmail.com> wrote:
> > >
> > >
> 翻了半天标准库没有找到排列组合算法,请问Python标准库提供了常用的排列组合算法了吗?大家平时都用什么库来操作排列组合呢?
> > >
> > > 另外,这个邮件列表跟google
> > >
> group的python.cn组会自动同步吗?是不是邮件列表里的信件会自动转到group里,而group里的帖子不会自动发给这个邮件列表?
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to
> > > python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info:
> > > http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> > Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>


--
"""Time is unimportant, only life important!
blogging  :  http://blog.zoomquiet.org/pyblosxom/
wiki enter:   http://wiki.woodpecker.org.cn/moin/ZoomQuiet
in douban:  http://www.douban.com/people/zoomq/
"""

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月06日 星期一 12:18

Bruce Wang number5 at gmail.com
Mon Mar 6 12:18:23 HKT 2006

On 3/6/06, shhgs <shhgs.efhilt at gmail.com> wrote:
> 我有思路了,过两天等有空了写出来
>
> 这段代码是不是够资格贴到cookbook?
>

够资格了 :)

其实那里没什么限制的

--
simple is good
http://brucewang.net

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月07日 星期二 08:14

shhgs shhgs.efhilt at gmail.com
Tue Mar 7 08:14:47 HKT 2006

Python就是爽

思路出来,代码只是小case,原本以为要调试一番,结果是白担心了

Permutaion用了链表,Combination用来二叉树,不过代码里看不出二叉树。这是设计算法的时候加的辅助线,真正写代码的时候反而用不着了。也挺有意思的。

已经给Python Cookbook发邮件了,希望能收录。

On 3/5/06, Bruce Wang <number5 at gmail.com> wrote:
> On 3/6/06, shhgs <shhgs.efhilt at gmail.com> wrote:
> > 我有思路了,过两天等有空了写出来
> >
> > 这段代码是不是够资格贴到cookbook?
> >
>
> 够资格了 :)
>
> 其实那里没什么限制的
>
> --
> simple is good
> http://brucewang.net
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PMenum.py
Type: text/x-python
Size: 3080 bytes
Desc: not available
Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20060306/21efd9be/PMenum.py

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号