algorithmics

Generate All Boolean Array Combinations

While writing Go tests for goxplorer, I wanted to test all boolean flags combinations without having to cascade for loops. This first method came to mind: package main import ( "fmt" ) func stob(bf []bool, s string) { for i, b := range s { if b == '0' { bf[i] = false } else { bf[i] = true } } } func main() { bf := []bool{false, false, false, false, false} for i := 0; i < 32; i++ { b := fmt.