In data analysis tasks, binary variables are usually encoded as $1$s and $0$s. In data sets with multiple binary variables, it is often necessary to create "interactions" of binary variables that can be mapped to integer categories. Is there a general way to construct unambiguous integer category codes from an arbitrary number of binary variables?
For instance, consider a survey where respondents are asked to state (1) whether they prefer vanilla or chocolate ice cream, and (2) whether they had eaten ice cream in the last week. The data for $N$ respondents will look something like a sequence $\bigl\{ \left( y_{1n}, y_{2n} \right) \bigr\}_{n=1}^N$, where $n$ indexes respondents, and $\left( y_{1n}, y_{2n} \right) \in \{0,1\}^2$ for every $n$. I'm looking for a way to construct a mapping $I$ such that: $$I\left( y_1, y_2 \right) = \begin{cases} a, &y_1 = 0 \land y_2 = 0 \\ b, &y_1 = 1 \land y_2 = 0 \\ c, &y_1 = 0 \land y_2 = 1 \\ d, &y_1 = 1 \land y_2 = 1 \end{cases} $$ for integers $a \neq b \neq c \neq d$, except for a arbitrary-length $y$ tuples (instead of just length 2).
This seems related to the construction of file permission codes in Unix, where you have three "variables" (read, write, and execute) and three "observations" (user, group, and other). Here the solution is to just "concatenate" all the binary values for each observation and read off the result as if it were an octal value. Using this method, one valid $I$ function above would be: $$I\left( y_1, y_2 \right) = \begin{cases} 00_2 \\ 01_2 \\ 10_2 \\ 11_2 \end{cases} = \begin{cases} 0_{10} \\ 1_{10} \\ 2_{10} \\ 3_{10} \end{cases} $$
Does this technique work for any $k\geq2$ number of binary variables?
Bonus question 1: it's always possible to recode a categorical variable with a finite number of categories $c$ as a collection of $c-1$ binary variables. Does that mean that, if a technique for arbitrary binary-variable combination does exist in general, then it's always possible to construct integer codes for arbitrary interactions of arbitrary integer-valued categorical variables? Assuming of course that every such $c$ is finite.
Bonus question 2: is there a closed-form expression for the Unix permission algorithm for arbitrary $k$?