#include int hats[6] = {0}; int count = 0; void nextChild(int childIndex, int whiteRemaining, int blackremaining) { int i; if (childIndex == 6) { count++; for (int i = 0; i < 6; i++) { if (hats[i] == -1) { printf("White"); } else { printf("Black"); } printf("\t"); } printf("\n"); } if (whiteRemaining > 0) { hats[childIndex] = -1; nextChild(childIndex + 1, whiteRemaining - 1, blackremaining); } if (blackremaining > 0) { hats[childIndex] = 1; nextChild(childIndex + 1, whiteRemaining, blackremaining - 1); } } int main() { nextChild(0, 3, 3); printf("Total: %d", count); return 0; }