This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/11364] half of permutations missing


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11364



------- Additional Comments From falk dot hueffner at student dot uni-tuebingen dot de  2003-06-29 16:31 -------
Subject: Re:  half of permutations missing

"craie at acm dot org" <gcc-bugzilla@gcc.gnu.org> writes:

> These are fine...
> 
> > 5 gives 60 permutations.
> > 6 gives 360 permutations.
> > 7 gives 2520 permutations.
> > 8 gives 20160 permutations.
> > 9 gives 181440 permutations.
> > 10 gives 1814400 permutations.
> > 
> All these are half what they should be!  The duplicate value is
> causing problems with the permutation algorithm.
> 
> I'm trying to test all arrangements of data in a list and am
> only able to move through half of them due to this 'glitch'.

You seem to have a wrong notion of "permutation". For example, the
sequence {1, 1, 1, 1} has exactly one permutation. Additionally, what
you seem to want (getting {1, 1, 1, 1} 24 times) is obvoiusly
impossible to implement with the interface of next_permutation.

To get what you want, you could for example use an array of pointers,
and use std::next_permutation on that.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]