Author: Gerd Isenberg
Date: 13:36:08 02/27/06
Go up one level in this thread
On February 27, 2006 at 15:56:14, Steffan Westcott wrote: >On February 27, 2006 at 13:36:52, Gerd Isenberg wrote: > >>Hi, >> >>while i indulge my current morbus knuth attack, which hits me so one, two times >>a year, i like to ask a question related to the "rotated" De Bruijn generator. >> >>I have a word "d" with a setwise interpretation ( a bitboard) and maximum >>cardinality of N (N bits set, let say 8). I like to enumerate all subsets, >>including the empty set and the original complete set. Looking for a smarter >>algorithm. >> > >Perhaps I missed something, but isn't this just a case of incrementing a number >and rippling a carry through the unwanted bits? Here is my answer, anyhow: > >void enumsets(const BitBoard d) >{ > BitBoard n = 0; > do { > do_something_with_set(n); > n = (n-d) & d; > } while (n); >} > > >Cheers, >Steffan Hi Steffan, exactly i was looking for. "rippling a carry through the unwanted bits" - very cute iterator. Cheers, Gerd
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.