Re: Combinations of lists

2012-10-06 Thread Joshua Landau
On 4 October 2012 16:12, Steen Lysgaard wrote: > 2012/10/4 Joshua Landau : > > On 3 October 2012 21:15, Steen Lysgaard wrote: > >> > >> Hi, > >> > >> thanks for your interest. Sorry for not being completely clear, yes > >> the length of m will always be half of the length of h. > > > > > > (Plea

Re: Combinations of lists

2012-10-04 Thread 88888 Dihedral
On Thursday, October 4, 2012 11:12:41 PM UTC+8, Steen Lysgaard wrote: > 2012/10/4 Joshua Landau : > > > On 3 October 2012 21:15, Steen Lysgaard wrote: > > >> > > >> Hi, > > >> > > >> thanks for your interest. Sorry for not being completely clear, yes > > >> the length of m will always be hal

Re: Combinations of lists

2012-10-04 Thread Steen Lysgaard
2012/10/4 Joshua Landau : > On 3 October 2012 21:15, Steen Lysgaard wrote: >> >> Hi, >> >> thanks for your interest. Sorry for not being completely clear, yes >> the length of m will always be half of the length of h. > > > (Please don't top post) > > I have a solution to this, then. > It's not sh

Re: Combinations of lists

2012-10-03 Thread Joshua Landau
On 3 October 2012 21:15, Steen Lysgaard wrote: > Hi, > > thanks for your interest. Sorry for not being completely clear, yes > the length of m will always be half of the length of h. > (Please don't top post ) I have a solution to this, then. It'

Re: Combinations of lists

2012-10-03 Thread 88888 Dihedral
Oscar Benjamin於 2012年10月4日星期四UTC+8上午4時29分51秒寫道: > Oscar wrote: > > >>> def uniquecombinations(h, m): > > >>> for ha in submultisets(h, len(h)//2): > > >>> hb = list(h) > > >>> for c in ha: > > >>> hb.remove(c) > > >>> yield [m[0] + a for a in ha] + [m[1

Re: Combinations of lists

2012-10-03 Thread Oscar Benjamin
Oscar wrote: >>> def uniquecombinations(h, m): >>> for ha in submultisets(h, len(h)//2): >>> hb = list(h) >>> for c in ha: >>> hb.remove(c) >>> yield [m[0] + a for a in ha] + [m[1] + b for b in hb] >>> >>> h = ['A', 'A', 'B', 'B'] >>> m = ['a', 'b'] >>> >>> f

Re: Combinations of lists

2012-10-03 Thread Steen Lysgaard
Hi, thanks for your interest. Sorry for not being completely clear, yes the length of m will always be half of the length of h. /Steen 2012/10/3 Joshua Landau : > On 3 October 2012 20:20, Oscar Benjamin wrote: >> >> On 3 October 2012 15:26, Steen Lysgaard wrote: >> > Hi, >> > >> > I am looking

Re: Combinations of lists

2012-10-03 Thread Joshua Landau
On 3 October 2012 20:20, Oscar Benjamin wrote: > On 3 October 2012 15:26, Steen Lysgaard wrote: > > Hi, > > > > I am looking for a clever way to compute all combinations of two lists. > Look > > at this example: > > > > h = ['A','A','B','B'] > > m = ['a','b'] > > > > the resulting combinations s

Re: Combinations of lists

2012-10-03 Thread Oscar Benjamin
On 3 October 2012 15:26, Steen Lysgaard wrote: > Hi, > > I am looking for a clever way to compute all combinations of two lists. Look > at this example: > > h = ['A','A','B','B'] > m = ['a','b'] > > the resulting combinations should be of the same length as h and each > element in m can be used tw

Re: Combinations of lists

2012-10-03 Thread Joshua Landau
On 3 October 2012 15:26, Steen Lysgaard wrote: > Hi, > > I am looking for a clever way to compute all combinations of two lists. > Look at this example: > > h = ['A','A','B','B'] > m = ['a','b'] > > the resulting combinations should be of the same length as h and each > element in m can be used t

Re: Combinations of lists

2012-10-03 Thread Manuel Pégourié-Gonnard
Steven D'Aprano scripsit : > On Wed, 03 Oct 2012 16:26:43 +0200, Steen Lysgaard wrote: > >> This is achieved by the code below, this however needs to go through all >> possible combinations (faculty of len(h)) and rule out duplicates as >> they occur and this is too much if for example len(h) is 1

Re: Combinations of lists

2012-10-03 Thread Steven D'Aprano
On Wed, 03 Oct 2012 16:26:43 +0200, Steen Lysgaard wrote: > Hi, > > I am looking for a clever way to compute all combinations of two lists. > Look at this example: > > h = ['A','A','B','B'] > m = ['a','b'] > > the resulting combinations should be of the same length as h and each > element in m

Re: Combinations of lists

2012-10-03 Thread Alain Ketterlin
Steen Lysgaard writes: > I am looking for a clever way to compute all combinations of two > lists. Look at this example: > > h = ['A','A','B','B'] > m = ['a','b'] > > the resulting combinations should be of the same length as h and each > element in m can be used twice. The sought after result us

Combinations of lists

2012-10-03 Thread Steen Lysgaard
Hi, I am looking for a clever way to compute all combinations of two lists. Look at this example: h = ['A','A','B','B'] m = ['a','b'] the resulting combinations should be of the same length as h and each element in m can be used twice. The sought after result using h and m from above is: