jelle-s / bitmaskgenerator
Generates all possible bitmasks with a minimum amount of positives (1's) and a certain length.
Installs: 228
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/jelle-s/bitmaskgenerator
Requires
- jelle-s/permutations: ^1.0
This package is auto-updated.
Last update: 2025-09-12 22:35:54 UTC
README
Usage:
use Jelle_S\Util\BitMask\BitMaskGenerator; $length = 5; $minPositives = 2; // BitMaskGenerator that generates bitmasks with a length of 5 and at least two // positives (1's). $generator = new BitMaskGenerator($length, $minPositives); while ($mask = $generator->getNextMask()) { print $mask . "\n"; }
Output:
00011
00101
00110
01001
01010
01100
10001
10010
10100
11000
00111
01011
01101
01110
10011
10101
10110
11001
11010
11100
01111
10111
11011
11101
11110
11111