I am struggling with programming the following (with GAS):
I have 14 boxes which are either empty or not and I need to keep track of which boxes are empty. My idea is to use a base2 control value to keep track of the which boxes are empty.
To illustrate I will use an example with only 3 boxes
I figured the following scheme would work:
- All boxes empty: 0 control value
- Only box 1 empty: 1 control value
- Only box 2 empty: 2 control value
- Boxes 1 and 2 empty: 3 control value
- Only box 3 empty: 4 control value
- Boxes 1 and 3 empty: 5 control value
- Boxes 2 and 3 empty: 6 control value
- No boxes empty: 7 control value
I need an algorithm to know which boxes are empty and how to update the control value as boxes are filled and/or emptied.
I assume(d) that there must exist ready to use algorithms for this functionality and hence this sort of use of a base2 series have a name that I can use to google, right?
In case this it the wrong place for this question please let me know. Thank you.