Activating the Valve, for example, would apply the mask '11000' and put the valve in position 2. Initially, all devices are set to position 1. Each time you activate a device, it alternates applying the two masks to the current state of the lights.īefore going any further, I think it will help to see the mask table. A mask is simply a predetermined binary number that is used to perform a bitwise operation with.
Each device has 2 5-digit binary masks associated with it. The room contains 4 devices: Valve, Lever, Switch and T.V.