List partitioning
- From: BimKif <NObimkifSPAM@xxxxxxxx>
- Date: Wed, 22 Oct 2008 16:47:24 +0200
Hi,
I'm looking for a way to get all the partitionings of N items into P groups (each group must have a size of either "int(N/P)" or "int(N/P)+1"). But I don't want any duplicate.
For example, with N=5 and P=2, I want to obtain:
[[i1,i2,i3],[i4,i5]],
[[i1,i2,i4],[i3,i5]],
[[i1,i2,i5],[i3,i4]],
[[i1,i2],[i3,i4,i5]],
[[i1,i3,i4],[i2,i5]],
[[i1,i3,i5],[i2,i4]],
[[i1,i3],[i2,i4,i5]],
[[i1,i4,i5],[i2,i3]],
[[i1,i5],[i2,i3,i4]]
but I dont want to obtain both [[i1,i2,i3],[i4,i5]] and [[i5,i4],[i3,i1,i2]], which are semanticaly equivalent in my context.
Is there a efficient way to do this in Prolog ?
Thanks in advance.
.
- Follow-Ups:
- Re: List partitioning
- From: Tudor Berariu
- Re: List partitioning
- From: tudor.berariu@xxxxxxxxx
- Re: List partitioning
- From: nameless
- Re: List partitioning
- From: pineapple . link
- Re: List partitioning
- Prev by Date: Designing unit tests and the use of consult/ensure_loaded
- Next by Date: Passing Prolog arguments to shell scripts
- Previous by thread: Designing unit tests and the use of consult/ensure_loaded
- Next by thread: Re: List partitioning
- Index(es):